xsl-list
[Top] [All Lists]

RE: Conditional tagging in xsl:for-each

2005-12-12 13:37:21
I am new to XSLT, so please forgive me if this is a FAQ 

It is a FAQ and we forgive you

http://www.dpawson.co.uk/xsl/sect2/N7450.html#d9550e13

Michael Kay
http://www.saxonica.com/


(I 
have found no useful reference on the web). I have the 
following XML source (snippet):

    <children>
        <child id="870">
            <file>dscn1095.jpg</file>
            <title>Some text.</title> 
        </child>
        <child id="871">
            <file>dscn1100.jpg</file>
            <title>More text</title> 
        </child>
        <child id="872">
            <file>dscn1101.jpg</file>
            <title>Still more text.</title> 
        </child>

The children should be transformed into a two-column table. I 
tried this, which makes the XSLT processors choke:

<xsl:template match="page[(_at_)type='galleries']/children">
    <table><tr>
    <xsl:for-each select="child">
        <td><img><xsl:attribute name="src"><xsl:value-of 
select="file" /></xsl:attribute></img><xsl:value-of 
select="title" /></td>
        <xsl:if test="not(position() mod 2)"></tr><tr></xsl:if>
    </xsl:for-each>
    </tr></table>
</xsl:template>

Obviously, they don't like the closing </tr> tag following my 
<xsl:if>. While I see the reason for the error, I cannot find 
a way around it. Is there a way to achieve what I want with XSLT?

Thanks,

Jan
-- 
There are 10 kinds of people:  those who understand binary, 
and those who don't

--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>