File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes XML schema (XSD) validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML schema (XSD) validation" Watch "XML schema (XSD) validation" New topic

XML schema (XSD) validation

Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Hi all,
Not sure if this is the right board, but here goes.

I have a small XML document, and currently I am validating it be hand.

I have 2 question:
1) would it (in your opionon) be quicker/more efficent to use SAX to validate it?
2)With XML Scheme is there a difference between an element or arrtibute being empty (ie it is optional) and that element having a value which is empty (equal to "")?

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Hi Gavin,

Definitely it would be faster to do this validation using program than doing the same manually.

If an attribute is mandatory then the element has to have that attribute or else it would fail in validation.Even empty attribute would do.

If attribute sex is mandatory for element name.then the following is valid.

<name sex="">rahul</name>

You can find some code example in XML faq for validation.

Rahul Bhattacharjee
LinkedIn - Blog
I agree. Here's the link:
subject: XML schema (XSD) validation
It's not a secret anymore!