[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Shorthand for XPath expression
William,
At 07:55 PM 7/18/01, Chris wrote: William, No. But you can do test=contains('bob-joe-ben', @name) And if you want to be super-careful about it, you can amend this to: test="contains(('bob-joe-ben', @name) and not(contains(@name, '-'))" Of course this won't work if any of your names contains your delimiter (so use a different one). You can't quite do ><xsl:if test="@name in ('bob', 'joe', 'ben')"> because XSL (XPath) has no notion of sets, exactly. Although it does have node sets. Which leads to the technique of keeping your list in an XML fragment (in the stylesheet or elsewhere) and then getting it as a node set. So you could do <local:names> <name>bob</name> <name>joe</name> <name>ben</name> </local:names> at the top level of your stylesheet (don't forget to declare the "local" namespace). Then bind this node set to a variable, as in <xsl:variable name="names" select="document('')/*/local:names/name"/> and then you can do test="@name=$names" which will test true if any of the nodes in $names has string-value equal to @name. (Do we have a name for this idiom, anyone?) This is good when things get hairy; use Chris's technique when things are light. Cheers, Wendell
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|