Subject: Re: dl/dt/dd matching From: Francois Belanger <francois@xxxxxxxxxxx> Date: Tue, 12 Jan 99 10:47:13 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: dl/dt/dd matching, Paul Prescod | Thread | Re: dl/dt/dd matching, James Clark |
xslp, Keith Visco | Date | Re: dl/dt/dd matching, Francois Belanger |
Month |