Re: [xsl] Trouble getting the self node attributes within for-each loop

Subject: Re: [xsl] Trouble getting the self node attributes within for-each loop
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 7 Dec 2007 01:26:51 GMT
> I run a for-each look over //zipcode,
don't use // unless you really mean it, it's potentially expensive,
searching to arbitrary depth, you probably just need select="zipcode"
here if the current node is territory.

> and store the
> results of the for-each into a variable (result tree fragment).

OK, possibly.


> I then pass this variable to another section of my code.

do you just mean it's in scope somewhere else or you explictly pass it as
a parameter? either way...

>  I can get the value of "name" correctly as it is an element.

In standard XSLT 1 you can not query into a result tree fragment, so
either you are using xslt 2 (and it's a temporary tree not a result tree
fragment) or you have used the node-set extension function?
Also <name> exists in your source but you said you were storing a
transformed result? presumably that also has a name element?

> My question is, is there a way to also get the value of the
> corresponding @zip?

if select="name" gets the name element select="@zip" might get the zip
attribute but this deends on the zip attribute being in the transformed
set of nodes (which you haven't shown) and that the transformed source is
available to be queried with xpath.


> If some sample XSLT would be useful, I can code something up quickly in
> case someone needs to see how I am doing things.

as you might guess, this would be useful...

David






________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread