What resources can I use to validate a DTD?

2020-07-13 08:42发布

问题:

What resources are available to validate a DTD? I want to be clear: I am not talking about validating XML documents against a DTD.

I am talking about making sure that the DTD itself is valid.

回答1:

I work with Oxygen xml editor, you can try for 30 day trial! Works very well with xml files, dtd, xslt... When you write DTD code you can validate it (document menu > validate). The dtd file is an xml file which describe a xml file.
This code:

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT chapter (title, paragraph)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT paragraph (#PCDATA)>

are valid. This code:

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT chapter (title, paragraph)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT paragraph (strong)>

give an alert. hope it work for you



回答2:

You are able to validate DTD files using the eclipse java IDE. I realise it is not a lightweight solution, however I found it useful whilst working with DTDs which would eventually be compiled to Java classes via xjc.

To do this you can load the .dtd file in eclipse (copy it into a project, or point your project towards your dtd file). Then in the file navigator in eclipse, you can right click on the dtd, then click validate.

For documentation see the Eclipse official website



回答3:

I found a solution. Validome is a free, online DTD and Schema validator. It does not require me to sign up for any trials, or install any frameworks or other software in order to validate a DTD. Hope this helps someone else. Cheers.



标签: xml dtd