Checking XML DTD syntax and validating XML

Discussion in 'XML' started by Clifford W. Racz, Jun 7, 2004.

  1. Does anyone know of a decent tool, preferably free, that will check and validate DTD syntax, to make sure that my DTD is correct?

    The only tool that I have found thus far is the IBM visual DTD tool, which I do like, but is limited. Basically, your DTD is "good" when it parses... and I am not sure this is the best way to do it.



    As for validation of XML, I have found a great tool, xmlvalid, here:
    < http://www.elcel.com/products/xmlvalid.html >


    Cliff
    Clifford W. Racz, Jun 7, 2004
    #1
    1. Advertising

  2. Hi Cliff

    xmlspy from altova is contains a DTD validator. Xmlspy is an excellent tool.
    Unfortunately it is not free, however you may download a 30day trial from
    their website.

    /Sebastian www.tomac.se

    "Clifford W. Racz" <> wrote in message
    news:...
    > Does anyone know of a decent tool, preferably free, that will check and

    validate DTD syntax, to make sure that my DTD is correct?
    >
    > The only tool that I have found thus far is the IBM visual DTD tool, which

    I do like, but is limited. Basically, your DTD is "good" when it parses...
    and I am not sure this is the best way to do it.
    >
    >
    >
    > As for validation of XML, I have found a great tool, xmlvalid, here:
    > < http://www.elcel.com/products/xmlvalid.html >
    >
    >
    > Cliff
    Sebastian Tomac, Jun 8, 2004
    #2
    1. Advertising

  3. Clifford W. Racz

    Ghee Guest

    Sebastian Tomac wrote:
    > xmlspy from altova is contains a DTD validator. Xmlspy is an excellent tool.
    > Unfortunately it is not free, however you may download a 30day trial from
    > their website.


    You can get a free copy - the entry level "home" version at
    http://www.altova.com/download_spy_home.html

    Ghee
    Ghee, Jun 8, 2004
    #3
  4. Clifford W. Racz

    Rainer Typke Guest

    http://xmlvalidation.com should work, too, and for free.

    Rainer


    Ghee <> wrote in message news:<>...
    > Sebastian Tomac wrote:
    > > xmlspy from altova is contains a DTD validator. Xmlspy is an excellent tool.
    > > Unfortunately it is not free, however you may download a 30day trial from
    > > their website.

    >
    > You can get a free copy - the entry level "home" version at
    > http://www.altova.com/download_spy_home.html
    >
    > Ghee
    Rainer Typke, Jun 15, 2004
    #4
  5. Thanks Rainer, but that only validates XML files, not DTD syntax checking.


    Clifford

    Rainer Typke wrote:
    > http://xmlvalidation.com should work, too, and for free.
    >
    > Rainer
    Clifford W. Racz, Jun 16, 2004
    #5
  6. Clifford W. Racz

    Rainer Typke Guest

    If you refer to a DTD in a checked XML document, the XML validator
    asks you to upload that as well and also validates it, if I am not
    mistaken.

    Cheers,

    Rainer

    "Clifford W. Racz" <> wrote in message news:<>...
    > Thanks Rainer, but that only validates XML files, not DTD syntax checking.
    >
    >
    > Clifford
    >
    > Rainer Typke wrote:
    > > http://xmlvalidation.com should work, too, and for free.
    > >
    > > Rainer
    Rainer Typke, Jun 17, 2004
    #6
  7. Oh, I see.

    The tool does validate an uploaded XML Schema against the XML Schema definition (again, another schema).

    The tool does not check DTD Syntax though. It treats it like and XSD and fails on the first entity.

    Thanks though for the comment.


    Rainer Typke wrote:
    > If you refer to a DTD in a checked XML document, the XML validator
    > asks you to upload that as well and also validates it, if I am not
    > mistaken.
    >
    > Cheers,
    >
    > Rainer
    Clifford W. Racz, Jun 17, 2004
    #7
  8. Clifford W. Racz

    Rainer Typke Guest

    "Clifford W. Racz" <> wrote in message news:<>...
    ....
    > The tool does validate an uploaded XML Schema against the XML Schema definition (again, another schema).
    >
    > The tool does not check DTD Syntax though. It treats it like and XSD and fails on the first entity.

    ....

    Well, you can't upload and check a DTD directly. But there is a way of
    forcing the tool to actually perform a DTD syntax check: just write an
    XML file that does nothing except for referring to your DTD and upload
    it. The tool will then prompt you for the DTD, you can upload it in a
    second step, and if there is a syntax error in your DTD, you will get
    an error message. If the DTD is correct but your dummy XML file does
    not conform to it, that fact will be reported after any errors in the
    DTD.

    This works for both DTDs and XSDs.

    You can test this workaround by using an error-free pair of an XML and
    DTD file (for example the files I will attach below), then insert a
    syntax error in the DTD (for example, change an ATTLIST into an
    ATLIST). The tool will then report that syntax error.

    Hope this clears it up. I see that it would be a nice future feature
    for the site to also offer syntax checks for DTD files without XML
    files, so you are not forced to do that workaround.

    Rainer

    XML file:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE personnel SYSTEM "personal.dtd">
    <personnel>

    <person id="Big.Boss">
    <name><family>Boss</family> <given>Big</given></name>
    <email></email>
    <link subordinates="one.worker two.worker three.worker four.worker
    five.worker"/>
    </person>

    <person id="one.worker">
    <name><family>Worker</family> <given>One</given></name>
    <email></email>
    <link manager="Big.Boss"/>
    </person>

    <person id="two.worker">
    <name><family>Worker</family> <given>Two</given></name>
    <email></email>
    <link manager="Big.Boss"/>
    </person>

    <person id="three.worker">
    <name><family>Worker</family> <given>Three</given></name>
    <email></email>
    <link manager="Big.Boss"/>
    </person>

    <person id="four.worker">
    <name><family>Worker</family> <given>Four</given></name>
    <email></email>
    <link manager="Big.Boss"/>
    </person>

    <person id="five.worker">
    <name><family>Worker</family> <given>Five</given></name>
    <email></email>
    <link manager="Big.Boss"/>
    </person>

    </personnel>


    DTD:

    <?xml encoding="UTF-8"?>
    <!ELEMENT personnel (person)+>

    <!ELEMENT person (name,email*,url*,link?)>
    <!ATTLIST person id ID #REQUIRED>
    <!ATTLIST person note CDATA #IMPLIED>
    <!ATTLIST person contr (true|false) 'false'>
    <!ATTLIST person salary CDATA #IMPLIED>

    <!ELEMENT name ((family,given)|(given,family))>

    <!ELEMENT family (#PCDATA)>

    <!ELEMENT given (#PCDATA)>

    <!ELEMENT email (#PCDATA)>

    <!ELEMENT url EMPTY>
    <!ATTLIST url href CDATA 'http://'>

    <!ELEMENT link EMPTY>
    <!ATTLIST link manager IDREF #IMPLIED>
    <!ATTLIST link subordinates IDREFS #IMPLIED>

    <!NOTATION gif PUBLIC '-//APP/Photoshop/4.0' 'photoshop.exe'>
    Rainer Typke, Jun 22, 2004
    #8
  9. Rainer,


    Ahh... I see what you are saying. This is effectively verifying syntax by failing if it doesn't parse in the XML validator. And, if it fails to parse, it throws an error and passes that along.

    That is what I am doing now to check my DTDs. If this is the best I can do without spending hundreds of dollars on a program, then so be it. It always helps to have another data point...


    Thanks,
    Clifford



    Rainer Typke wrote:
    > ....
    >
    > Well, you can't upload and check a DTD directly. But there is a way of
    > forcing the tool to actually perform a DTD syntax check: just write an
    > XML file that does nothing except for referring to your DTD and upload
    > it. The tool will then prompt you for the DTD, you can upload it in a
    > second step, and if there is a syntax error in your DTD, you will get
    > an error message. If the DTD is correct but your dummy XML file does
    > not conform to it, that fact will be reported after any errors in the
    > DTD.
    >
    > This works for both DTDs and XSDs.
    Clifford W. Racz, Jun 23, 2004
    #9
    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. Ben Jessel
    Replies:
    0
    Views:
    400
    Ben Jessel
    Aug 5, 2004
  2. Replies:
    1
    Views:
    391
    Stanimir Stamenkov
    Jan 21, 2005
  3. bugbear
    Replies:
    0
    Views:
    1,008
    bugbear
    Aug 28, 2003
  4. test
    Replies:
    2
    Views:
    2,024
    Oliver Wong
    Jul 28, 2006
  5. salimk786
    Replies:
    8
    Views:
    1,622
    Roedy Green
    Aug 4, 2007
Loading...

Share This Page