



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A vertical bar ( | ) is used to indicate one element or another. A DTD follows for a grocery store application. grocery.dtd. <!-- A document type definition ...
Typology: Slides
1 / 6
This page cannot be seen from the preview
Don't miss anything!




XML Document Type Definitions
Extensible Markup Language (XML) has developed in a major way in the last few years. It has become one of the most important means of exchanging information of all kinds on the Internet. And there are now a number of different specialized versions of XML. These range from markup for chemistry documents to a quick way to distribute news releases.
Specialized versions are accompanied by document type definitions (DTDs) and/or schema. Both provide some information about the tags used in the field, but schema, being more recent, are more extensive. However, we will begin with a look at DTDs.
Document Type Definitions
A DTD for an xml file is a list of elements (tags) used in the file, together with some information about how they are defined. The document must have a single root node. This is followed by the children of the root and either their children or data type. In a DTD there are only two data types, PCDATA (parsed character data) or CDATA, unparsed character data. Most of the examples will use parsed character data.
A DTD also indicates how many times an element can occur in the file. The default is once. But most files use the same tag names a number of times. The notation used is similar for that used in regular expressions.
A DTD follows for a grocery store application.
grocery.dtd
From this DTD you can see that the root element is
A file that satisfies all these requirements follows:
Some browsers will use this information to display the file while others will ignore it. Both Foxfire and Netscape version 7.2 understand the style sheet, while Internet Explorer version 6.0 does not.
The following style sheet will display the file in a table. grocery.css
/* Style sheet for address application. */ grocery { font-family: "Times New Roman", serif display: table; border-style: solid; border-width: thin; margin-left: 1.0cm; margin-top: 1.0cm; } heading, fruit, vegetables, bakery { display: table-row; } name, id, quantity, price { display: table-cell; border-style: solid; border-width: thin; padding: 0.3cm; text-align: center; }
If this style sheet is applied, the display looks like the following in Foxfire.
This style sheet says that the root element, grocery, should be displayed as a table. display: table; The other styles determine the font and table properties such as a solid, thin border and 1 cm margins.
The columns of the table are given by the next elements, heading, fruit, vegetables, and bakery. The style for these is display: table-row. This will display these elements as rows.
Finally the data elements, name, id, quantity, and price, will be displayed in the table cells. display: table-cell; The cell styles must also have instructions as to how the borders should appear.
There are many other applicable styles. W3Schools has an extensive list in their tutorial on CSS.
Attribute Lists in DTDs
XML tags may include attributes. These are name-value pairs such as width = "300". We have seen these in applet and image tags. They can be used in XML and are required in some places. An example might be the following xml file that contains information about students in a course. Each exam grade has a weight attribute to indicate how it should factor into the course grade.