|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Building html table from atributes
First an XSLT 2.0 solution:
<xsl:variable name="doc" select="/XDocument"/>
<xsl:for-each select="1 to max($doc/XDocCell/@col)">
<xsl:variable name="col" select="position()"/>
<tr>
<xsl:for-each select="1 to max($doc/XDocCell/@row)">
<xsl:variable name="row" select="position()"/>
<td><xsl:value-of select="$doc/XDocCell[@row=$row and
@col=$col]"/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
The XSLT 1.0 solution has the same structure, except you need to be a
bit more inventive.
To iterate a fixed number of times, use the approach:
<xsl:for-each select="(//node())[position() <= $n]">
To find the maximum row/column, you can use the standard ways of getting
max/min (see the FAQ).
Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Jarkko.Moilanen@xxxxxx
> Sent: 08 August 2002 13:38
> To: xsl-list
> Subject: Building html table from atributes
>
>
> Hi!
>
> I have been given a challenge and I have no idea how to start
> solving it. I should build html table from xml file using
> xslt. The xml file would be similar to below:
>
> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
> <XDocument>
> <XDocTemplate>111111aaaaaaa</XDocTemplate>
>
> <XDocCell row="1" col="1">
> <XDocPretext>Text</XDocPretext>
> </XDocCell>
>
> <XDocCell row="1" col="2">
> <XDocPretext>Text</XDocPretext>
> </XDocCell>
>
> <XDocCell row="1" col="3">
> <XDocPretext>Text</XDocPretext>
> </XDocCell>
>
> <XDocCell row="1" col="4">
> <XDocPretext>Text</XDocPretext>
> </XDocCell>
>
> <XDocCell row="2" col="1">
> <XDocPretext>Text</XDocPretext>
> </XDocCell>
>
> <XDocCell row="2" col="2">
> <XDocPretext>Text</XDocPretext>
> </XDocCell>
> </XDocument>
>
> Now I should place the <XDocPretext> contents to different
> cell in the table. The correct cell is indicated in the
> <XDocCell> attributes row and
> col. The table should always have four cell in a row, even if there
> is no content (eg. element for that cell in the xml file).
>
> Please give me some hints how to start working with this.
>
> Cheers
> Jarkko
>
>
> ****************************************************************
> Jarkko Moilanen "Erehtyminen on inhimillista,
> Researcher/ ITCM mutta todella suuret mokat
> jm60697@xxxxxx vaativat tietokoneen käyttöä."
> www.uta.fi/~jm60697
> GSM: +358 50 3766 927
> ****************************************************************
> * ITCM | Information Technology and Crisis Management
> * http://www.itcm.org
> ****************************************************************
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








