DTD/XSD in java

A

Arun

I need to take either a DTD/XSD (preferably a DTD), and use it as a
schema to process an XML file.
Can someone tell me the best way to do so?
 
M

Martin Honnen

Arun said:
I need to take either a DTD/XSD (preferably a DTD), and use it as a
schema to process an XML file.
Can someone tell me the best way to do so?

With Sun JDK 1.5 there is a special package
<http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/package-summary.html>
for validating against a schema (XSD for example).
DTD validation is different as a DTD is supposed to be linked in from
the XML instance via the
<!DOCTYPE root-element SYSTEM "whatever.dtd">
there all you need to do with Sun JDK 1.4 or later is to use an
appropriate factory (e.g. SAXParserFactory or DocumentBuilderFactory)
from javax.xml.parsers and call setValidating(true).
 
A

Arun

O yes that's right...

I've used antstructure to extract a DTD and now need to convert that to
XSD so i can have a schema to validate XML files used in an app im
creating. Having problems converting it correctly though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top