Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2006, 06:17 AM
Authorized User
 
Join Date: Jul 2006
Location: Valencia, Valencia, Spain.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default retrieving information from a parent node

How can I retrieve the attributes(the complete tag) of a parent node while I'm at one of it's childs?

Ive tried various xpath expression but none worked.

My problem is the following:

INPUT xml
---------

<a a1=1 a2=0>
  <b> </b>
  <b> </b>
  <b> </b>
<a/>

XSLT
----
<xsl:template match = "a" >
<xsl:for-each select="b">

<!-not related code-->

<!-- in this point I have to do: <xsl:copy-of select="@*"/>
(output -> <a a1=1 a2=0> )-->

</xsl:for-each>

</xsl:template>

Thanks.

Tomi.



 
Old September 6th, 2006, 06:53 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default


select="../@*"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 6th, 2006, 06:54 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well you can access them at from the child as ../@* or you could save them before you enter the <xsl:for-each select="b">, <xsl:variable name="aAttributes" select="@*"/> and reuse $aAttributes within the for-each.

--

Joe (Microsoft MVP - XML)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy parent node and not its children bonekrusher XSLT 4 August 29th, 2007 08:44 AM
Retrieving information from disabled drop down misskaos99 Classic ASP Basics 7 February 9th, 2007 12:41 PM
Finding parent node Chamkaur XSLT 4 August 9th, 2006 06:26 AM
How to delete an element and parent node. crossedge XSLT 1 March 14th, 2006 05:10 AM
Saving the parent node Doyle Bradely XML 2 December 23rd, 2003 07:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.