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: "Chaudhary, Harsh" <HCHAUDHA@xxxxxxxxx>
Date: Thu, 6 Dec 2007 19:31:08 -0600

I apologize for the incomplete question but it is about 8:00 here and it
was getting pretty late. I figured out what I was doing wrong. The
result of a tired mind I guess. Basically, I was passing the value-of
the zipcode element as value of the variable whereas I should have been
doing a copy-of.

Appreciate your input.


-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Thursday, December 06, 2007 7:27 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Trouble getting the self node attributes within
for-each loop

> 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
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
available to be queried with xpath.

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

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


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