[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Validating against a Schema
- From: Eric van der Vlist <vdv@dyomedea.com>
- To: Richard Featherstone <R.Featherstone@uea.ac.uk>
- Date: Fri, 06 Jul 2001 10:53:34 +0200
Richard Featherstone wrote:
>
> Could someone either tell me how or point me in the right direction to
> find out how to validate an XML doc against a Schema using Java. I can
> parse without validating but don't know
>
> a) how the parser can decide what Schema is being used from the XML doc
> and where to locate it
First thing, you need to use a XML parser that supports W3C XML Schema
such as Xerces-J [1] (1.4.1 or above) .
Then, the parser will have 3 ways to locate the schema to use.
1) Parsers are required to provide an implementation specific way to
define the schema locations as parameters.
Xerces-J does this through the
http://apache.org/xml/properties/schema/external-schemaLocation and
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
properties.
2) Using the xsi:schemaLocation and xsi:noNamespaceSchemaLocation
attributes in the instance document.
3) Trying to dereference the URI associated with the namespace to see if
there is a schema at this location.
>
> b) how to configure the parser to validate the doc against the schema
Using the "isValidating" method.
> I apologise if this is the wrong place to ask a question like this but
> I've spent days looking everywhere for the answer.
You should have asked before ;=)
Hope this helps.
Eric
[1] http://xml.apache.org/xerces-j/index.html
>
> thanks in advance
>
> Richard
>
--
See you at XTech in San Diego.
http://conferences.oreillynet.com/cs/os2001/view/e_spkr/790
------------------------------------------------------------------------
Eric van der Vlist http://xmlfr.org http://dyomedea.com
http://xsltunit.org http://4xt.org http://examplotron.org
------------------------------------------------------------------------