| |
Here is a simple set of tables that give the name and location
of each XML file included in the collection of example files for
XML for the World Wide Web: Visual QuickStart Guide. Instead
of just giving you the snippets of code that are shown in the illustrations
(which would be of limited use), I have fleshed out those examples
and commented them (within the files themselves) so that you can
get more out of them, tinker with them, test them, and ultimately,
see how they work. I hope they are worthwhile. Comments
are welcome.
You can download all the examples for Macintosh
or for Windows/Unix.
If you have any questions, suggestions, or corrections, please
contact me.
Introduction
The files from this chapter are in the introduction folder.
| Page |
Section |
Code |
| 12 |
The Problem wth HTML |
|
| 13 |
The Power of XML |
|
| 15 |
XML in the Real World |
|
| 16 |
About This Book |
|
Part 1: XML
Chapter 1, Writing XML
The files from this chapter are in the writing folder.
Part 2: DTDs
Chapter 2, Creating a DTD
The files from this chapter are in the dtd_creating folder.
Chapter 3, Defining Elements and Attributes
in a DTD
The files in this section are in the dtd_defining folder.
You'll note that these files contain more than what is shown in
the illustrations. I have fleshed out these examples so that you
can really test them against an XML
Validator. In fact, I heartily recommend doing so. Copy them
to your server, play around with them, and then study the error
messages that XML Validator gives you! I hope you find them useful.
| Page |
Section |
Code |
| 44 |
Defining an Element to Contain Only Text |
onlytext.dtd,
onlytext.xml |
| 45 |
Defining an Element to Contain One Child |
onechild.dtd,
onechild.xml |
| 46 |
Defining an Element to Contain a Sequence |
sequence.dtd,
sequence.xml |
| 47 |
Defining Choices |
choices.dtd,
Figure 3.11: choices.xml,
choices2.xml
Figure 3.12: choices_invalid.xml,
choices_invalid2.xml
|
| 48 |
Defining How Many Units |
howmany.dtd, howmany2.dtd
|
| 50 - 51 |
Defining Simple Attributes |
Figure 3.16: att_optional.dtd
Figure 3.17: attribute_optional.xml,
attribute_optional2.xml,
attribute_optional3.xml
Figure 3:18: att_required.dtd
Figure 3:19: att_required_choice1.xml,
att_required_choice2.xml,
att_required_choice3.xml
Figure 3.20: att_default.dtd
Figure 3.21:att_default1.xml,
att_default2.xml,
att_default3.xml
Figure 3.22: att_fixed.dtd
Figure 3.23: att_fixed1.xml,
att_fixed2.xml,
att_fixed3.xml
|
| 52 |
Defining Attributes with Unique Values |
att_unique.dtd
Figure 3.25: att_unique1.xml
(top), att_unique2.xml
(bottom) |
| 53 |
Referencing Attributes with Unique Values |
Figures 3.26 and 3.28: idref.dtd
Figure 3.27: idref.xml
Figure 3.29: idrefs.xml
|
| 54 |
Restricting Attributes to Valid XML Names |
nmtoken.dtd
nmtoken.xml, nmtoken2.xml
|
Chapter 4, Entities and Notations in DTDs
The files in this section are in the dtd_entities folder.
Part 3: XML Schema and Namespaces
Note that the examples in these chapters are almost all based on
the end_species.xsd and end_species.xml
files, with minor changes, according to the topic in question. More
importantly, I have gone to the trouble (over two excrutiating months)
to flesh out the examples so that you can really play around with
them, send them to XSV for validation and see how they work. Please
do copy them to your own site, and then test them and retest them
and analyze them. Pay special attention to the comments within the
documents, in which I explain which parts are in question and what
is going on with them. I hope you find them useful. Let me know.
Chapter 5, XML Schema
The files in this section are in the schemas folder.
Chapter 6, Defining Simple Types
The files in this section are in the schemas_simple folder.
| Page |
Section |
Code |
| 76-77 |
Declaring an Element with a Simple Type |
Figure 6.1: simpletype.xsd
Figure 6.2: simpletype1.xml
Figure 6.3: simpletype2.xml
Figure 6.4:simpletype_date.xsd
Figure 6.5: simpletype_date.xml
Figure 6.6: simpletype_date2.xml
|
| 78-79 |
Using Date and Time Types |
Figure 6.7: timeDuration.xsd,
timeDuration.xml
Figure 6.8: time.xsd,
time.xml
Figure 6.9: timeInstant.xsd,
timeInstant.xml
Figure 6.10: date.xsd,
date.xml
Figure 6.11: month.xsd,
month.xml
Figure 6.12: year.xsd,
year.xml
Figure 6.13: century.xsd,
century.xml
Figure 6.14: recurringDate.xsd,
recurringDate.xml
Figure 6.15: recurringDay.xsd,
recurringDay.xml
|
| 80 |
Using Number Types |
numbers.xsd
Figure 6.17: numbers.xml
Figure 6.18: numbers2.xml
|
| 81 |
Deriving Custom Simple Types |
custom_simple.xsd,
custom_simple.xml |
| 82 |
Using Anonymous Custom Types |
anonymous_simple.xsd,
anonymous_simple.xml |
| 83 |
Specifying a Set of Acceptable Values |
enumeration.xsd,
enumeration.xml |
| 84-85 |
Specifying a Pattern for a Simple Type |
Figure 6.27: pattern.xsd
Figure 6.28: pattern.xml
Figure 6.29: timeDuration_andpattern.xsd
Figure 6.30: timeDuration_andpattern.xml
Figure 6.31: pattern_choices.xsd
Figure 6.32: pattern_choices.xml
|
| 86-87 |
Specifying a Range of Acceptable Values |
Figure 6.33: maxInclusive.xsd
Figure 6.34: maxInclusive.xml
Figure 6.35: maxExclusive.xsd
Figure 6.36: maxExclusive.xml
Figure 6.37: minInclusive.xsd
Figure 6.38: minInclusive.xml,
minInclusive2.xml
Figure 6.39: minExclusive.xsd
Figure 6.40: minExclusive.xml,
minExclusive2.xml
|
| 88 |
Limiting the Length of a Simple Type |
Figures 6:41 and 6:42: length.xsd,
length.xml
Figure 6:43: maxLength.xsd
Figure 6.44: maxLength.xml
Figure 6.45: maxLength2.xml
|
| 89 |
Limiting a Number's Digits |
precision_scale.xsd
Figure 6.47: precision_scale.xml,
precision_scale2.xml
Figure 6.48: precision_scale3.xml,
precision_scale4.xml
|
| 90 |
Creating List Types |
Figures 6.49 and 6.50: list.xsd,
list.xml
Figures 6.51 and 6.52: list_length.xsd,
list_length.xml
|
| 91 |
Predefining an Element's Content |
Figure 6.53: fixed.xsd
Figures 6.54 and 6.55: fixed.xml,
fixed2.xml
Figure 6.56: default.xsd
Figures 6.57 and 6.58: default.xml,
default2.xml
|
Chapter 7, Defining Complex Types
The files in this section are in the schemas_complex folder.
Chapter 8, Using Namespaces in XML
The files in this section are in the namespaces folder.
Note that no Schema files are given for the latter examples...we
don't get to validating XML files that use namespaces until the
next chapter. If there is sufficient interest, I could work out
the appropriate schema files. Let me know.
Chapter 9, Namespaces, Schemas, and Validation
The files in this section are in the namespaces_sv folder.
Part 4: XSLT and XPath
Note that the examples in these chapters are almost all based on
the tigers_rhinos.xml and tigers_complete.xsl
files. The XSLT files gradually build up to the tigers_complete.xsl
file, with minor changes depending on the topic in question. For
maximum effect, you'll also need the tiger.jpg
and rhino.jpg images.
Chapter 10, XSLT
The files in this section are in the xslt folder. Note
that all of these XSLT files transform the very same tigers_rhinos.xml
file. The HTML files shown were generated by transforming the tigers_rhinos.xml
file with the given XSLT file, using Saxon.
Chapter 11, XPath: Patterns and Expressions
The files in this section are in the xpath folder. Note
that many of the examples in this chapter use the same files as
examples from the XSLT chapter. That's because we've already seen
some of these patterns and expressions, but they are explained and
highlighted here. Note also that the HTML files shown were generated
by transforming the tigers_rhinos.xml
file with the given XSLT file, using Saxon.
Chapter 12, Test Expressions and Functions
The files in this section are in the expressions folder.
Note that the first seven HTML files (pages 164-170) shown were
generated by transforming the tigers_rhinos.xml
file with the given XSLT file, using Saxon.
The examples from pages 171-173 are generated by transforming the
tigers_rhinos_noinitials.xml
file with the given XSLT file, also using Saxon. Also note that
up until page 169, for simplicity's sake, I did not include the
picture template. It appears again from page 170 on. You can find
more information about the picture template in the Generating Attributes
section on page 151 in Chapter 10.
| Page |
Section |
Code |
| 164 |
Comparing Two Values |
same as choose.xsl,
choose.html (from page 149, Chapter
10) |
| 165 |
Testing the Position |
position.xsl,
position.html |
| 166 |
Subtotaling Values |
sum.xsl, sum.html |
| 167 |
Counting Nodes |
count.xsl,
count.html |
| 168 |
Multiplying, Dividing, Adding, Subtracting |
multiply.xsl,
multiply.html |
| 169 |
Formatting Numbers |
formatnumber.xsl,
formatnumber.html |
| 170 |
Rounding Numbers |
ceiling.xsl,
ceiling.html (again,
notice that the picture template from page 151 is used here--for
the first time in this chapter) |
| 171-172 |
Extracting Substrings |
Figure 12.19: tigers_rhinos_noinitials.xml
(All the other XSLT files refer to the tigers_rhinos.xml
file.)
Figures 12.20 and 12.21: substring.xsl,
substring.html
Figures 12.22 and 12.23: substring_after.xsl,
substring_after.html
|
| 173 |
Capitalizing Strings |
translate.xsl,
translate.html |
Part 5: Cascading Style Sheets
Note that the examples in these chapters are almost all based on
the panthers.xml and panthersblurb.xml
files. I have created a separate xml file for each example that
references the proper CSS stylesheet, but unless noted, all the
XML files are otherwise identical. The CSS files build on each other
gradually.
Chapter 13, Setting up CSS
The files in this section are in the css folder.
Chapter 14, Layout with CSS
The files in this section are in the css_layout folder.
The XML files formatted by the CSS examples on pages 190-197 are
identical to panthers.xml,
except for the call to the individual stylesheet. The XML files
used from pages 198-205 are identical to panthersblurb.xml--except
for the call to the individual stylesheet--(which only differs from
panthers.xml in the addition
of an extra sidebar (blurb) paragraph.) Finally, the examples in
the last two sections (pages 206-9) are identical to the pantherlist.xml
file--again, except for the call to the individual stylesheet.
Chapter 15, Formatting Text with CSS
The files in this section are in the css_text folder. All
of the XML files are identical to panthers_layout.xml,
except for the call to the individual stylesheet. Indeed panthers_layout.xml
is simply the same panthersblurb.xml
file we saw in the last chapter with a call to the layout.css
stylesheet which includes all the layout information we added in
Chapter 14. Note also that you'll need the embedded font files for
all the examples from page 211 on, and that the embedded fonts will
only be visible in IE5 for Windows.
Part 6: XLink and XPointer
Chapter 16, XLink and XPointer
Since none of the examples in this chapter can really be tested
yet (except for well-formedness, but that's pretty boring), I haven't
taken the trouble of posting the code. If you really want a copy
of it, just let me know. I'd be happy to give it to you (or post
it, if a lot of you want it). Once browsers can deal with XLink
and XPointer, I will make these examples more real and then post
the code so you can see how they work for yourselves. Comments?
Appendices
Appendix A: XHTML
You can find these files in the xhtml folder.
Appendix B: XML Tools
These are the most up-to-date links to the tools listed.
| Page |
Section |
Code |
| 244 |
Validating XML Files against a DTD |
Brown University's Scholarly Technology Group's
XML
Validator |
| 245 |
Validating XML with a Schema |
XML
Schema Validator from the W3C |
| 246 |
Transforming XML with an XSLT Processor |
Michael Kay's Saxon
J. David Eisenberg's MacTransform
|
Appendices C and D: Special
Symbols and Colors in Hex
You can find links to these tables in the Extras
section of my HTML4 Web site. Click on Useful Files to find the
appropriate table.

Index
You can find the complete index
online!

|
|