Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] populate nodelist variable with a variable in select statement

From: "Michael Kay" <mike@------------>
To:
Date: 12/1/2008 11:51:00 PM
Variables hold values, not fragments of path expressions. There's no
facility in standard XSLT to construct an XPath expression from a string at
run-time, which is what you are trying to do. However, many processors have
an extension to do this, generally called xx:evaluate() or similar.

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

> -----Original Message-----
> From: Lara Brian [mailto:lara_bc@xxxxxxxxx]
> Sent: 01 December 2008 23:45
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] populate nodelist variable with a variable in
> select statement
>
> Hi,
> I am trying to populate a variable with a nodelist that takes
> a variable in its select statement.
>
> For example,
> <xsl:variable name="myNodeSet"
> select="site/assets/asset[(type/@code = 'aaa') and
> starts-with(@vpath,'my/path/')  and (lang='us_en') and
> $SEARCH_STRING]"/>
>
> and SEARCH_STRING is defined as
> <xsl:param
> name="SEARCH_STRING"> and ( (related/@code = '111') or
> (related/@code = '222') or (related/@code = '333') )</xsl:param>
>
> My xml is of the form,
> <site>
> <assets>
> <asset vpath="my/path/and/more">
> <lang>eng</lang>
> <featured-item>No</featured-item>
> <type code="aaa"/>
> <related code="111"/>
> <related code="777"/>
> </asset>
> <asset>
>   ...
> </asset>
> </assets>
> <site>
>
> Is
> this even possible? I can do this using <xsl choose> and
> checking each condition and setting the variable accordingly,
> but in future if i have more conditions for the variable, i
> need to add more conditions in all my xsls. It would be nice
> if i can set this variable in one place and then use it use
> it as a replace string.
>
> Thanks for any help or pointers in this regard.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent