Datasheet

Williams c01.tex V3 - 07/31/2009 2:53pm Page 11
Chapter 1: First Steps with XSLT
<xsl:template match
=
"usage">
<h2>Usage</h2>
<xsl:apply-templates select
=
"p"/>
</xsl:template>
<xsl:template match
=
"p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match
=
"attr | element">
<code>
<xsl:value-of select
=
"."/>
</code>
</xsl:template>
<xsl:template match
=
"code">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Transforming Locally
This time you’ll run the stylesheet processor ‘‘locally,’’ rather than on the browser. The setup suggestions
that follow make further use the Oxygen IDE . You’ll also look briefly at invoking the Java command-line
interface for the Saxon processor.
Try It Out Configuring a Transformation
You can use the Oxygen IDE to set up a transformation, providing a range of configuration values.
Essentially, you provide input and output values, which are associated with the source file and saved
automatically for reuse. To avoid typing long paths, you can use editor variables recognized by the
application, such as ‘‘
${cfdu}
’’ for ‘‘current file directory URL.’’
1. Open
xsl_stylesheet.xml
in the XML editor.
2. Choose XML Configure Stylesheet Transformation.
3. Click New in the dialog that opens, and name the scenario xml2xhtml in the Edit Scenario dialog
that appears, as shown in Figure 1-1. By default, the variable
"${currentFileURL}"
is used for
the XML URL setting.
4. On the XSLT tab, insert ${cfdu}local.xsl in the XSL URL control.
5. Choose Saxon6.5.5 in the Transformer drop-down. Figure 1-1 shows the settings.
6. On the Output tab, accept the default setting Save as
${cfn}.html
, which will save the XHTML
file in the same directory as the source, with the current filename.
7. Check Show in Browser and click OK.
8. In the main dialog, click Transform Now.
11