Hi,

first a question: how do I detect which version of Xerces C is
installed? My current interface to Xerces 2.7.0 uses DOMBuilder, which
is deprecated in 3.0. I already switched to DOMLSParser and it works
fine -- but the resulting source code is incompatible with 2.7.0. Is
there a clean way to detect the version? (other than looking for the
DOMLSParser/DOMBuilder classes).

I noticed some strange behaviour in Xerces 3.0 when using XInclude:
I've written a small test app which parses a file containing the
following XInclude spec and serializes the result:

<xi:include href="willi.xml" xmlns:xi="http://www.w3.org/2001/XInclude";>
  <xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude";>
    <class id="i1">
      <member nodes="p18 p29" scc="s7"/>
      <member nodes="p22 p31" scc="s11"/>
    </class>
  </xi:fallback>
</xi:include>

Parsing of the file seems to work fine. In case the file "willi.xml"
exists it is included and the result is properly serialized. However, I
get an infinite loop during serialization (which eats up memory) if
"willi.xml" does NOT exist. In case I remove the fallback element
(including its childs) completely, serialization works as expected and
the unevaluated xi::include-element can be found in the output.

Here is a debugger session:

(gdb) run test.xml
Starting program:
/home/weitzel/uni/FLUX/trunk/xml/support/.libs/lt-xmltest test.xml
[Thread debugging using libthread_db enabled]
[New Thread 1083798464 (LWP 28539)]
Warning: XML parser: Element 'math' was referenced in a content model
but never declared
Warning: XML parser: Unable to include resource
'file:///home/weitzel/uni/FLUX/trunk/xml/support/willi.xml'
^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 1083798464 (LWP 28539)]
0x4023f796 in xercesc_3_0::XMLFormatter::specialFormat (this=0x80cb048,
    toFormat=0xbf99d55c, count=1,
    escapeFlags=xercesc_3_0::XMLFormatter::NoEscapes)
    at xercesc/framework/XMLFormatter.cpp:635
635                                     , const EscapeFlags     escapeFlags)

Here's a backtrace of the endless loop:

#0  0x4023f796 in xercesc_3_0::XMLFormatter::specialFormat (this=0x80cb048,
    toFormat=0xbf99d55c, count=1,
    escapeFlags=xercesc_3_0::XMLFormatter::NoEscapes)
    at xercesc/framework/XMLFormatter.cpp:635
        srcPtr = <value optimized out>
        endPtr = (const XMLCh *) 0xbf99d55e
#1  0x4023f547 in xercesc_3_0::XMLFormatter::formatBuf (this=0x80cb048,
    toFormat=0xbf99d55c, count=1,
    escapeFlags=xercesc_3_0::XMLFormatter::DefaultEscape,
    unrepFlags=xercesc_3_0::XMLFormatter::DefaultUnRep)
    at xercesc/framework/XMLFormatter.cpp:399
        theChars = <value optimized out>
        actualEsc = xercesc_3_0::XMLFormatter::NoEscapes
        actualUnRep = xercesc_3_0::XMLFormatter::UnRep_CharRef
        srcPtr = <value optimized out>
        endPtr = <value optimized out>
#2  0x4023f8e2 in xercesc_3_0::XMLFormatter::operator<< (this=0x80cb048,
    toFormat=32) at xercesc/framework/XMLFormatter.cpp:544
        szTmp = {32, 0}
#3  0x4021f259 in xercesc_3_0::DOMLSSerializerImpl::printIndent (
    this=0x80d2848, level=4294967295)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:1626
        i = 9237639
#4  0x4022090b in xercesc_3_0::DOMLSSerializerImpl::processNode (
    this=0x80d2848, nodeToWrite=0x409c2cb0, level=2)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:787
        filterAction = xercesc_3_0::DOMNodeFilter::FILTER_ACCEPT
        nodeLine = <value optimized out>
        namespaceMap = <value optimized out>
        child = <value optimized out>
        nodeName = (const XMLCh *) 0x80a4254
        nodeValue = (const XMLCh *) 0x0
        lent = 0
