Re: [xml] 2Bugs in xmlTextReaderExpand()

On Wed, Jul 16, 2003 at 11:36:46PM +0200, Berlinez Oussorov fhtw-berlin de wrote:

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 
children and next - elements i can see this. 

  Your code is very hard to read.

name = xmlTextReaderLocalName(reader);
    if(name != NULL){
        if (strcmp(name,"bvclsadr")==0){

  this is not sufficient test, you may visit element nodes twice,
check the documentation and the type too.

             node = xmlTextReaderExpand(reader);
             verarbeite(node);           /*Print nodes rekursive 

  this also print the next siblings and their subtree hence the problem

             ret = xmlTextReaderNext(reader);

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){
        if(node->type == XML_TEXT_NODE){
            if((value = node->content) != NULL){
                printf("%s",po_strdelbtn(value)); /*a trim() 
- Function*/

   if this really does a trim (i.e. both side of the string),
then po_strdelbtn has to leak or not be thread safe, looks poor...


        /*all Child Nodes rekursive*/
        if(node->type == XML_ELEMENT_NODE){
        /*all Next Elemente rekursive*/

 This also print the siblings of the returned node, no garantee
is provided by Expand, all you know is that the subtree of the given
node is expanded, that's all.

xmlTextReaderRead() call...Nr:2

  Normal, the chunk processed was more than the first bvclsadr

xmlTextReaderRead() call...Nr:4
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.

  I'm not sure about this, you don't even give the full code, I can't
see if you stop on <bvclsadr/> too and not just <bvclsadr>.
Provide a complete small python example using the serialize() call
for dumping instead of your own routine and I will check what's happening


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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