Hi,
I wan to validate a xml file with a xsd file.
So there istructions:
SchemaFactory sf =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new File(".../file.xsd"));
But when i build new instance of schema (sf.newSchema(...))
java give this error:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read
schema document XXXX', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
I have tried with several xsd files that seem are ok.
The file path is right.
What also con be?
Thanks,
slc.
Andrew Thompson - 12 Dec 2007 10:06 GMT
..
>I wan to validate a xml file with a xsd file.
>
>So there istructions:
..hmm. Code snippets are less helpful than an SSCCE*
>SchemaFactory sf =
>SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
>
>Schema schema = sf.newSchema(new File(".../file.xsd"));
Exactly where is File(".../file.xsd") ?
// test the path!
File testFile = new File(".../file.xsd");
System.out.println( testFile + " testFile.exists: " + testFile.exists() );
>But when i build new instance of schema (sf.newSchema(...))
>java give this error:
[quoted text clipped - 6 lines]
>I have tried with several xsd files that seem are ok.
>The file path is right.
I doubt that. You should check it specifically, by
adding the few lines shown above.
* The SSCCE
<http://www.physci.org/codes/sscce.html>

Signature
Andrew Thompson
http://www.physci.org/
Arne Vajhøj - 16 Dec 2007 02:07 GMT
> I wan to validate a xml file with a xsd file.
> SchemaFactory sf =
> SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
[quoted text clipped - 11 lines]
> I have tried with several xsd files that seem are ok.
> The file path is right.
Are you sure about the 3 dots ?
Arne