By Erik T. Ray
Price: $39.95 USD
£28.50 GBP
Cover | Table of Contents | Colophon
<caldata>
<holiday type="international">
<name>New Year's Day</name>
<date><month>January</month><day>1</day></date>
</holiday>
<holiday type="personal">
<name>Erik's birthday</name>
<date><month>April</month><day>23</day></date>
</holiday>
<holiday type="national">
<name>Independence Day</name>
<date><month>July</month><day>4</day></date>
</holiday>
<holiday type="religious">
<name>Christmas</name>
<date><month>December</month><day>25</day></date>
</holiday>
</caldata>
http://www.lysator.liu.se/~lenst/. It adds
menus and commands for inserting tags and showing information about a
DTD. It even comes with an XML parser that can detect structural
mistakes while you're editing a document. Using
psgml and a feature called
"font-lock," you can set up
xemacs, an X Window version of
emacs, to highlight markup in color. Figure 1-5 is a snapshot of xemacs
with an XML document open.
http://www.w3.org/TR/2000/REC-xml-20001006).
This is the second edition of the original which first appeared in
1998. You may also find Tim Bray's annotated,
interactive version useful. Go and check it out at http://www.xml.com/axml/testaxml.htm.|
Object
|
Purpose
|
Example
|
|---|---|---|
|
empty element
|
Represent information at a specific point in the document.
|
<xref linkend="abc"/>
|
|
container element
|
Group together elements and character data.
|
<p>This is a paragraph.</p>
|
|
declaration
|
Add a new parameter, entity, or grammar definition to the parsing
environment.
|
<!ENTITY author "Erik Ray">
|
|
processing instruction
|
Feed a special instruction to a particular type of software.
|
<?print-formatter force-linebreak?>
|
|
comment
|
Insert an annotation that will be ignored by the XML processor.
|
<!— here's where I left off —>
|
|
CDATA section
|
<?xml version="1.0" standalone="no"?> The XML declaration <!DOCTYPE Beginning of the DOCTYPE declaration reminder Root element name SYSTEM "/home/eray/reminder.dtd" DTD identifier [ Internal subset start delimiter <!ENTITY smile "<graphic file="smile.eps"/>"> Entity declaration ]> Internal subset end delimiter <reminder> Start of document element ⌣ Reference to the entity declared above <msg>Smile! It can always get worse.</msg> </reminder> End of document element
<?xml (1),
contains a number of parameters (2), and ends with the delimiter
&), the entity name, and a semicolon
(;). The following is an example of a document
that declares three general entities and references them in the text:<?xml version="1.0"?> <!DOCTYPE message SYSTEM "/xmlstuff/dtds/message.dtd" [ <!ENTITY client "Mr. Rufus Xavier Sasperilla"> <!ENTITY agent "Ms. Sally Tashuns"> <!ENTITY phone "<number>617-555-1299</number>"> ]> <message> <opening>Dear &client;</opening> <body>We have an exciting opportunity for you! A set of ocean-front cliff dwellings in Piñata, Mexico, have been renovated as time-share vacation homes. They're going fast! To reserve a place for your holiday, call &agent; at ☎. Hurry, &client;. Time is running out!</body> </message>
<!-- (1) and ends with the
delimiter --> (3). Between these delimiters
goes the comment text (2) which can be just about any kind of text
you want, including spaces, newlines, and markup. The only string not
allowed inside a comment is two or more dashes in succession, since
the parser would interpret that string as the end of the comment.
<p>The quick brown fox jumped<!-- test -->over the lazy dog. The quick brown <!-- test --> fox jumped over the lazy dog. The<!-- test -->quick brown fox jumped over the lazy dog.</p>
<p>The quick brown fox jumpedover the lazy dog. The quick brown fox jumped over the lazy dog. Thequick brown fox jumped over the lazy dog.</p>
nobody:*:-2:-2:Unprivileged User:/nohome:/noshell root:*:0:0:System Administrator:/var/root:/bin/tcsh daemon:*:1:1:System Services:/var/root:/noshell smmsp:*:25:25:Sendmail User:/private/etc/mail:/noshell
nobody:*:-2:-2:Unprivileged User:/nohome:/noshell root:*:0:0:System Administrator:/var/root:/bin/tcsh daemon:*:1:1:System Services:/var/root:/noshell smmsp:*:25:25:Sendmail User:/private/etc/mail:/noshell
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<!-- KEY VALUE -->
<key>BothSides</key> <false/>
<key>Level</key> <integer>1</integer>
<key>PlayerHasWhite</key> <true/>
<key>SpeechRecognition</key> <false/>
</dict>
</plist>
<?xml version="1.0"?> <svg> <desc>Three shapes</desc> <rect fill="green" x="1cm" y="1cm" width="3cm" height="3cm"/> <circle fill="red" cx="3cm" cy="2cm" r="4cm"/> <polygon fill="blue" points="110,160 50,300 180,290"/> </svg>
<census-record taker="9170">
<date><month>?</month><day>110</day><year>03</year></date>
<address>
<city>Munchkinland</city>
<street></street>
<county></county>
<country>Here, silly</country>
<postalcode></postalcode>
</address>
<person employed="fulltime" pid="?">
<name>
<last>Burgle</last>
<first>Brad</first>
</name>
<age>2131234</age>
<gender>yes</gender>
</person>
</census-record>
date and zeroOrMore for specifying optional repeating
content. Declarations can contain other declarations, leading to a
more natural representation of a document's
structure.<element name="worklog"
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:ann="http://relaxng.org/ns/compatibility/annotations/1.0">
<ann:documentation>A document for logging work activity, broken down
into days, and further into tasks.</ann:documentation>
<zeroOrMore>
<element name="day">
<attribute name="date">
<text/>
</attribute>
<zeroOrMore>
<element name="task">
<element name="description">
<text/>
</element>
<element name="time-start">
<text/>
</element>
<element name="time-end">
<text/>
</element>
</element>
</zeroOrMore>
</element>
</zeroOrMore>
</element>
<!ELEMENT worklog (day*)> <!ELEMENT day (task*)> <!ELEMENT task (description, time-start, time-end)> <!ELEMENT description #PCDATA> <!ELEMENT time-start #PCDATA> <!ELEMENT time-end #PCDATA> <!ATTLIST day date CDATA #REQUIRED>
<schema xmlns="http://www.ascc.net/xml/schematron">
<pattern>
<rule context="XPath Expression">
<assert test="XPath Expression">
message
</assert>
<report test="XPath Expression">
message
</report>
...more tests...
</rule>
...more rules...
</pattern>
...more patterns...
</schema>
pattern in Schematron does not carry the same
meaning as patterns in RELAX NG. Here, it's just a
logical grouping of rules. If your schema is testing books, one
pattern may hold rules for chapters while another groups rules for
appendixes. So think of this as more of a higher-level, conceptual
testing pattern, rather than as a specific node-matching pattern.rule.
Its context attribute contains an XSLT pattern
that matches nodes. Each node found becomes the context
node, on which all tests inside the rule are applied.report and
assert, each apply a test to the context node. The
test is another XPath expression, stored in a test
attribute. report's contents will
be output if its XPath expression evaluates to
"true." |
Feature
|
DTD
|
W3C Schema
|
RELAX NG
|
Schematron
|
|---|---|---|---|---|
|
XML syntax
|
No
|
Yes
|
Yes
|
Yes
|
|
Namespace compatible
|
No
|
Yes
|
Yes
|
Yes
|
|
Declares entities
|
Yes
|
No
|
No
|
No
|
|
Tests datatypes
|
No
|
Yes
|
Yes
|
Yes
|
|
Default attribute values
|
Yes
|
Yes
|
No
|
No
|
|
Notations
|
Yes
|