DTD/XSD in java

Discussion in 'XML' started by Arun, Jan 21, 2005.

  1. Arun

    Arun Guest

    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?
    Arun, Jan 21, 2005
    #1
    1. Advertising

  2. Arun wrote:

    > 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).


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 21, 2005
    #2
    1. Advertising

  3. Arun

    Arun Guest

    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.
    Arun, Jan 22, 2005
    #3
  4. /Arun/:

    > 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.


    Use some ready-made utility like "trang"
    <http://www.thaiopensource.com/relaxng/trang.html>. You may observe
    the tools <http://www.w3.org/XML/Schema#Tools> listed on the XML
    Schema page as there are similar utilities, too.

    --
    Stanimir
    Stanimir Stamenkov, Jan 24, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joseph Tilian
    Replies:
    0
    Views:
    340
    Joseph Tilian
    Dec 21, 2004
  2. Replies:
    1
    Views:
    385
    Stanimir Stamenkov
    Jan 21, 2005
  3. Ronald Fischer
    Replies:
    4
    Views:
    1,743
    Ronald Fischer
    Mar 17, 2005
  4. Matt
    Replies:
    3
    Views:
    37,205
    MKNDK
    Sep 11, 2008
  5. test
    Replies:
    2
    Views:
    1,999
    Oliver Wong
    Jul 28, 2006
Loading...

Share This Page