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

[no subject]

[no subject]
There are cases where using functions - especially memo functions - in match
patterns can be useful, but I don't think that's particularly the case here.
There are also cases where using global variables is effective, e.g if you
want to treat the first X sibling after a Y specially, the most effective way
might be

<xsl:variable name="special-Xs" select="//Y/following-sibling::X[1]"/>

<xsl:template match="$special-Xs">  (XSLT 3.0)

or

<xsl:template match="*[. intersect $special-Xs]">  (XSLT 2.0)

Michael Kay
Saxonica




> On 6 Jan 2017, at 17:56, Wendell Piez wapiez@xxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello XSL-List,
>
> I am having more and more occasions these days to handle HTML @class
> semantics, which as you probably know can be 'overloaded' in the sense
> that multiple values (NMTOKEN) of 'class' may have to be distinguished
> and handled separately.
>
> An idiom for matching any element .foo (CSS selector) could be
>
> <xsl:template match="*[tokenize(@class,'\s+')='foo')]">
>   ...
> </xsl:template>
>
> This will match the element by virtue of the value being present on
> the @class, split apart at white space and compared (many-to-one) with
> =
>
> (That logic can of course be relegated to a stylesheet function call
> for neatness. It's true you can get an element matching more than one
> template this way: that's the idea.)
>
> Question: I can define a key, as in
>
> <xsl:key name="elements-by-class" match="*[matches(@class,'\S')]"
> use="tokenize(@class,'\s+')"/>
>
> then
>
> <xsl:template match="key('elements-by-class','foo')">
> ...
> </xsl:template>
>
> I regard this as a neat trick, and think it might be an "improvement"
> :-) but I suppose from one point of view at least, that may be
> arguable.
>
> What do readers think? Should I prefer a stylesheet function instead?
> (John Lumley what do you think?)
>
> Regards,
> Wendell
>
> --
> Wendell Piez | http://www.wendellpiez.com
> XML | XSLT | electronic publishing
> Eat Your Vegetables
> _____oo_________o_o___ooooo____ooooooo_^

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.