This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Building html table from atributes
- From: Jarkko dot Moilanen at uta dot fi
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 09 Aug 2002 09:11:47 +0300 (EEST)
- Subject: RE: [xsl] Building html table from atributes
- References: <000501c23ee3$aacc4fd0$6401a8c0@pcukmka>
- Reply-to: xsl-list at lists dot mulberrytech dot com
To make it sure that I understood correctly:
> First an XSLT 2.0 solution:
>
> <xsl:variable name="doc" select="/XDocument"/>
// variable that points to root element
> <xsl:for-each select="1 to max($doc/XDocCell/@col)">
// selects all elements (attribute col of XDocCells) from 1 to the max,
// using the doc variable.
> <xsl:variable name="col" select="position()"/>
// col variable that declares position
> <tr>
> <xsl:for-each select="1 to max($doc/XDocCell/@row)">
// selects all elements (attribute row of XDocCells) from 1 to the max,
// using the doc variable.
> <xsl:variable name="row" select="position()"/>
// row variable that declares position
> <td><xsl:value-of select="$doc/XDocCell[@row=$row and @col=$col]"/></td>
// selects all row and col atributes (from xml file) that equals
// variables row and col
> </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]">
// selects nodes whose position is less or equal to variable n, correct?
> 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@ntlworld.com
> work: Michael.Kay@softwareag.com
>
>
> > -----Original Message-----
> > From: owner-xsl-list@lists.mulberrytech.com
> > [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of
> > Jarkko.Moilanen@uta.fi
> > Sent: 08 August 2002 13:38
> > To: xsl-list
> > Subject: [xsl] 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@uta.fi 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
>
>
****************************************************************
Jarkko Moilanen "Erehtyminen on inhimillista,
Researcher/ ITCM mutta todella suuret mokat
jm60697@uta.fi 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