Browse DevX
Sign up for e-mail newsletters from DevX


XML DTDs : Page 2

Valid XML documents follow a set of rules defined in a associated DTD. This Document Type Definition defines elements, attributes, and relationships between elements.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Finding a DTD
Using a DTD doesn't necessarily mean you have to create one from scratch. There are a number of existing DTDs, with more being added everyday.

Shared DTDs
As XML becomes wide-spread, your industry association or company is likely to have one or more published DTDs that you can use and link to. These DTDs define tags for elements that are commonly used in your applications. You don't need to recreate these DTDs -- you just point to them in your doctype tag in your XML file, and follow their rules when you create your XML document.

Some of these DTDs may be public DTDs, like the HTML DTD. Others may belong to your company. If you are interested in using a DTD, ask around and see if there is a good match that already exists.

Create Your Own External DTD
Another option is to create your own DTD. The DTD can be very simple and basic or it can be large and complex. The DTD will be a reflection of the needs of your document.

It is perfectly acceptable to have a DTD with just four or five basic elements if that is what your document needs. Don't feel that creating a DTD necessarily needs to be a huge undertaking.

However, if your documents are complex, do plan on setting aside time -- several days or several weeks -- to understand the document and the document elements and create a solid DTD that will really work for you over time. Remember, you'll be able to use this DTD with many individual documents, so it is worth the time to think it through and craft it well.

Create Your Own Internal DTDs
You can insert DTD data within your DOCTYPE definition in an individual XML document. If you're worked with CSS styles, you can think of this as being a little like putting style data into your file header.

DTDs inserted this way are used in that specific XML document only. This might be the approach to take if you want to validate the use of a small number of tags in a single document or to make elements that will be used only for one document.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date