xsl-list
[Top] [All Lists]

Re: [xsl] Aligning Parallel Columns

2011-01-15 09:32:21
On 2011-01-15 13:38, G. Ken Holman wrote:
At 2011-01-15 07:22 -0500, I wrote:
Use for-each-group on the name attributes.  You will end up with five
groups.  As you walk through each of the five groups, looking at each
element's parent will tell you which side of the table the item
belongs in.

More precisely, as you walk through each of the five groups of
attributes, walk through the parent elements in table column order to
select that member of the group that is a descendant of the parent. 
That way you'll walk through the group in the correct order to generate
table cells and know if the item is absent from the parent to know to
put in an empty cell.

I hope this helps.

. . . . . . . . Ken

Thanks for the hint. My current solution depends on being able to sort
the names, which isn't entirely satisfying ($a and $b contain the two
divs to be aligned):

    <table>
        <xsl:for-each-group group-by="@name" select="$a/p, $b/p">
            <xsl:sort select="@name"/>

            <xsl:variable name="name" select="@name"/>

            <tr>
                <td>
                    <xsl:value-of select="$name"/>
                </td>
                <td>
                    <xsl:if test="$a/p[@name = $name]">
                        <xsl:apply-templates select="$a/p[@name = $name]"/>
                    </xsl:if>
                </td>
                <td>
                    <xsl:if test="$b/p[@name = $name]">
                        <xsl:apply-templates select="$b/p[@name = $name]"/>
                    </xsl:if>
                </td>
             </tr>
        </xsl:for-each-group>
    </table>


Jeroen.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>