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

Re:Generating table rows... selecting a run of empty

Subject: Re:Generating table rows... selecting a run of empty elements
From: david <dariggs@xxxxxxxxxxxxxxx>
Date: Fri, 11 Feb 2005 16:29:52 +0900
selecting table row
Thanks Wendell,

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])]"/>

Thanks,

David Riggs, Kyoto



Wendell answered my original query with:
--------------------------
>>I understand how to select the elements with not(text()) and to use an
>>Xpath expression to make a new row every
>>four items, but I do not see how to select a run of content-less
>>elements that need to be treated that way.


This is a pattern I've been using myself lately, to generate labels (effectively, same problem):

<xsl:template name="rowsof4">
   <xsl:param name="nodes" select="/self::*"/>
   <!-- the default is a fancy way of saying 'no nodes'
        (by asking for the root node that is an element) -->
   <xsl:for-each select="$nodes">
     <xsl:variable name="node-position" select="position()"/>
     <xsl:if test="$node-position mod 4 = 1">
     <tr>
        <xsl:apply-templates mode="cell"
           select=". | $nodes[$node-position + 1]
                     | $nodes[$node-position + 2]
                     | $nodes[$node-position + 3]"/>
     </tr>
   </xsl:for-each>
</xsl:template>

then...

<xsl:call-template name="rowsof4">
<xsl:with-param name="nodes" select="$the-elements-you-want-in-your-rows]"/>
</xsl:call-template>


... leaving the rest (e.g. the "cell" mode) for you to fill in.

--------------------

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.