xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ori D. (JIRA)" <xerces-c-...@xml.apache.org>
Subject [jira] Created: (XERCESC-1626) loadGrammar is releasing a DOMBuilder previously parsed document when it shouldn't
Date Tue, 22 Aug 2006 20:36:16 GMT
loadGrammar is releasing a DOMBuilder previously parsed document when it shouldn't

                 Key: XERCESC-1626
                 URL: http://issues.apache.org/jira/browse/XERCESC-1626
             Project: Xerces-C++
          Issue Type: Bug
          Components: DOM, Validating Parser (Schema) (Xerces 1.5 or up only)
    Affects Versions: 2.7.0
         Environment: Windows XP Pro 32bit, 
Visual C++ 6.0 sp5

            Reporter: Ori D.

I'm parsing xml file using Xerces-c 2.7 DOM.
After loading a schema grammar to the parser, my previously parsed xml document is released
(and therefore further access to the document in the code causes segmentation fault)

I do the following things (more or less):

1. create a XMLGrammarPoolImpl object and then create a new
DOMBuilder using it as an input.

m_grammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
m_DomImpl = DOMImplementationRegistry::getDOMImplementation(gLS);
m_DomParser = ((DOMImplementationLS*)m_DomImpl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,
0, XMLPlatformUtils::fgMemoryManager, m_grammarPool);
m_DomParser->setFeature(XMLUni::fgDOMNamespaces, true);
m_DomParser->setFeature(XMLUni::fgXercesSchema, true);
m_DomParser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
m_DomParser->setFeature(XMLUni::fgDOMValidateIfSchema, true);
m_DomParser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);

2. Parse an xml file using the DOMBuilder and keep a reference to
the DOMDocument, 'doc'

doc = m_DomParser->parse(inputSource);

3. Create a new DOMInputSource and call DOMBuilder
->loadGrammar(inputSrc, SchemaGrammarType, true)

SchemaGrammar *pGrammar = (SchemaGrammar*) m_DomParser->loadGrammar(schemaInputSource,
Grammar::SchemaGrammarType, true);

The result is that my previous parsed document, 'doc' is being released by the following code
in parsers\DOMBuilderImpl.cpp on DOMBuilderImpl::loadGrammar  (line 703):

        // Release DOM tree - DTD

        DOMDocument* doc = adoptDocument();

        if (doc)


This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


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

View raw message