RE: [xsl] RE:"*NEVER* use for-each"

Subject: RE: [xsl] RE:"*NEVER* use for-each"
From: "FINLEY, Mike" <Mike.FINLEY@xxxxxxxxxx>
Date: Fri, 2 Mar 2001 11:56:27 -0000
I've rewritten my xsl to use templates (with modes, which I think I needed)
and found that the processing time increased by about 15% using the MSXML
parser. (This does not include time to load and parse the XSL or XML
documents). Memory usage was similar in each case, too.

-----Original Message-----
From: FINLEY, Mike [mailto:Mike.FINLEY@xxxxxxxxxx]
Sent: 27 February 2001 16:41
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: [xsl] RE:"*NEVER* use for-each"


As a beginner, who has just used for-each to solve a problem, why should I
never use it?

(OK, I admit having checked the <xsl:sort> description in Mike Kay's book I
could probably have used another template, but why is that preferable to
using for-each?)

mike

-----Original Message-----
From: Chris Bayes [mailto:Chris@xxxxxxxxxxx]
Sent: 27 February 2001 16:20
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Can I access the children by their Index?


Daniel,
You are looking at this the wrong way
Beginners rule #1 *NEVER* use for-each
I guess you want to make a table with rows for each of the children of
ESTIMATEDATA
What you want is something like this
<xsl:template match="ESTIMATEDATA">
	<table>
		<xsl:apply-templates />
	</table>
</xsl:template>
<xsl:template match="ESTIMATEDATA/*">
	<tr>
		<td><xsl:value-of select="@name" /></td>
		<td><xsl:value-of select="@grade" /></td>
		<td><xsl:value-of select="." /></td>
	</tr>
</xsl:template>

But then maybe you don't.

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Daniel Newman
>Sent: 27 February 2001 15:34
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: RE: [xsl] Can I access the children by their Index?
>
>
>sorry all, thought my original request might confuse. Time for more
>illustration. My XML (the part we're interested in anyway) looks like this:
>
> <ESTIMATEDATA>
>  <SALES name="Sales" grade="none">***.*</SALES>
>  <PROFIT name="Profit" grade="none">**.*</PROFIT>
>  <EPS name="EPS" grade="none">**.*</EPS>
>  <CFPS name="CFPS" grade="none" />
>  <DPS name="DPS" grade="none">**.**</DPS>
>  <PE name="P/E Ratio" grade="none">**.*</PE>
>  <DIVCOVER name="Div Cover" grade="none">*.*</DIVCOVER>
>  <DIVYIELD name="Yield" grade="none">*.*</DIVYIELD>
>  <PEG name="PEG Factor" grade="none" />
> </ESTIMATEDATA>
>
>Now I want to set up a function that will loop 9 times, and then retrieve
>the value of that child node. I don't want to refer to each child by their
>name, as this would mean getting rid of the loop and having nine
>table rows.
>There must be a way of accessing CFPS without calling it by name. So again,
>can I get the value of CFPS by doing something like:
>
>xsl:value-of select="../../../ESTIMATEDATE/child(4)/@name"
>
>Anyone had this problem?
>
>Thanks if you know
>
>Daniel.
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


___________________________________________________________________________
This email is confidential and intended solely for the use of the 
individual to whom it is addressed. Any views or opinions presented are 
solely those of the author and do not necessarily represent those of 
Sema. 
If you are not the intended recipient, be advised that you have received
this
email in error and that any use, dissemination, forwarding, printing, or 
copying of this email is strictly prohibited.

If you have received this email in error please notify the Sema UK
Helpdesk by telephone on +44 (0) 121 627 5600.
___________________________________________________________________________

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

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


Current Thread