neilg 2002/11/11 12:47:31 Modified: java/src/org/apache/xerces/impl/xs XMLSchemaLoader.java Log: fixing bug 14455. Since it is not possible to read a byte stream twice, we used to fail when we tried doing so. Revision Changes Path 1.12 +31 -4 xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java Index: XMLSchemaLoader.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- XMLSchemaLoader.java 28 Oct 2002 05:06:30 -0000 1.11 +++ XMLSchemaLoader.java 11 Nov 2002 20:47:31 -0000 1.12 @@ -186,6 +186,7 @@ private String fExternalSchemas = null; private String fExternalNoNSSchema = null; private Object fJAXPSource = null; + private Hashtable fJAXPCache; private Locale fLocale = Locale.getDefault(); private XSDHandler fSchemaHandler; @@ -243,6 +244,7 @@ fCMBuilder = builder; fSchemaHandler = new XSDHandler(fGrammarBucket); fDeclPool = new XSDeclarationPool(); + fJAXPCache = new Hashtable(); } /** @@ -448,6 +450,7 @@ fSchemaHandler.setDeclPool(null); } fSubGroupHandler.reset(); + fJAXPProcessed = false; } // reset() /** @@ -576,6 +579,7 @@ * that it should. - NG */ private void processJAXPSchemaSource(Hashtable locationPairs) throws IOException { + fJAXPProcessed = true; if (fJAXPSource == null) { return; } @@ -585,6 +589,14 @@ String sid = null; if (componentType == null) { // Not an array + if(fJAXPSource instanceof InputStream || + fJAXPSource instanceof InputSource) { + SchemaGrammar g = (SchemaGrammar)fJAXPCache.get(fJAXPSource); + if(g != null) { + fGrammarBucket.putGrammar(g); + return; + } + } fXSDDescription.reset(); xis = xsdToXMLInputSource(fJAXPSource); sid = xis.getSystemId(); @@ -594,8 +606,12 @@ fXSDDescription.setExpandedSystemId(sid); fXSDDescription.fLocationHints = new String[]{sid}; } - fJAXPProcessed = true; - fGrammarBucket.putGrammar(loadSchema(fXSDDescription, xis, locationPairs)); + SchemaGrammar g = loadSchema(fXSDDescription, xis, locationPairs); + if(fJAXPSource instanceof InputStream || + fJAXPSource instanceof InputSource) { + fJAXPCache.put(fJAXPSource, g); + } + fGrammarBucket.putGrammar(g); return ; } else if ( (componentType != Object.class) && (componentType != String.class) && @@ -614,10 +630,17 @@ // JAXP spec. allow []s of type String, File, InputStream, // InputSource also, apart from [] of type Object. Object[] objArr = (Object[]) fJAXPSource; - fJAXPProcessed = true; //make local vector for storing targetn namespaces of schemasources specified in object arrays. Vector jaxpSchemaSourceNamespaces = new Vector() ; for (int i = 0; i < objArr.length; i++) { + if(objArr[i] instanceof InputStream || + objArr[i] instanceof InputSource) { + SchemaGrammar g = (SchemaGrammar)fJAXPCache.get(objArr[i]); + if (g != null) { + fGrammarBucket.putGrammar(g); + continue; + } + } fXSDDescription.reset(); xis = xsdToXMLInputSource(objArr[i]); sid = xis.getSystemId(); @@ -639,6 +662,10 @@ } else{ jaxpSchemaSourceNamespaces.add(targetNamespace) ; + } + if(objArr[i] instanceof InputStream || + objArr[i] instanceof InputSource) { + fJAXPCache.put(objArr[i], grammar); } fGrammarBucket.putGrammar(grammar); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]