You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2008/09/09 17:57:59 UTC
svn commit: r693499 - in
/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces:
impl/xs/traversers/XSDHandler.java jaxp/validation/BaseSchemaFactory.java
Author: mrglavas
Date: Tue Sep 9 08:57:58 2008
New Revision: 693499
URL: http://svn.apache.org/viewvc?rev=693499&view=rev
Log:
JIRA Issue #1313:
http://issues.apache.org/jira/browse/XERCESJ-1313
Completed support for schema loading from a StAX source.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/BaseSchemaFactory.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java?rev=693499&r1=693498&r2=693499&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java Tue Sep 9 08:57:58 2008
@@ -24,6 +24,8 @@
import java.util.Stack;
import java.util.Vector;
+import javax.xml.stream.XMLStreamException;
+
import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLEntityManager;
import org.apache.xerces.impl.XMLErrorReporter;
@@ -55,6 +57,7 @@
import org.apache.xerces.util.DOMInputSource;
import org.apache.xerces.util.DefaultErrorHandler;
import org.apache.xerces.util.SAXInputSource;
+import org.apache.xerces.util.StAXInputSource;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.util.XMLSymbols;
import org.apache.xerces.util.URI.MalformedURIException;
@@ -367,6 +370,7 @@
SchemaDOMParser fSchemaParser;
SchemaContentHandler fXSContentHandler;
+ StAXSchemaParser fStAXSchemaParser;
XML11Configuration fAnnotationValidator;
XSAnnotationGrammarPool fGrammarBucketAdapter;
@@ -553,7 +557,30 @@
return null;
}
schemaRoot = DOMUtil.getRoot(schemaRootDoc);
- }
+ }
+ else if (is instanceof StAXInputSource) {
+ StAXInputSource sis = (StAXInputSource)is;
+ if (fStAXSchemaParser == null) {
+ fStAXSchemaParser = new StAXSchemaParser();
+ }
+ fStAXSchemaParser.reset(fSchemaParser, fSymbolTable);
+ try {
+ if (sis.getXMLEventReader() != null) {
+ fStAXSchemaParser.parse(sis.getXMLEventReader());
+ }
+ else {
+ fStAXSchemaParser.parse(sis.getXMLStreamReader());
+ }
+ }
+ catch (XMLStreamException e) {
+ return null;
+ }
+ schemaRootDoc = fStAXSchemaParser.getDocument();
+ if (schemaRootDoc == null) {
+ return null;
+ }
+ schemaRoot = DOMUtil.getRoot(schemaRootDoc);
+ }
else {
schemaRoot = getSchemaDocument(schemaNamespace, is,
referType == XSDDescription.CONTEXT_PREPARSE,
@@ -1788,7 +1815,30 @@
return null;
}
return DOMUtil.getRoot(root);
- }
+ }
+ else if (schemaSource instanceof StAXInputSource) {
+ StAXInputSource sis = (StAXInputSource)schemaSource;
+ if (fStAXSchemaParser == null) {
+ fStAXSchemaParser = new StAXSchemaParser();
+ }
+ fStAXSchemaParser.reset(fSchemaParser, fSymbolTable);
+ try {
+ if (sis.getXMLEventReader() != null) {
+ fStAXSchemaParser.parse(sis.getXMLEventReader());
+ }
+ else {
+ fStAXSchemaParser.parse(sis.getXMLStreamReader());
+ }
+ }
+ catch (XMLStreamException e) {
+ return null;
+ }
+ Document root = fStAXSchemaParser.getDocument();
+ if (root == null) {
+ return null;
+ }
+ return DOMUtil.getRoot(root);
+ }
return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
} // getSchema(String, String, String, boolean, short): Document
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/BaseSchemaFactory.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/BaseSchemaFactory.java?rev=693499&r1=693498&r2=693499&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/BaseSchemaFactory.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/BaseSchemaFactory.java Tue Sep 9 08:57:58 2008
@@ -23,9 +23,11 @@
import java.util.Locale;
import javax.xml.XMLConstants;
+import javax.xml.stream.XMLEventReader;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
@@ -38,6 +40,7 @@
import org.apache.xerces.util.SAXInputSource;
import org.apache.xerces.util.SAXMessageFormatter;
import org.apache.xerces.util.SecurityManager;
+import org.apache.xerces.util.StAXInputSource;
import org.apache.xerces.util.XMLGrammarPoolImpl;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.grammars.Grammar;
@@ -190,6 +193,16 @@
String systemID = domSource.getSystemId();
xmlInputSources[i] = new DOMInputSource(node, systemID);
}
+ else if (source instanceof StAXSource) {
+ StAXSource staxSource = (StAXSource) source;
+ XMLEventReader eventReader = staxSource.getXMLEventReader();
+ if (eventReader != null) {
+ xmlInputSources[i] = new StAXInputSource(eventReader);
+ }
+ else {
+ xmlInputSources[i] = new StAXInputSource(staxSource.getXMLStreamReader());
+ }
+ }
else if (source == null) {
throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(Locale.getDefault(),
"SchemaSourceArrayMemberNull", null));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org