|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Storing an XPath fragment in a variable
Hi Jason,
At 04:18 PM 7/13/2005, you wrote: I'm using the following partial XPath expression...: This works, but it's exactly the same as select="RED | GREEN | BLUE", so why don't you use that? *[name()='RED' or name() = 'GREEN' or name() = 'BLUE'] translates as "all child elements whose name is 'RED', or 'GREEN', or 'BLUE'" RED | GREEN | BLUE translates as "all RED, GREEN or BLUE child elements". Is it possible to store a fragment of an XPath expression in a variable or is there another method of eliminating redundancy that I'm not aware of? No there isn't, without an evaluation function such as saxon:evaluate that lets you parse and evaluate strings back into as XPath. On the other hand, this isn't really necessary most of the time, since you can easily bind the set of nodes (whatever RED, GREEN and BLUE child elements you have) to a variable, and reuse that. So <xsl:variable name="brights" select="RED | GREEN | BLUE"/> ... <xsl:apply-templates select="$brights"/> works just fine. So will select="$brights | GREY" if you want to add GREY children to the mix. Whether you need something more powerful than this we can't see without looking at your actual case; but this is usually plenty powerful enough. Cheers, Wendell
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








