title: Confused in selecting ancestor name
body: <p>I'm trying to print ancestor node name using XSLT.</p>
  
  <p>Below is my XSLT.</p>
  
  <pre><code>&lt;xsl:apply-templates select="(//title)[1]"/&gt;
  
  &lt;xsl:template match="title"&gt;
  &lt;xsl:value-of select="name(ancestor::node())"/&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>And my XML is as below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;catalog&gt;
      &lt;!--ancestor--&gt;
      &lt;cd&gt;
          &lt;!--parent--&gt;
          &lt;title name="titleName" property="propertyName"&gt;Empire Burlesque&lt;/title&gt;
          &lt;!--self--&gt;
          &lt;artist&gt;Bob Dylan&lt;/artist&gt;
          &lt;!--following-sibling--&gt;
          &lt;country&gt;USA&lt;/country&gt;
          &lt;!--following-sibling--&gt;
          &lt;company&gt;Columbia&lt;/company&gt;
          &lt;!--following-sibling--&gt;
          &lt;price&gt;10.90&lt;/price&gt;
          &lt;!--following-sibling--&gt;
          &lt;year&gt;1985&lt;/year&gt;
          &lt;!--following-sibling--&gt;
      &lt;/cd&gt;
  &lt;/catalog&gt;
  </code></pre>
  
  <p>Here when I use the below statement.</p>
  
  <pre><code>&lt;xsl:value-of select="name(../..)"/&gt;
  </code></pre>
  
  <p>else when I use </p>
  
  <pre><code>&lt;xsl:value-of select="name(ancestor::node())"/&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;xsl:value-of select="name(ancestor::*)"/&gt;
  </code></pre>
  
  <p>it is giving me the below Exception</p>
  
  <pre><code>XSLT 2.0 Debugging Error: Error: file:///C:/Users/u0138039/Desktop/Training%20Docs/XSLT%20Training/Sample.xsl:209: Wrong occurrence to match required sequence type -   Details: -     XPTY0004: The parameter value ('3' item(s)) at position '1' of the 'name' function has the wrong occurrence to match the sequence type node() ('zero or one')
  </code></pre>
  
  <p>but to get the parent name, when I use </p>
  
  <pre><code>&lt;xsl:value-of select="name(parent::*)"/&gt;
  </code></pre>
  
  <p>please let me know why this working for <code>parent</code> but not for <code>ancestor</code>.</p>
  
  <p>This is very confusing. How can I get the <code>ancestor</code> name using something like <code>&lt;xsl:value-of select="name(ancestor::node())"</code>.</p>
  
  <p>Thanks</p>