1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3version="1.0" >
4
5   <xsl:output method="text"/>
6   <xsl:template match="*">
7     <xsl:text>&#x0A;selecting by element:    </xsl:text>
8     <xsl:for-each select="ancestor-or-self::*">
9       <xsl:text>/</xsl:text>
10       <xsl:value-of select="@name"/>
11     </xsl:for-each>
12     <xsl:text>&#x0A;          by attribute:  </xsl:text>
13     <xsl:for-each select="ancestor-or-self::*/@name">
14       <xsl:text>/</xsl:text>
15       <xsl:value-of select="."/>
16     </xsl:for-each>
17     <xsl:text>&#x0A;</xsl:text>
18     <xsl:apply-templates/>
19   </xsl:template>
20
21</xsl:stylesheet>
22