[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Aligning Parallel Columns
Subject: Re: [xsl] Aligning Parallel Columns From: Jeroen Hellingman <jeroen@xxxxxxxx> Date: Sat, 15 Jan 2011 23:23:36 +0100 |
After puzzling a little further, I came up with the following: This pulls the inserted lines into the table cell with the matching lines, which isn't bad for my application, as mostly, such extra lines will be split-of parts of paragraphs anyway. <xsl:template name="align-paragraphs"> <xsl:param name="a"/> <xsl:param name="b"/> <xsl:variable name="anchors" as="xs:string*"> <xsl:for-each-group select="$a/p/@name, $b/p/@name" group-by="."> <xsl:if test="count(current-group()) = 2"> <xsl:sequence select="string(.)"/> </xsl:if> </xsl:for-each-group> </xsl:variable> <table> <xsl:for-each select="$a/p[@name = $anchors]"> <xsl:variable name="name" select="@name"/> <tr> <td> <p><xsl:apply-templates select="."/></p> <xsl:call-template name="output-inserted-lines"> <xsl:with-param name="start" select="."/> <xsl:with-param name="anchors" select="$anchors"/> </xsl:call-template> </td> <td> <p><xsl:apply-templates select="$b/p[@name = $name]"/></p> <xsl:call-template name="output-inserted-lines"> <xsl:with-param name="start" select="$b/p[@name = $name]"/> <xsl:with-param name="anchors" select="$anchors"/> </xsl:call-template> </td> </tr> </xsl:for-each> </table> </xsl:template> I didn't grasp the function idea entirely, but using a recursive template works fine. The paragraphs that go into the table still have internal structure that needs to be rendered. <xsl:template name="output-inserted-lines"> <xsl:param name="start" as="node()"/> <xsl:param name="anchors"/> <xsl:variable name="next" select="$start/following-sibling::*[1]"/> <xsl:if test="not($next/@name = $anchors)"> <xsl:if test="$next"> <p><xsl:apply-templates select="$next"/></p> <xsl:call-template name="output-inserted-lines"> <xsl:with-param name="start" select="$next"/> <xsl:with-param name="anchors" select="$anchors"/> </xsl:call-template> </xsl:if> </xsl:if> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Aligning Parallel Columns, Jeroen Hellingman | Thread | [xsl] List of effective pages?, Dan Vint |
Re: [xsl] Aligning Parallel Columns, Jeroen Hellingman | Date | [xsl] List of effective pages?, Dan Vint |
Month |