File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Product and Other Certifications and the fly likes Validating an Instance Document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Validating an Instance Document" Watch "Validating an Instance Document" New topic

Validating an Instance Document

Hongqing Lu

Joined: Jan 14, 2004
Posts: 13
I want to validate an instance document user.xml based on user.xsd.
<?xml version="1.0"?>
<xs:schema xmlns:xs="">
<xs:element name="user">
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
xml file is user.xml:
<?xml version="1.0"?>
<user xmlns:xsi=""
when I begin to validate the user.xml based user.xsd
the parser give the following error:
unable to determine location of schema components set
Both user.xsd and user.xml in the same directory in my pc.
How to fix it?
Any help would be appreciated.
Andy Smith
Ranch Hand

Joined: Sep 28, 2003
Posts: 239
Try using
as u hav not mentioned any targetNamespace in ur Schema so use noNamespaceSchemaLocation instead of schemaLocation.
This might work. plz check..

Share Knowledge to gain it.
SCJP 2, SCWCD 2, SCDJWS, IBM 141 (In Progress), IBM 486 (Next)
Marcelo Sousa Ancelmo
Ranch Hand

Joined: Jan 17, 2002
Posts: 498

Are you using Xerces-J to validate the document?
To validate a XML Document using Xerces do the following (I believe you are using JAXP):

The System property can be passed as a command line argument using -D option or can be put in a property file.
In this example I used a SAX based approach, but you can use DOM as well

Marcelo Sousa Ancelmo - Brazil
I agree. Here's the link:
subject: Validating an Instance Document
jQuery in Action, 3rd edition