[xml] 2Bugs in xmlTextReaderExpand()



Hallo

I use libxml2.5.8 and in xmlTextReaderExpand() Function
is 2 bugs. The pruduced Node with the subtree contains more Nodes
then the subtree should. If i print rekursiv all Subtree-Nodes 
with
children and next - elements i can see this. 


...
name = xmlTextReaderLocalName(reader);
    if(name != NULL){
        if (strcmp(name,"bvclsadr")==0){
             node = xmlTextReaderExpand(reader);
             verarbeite(node);           /*Print nodes rekursive 
hier*/
             ret = xmlTextReaderNext(reader);
        }
...

    void
verarbeite( node )
    xmlNodePtr node;
{
    xmlChar *name=NULL;
    xmlChar *value=NULL;
    xmlChar *content=NULL;

    if(node != NULL){
    /*For this Node print all children and next Nodes*/
        if(node->type == XML_ELEMENT_NODE){
            printf("<%s>",node->name);
        }
        if(node->type == XML_TEXT_NODE){
            if((value = node->content) != NULL){
                printf("%s",po_strdelbtn(value)); /*a trim() 
- Function*/
            }
        }

        /*all Child Nodes rekursive*/
        if(node->children!=NULL){
            if(node->children->type==XML_ELEMENT_NODE){
                printf("\n\t");
            }
            verarbeite(node->children);
        }
        if(node->type == XML_ELEMENT_NODE){
            printf("</%s>",node->name);
        }
        /*all Next Elemente rekursive*/
        if(node->next!=NULL){
            if(node->next->type==XML_ELEMENT_NODE){
                printf("\n\t");
            }
            verarbeite(node->next);
        }
    }
}

For the xml-File:
<?xml version="1.0"?>
<Telegramme  xmlns="http://www.storagement.de/LVS/Telegramme";>
<bvclsadr
        LEN="001"  SKZ="001">
        <BOVACSA>00001</BOVACSA>
        <LANR>nr2001</LANR>
        <ANRED>Herr</ANRED>
        <VSAD1>Name1</VSAD1>
        <VSAD2>Name2</VSAD2>
        <VSAD3>Name3</VSAD3>
</bvclsadr>
<bvclsadr
        LEN="001"  SKZ="001">
        <BOVACSA>00002</BOVACSA>
        <LANR>nr2002</LANR>
        <ANRED>Herr</ANRED>
        <VSAD1>Name1</VSAD1>
        <VSAD2>Name2</VSAD2>
        <VSAD3>Name3</VSAD3>
</bvclsadr>
<bvclsadr
        LEN="001"  SKZ="001">
        <BOVACSA>00003</BOVACSA>
        <LANR>nr2003</LANR>
        <ANRED>Herr</ANRED>
        <VSAD1>Name1</VSAD1>
        <VSAD2>Name2</VSAD2>
        <VSAD3>Name3</VSAD3>
</bvclsadr>

</Telegramme>

This is the output with marks of
xmlTextReaderRead() calls for that xml-File:
xmlTextReaderRead() call...Nr:1

xmlTextReaderRead() call...Nr:2
<bvclsadr>
        <BOVACSA>00001</BOVACSA>
        <LANR>nr2001</LANR>
        <ANRED>Herr</ANRED>
        <VSAD1>Name1</VSAD1>
        <VSAD2>Name2</VSAD2>
        <VSAD3>Name3</VSAD3></bvclsadr>
        <bvclsadr>
        <BOVACSA>00002</BOVACSA>
        <LANR>nr2002</LANR>
        <ANRED>Herr</ANRED>
        <VSAD1>Name1</VSAD1>
        <VSAD2>Name2</VSAD2>
        <VSAD3>Name3</VSAD3></bvclsadr>
        <bvclsadr>
        <BOVACSA>00003</BOVACSA>
        <LANR></LANR></bvclsadr>
xmlTextReaderRead() call...Nr:3
<bvclsadr>
        <BOVACSA>00002</BOVACSA>
        <LANR>nr2002</LANR>
        <ANRED>Herr</ANRED>
        <VSAD1>Name1</VSAD1>
        <VSAD2>Name2</VSAD2>
        <VSAD3>Name3</VSAD3></bvclsadr>
        <bvclsadr>
        <BOVACSA>00003</BOVACSA>
        <LANR></LANR></bvclsadr>
xmlTextReaderRead() call...Nr:4
<bvclsadr>
        <BOVACSA>00003</BOVACSA>
        <LANR></LANR></bvclsadr>
xmlTextReaderRead() call...Nr:5

xmlTextReaderRead() call...Nr:6

As you see at output between Reader() calls 4 and 5 
the Expand Function has build invalid Tree. That is
the second bug. Sometimes Expand - Function produces
invalid Node.

with best regards
Evgueni Oussorov

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]