Mastering Resin

StyleScript and XSL

As you've noticed, all of the XSL files for XTP use the traditional XSL syntax in order to grab the new tags added to the XTP file. Traditional XSL is very strict and follows all of the XML guidelines. You can learn about XSL in several books, including XSL Essentials by Michael Fitzgerald.

Resin has taken the liberty to lighten up the XSL syntax specifically for use with XTP files. XSLT-Lite or StyleScript doesn't follow the traditional XSL rules but vastly simplifies the verbosity involved. In this section, we cover a few examples to show how StyleScript relates to XSL.

First, consider this XSL declaration to match on a tag like <centerbig>:

<xsl:template match="centerbig"> <CENTER><H1> <xsl:apply-templates select="node()|@*"/> </H1></CENTER> </xsl:template>

If we convert this to StyleScript, it would look like this:

centerbig << <CENTER><H1> <xsl:apply-templates/> </H1><CENTER> >>

The matching string value typically found in the match="" of the <xsl:template> is used as a major heading in StyleScript using the << and >> symbols as beginning and end designators. StyleScript is easy to read because the template pattern has its own line. You can rewrite the XSL used to copy input to output using StyleScript:

node() |@* << <xsl:copy> <xsl:apply-templates select='node()|@*'/> </xsl:copy> >>

As you can see, some <xsl:> tags are used in StyleScript. The following list provides examples of the major StyleScript pieces available with Resin.

Категории