[
https://issues.apache.org/jira/browse/XERCESJ-1754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17676910#comment-17676910
]
Mukul Gandhi commented on XERCESJ-1754:
---------------------------------------
I've written a Java program, with following outline, to debug this issue,
String xmlParserClass = "org.apache.xerces.parsers.SAXParser";
String schemaFeature = "http://apache.org/xml/features/validation/schema";
String xmlDocument = "test.xml";
XMLReader xmlReader = XMLReaderFactory.createXMLReader(xmlParserClass);
xmlReader.setFeature(schemaFeature, true);
xmlReader.setErrorHandler(new XmlParseErrorHandler());
xmlReader.parse(xmlDocument); // parse and validate (a)
xmlReader.parse(xmlDocument); // parse and validate, again (b)
I've used your, attached XML instance and XML Schema documents. But I've run
the XML Schema validation with 1.0 mode. i.e, I've modified the XML instance
documents that you've have shared, as following,
<Doc xmlns="http://example.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ test.xsd">
........
As we can see that, on the Java commented lines above [(a) and (b)], we do XML
Schema validation twice (with XML instance and XML Schema documents remaining
same) reusing the same XMLReader object instance. And on both occasions (a) and
(b), I don't get any XML Schema validation errors.
Out of curiosity, if I add little delay between xmlReader.parse ... calls like
below, I still don't get any XML Schema validation errors.
Thread.sleep(1000 * 5);
Do you think, this issue is with XercesJ's XML Schema 1.1 validator, and not
with 1.0 validator?
> XMLSchemaValidator reset no longer resets id validation caches
> --------------------------------------------------------------
>
> Key: XERCESJ-1754
> URL: https://issues.apache.org/jira/browse/XERCESJ-1754
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Reporter: Radu Coravu
> Priority: Major
> Attachments: test.xml, test.xsd
>
>
> I validate an XML with an XML Schema 1.1 file.
> On the first validation the XML is reported valid.
> On the second validation I re-use the parser, the ID values inside elements
> are reported as duplicate and I get errors like this reported:
> {code}Message: cvc-type.3.1.3: The value 'thing122' of element 'uid' is not
> valid.{code}
> Looking at the method
> org.apache.xerces.impl.xs.XMLSchemaValidator.reset(XMLComponentManager),
> there is a fast return inside it:
> {code} if (!parser_settings) {
> // parser settings have not been changed
> fValidationManager.addValidationState(fValidationState);
> // the node limit on the SecurityManager may have changed so need
> to refresh.
> nodeFactory.reset();
> // Re-parse external schema location properties.
> XMLSchemaLoader.processExternalHints(
> fExternalSchemas,
> fExternalNoNamespaceSchema,
> fLocationPairs,
> fXSIErrorReporter.fErrorReporter);
> return;
> }{code}
> and this means all the code which for example cleared the IDs cache:
> {code} // reset ID Context
> if (fIDContext != null) {
> fIDContext.clear();
> }{code}
> is no longer executed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]