You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Christoph Metzendorf <Ch...@ptv.de> on 2003/06/20 10:18:17 UTC

Validate against XML Schema without URI

Hi,

how can I validate a XML document against a XML Schema, where the schema
isn't available as a file or something else one could point at with a URI.
Instead the schema's content comes as a string representation out of a
database. Supports Xerces validation against a string of an XML Schema? If
so, how can this be done? If it's not possible, does anyone know a XML
parser for Java which supports this task?

Thanks in advance,
Christoph

Re: Validate against XML Schema without URI

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
Validate against XML Schema without URII think you would:

  1.  Add an externalSchemaLocation property to the parser which specifies a URI of your choice for the schema for the given namespace.
  2.  Provide an org.xml.sax.EntityResolver specialization for the parser whose resolveEntity which would treat this particular URI specially when it was passed as systemId, to wit
     -- extract the string representing the entire schema from the database
     -- construct a java.io.StringReader on this string
     -- return an org.sax.InputSource based on that Reader

If you can get the schema out of the database as an InputStream, you can skip the step of making a string out of it, just construct the InputSource on that stream.

The documentation for EntityResolver gives more detail.

Jeff
  ----- Original Message ----- 
  From: Christoph Metzendorf 
  To: xerces-j-user@xml.apache.org 
  Sent: Friday, June 20, 2003 1:18 AM
  Subject: Validate against XML Schema without URI


  Hi, 

  how can I validate a XML document against a XML Schema, where the schema isn't available as a file or something else one could point at with a URI. Instead the schema's content comes as a string representation out of a database. Supports Xerces validation against a string of an XML Schema?