Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
I left out the part of the
match=“specref”
template that handles the error case. Generally, this stylesheet does not do much validation of this kind, and it would probably be a good thing if it did more. Many errors in source documents, if they pass the checks performed by the DTD, are detected only because the HTML that's generated turns out to be invalid.
Setting Out the Production Rules
Now we get to a more interesting area. The XML Recommendation contains syntax production rules, and these are marked up in some detail. A sequence of production rules is contained within a
Document
This is of course the production rule for an XML document, which appears in the specification as shown in
Figure 18-4
.
In some cases the production rules within a
Here are the top-level template rules:
select=“lhs | rhs[preceding-sibling::*[1][name()!=‘lhs’]] | com[preceding-sibling::*[1][name()!=‘rhs’]] | constraint[preceding-sibling::*[1][name()!=‘rhs’]] | vc[preceding-sibling::*[1][name()!=‘rhs’]] | wfc[preceding-sibling::*[1][name()!=‘rhs’]]”/>
select=“lhs |
rhs[preceding-sibling::*[1][name()!=‘lhs’]] |
com[preceding-sibling::*[1][name()!=‘rhs’]] |
constraint[preceding-sibling::*[1][name()!=‘rhs’]] |
vc[preceding-sibling::*[1][name()!=‘rhs’]] |
wfc[preceding-sibling::*[1][name()!=‘rhs’]]”/>
To understand this, let's first ignore the horrendous
select
expression that appears in the last two rules.
Now let's look at the monster
select
expression. A production rule (
A rule with one
As the comment says, the
select
expression is processing the children of the
lhs1
,
rhs2
,
wfc2
, and
wfc3
. More precisely, the selected elements include every
We'll now look at the template rules that will match these elements. First, the