After a bit of playing I got it to work with JAXP 1.4!
SchemaFactory factory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema();
Source ss = new StreamSource(inputstream, uri);
Validator v = schema.newValidator();
v.validate(ss);
Thanks for the help Stefan.
James.
-----Original Message-----
From: Stefan Bodewig [mailto:[email protected]]
Sent: Monday, 22 March 2010 11:44 PM
To: [email protected]
Subject: Re: [Xmlunit-general] xmlunit and setSystemId
On 2010-03-22, James Sewell <[email protected]> wrote:
> From looking at JAXP 1.3 I still can't see a way of defining an
> absolute URI to use when working with relative schema locations
> (unless this is what a ResourceResolver is for??)
Honestly I'm not sure whether ResourceResolver would be used for
schemaLocation hints since the docs (for
SchemaFactory#setResourceResolver) only talk about import and include.
It may be worth a try, but I'm afraid XMLUnit currently wouldn't give
you the access you'd need.
> As mentioned all my schema location information is included by way of
> xsi:SchemaLocation elements, but as they are relative (to the original
> XML document location) I need to be able to define a URI to use as a
> base.
If you are specifiying your input (the XML document) as a Source
instance it may be sufficient if this Source has the correct system ID.
I know you've tried that for the SAX InputSource used in the "old"
validation API, maybe JAXP13's take will yield better results.
> I could grab the elements from the XML document and use these schemas
> with addSchemaSource, but it seems like this should be unnecessary?
I agree there should be a better way. Unfortunately I haven't played
with that part of JAXP too much, so I can't help much more than ask you
to try out things.
Stefan
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general
The contents of this email are confidential and may be subject to legal or
professional privilege and copyright. No representation is made that this email
is free of viruses or other defects. If you have received this communication in
error, you may not copy or distribute any part of it or otherwise disclose its
contents to anyone. Please advise the sender of your incorrect receipt of this
correspondence.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general