xsl-list
[Top] [All Lists]

Re: Vertical display

2003-04-28 05:02:44
These templates produces the output you want. There must, however, be an easier 
way...

/Marcus

<xsl:template match="com">
  <table>
    <xsl:call-template name="verticalTable">
      <xsl:with-param name="rowIndex" select="1"/>
      <xsl:with-param name="endIndex" select="3"/>
    </xsl:call-template>
  </table>
</xsl:template>

<xsl:template name="verticalTable">  
  <xsl:param name="rowIndex"/>
  <xsl:param name="endIndex"/>
  <xsl:if test="not($rowIndex &gt; $endIndex)">
    <xsl:call-template name="doRow">
      <xsl:with-param name="rowIndex" select="$rowIndex"/>
    </xsl:call-template>
    <xsl:call-template name="verticalTable">
      <xsl:with-param name="rowIndex" select="$rowIndex + 1"/>
      <xsl:with-param name="endIndex" select="$endIndex"/>
    </xsl:call-template> 
  </xsl:if>
</xsl:template>

<xsl:template name="doRow">
  <xsl:param name="rowIndex"/>
  <xsl:variable name="nodes" select="/o/com/*"/>
  <xsl:if test="$nodes">
    <tr>
      <xsl:for-each select="$nodes">
        <td><xsl:value-of select="*[position() = $rowIndex]"/></td>
      </xsl:for-each>
    </tr>
  </xsl:if>
</xsl:template>


----- Original Message ----- 
From: "Sundar Shanmugasundaram" <SSHANMUGASUNDARAM(_at_)selectica(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, April 28, 2003 12:43 PM
Subject: [xsl] Vertical display


<?xml version="1.0"?>
<o>
<com>
<hereyougo>
<first>1</first>
<second>2</second>
<third>3</third>

</hereyougo>
<imaycome>
<four>4</four>
<five>5</five>
<six>6</six>

</imaycome>
<imaycome1>
<four1>41</four1>
<five1>51</five1>
<six1>61</six1>

</imaycome1>
<imaycome2>
<four2>42</four2>
<five2>52</five2>
<six2>62</six2>

</imaycome2>

</com>
</o>

Hi,

This is the xml file. I want to display in HTML table as follows :

1      4        41       42
2      5        51       52
3      6        61       62

How will i do that?

Please give XSL template.

thanks and regards,
sundar

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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