XSLT for Dummies Cheat Sheet

 
xslt for dummies
XSLT for Dummies Cheat Sheet
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002
  

XSLT Elements

Note: Common syntax section lists the element with the most commonly used attributes, but not all of them. Also, italicized attributes are optional.

Primary

xsl:apply-templates

Defines the node set to be processed by the current element. If the select attribute is defined, then only the result of that expression will be processed. If select is not defined, then the current node and all child nodes will be processed.

Common Syntax
 <xsl:apply-templates  select= "expression"/>  

xsl:call-template

Calls a named template. May contain xsl: with-param elements.

Common Syntax
 <xsl:call-template name="templatename"/> 

xsl:copy

Performs a literal copy of the current node to the result tree without making any conversions. No child nodes or attributes are copied .

Common Syntax
 <xsl:copy> <! Template body > </xsl:copy> 

xsl:copy-of

Performs a literal copy of the current node to the result tree, but unlike xsl:copy , it does copy child nodes and attributes.

Common Syntax
 <xsl:copy-of select="expression"/> 

xsl:number

Writes a formatted number to the result tree.

Common Syntax
 <xsl:number  level="singlemultipleany" count="pattern" from="pattern" value="expression" format= "{formatstring}" letter- value="{alphabetictraditional}" grouping-separator="{character}" grouping-size="{number}"/>  

xsl:output

Specifies the format of the output document.

Common Syntax
 <xsl:output  method="xmlhtmltextname" version="version" encoding="text" omit-xml- declaration="yesno" standalone="yesno" indent="yesno"/>  

xsl: sort

Sorts a node set. Valid only as a child of xsl: for-each and xsl:apply-templates elements.

Common Syntax
 <xsl:sort select="expression"  order= "ascendingdescending" case- order="upper-firstlower-first"/>  

xsl:stylesheet

Defines an XSLT stylesheet. Same as xsl: transform element.

Common Syntax
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <! Stylesheet content > </xsl:stylesheet> 
 

xsl:template

Defines a template rule for the result tree.

Common Syntax
 <xsl:template name="name" match=" pattern"> <! Template body > </xsl:template> 

xsl:text

Writes literal text to the result tree.

Common Syntax
 <xsl:text> <! Text > </xsl:text> 

xsl:transform

Defines an XSLT stylesheet. Same as xsl:stylesheet element.

Common Syntax
 <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/ XSL/Transform"> <! Content > </xsl:transform> 

xsl:value-of

Inserts the value of the expression into the result tree.

Common Syntax
 <xsl:value-of select="expression"/> 

XPath Shorthand

Shorthand

Equivalent

Definition

Example

(nothing)

child::

When no axis is defined, a value of child:: is assumed.

match="book" is the same as match="child::book"

@

attribute::

Selects an attribute of the context node

select="@id" is the same as select="attribute::id"

.

self::node()

Selects the context node.

.//book is the same as self::node()/ descendant-or-self::node()/book

..

parent::node()

Selects the parent of the

../book is the same as context node. parent::node()/book

//

/descendant-or- self::node()/

Searches the entire source tree for a specific node set either by name or by type.

//title is the same as /descendant-or- self::node()/title

  
 
 
2000-2002    Feedback


XSLT For Dummies
XSLT for Dummies
ISBN: 0764536516
EAN: 2147483647
Year: 2002
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net