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

Re: PARAMS and VARIABLES in XSL

Subject: Re: PARAMS and VARIABLES in XSL
From: mark bordelon <markcbordelon@xxxxxxxxx>
Date: Tue, 30 Jan 2007 13:20:46 -0800 (PST)
Re:  PARAMS and VARIABLES in XSL
Dave,

This worked beautifully. Thanks.
I will have to read your informative response
carefully to get all the added value. Once again,
thanks for taking the time to help a new guy.

Mark

--- David Carlisle <davidc@xxxxxxxxx> wrote:

> 
> I don't think you need any variables, despite the
> subject line,
> 
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:strip-space elements="clause"/>
> <xsl:output indent="yes"/>
> 
> <xsl:template match="*">
>   <xsl:copy>
>     <xsl:copy-of select="@*"/>
>     <xsl:apply-templates/>
>   </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="word">
>  <word
>
soundtime="{((.|preceding-sibling::sound)/@time)[last()]}">
>    <xsl:apply-templates/>
>  </word>
> </xsl:template>
> 
> <xsl:template match="sound"/>
> 
> </xsl:stylesheet>
> 
> to comment on your code
> 
> 
> <xsl:template match="//clause/*">
> 
> there's never a need to start a match pattern with
> // it doesn't chage
> which nodes are matched (not quite true in xslt)
> 
> <xsl:if test="local-name() = 'sound'">
> 
> generally it's better to avoid doing string tests
> against element names
> 
> <xsl:if test="self::sound">
> 
> is likely to be more efficient 9and safer in a
> namespace context)
> 
> <xsl:if test="local-name() = 'sound'">
> <xsl:param name="soundtime" select="@time" />
> </xsl:if>
> 
> 
> xsl:param can only be used at the top level as a
> template, where they
> must come first, or for global parameters must be at
> the top levl of the
> styleseet. You could use xsl:variable there but the
> scope of a variable
> binding is to the end of the containing element, so
> the variable would
> go out of scope at the </xsl:if>
> 
> In more complicated case you do need to use a
> parameter but in that case
> you need to apply templates in a different order,
> instead of applying
> templates to all the children, just apply templates
> to the first child,
> then have each child apply templates to the next
> sibling, passing on a
> paramater with xsl:with-param. This is usually known
> as a tree-walking
> idiom, google should show some examples, but in this
> case you can
> directly evaluate the required value on each node,
> so there is no need
> for a parameter to accumulate earlier results.
> 
> David
> 
> 



 
____________________________________________________________________________________
Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.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.