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

Re: [none] (Wendy's question)

Subject: Re: [none] (Wendy's question)
From: korolkm@xxxxxxxxxxxxxxxxxxxx
Date: Fri, 26 Feb 1999 19:03:24 +0300
xsl select constant for each
Wendy wrote:

> Within an XSL Stylesheet how can we dynamically change the select
attribute of
> "for-each" xsl element.
> Eg
>     <xsl:for-each select='Some Default'>
>     ...
>     </xsl:for-each>
> Now I want to dynamically transform the above xsl to the following xsl
>     <xsl:for-each select='ElementName[@value="Contents of a Variable"]'>
>     ...
>     </xsl:for-each>

I asked this question some days ago to Scott Boag (developer of LotusXSL
processor) and his answer was NO, THIS IS NOT POSSIBLE with current XSL
draft. In general this effect could be acheived the following way:
1) you put an Attribute Value Template (AVT) that references some constant
into attribute:
     <xsl:for-each select="ElementName[@value='{constant(some-constant)}']">
2) before running your XSL processor you programmatically set value to this
constant
	processor.setConstant ("some-constant", "Contents of a variable");
3) run your porcessor. During the run value of the constant will be
substituted and effect in actual processing of 
           <xsl:for-each select="ElementName[@value='Contents of a
Variable']">
I do not know about other processors, but LotusXSL has this nice
"setConstant" function.

This sounds nice, but as Scott explaned, current draft allows AVT to be used
everywhere with exception of "select" and "match" patterns. So, this elegant
approach is not possible and does not have any reasonable replacement
currently. I myself miss this approach very much. I tried it with an old
version of LotusXSL that wrongly allowed this forbidden behaviour and found
it very comfortable.

The alternatives are:
1) Preprocess text of your XSL document and perform text substitution for
"Some Default" string. Then parse preprocessed stylesheet and apply it to
XML file.
2) Do similar thing with DOM tree of your XSL stylesheet: find a node that
needs to be substituted, substitute it with actual value of template and
then apply this preprocessed DOM tree to an XML document. This is more
preferrable than first approach if you need to apply your stylesheet
template many times - you do not need to reparse it every time.

But to my taste these two alternative approaches are not as elegant as the
forbidden one :-(

Michael


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.