[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem with xsl:template using XSLT 1.0

Subject: RE: Problem with xsl:template using XSLT 1.0
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 5 Dec 2007 16:42:43 -0000
RE:  Problem with xsl:template using XSLT 1.0
>     Remember that your <xsl:template/> elements should match
>     fairly generically (match="player" in this case), and
>     your <xsl:apply-templates/> elements should be where you
>     narrow down your selection.
> 
>   I just say that in general, I would give instead the 
> opposite advice.  Of course, there is place for both 
> patterns, and I expect any not-simple-toy-stylesheet to use 
> both.  With experience, when using one or the other become 
> quite obvious.

To me the telltale sign that you've got it wrong is when the body of the
xsl:template rule consists of an xsl:choose instruction.

There are many cases where it really doesn't matter too much. For example,
"process all attributes except width and height" (which came up this
morning) can equally well be written as

<xsl:apply-templates select="@* except (@width, @height)"/>

or as <xsl:apply-templates select="@*"/> with

<xsl:template match="@width|@height"/>

There really isn't all that much to choose between them. However, if you're
only processing a very small proportion of the nodes, then selecting the
nodes to be processed in the select attribute of xsl:apply-templates will
probably be more efficient.

Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.