[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] [xsl-list] Storing an XPath fragment in a variable


Subject: Re: [xsl] [xsl-list] Storing an XPath fragment in a variable
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 13 Jul 2005 17:31:55 -0400

Jason,

Adding to the last post, here's a technique sometimes useful in XSLT 1.0 for parameterizing the kind of thing you're interested in.

At the top of the stylesheet, bind into a global variable all the elements you want of a particular kind:

<xsl:variable name="brights" select="//RED | //GREEN | //BLUE"/>

Then when you have, say, a bunch of child elements at hand and you only want the members of this set, you can do:

<xsl:for-each select="*[count(.|$brights)=count($brights)]">
...<xsl:for-each>

It translates into English as "child elements which, when added to the set of $brights and counted, yield the count of the set of $brights", which is only true for those child elements in the set.

In XPath 2.0 there are much easier ways to do this.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


Current Thread
Keywords