#5  0x4022095b in xercesc_3_0::DOMLSSerializerImpl::processNode (
    this=0x80d2848, nodeToWrite=0x409c19e0, level=2)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:988
        filterAction = xercesc_3_0::DOMNodeFilter::FILTER_ACCEPT
        nodeLine = 2
        namespaceMap = (xercesc_3_0::RefHashTableOf<short unsigned int> *) 0x0
        child = (DOMNodeSPtr) 0x409c2cb0
        nodeName = (const XMLCh *) 0x409c1a24
        nodeValue = <value optimized out>
        lent = <value optimized out>
#6  0x4022095b in xercesc_3_0::DOMLSSerializerImpl::processNode (
    this=0x80d2848, nodeToWrite=0x80a4330, level=1)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:988
        filterAction = xercesc_3_0::DOMNodeFilter::FILTER_ACCEPT
        nodeLine = 2
        namespaceMap = (xercesc_3_0::RefHashTableOf<short unsigned int> *) 0x0
        child = (DOMNodeSPtr) 0x409c19e0
        nodeName = (const XMLCh *) 0x80a31dc
        nodeValue = <value optimized out>
        lent = <value optimized out>
#7  0x40220f56 in xercesc_3_0::DOMLSSerializerImpl::processNode (
    this=0x80d2848, nodeToWrite=0x80a2a80, level=0)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:746
        docu = (const xercesc_3_0::DOMDocument *) 0x80a2a74
        child = (DOMNodeSPtr) 0x80a4330
        nodeName = (const XMLCh *) 0x40373916
        nodeValue = (const XMLCh *) 0x80a2a74
        lent = <value optimized out>
#8  0x4022241a in xercesc_3_0::DOMLSSerializerImpl::processNode (
    this=0x80d2848, nodeToWrite=0x80a2a80)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:1594
No locals.
#9  0x4022258f in xercesc_3_0::DOMLSSerializerImpl::write (this=0x80d2848,
    nodeToWrite=0x80a2a80, destination=0x80ca298)
    at xercesc/dom/impl/DOMLSSerializerImpl.cpp:512
        janName = {<xercesc_3_0::XMemory> = {<No data fields>},
  fData = 0x80cb048}
        pTarget = (class xercesc_3_0::XMLFormatTarget *) 0x80d1fc0
        janTarget = {<xercesc_3_0::XMemory> = {<No data fields>}, fData = 0x0}
        docu = <value optimized out>
        lsEncoding = <value optimized out>
#10 0x40024d04 in xml::DOMWriterImplL3::writeToStream (this=0x80a9de0,
    out_file=0x406ae3a0) at DOMWriterImplL3.cc:128
        theSerializer = (xercesc_3_0::DOMLSSerializer *) 0x80d2848
        theOutput = (class xercesc_3_0::DOMLSOutput *) 0x80ca298
        gSplitCdataSections = false
        gDiscardDefaultContent = true
        gFormatPrettyPrint = true
        gWriteBOM = false
        config = (class xercesc_3_0::DOMConfiguration *) 0x80d284c
        myFormatTarget = (class xercesc_3_0::XMLFormatTarget *) 0x80d1fc0
        buffer = (const XMLByte *) 0x1 <Address 0x1 out of bounds>
        buffer_length = 1073831104
        nblocks = 3214530561
        e = (class xercesc_3_0::XMLException
     &) @0xbf99d848: {<xercesc_3_0::XMemory> = {<No data fields>},
  _vptr.XMLException = 0xbf99d8a8, fCode = 134519955,
  fSrcFile = 0x80a9de0 "ΒΈΒΊ\004\b\001", fSrcLine = 1080746912,
  fMsg = 0x80a2a74, fMemoryManager = 0x40024471}
#11 0x08049c93 in main (argc=2, argv=0xbf99d934) at XMLTest.cc:36
        doc = (class xercesc_3_0::DOMDocument *) 0x80a2a74
        dr = (xml::DOMReader *) 0x8095078
        dw = (xml::DOMWriter *) 0x80a9de0

the endless loop is located in

xercesc_3_0::DOMLSSerializerImpl::printIndent (this=0x80d2848,
    level=4294967295) at xercesc/dom/impl/DOMLSSerializerImpl.cpp:1625
1625            for(unsigned int i = 0; i < level; i++)
(gdb) print level
$1 = 4294967295
(gdb) print i
$2 = 9237639

Thank you! :-)
-- 
Cheers,
Michael

Reply via email to