Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Validating an Instance Document

Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using
as u hav not mentioned any targetNamespace in ur Schema so use noNamespaceSchemaLocation instead of schemaLocation.
This might work. plz check..
Ranch Hand
Posts: 498
Eclipse IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Danger, 10,000 volts, very electic .... tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic