Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
lhs |
rhs[preceding-sibling::*[1][not(self::lhs)]] |
com[preceding-sibling::*[1][not(self::rhs)]] |
constraint[preceding-sibling::*[1][not(self::rhs)]] |
vc[preceding-sibling::*[1][not(self::rhs)] |
wfc[preceding-sibling::*[1][not(self::rhs)]]”>
Now, we define a set of simple template rules to produce the empty cells in each row, depending on the type of the first element in the row:
And finally we provide one template rule for each kind of element, which simply outputs the content of the appropriate cells in the table. There is no longer any need for it to worry about what comes afterwards: that's taken care of by the iteration in the master
show.prod
template.
As before, I left out the logic for
For completeness, here is the
show.diff
template:
select=“concat(‘diff-’, ancestor-or-self::*/@diff)”/>
Finally, there's one other question that needs to be asked: Is it appropriate to be generating HTML Overlay Stylesheets As I mentioned at the start, diffspec.xsl This stylesheet module is used to do change marking for documents such as the XML Recommendation. You can see an example of its output at For some of the W3C specifications, editors maintain change markup by hand as they make changes to documents. Typically, the markup looks like this: (Of strings or names:) Two strings or names being compared identical. … In other cases, the change markup is generated automatically by running a comparison program (written in XSLT, naturally) against the two documents. I don't know which approach was used for the XML Recommendation, but the markup is the same either way, so it doesn't affect this stylesheet. The way this module works is interesting. It contains template rules that override all other rules in the base stylesheet. For example, changes marked as additions ( This matches every element with the attribute
markup here at all? Good practice dictates that HTML tables should be used only for tabular information, and not to achieve manual control over the layout of the output page. I think one could argue this example either way. Certainly, use of CSS positioning would be an alternative worth considering.
xmlspec.xsl
is just one module in the stylesheet used to format the XML Recommendation. The
xmlspec.xsl
module is imported by
diffspec.xsl
, which in turn is imported by
REC-xml.xsl
. We will now take a look at these two “overlays”, which modify the behavior of the base stylesheet.
http://www.w3.org/TR/REC-xml/REC-xml-20060816-review.html
where it is used to show the changes between the third and fourth editions of the Recommendation.
@diff=“add”
) are handled by this rule:
diff=“chg”
, indicating that the content has changed. If the global parameter
$show.diff.markup
is set to 0, to disable change marking, the template calls
super()
in an object-oriented program, invokes the base template rule in the imported stylesheet (in this case
xmlspec.xsl)
. Otherwise, it invokes a named template
diff-markup.
, which we will now examine. The template reads:Other books