Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 August 4th, 2006, 07:54 PM
Authorized User
 
Join Date: Jun 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Understanding Axes

Hi there,

In order to understand how axes work, I decided to create attributes in each of my various templates that displays the name of the current node the XSLT is processing and which nodes are its parent, siblings etc. Below is an example of the template

<xsl:template match="LoanPurpose/LendingPurposeCode">
        <LendingPurposeCode>
            <xsl:attribute name="CurrentNode"><xsl:value-of select="current()"/></xsl:attribute>
<xsl:attribute name="ParentNode"><xsl:value-of select="parent::node()"/></xsl:attribute>

            <xsl:copy-of select="@*"/>

I am not sure if the above makes any sense but what I trying to find out is whenever I call a particular template, I want to know how to rerieve data from the various axes.

When I run the above example, I get blank in the attributes. However, when I use name() instead of current() for <xsl:attribute name="CurrentNode">, I get the current element name that the XSLT is processing but what about retrieving its parent element name?

thanks

 
Old August 6th, 2006, 03:09 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

xsl:value of, when applied to a node, displays the string value of the node. To display the name of the node, use the name() function.

name() or name(.) displays the name of the current node

name(..) displays the name of the parent of the current node.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help understanding validation kscase Pro Visual Basic 2005 1 July 7th, 2007 07:15 PM
Need help understanding DataRow asp_convert ADO.NET 3 March 13th, 2007 02:39 PM
Need help understanding databinding asp_convert ASP.NET 2.0 Basics 0 February 11th, 2007 07:17 PM
Understanding Session rajuru Beginning PHP 2 September 25th, 2004 05:05 AM
Manipulating Excel Chart Axes from VB.NET Whitehall2000 VB.NET 2002/2003 Basics 0 September 25th, 2003 09:07 AM





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