• 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 can i validate?

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How can I parse a XML, validating it to the XSD using SAX parser?
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suhas,
I would suggest getting a good textbook, "Java & XML" (2nd edition) by Brett McLaughlin is an excellent introduction to XML handling with java.

As a quick intro, you need to :

1) Create an XML reader using SAX factory method


2) Define a class that implements the ContentHandler interface and register an instance of that class with the reader.


3) Create an InputSource that points to the XML file to parse


4) Set the appropriate features on the parser to turn on validation eg
<>

5) Call parse() on the reader, all event will then be sent to the object that you registered as the contentHandler.



/Tom
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic