Wildcards
There are a couple of different wildcard techniques. One of the
simplest is to just not specify a type name with the <element>
tag, which means that the pattern will match with any parent element.
The same can be used with the <target-element> tag, to match
all elements within the related elements rather than the specific target
element.
The "content" element of the example XML file is modified to include
another, new XML element, the BODYQUOTE:
<content>
<title>What is XML?</title>
<body>
<BODYQUOTE>XML is Extended Markup Language</BODYQUOTE>,
a generic language used to generate documents without
following predefined element types.
</body>
</content>
Next, a new rule is added to the XSL file that looks for a
target-element type of BODYQUOTE, contained within any number of other,
unknown elements:
<rule>
<element>
<target-element type="BODYQUOTE"/>
</element>
<SPAN font-weight="bold" color="green" font-style="italic">
<children/>
</SPAN>
</rule>
The result of running this XSL rule on the modified XML file can be
seen in the next
generated example.
In this example, the SPAN style, with the bold, green, italic font is
applied to the BODYQUOTE contents.
This article has demonstrated just some of the results that can be
accomplished with some simple tags and a fairly simple processor. There
are other aspects of XSL that haven't even been covered in this article,
such as adding actions to a style, the use of filtering, even adding
script to handle dynamic HTML. However, before I close the article, I
want to talk about one more aspect of XSL and that is the CSS
properties used in the style sheets.
The Root Rule
Add a little style to your XML document with XSL - a Working Example
The CSS Styles
|