• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to validate xml using local xsd

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lookup into DOM and SAX parsers.

-Manhar.
 
eat bricks! HA! And here's another one! And a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic