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 Robert van Loenhout <r....@greenvalley.nl> on 2004/02/17 10:42:48 UTC

Schema validation without file

Hi,

is it possible with Xerces 2.6.1 to validate an XML document with an XML
Schema, where the schema is in memory (string or InputStream).
Or is it only possible to validate with the schema as a file location and
the SCHEMA_LOCATION or SCHEMA_NONS_LOCATION property?
Could someone mail me an example if this is possible.

Thanks!
Robert.



                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Schema validation without file

Posted by Phil Weighill-Smith <ph...@volantis.com>.
Provide an EntityResolver that returns your schema document as a stream
of some sort wrapped in an InputSource and assign the entity resolver to
the XML reader.

class MyEntityResolver implements EntityResolver {
    public InputSource resolveEntity(String publicId,
        String systemId) throws SAXException, IOException {
        InputSource inputSource = null;

        if (MY_SCHEMA_LOCATION.equals(systemId)) {
            inputSource = new InputSource(mySchemaInputStream);
        }

        return inputSource;
    }
}

Phil :n)

 On Tue, 2004-02-17 at 09:42, Robert van Loenhout wrote:

> Hi,
> 
> is it possible with Xerces 2.6.1 to validate an XML document with an XML
> Schema, where the schema is in memory (string or InputStream).
> Or is it only possible to validate with the schema as a file location and
> the SCHEMA_LOCATION or SCHEMA_NONS_LOCATION property?
> Could someone mail me an example if this is possible.
> 
> Thanks!
> Robert.

-- 
Phil Weighill-Smith <ph...@volantis.com>
Volantis Systems

Re: Schema validation without file

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
At least two choices:
1.  You could take all the in-memory schemas and pre-parse them into a
grammar pool.  See the Grammars FAQ.
2.  You could put some URIs into the SCHEMA_LOCATION list but provide an
EntityResolver subclass which knew how to find the in-memory strings or
input streams corresponding to those particular URIs and create an
InputSource on those objects.

Jeff

----- Original Message ----- 
From: "Robert van Loenhout" <r....@greenvalley.nl>
To: <xe...@xml.apache.org>
Sent: Tuesday, February 17, 2004 1:42 AM
Subject: Schema validation without file


> Hi,
>
> is it possible with Xerces 2.6.1 to validate an XML document with an XML
> Schema, where the schema is in memory (string or InputStream).
> Or is it only possible to validate with the schema as a file location and
> the SCHEMA_LOCATION or SCHEMA_NONS_LOCATION property?
> Could someone mail me an example if this is possible.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org