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 Evyatar Kafkafi <Ev...@orsus.com> on 2002/08/08 15:17:20 UTC
XSD from a string in java
Hi all,
I've successfully validated a XML file compared to its XSD file. But for the
project i'm working on, the xml and XSD information must come from a
string object instead of a file object.
So, i've got 2 strings:
1 containing XML
and 1 containing XSD
i've been able to parse an xml-string with
parser.parse(new InputSource(new StringReader(xml)));
but i can not find where i can saywhere the XSD must come from...
the property http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
only accepts files as it's value...
is there any other way to realize this ?
TIA
Evyatar
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: XSD from a string in java
Posted by Loz <lo...@flower.powernet.co.uk>.
Loz wrote:
>
> You can register an EntityHandler when you set up your sax parser.
Sorry that should be EntityResolver.
apologies
Loz
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: XSD from a string in java
Posted by Loz <lo...@flower.powernet.co.uk>.
Evyatar Kafkafi wrote:
> Hi all,
>
> I've successfully validated a XML file compared to its XSD file. But for the
> project i'm working on, the xml and XSD information must come from a
> string object instead of a file object.
>
> So, i've got 2 strings:
> 1 containing XML
> and 1 containing XSD
>
> i've been able to parse an xml-string with
> parser.parse(new InputSource(new StringReader(xml)));
>
> but i can not find where i can saywhere the XSD must come from...
>
> the property http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
> only accepts files as it's value...
>
> is there any other way to realize this ?
>
> TIA
> Evyatar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
You can register an EntityHandler when you set up your sax parser. The
parser will call back on this interface whenever it tries to read an
external entity. You can create a second input source with your xsd in
there. There is a bug in xerces 2.0.2 which means you should also set a
systemId on your input source in this case (see
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11455)
cheers
Loz
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org