This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Hopefully not a terribly silly question
- From: Trevor Nash <tcn at melvaig dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 03 Jan 2002 19:03:20 +0000
- Subject: Re: [xsl] Hopefully not a terribly silly question
- Organization: Melvaig Software Engineering Limited
- References: <20020103162337.51519.qmail@web14508.mail.yahoo.com> <3C349320.6040502@aol.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Morgan,
You are trying to fish out the column name every time you need it.
Better to make a list of them once in a global variable:
<xsl:variable name="col-names" select="/result/row[1]/column/@name" />
<!-- that gives you a node-set with the name attributes in document
order -->
Then instead of
> <xsl:value-of select="concat('/result/row[1]/column[', position(),']/@name')"/>
try
<xsl:variable name="col-no" select="position()" />
<xsl:value-of select="$col-names[$col-no]" />
to give you the name of the current column. (Don't put position()
directly, because it changes its value according to the context).
>Unfortunately, I get a the literal string result of the concat()
>function, instead of the actual data value. Is there some sort of
>eval() function that I need to use? Am I approaching this incorrectly?
> I know that XSL is quite a paradigm shift from traditional programming
>methods.
True. You can improve this a lot by letting templates do the work for
you instead of explicitly navigating the source tree. I also think
you are going to miss the first row of data: you want to print the
column headings *and* the values on the first row, not just the names.
There isn't a standard 'eval' function BTW, though some processors
have it as an extension function.
Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email
Melvaig Software Engineering Limited
voice: +44 (0) 1445 771 271
email: tcn@melvaig.co.uk
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list