You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2004/01/29 22:11:49 UTC

DO NOT REPLY [Bug 26537] New: - Bad isEmpty argument for the advanced startElement() event

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26537>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26537

Bad isEmpty argument for the advanced startElement() event

           Summary: Bad isEmpty argument for the advanced startElement()
                    event
           Product: Xerces-C++
           Version: 2.4.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: SAX/SAX2
        AssignedTo: xerces-c-dev@xml.apache.org
        ReportedBy: jlegare@omnimark.com


The SAX2 advanced startElement event should be passed an argument isEmpty=true
if the element is empty (like <a/>). But false is passed instead.

Another problem is that, for empty elements, the startElement/endElement event
pair for the "plain" handler and the startElement for the advanced handler are
misaligned. For nonempty elements the ordering of events is
plainStart;advancedStart;plainEnd;advancedEnd and for empty elements it's
plainStart;plainEnd;advancedStart. This ordering makes it impossible to use the
combination advanced startElement / plain endElement.

Here's a patch against the Xerces release 2.4 that fixes the two problems:

==== xerces-c-src2_4_0/src/xercesc/internal/IGXMLScanner.cpp#2 (text) ====
 
2776c2776
<             , false
---
>             , isEmpty
2911c2911
<         if (fDocHandler)
---
>         if (!isEmpty && fDocHandler)
 
==== xerces-c-src2_4_0/src/xercesc/internal/WFXMLScanner.cpp#2 (text) ====
 
1536c1536
<             , false
---
>             , isEmpty
 
==== xerces-c-src2_4_0/src/xercesc/parsers/SAX2XMLReaderImpl.cpp#2 (text) ====
 
965,967c965,968
<     // Bump the element depth counter if not empty
<     if (!isEmpty)
<         fElemDepth++;
---
>     XMLBufBid elemQName( &fStringBuffers ) ;
>
>     // Bump the element depth counter
>     fElemDepth++;
971d971
<         XMLBufBid elemQName( &fStringBuffers ) ;
1042,1071d1041
<
<
<         // If its empty, send the end tag event now
<         if (isEmpty)
<         {
<             // call endPrefixMapping appropriately.
<             if (getDoNamespaces())
<             {
<                 fDocHandler->endElement
<                 (
<                     fScanner->getURIText(elemURLId)
<                     , elemDecl.getBaseName()
<                     , elemQName.getRawBuffer()
<                 );
<
<                 unsigned int numPrefix = fPrefixCounts->pop();
<                 for (unsigned int i = 0; i < numPrefix; ++i)
<                 {
<                     XMLBuffer * buf = fPrefixes->pop() ;
<                     fDocHandler->endPrefixMapping( buf->getRawBuffer() );
<                     fStringBuffers.releaseBuffer(*buf) ;
<                 }
<             }
<             else
<             {
<                 fDocHandler->endElement(XMLUni::fgZeroLenString,
<                                 elemDecl.getBaseName(),
<                                 elemDecl.getFullName());
<             }
<         }
1090a1061,1089
>
>     // If its empty, send the end tag event now
>     if (fDocHandler && isEmpty)
>     {
>        // call endPrefixMapping appropriately.
>        if (getDoNamespaces())
>        {
>           fDocHandler->endElement
>              (
>               fScanner->getURIText(elemURLId)
>               , elemDecl.getBaseName()
>               , elemQName.getRawBuffer()
>               );
>
>           unsigned int numPrefix = fPrefixCounts->pop();
>           for (unsigned int i = 0; i < numPrefix; ++i)
>           {
>              XMLBuffer * buf = fPrefixes->pop() ;
>              fDocHandler->endPrefixMapping( buf->getRawBuffer() );
>              fStringBuffers.releaseBuffer(*buf) ;
>           }
>        }
>        else
>        {
>           fDocHandler->endElement(XMLUni::fgZeroLenString,
>                                   elemDecl.getBaseName(),
>                                   elemDecl.getFullName());
>        }
>     }

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org