[xsl] <xsl:for-each select> and acessing the parent tag's attribute

Subject: [xsl] <xsl:for-each select> and acessing the parent tag's attribute
From: Priya Pinto <Priya.P@xxxxxxxxxxxxxxxxxx>
Date: Sun, 15 Apr 2001 17:48:50 +0400

I want to know how to get the value of the parent tag when you are in an
<xsl:for-each select> of the child tag

Here is an illustration of what I want

this is the xml file

<?xml version="1.0" encoding="UTF-8"?>
<Country Name="Afghanistan">
<Region Name="Herat">
<City Name="Herat"></City>
<City Name="Kabul"></City>
<City Name="Kandahar"></City>
<City Name="Mazar-e Sharif"></City>
<Country Name="Albania">
<City Name="Shkoder"></City>
<City Name="Tirane"></City>

The XSL code

<xsl:for-each select="World/Country/City">
<country><xsl:value-of select="World/Country/@Name"/></country>
<region><xsl:value-of select="Region/@Name"/></region>
<city><xsl:value-of select="Region/City/@Name"/></city>

This code does not give me the required result.


Priya Ann Pinto
Software Engineer - Java
Email : Priya.P@xxxxxxx


P.O. Box 74500
Dubai, United Arab Emirates
Phone   : +971 4 330 3778
Fax     : +971 4 330 3779
Website : http://www.ITCC.ws

This message and any attachments are confidential to the ordinary
user of the email address to which it is addressed and may also be
legally privileged. If you are not the intended recipient, the
printing, copying, forwarding, disclosure, or use of any part of this
message or its attachments is strictly prohibited, and may be
unlawful. If you have received this message in error, please inform
the sender immediately by return e-mail and then promptly delete
it from your system.

We strongly recommend that you read the complete version of this
confidentiality note and disclaimer, available on our website at

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

Current Thread