[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Display more than one table in generic xslt - reg

Subject: Re: Display more than one table in generic xslt - reg
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 24 Mar 2010 13:04:00 +0100
Re:  Display more than one table in generic xslt - reg
Ramesh Kumar wrote:
The required HTML output is like....

<HTML><BODY>
<Table>
<TR><TD>
<Table border="1">
<tr><td>SysID</td><td>WFDocID</td></tr>
<tr><td>-2008080800041</td><td>0</td></tr>
</Table>
</TD></TR>
<TR><TD>&nbsp;</TD></TR>
<TR><TD>
<Table border="1">
<tr><td>SysID</td><td>ParentSysID</td></tr>
<tr><td>-2008080800045</td><td>-2008080800041</td></tr>
<tr><td>-2008080800046</td><td>-2008080800041</td></tr>
</Table>
</TD></TR>
</Table>
</Body>
</HTML>

Here is an XSLT 1.0 stylesheet:


<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

  <xsl:output method="html" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:key name="by-name"
           match="/*/*"
           use="concat('{', namespace-uri(), '}', local-name())"/>

<xsl:template match="/">
<html>
<body>
<table>
<tbody>
<xsl:apply-templates select="*/*[generate-id() = generate-id(key('by-name', concat('{', namespace-uri(), '}', local-name()))[1])]" mode="table"/>
</tbody>
</table>
</body>
</html>
</xsl:template>


<xsl:template match="/*/*" mode="table">
<tr>
<td>
<table border="1">
<thead>
<tr>
<xsl:apply-templates mode="th"/>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="key('by-name', concat('{', namespace-uri(), '}', local-name()))"/>
</tbody>
</table>
</td>
</tr>
<xsl:if test="position() != last()">
<tr>
<td>&#160;</td>
</tr>
</xsl:if>
</xsl:template>


  <xsl:template match="/*/*/*" mode="th">
    <th>
      <xsl:value-of select="local-name()"/>
    </th>
  </xsl:template>

  <xsl:template match="/*/*">
    <tr>
      <xsl:apply-templates/>
    </tr>
  </xsl:template>

  <xsl:template match="/*/*/*">
    <td>
      <xsl:value-of select="."/>
    </td>
  </xsl:template>

</xsl:stylesheet>

Its output is a bit more structured (using tbody, thead, and th) than your sample but it should give you an idea how to approach that.

--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.