To Apply or Copy, That Is the Question

 
xslt for dummies
Chapter 18 - Ten Most Confusing Things About XSLT
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002
  

When you create result trees, you may not be sure when to use xsl:apply-templates , xsl:copy , xsl:copy-of , xsl:value-of , and other XSLT instructions inside your template rules. The following guidelines can help you decide what to do:

  • Use xsl:apply-templates when you want to return the content and text nodes of the current element and its children, but not the surrounding element tags.

  • Use xsl:copy to preserve the current nodes start and end tags during processing, but not its children or attributes. Content inside the tags is included only if you add an xsl:apply-templates instruction inside the xsl:copy element.

  • Use xsl:copy-of when you want to copy the whole kit n caboodlethe current nodes tags, content, attributes, and children. This instruction copies all the nodes returned from its required select attribute.

  • Use xsl:value-of when you want to convert the result to text. The conversion process removes all tags and elements. If the result is a single node, its content is converted to text. If the result is a node set, the first node in the set is used in the conversion.

I explain these instructions fully in Chapter 4.

  
 
 
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