xsl-list
[Top] [All Lists]

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

2005-07-13 14:31:55
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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--