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

Re: Hopefully not a terribly silly question

Subject: Re: Hopefully not a terribly silly question
From: Trevor Nash <tcn@xxxxxxxxxxxxx>
Date: Thu, 03 Jan 2002 19:03:20 +0000
trevor nash
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@xxxxxxxxxxxxx

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


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.