|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl:when element test with number
>
> I have an xsl:when test that is testing for an exact element
> name: <xsl:when test="name(.)='my_element'>...</xsl:when>
>
> This works fine if this is all I need, but the problem is
> that it also needs to test for the possibility of
> 'my_element_N' where N is any positive number
> ('my_element_12' for example). I've tried the following to
> account for the extra underscore in the element name:
> <xsl:when test="name(.)='my_element' or starts-with(name(.),
> 'my_element_')">...</xsl:when>
>
> This worked until I realized there are names such as
> 'my_element_data' or 'my_element_information' etc. which are
> elements I do not want to process here.
>
> Is there a way to search for exactly 'my_element_N' using
> number() or some other function so I can test for the
> possibility of 'my_element_1' or 2 or 3 or 672? Any
> suggestions would be appreciated!
Easy with 2.0, you can do test="matches(name(), 'my_element_[0-9]+')".
In 1.0 you'll have to do something like
string(number(substring-after(name(), 'my_element')) != 'NaN'.
But why are you packing information into the element name anyway? That's
what attributes are for.
Michael Kay
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
|

Cart








