logo       

[jira] Created: (XERCESJ-1101) Validating DocumentBuilder instance fails to: msg#00000

Subject: [jira] Created: (XERCESJ-1101) Validating DocumentBuilder instance fails to parse more than one XML document.
Validating DocumentBuilder instance fails to parse more than one XML document.
------------------------------------------------------------------------------

         Key: XERCESJ-1101
         URL: http://issues.apache.org/jira/browse/XERCESJ-1101
     Project: Xerces2-J
        Type: Bug
  Components: JAXP (javax.xml.parsers)  
    Versions: 2.7.0, 2.7.1    
    Reporter: Vojtech Habarta
    Priority: Critical



When DocumentBuilder instance with W3C XML Schema validation is created using 
JAXP 1.2 and is used for parsing it fails on second XML document.

Here is sample code snippet:

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    Object[] schemaSource = new Object[] {
        // it is important to pass schemas as InputStreams to prevent schemas 
reparsing
        ParsingTest.class.getResourceAsStream("ParsingTest.xsd"),
    };
    
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage";, 
"http://www.w3.org/2001/XMLSchema";);
    
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource";, 
schemaSource);
    DocumentBuilder documentBuilder = factory.newDocumentBuilder();
    documentBuilder.setErrorHandler(...);
    documentBuilder.parse(new FileInputStream("C:\\ParsingTest.xml"));
    System.out.println("OK");
    documentBuilder.parse(new FileInputStream("C:\\ParsingTest.xml"));
    System.out.println("OK");

When this code is run it throws this exception:

Exception in thread "main" org.xml.sax.SAXParseException: cvc-elt.1: Cannot 
find the declaration of element 'A'.
        at 
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 
Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at 
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
        at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
        at test.ParsingTest.main(ParsingTest.java:34)

This code fail on Xerces 2.7.0 and 2.7.1. It works on Xerces 2.2.1, 2.3.0, 
2.4.0, 2.5.0, 2.6.0, 2.6.1 and 2.6.2. It also works on jaxp 1.2.2, jaxp 1.3.1 
and JDK 1.5.

This issue is very important for us because new validation API doesn't meet our 
performance requirements and requires JAXP 1.3 compatible parser (is less 
portable).


-- 
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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe