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

Display table where colomns are variable

Subject: Display table where colomns are variable
From: "Tim Watts" <timw@xxxxxxx>
Date: Tue, 13 Mar 2001 15:20:21 +1100
Welcome to today's tiny puzzle...

I would like to use a standard template to display data throughout a site,
but the number of columns required will be different depending on the
various pieces of data required to be displayed.

Each XSL would call an external document which contains the

This would use something simular to following to select the child element
which the rows are created for...

<xsl:apply-template select="root/parent/child" />

and for each root/parent/child node the row is created with a template which
should call the showdata template(external shared template) for each of the
select nodes for which we want to display the data.

<xsl:template match="root/parent/child">
  <xsl:call-template name="showdata">
    <xsl:with-param name="column1"><xsl:value-of
select="firstname"><xsl:text> </xsl:text><xsl:value-of
    <xsl:with-param name="column2" select "otherthing" />
    <xsl:with-param name="column3" select "someotherthing" />
    <xsl:with-param name="column4" select "somethingelse" />

which calls the following template "showdata" in an external document...

<xsl:template name="showdata">
    <xsl:param name="column1">Null</xsl:param>
    <xsl:param name="column2">Null</xsl:param>
    <xsl:param name="column3">Null</xsl:param>
    <xsl:param name="column4">Null</xsl:param>
    <xsl:if test="not($column1='Null')"><td><xsl:value-of select="$column1"
    <xsl:if test="not($column2='Null')"><td><xsl:value-of select="$column2"
    <xsl:if test="not($column3='Null')"><td><xsl:value-of select="$column3"
    <xsl:if test="not($column4='Null')"><td><xsl:value-of select="$column4"

There are some problems with this approach -
One, it is long-winded
Two, by using "Null" as a test if a value for that param was passed, if you
want the value to say "Null" it won't work
Three, there will have to be a max no. of columns (however many column
params that are allowed for) - although practically, you will probably want
to set a max anyway.

Could someone come up with a better solution than the one devised here? I
would really appreciate it.


Tim Watts

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

Current Thread


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.
First Name
Last Name
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.