Hi Ross, If you can use JAXP 1.3 's Schema Validation API, then you can do something like :
StringReader xsdbuf = new StringReader(xsd); Schema schema = SchemaFactory.newSchema(new StreamSource(xsdbuf)); Then set the schema instance so obtained on the DocumentBuilderFactory / SaxParserFactory. Following write-ups may be of help : https://jaxp.dev.java.net/1.3/article/jaxp-1_3-article.html#Schema_Validation_Framework See the section titled : " Validation and Schema caching JAXP API" in this article. http://www.ibm.com/developerworks/xml/library/x-jaxp13a.html Hope this helps. -Prashant On Wed, 2008-04-16 at 10:10 -0700, RossOliver wrote: > Hey, > > I'm designing a servlet that takes uploaded XML and XSD files and validates > them using Xerces. The problem I have is that my XML and XSD files are > stored as Strings (this is unavoidable). I can give the parser the XML file > easily enough using: > > parser.parse( new InputSource( new StringReader( xml ) ) ); > > However, setting the XSD schema file is not as easy. It doesn't seem to > support the InputSource type as the value of the setProperty method. I have > also tried using a ByteArrayInputStream: > > parser.setProperty( > "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", > new ByteArrayInputStream( xsd.getBytes() ) ); > > As well as converting the string into a StreamSource and then into a Schema > object from the StreamSource, which also throws class cast exceptions... > > Any help would be greatly appretiated. > > Thanks for your time, > > -Ross --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]