Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

SchemaFactory.newSchema(..)

Thread view: 
slc - 12 Dec 2007 09:20 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.