Re: [xsl] FW: Two-Column XSL question

Subject: Re: [xsl] FW: Two-Column XSL question
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 31 Jan 2008 11:22:13 -0500
Josh,

At 10:09 AM 1/31/2008, you wrote:
It worked for me, but I need some help understanding what these items are actually doing:
1- <xsl:variable name="others" select="following-sibling::option[position()
&lt; 2]" />

This is selecting all the 'option' elements on the following-sibling:: axis whose position on that axis is less than 2, and binding them to the 'others' variable.


It could be written more concisely as "following-sibling::option[1]"; the reason you're seeing the "less than 2" logic here is probably that the significance of 2 here is that it's the number of columns: for three columns, $others should include both the following sibling and the next following sibling, i.e. "following-sibling::option[position() &lt; 3]". In other words, this bit of code was originally written to be more general than your case.

2- <xsl:for-each select=".|$others">

This is selecting the current node "." along with the nodes bound to $others (in your case, its following-sibling 'option' element) for processing), using the union operator "|". So its saying "for me and the node that belong in the same row in the other column" (since for you, $others is at most a single node).


3- <xsl:if test="not($others)">

This is fallback logic, for the case where you've run out of nodes and $others is empty. (A node set cast to a Boolean returns false if the set is empty, so not($others) is true when no nodes are bound to $others.


I hope this helps. Thanks for asking.

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