Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • rajeev 18 posts 38 karma points
    Feb 09, 2011 @ 02:02
    rajeev
    0

    creating unclosed tag in xslt

    I have two nested foreach loop. inner loop generates <td> tags to construct a table. IF i try to add this line

    <xsl:if test="position() mod 3 =0"><tr></xsl:if>  

    Similary another if for </tr> tag.  

    But when I saves my xslt it gives me error for unclosed <tr> tag.

    Please help me how  I can do this.

     

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Feb 09, 2011 @ 06:25
    Jan Skovgaard
    0

    Hi rajeev

    You need to cheat a bit here in order to make this work

    Try writing this

    <xsl:if test="position() mod 3 =0"><xsl:text disable-output-escaping="yes"><![CDATA[<tr>]]></xsl:text></xsl:if> - This should be enough and let's the XML parser know it should not try to parse this element.

    So to make your </tr> work I guess it should be placed within the same test? Like this

    <xsl:if test="position() mod 3 =0">

    <xsl:text disable-output-escaping="yes"><![CDATA[<tr>]]></xsl:text>

    <!--your code here-->

    <xsl:text disable-output-escaping="yes"><![CDATA[</tr>]]></xsl:text>

    </xsl:if>

    Does this help?

    /Jan

  • rajeev 18 posts 38 karma points
    Feb 09, 2011 @ 06:38
    rajeev
    0

    Even if i do this  <table><xsl:text disable-output-escaping="yes"><![CDATA[<tr>]]></xsl:text><xsl:text disable-output-escaping="yes"><![CDATA[</tr>]]></xsl:text></table>

    I get nothing. I can't see the <tr> tag in source of page that i need to show.

  • Chriztian Steinmeier 2737 posts 8401 karma points MVP 5x admin c-trib
    Feb 09, 2011 @ 20:52
    Chriztian Steinmeier
    1

    Hi rajeev,

    Take a look at my solution for this one: http://our.umbraco.org/forum/developers/xslt/11692-Simple-table-row-example-with-XSLT-templates

    which was a modification of this one: http://our.umbraco.org/forum/developers/xslt/11527-Problem-with-listing-HTLM-strcuture-with-XSLT

    They show how to properly deal with tables (or other grouped output).

    Please ask away here if you need further help - maybe show a little more of your code, so we can guide you as good as possible.

    /Chriztian

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Feb 09, 2011 @ 21:01
    Jan Skovgaard
    0

    Hi Rajeev

    You should definently listen to Chriztian on this one and not my evil twin who must have posted earlier *ahem*...:-) That's apparently a study on how NOT to do it. I hang my head in shame and go to the naughty corner for a while.

    Thumbs up Chriztian and thanks for making elegant solutions :-)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft