I think what you need is the EntityResolver, you set a EntityResolver to the parser, during the parsing/validation, the parser calls your EntityResolver to get the XSD, then you return the in-memory XSD from the EntityResolver, be sure set the SystemId on the returned InputSource.
Benson. -----Original Message----- From: Lauren Bish [mailto:[EMAIL PROTECTED] Sent: Friday, June 24, 2005 10:08 AM To: [email protected] Subject: Re: XML Schema validation without XSD file but with XSD in memory?? Thanks George, That helps a lot. What I have is a class that, on the fly (i.e., can change dynamically from one instant to the next), defines a structure against which I need to validate a given subset of XML - so I need to convert that class into an in memory XSD and then hand that to the parser. I was thinking that instead of creating an XSD file from my class, that I could somehow take my class and create the XSD in memory without having to create a string representation of the XSD. But I will figure it out with that link I think - apparently the object I want to create either a org.apache.xerces.xni.grammars.XSGrammar; or an org.apache.xerces.xs.XSModel. George Cristian Bina wrote: > Hi Lauren, > > For validating a document with a specified schema see > http://xml.apache.org/xerces2-j/faq-grammars.html > > If you have the schema document as a String in memory then you can > very > easily feed that to the parser. The parser needs an InputSource and that > does not require a file, you can set directly a Reader that can be a > StringReader created over the String that represents your schema. > > Hope that helps, > George > --------------------------------------------------------------------- > George Cristian Bina > <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger > http://www.oxygenxml.com > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
