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

Re: dl/dt/dd matching

Subject: Re: dl/dt/dd matching
From: Francois Belanger <francois@xxxxxxxxxxx>
Date: Tue, 12 Jan 99 10:47:13 -0500
dl dd dt
James Clark wrote on 11/01/99 22h31:

>Francois Belanger wrote:
>> 
>> I'm scratching my head on this one.
>
>I've been scratching my head for years on this one.  It's a problem in
>DSSSL too.
>
>> What were trying to do is layout a suite of dt/dd within a dl as a table
>> with a row for each dt. Since there's no container for each dt (the
>> corresponding dl are siblings, not children of the dt node), how can one
>> start a new row for each dt and express that in XSL?
>
>XSL can't handle this at the moment, but I think it needs to.

Definitvely, this issue rises from time to time, and not only with 
dl/dd/dt.

>One solution is to allow nodes to be grouped together:
>
>[[A1, B1], [A2, B2], [A3, B3]]
>
>and then specify an operation f on the results of groups, thus getting
>
>f(r(A1) + r(B1)) + f(r(A2) + r(B2)) + f(r(A3) + r(B3))
>
>For example, it might look like this:
>
><xsl:template match="dl">
>  <table>
>    <xsl:for-each select="dt|dd">
>      <xsl:group start="dt">
>         <tr><xsl:contents/></tr>
>      </xsl:group>
>      <td><xsl:apply-templates/></td>
>    </xsl:for-each>
>  </table>
></xsl:template>
>
>xsl:group modifies the operation of xsl:for-each and xsl:apply-templates
>just as xsl:sort does.  The start attribute is a match pattern that
>specifies the nodes that start a group; the content specifies what to do
>with the result of processing the members of the group; within
>xsl:group, xsl:contents refers to the result of appending the results of
>processing the members of the group.

My prefered approach, altough the xsl:macro-like xsl:contents is not that 
intuitive and reading it does not show how the output will nest. How 
about:

<xsl:template match="dl">
  <table>
    <xsl:for-each select="group(dt)">
         <tr><xsl:apply-templates/></tr>
    </xsl:for-each>
  </table>
</xsl:template>

<xsl:template match="dt|dd">
    <td>
      <xsl:apply-templates/>
    </td>
</xsl:template>

This way one can see that the tr will enclose the td.

>xsl:continue says the content gets added to the previous sibling in the
>result element tree.   This is simpler but has some problems.

It's maybe simpler to write but the xsl:group or my proposition seems 
more flexible.

Maybe both xsl:continue and xsl:group are needed?



Francois Belanger
Sitepak, Bringing Internet Business into Focus
http://www.sitepak.com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.