open HTML tags problem

Discussion in 'XML' started by ree32@hotmail.com, Jun 23, 2005.

  1. Guest

    I am new to XSL but I need to create a display where the layout is

    <tr> <td> <item/ ></td> <td> <item/ ></td> </tr>
    <tr> <td> <item/ ></td> <td> <item/ ></td> </tr>
    and so on ..

    A column table.

    But inorder to this I am trying to do the following

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

    <xsl: something .. to add <td> <item/ ></td>

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

    But it wont let me use the open tag <tr>, is there a way around using
    open tags. If not is there a solution to achieve what I am after ?
    , Jun 23, 2005
    #1
    1. Advertising

  2. writes:

    > I am new to XSL but I need to create a display where the layout is
    >
    > <tr> <td> <item/ ></td> <td> <item/ ></td> </tr>
    > <tr> <td> <item/ ></td> <td> <item/ ></td> </tr>
    > and so on ..
    >
    > A column table.
    >
    > But inorder to this I am trying to do the following
    >
    > <xsl:if test="position() mod 2 = 0">
    > <tr>
    > </xsl:if>
    >
    > <xsl: something .. to add <td> <item/ ></td>
    >
    > <xsl:if test="position() mod 2 = 0">
    > </tr>
    > </xsl:if>
    >
    > But it wont let me use the open tag <tr>, is there a way around using
    > open tags. If not is there a solution to achieve what I am after ?


    XSLT never works with tags, it generates a node tree, and you can't
    have half a node. Also more directly, the stylesheet has to be a well
    formed XML document.

    You want to start a new row every second item, and in that row you want
    to process this node and the next, so code that directly in xslt
    in terms of this node tree, nit in trems of tags that may be used if
    this node tree is ever serialised:


    <xsl:for-each select="*[position() mod 2 = 0]">
    <tr>
    <xsl:apply-templates select=".|following-sibling::*[1]"/>
    </tr>
    </xsl:for-each>

    <xsl:template match="abc">
    <td>
    <xsl:apply-templates/>
    </td>
    </xsl:templates>

    David
    David Carlisle, Jun 23, 2005
    #2
    1. Advertising

  3. Guest

    Thanks so producing a 5 column table would be impossible as you can't
    get a sibling 5 items down?
    , Jun 23, 2005
    #3
  4. writes:

    > Thanks so producing a 5 column table would be impossible as you can't
    > get a sibling 5 items down?


    ???

    you can select any number of siblings. I just showed 2 as that's
    what you asked for.If you want 5 then

    <xsl:for-each select="*[position() mod 5 = 0]">
    <tr>
    <xsl:apply-templates select=".|following-sibling::*[position()&lt;5]"/>
    </tr>
    </xsl:for-each>

    <xsl:template match="abc">
    <td>
    <xsl:apply-templates/>
    </td>
    </xsl:templates>

    David
    David Carlisle, Jun 23, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dean H. Saxe
    Replies:
    0
    Views:
    1,024
    Dean H. Saxe
    Jan 3, 2004
  2. Rob Nicholson
    Replies:
    3
    Views:
    717
    Rob Nicholson
    May 28, 2005
  3. Donald Firesmith

    html tags within meta tags allowed?

    Donald Firesmith, Jan 5, 2005, in forum: XML
    Replies:
    5
    Views:
    883
    Andy Dingley
    Jan 8, 2005
  4. Replies:
    10
    Views:
    758
    Spartanicus
    May 16, 2006
  5. open html tags

    , Sep 24, 2007, in forum: HTML
    Replies:
    6
    Views:
    430
    Neredbojias
    Sep 26, 2007
Loading...

Share This Page