Re: [xsl] Re:Generating table rows... selecting a run of empty elements

Subject: Re: [xsl] Re:Generating table rows... selecting a run of empty elements
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 14 Feb 2005 15:30:16 -0500
Hi David,

At 02:29 AM 2/11/2005, you wrote:
Your example is a fine way to break the table into rows, but I am still left with the core problem:

How do I select a run of emptpy elements for processing into a table with rows?

I.e. I have

<photo title="9 jo kesa with Sanskrit A" file="Daimonji.023.jpg"> This robe was found in 1955 after ... end of description. </photo>

<photo title="hand bell from Hondo" file="Daimonji.024.jpg"/>
<photo title="hand bell from Hondo" file="Daimonji.025.jpg"/>
<photo title="hand bell from Hondo" file="Daimonji.026.jpg"/>
<photo title="hand bell from Kaisando" file="Daimonji.027.jpg"/>
<photo title="hand bell from Sanmon" file="Daimonji.028.jpg"/>
<photo title="hand bell from Hondo" file="Daimonji.029.jpg"/>

<photo title="9 jo kesa with Ring TieA" file="Daimonji.032.jpg"> Very fine condition linen robe. The carved box ... end of description. </photo>

And I want to apply table processing to that central run of 6 elements, making a table of one and a half rows of four each. The elements with paragraphs of text are handled in a different way. I can select the first empty <photo ../> element with

<xsl:template match="photo[not(text())][preceding-sibling::photo[1][text()]]">

But how do I assign that and the following 5 elements to a variable, with which I can then call the "rowsof4" template?

I think I want something like the following, but it fails with the "wrong number of arguments".

<xsl:with-param name="nodes" select=". | following-sibling::photo[not(text())][position() &lt;position(following-sibling::photo[text()][1])]"/>

Yes -- this won't work because you can't use position() that way -- since position() refers to a node's position relative to its processing context, it can only operate on the context node. So you can't ever say "position($node)".

This is actually a grouping problem. Abstractly, the problem is that you need to get from


and retrieve, with each b whose immediately preceding sibling is not a b, itself plus the subsequent b elements up to the next element not a b.

In particular, this is a "positional grouping" problem, and as such is easiest to accomplish in two passes. (It's probably not impossible to do in one pass -- except the XPath in a key declaration used to retrieve the sets is going to be quite, mm, tortuous.)

Do a little digging into "positional grouping" (check as well as the other usual places) to see where I'm going with this. If XSLT 2.0 is an option, you might look at the support it provides for grouping.


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 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