<< Chapter < Page Chapter >> Page >

One file contains the information content of the document (words, pictures, etc.) . This is the part containing tags, elements, content, and attributes that the author wants to expose to the client. I have discussed this part in previouslessons.

A second file is the DTD, which meets the definition given above.

A third file is a stylesheet that establishes how the content that conforms to the DTD is to be rendered on the output device. This is how the author wantsthe material to be presented to the client.

Rendering

For example a tag with an attribute of "red" might cause something to be presented bright red according to one stylesheet and dull red according toanother stylesheet. (It might even be presented as some shade of green according to still another stylesheet.)

With XML, the DTD is optional but the stylesheet (or some processing mechanism that substitutes for a stylesheet) is generally required. Something has to beable to render the content in the manner that the author intended it to be rendered. Otherwise, the client will be forced to view the document as raw XMLtext, which usually isn't very enjoyable.

A DTD can be very complex

Once again, according to the XML FAQ :

"... the design and construction of a DTD can be a complex and non-trivial task, so XML has been designed so it can be used either with orwithout a DTD. DTDless operation means you can invent markup without having to define it formally. To make this work, a DTDless file in effect 'defines'its own markup, informally, by the existence and location of elements where you create them. But when an XML application such as a browser encounters aDTDless file, it needs to be able to understand the document structure as it reads it, because it has no DTD to tell it what to expect, so some changeshave been made to the rules."

Without the technical jargon please

In other words, it is entirely possible to create an XML document without the requirement for a DTD.

What is a valid document?

In the normal sense of the word, if something is invalid , that usually means that it is not any good. However, that is not the case for XML. Aninvalid XML document can be a perfectly good and useful document.

A valid XML document is one that conforms to an existing DTD in every respect.

In other words, unless the DTD allows a tag with the name "color", an XML document being validated against that DTD containing a tag with that name is notvalid.

However, because XML does not require a DTD, an XML processor cannot require validation of the document. Many very useful XML documents are not valid, simplybecause they were not constructed according to an existing DTD.

An XHTML document

The document that you are now reading was originally created as a valid XML document before being transformed to CNXML and uploaded to the Connexions website. It wascreated as a special flavor of XML known as XHTML. As I mentioned earlier, the document was created using W3C'sWYSIWYG Editor/Browser named Amaya . (Subsequent edited versions have been created using Microsoft Expression Web versions 3 and 4.)

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to xml. OpenStax CNX. Dec 02, 2014 Download for free at https://legacy.cnx.org/content/col11207/1.18
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to xml' conversation and receive update notifications?

Ask