File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes how to validate xml using local xsd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "how to validate xml using local xsd" Watch "how to validate xml using local xsd" New topic
Author

how to validate xml using local xsd

giridhar challa
Greenhorn

Joined: May 02, 2006
Posts: 18
Hi,
I am new to schemas.

I have one basic doubt.
I have one xml like this.

<?xml version="1.0"?>
<!--
<!DOCTYPE note SYSTEM "note.dtd">
-->


<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>

</note>

And i have note.xsd as follows.

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

As scehmas are much better than dtds
how can i validate note.xml with note.xsd if both are located in the same directory.
Manhar Puri
Ranch Hand

Joined: Aug 23, 2005
Posts: 41
Is this realted to web services? Please give more details as to what you are trying to do.

There are tools out there like xmlbeans which do schema validation automatically (when u request it to) for you when converting java beans to xml or vice versa.

-Manhar.
[ June 16, 2006: Message edited by: Manhar Puri ]
giridhar challa
Greenhorn

Joined: May 02, 2006
Posts: 18
Thanks for your intrest.
I am new to web services.

It is not related to web services.
recently i have started working on web services.
i got to know that schemas, xml namespaces and wsdl are the basics for webservices.
I was going through schema tutorial from w3schools.com.
There i got to know that they are validating the xml document with schema document which is located at w3schools.com.

If I have xml doc and schema doc located at my c:\gir\tutorial_schema.

how to mention in xml doc to validate from the required schema doc?

once again thanks for your intrest.

regards,
giridhar.
Manhar Puri
Ranch Hand

Joined: Aug 23, 2005
Posts: 41
Lookup into DOM and SAX parsers.

-Manhar.
 
GeeCON Prague 2014
 
subject: how to validate xml using local xsd