title: Cannot select element in node-set() result using name, but * finds it
body: <p>I have an XSLT 1.0* style sheet which does some pre-processing and creates a result fragment consisting of a list of elements <code>&lt;x&gt;</code>, each of which has two children - let's call then <code>&lt;a&gt;</code> and <code>&lt;b&gt;</code>.</p>
  
  <p>So the generated list looks like:</p>
  
  <pre><code>&lt;x&gt;&lt;a&gt;A-content&lt;/a&gt;&lt;b&gt;B-content&lt;/b&gt;&lt;/x&gt;
  &lt;x&gt;&lt;a&gt;A-content&lt;/a&gt;&lt;b&gt;B-content&lt;/b&gt;&lt;/x&gt;
  ...
  &lt;x&gt;&lt;a&gt;A-content&lt;/a&gt;&lt;b&gt;B-content&lt;/b&gt;&lt;/x&gt;
  </code></pre>
  
  <p>I then convert this into a node set using node-set() and use apply-templates to convert all the <code>&lt;x&gt;</code> elements to the output representation.</p>
  
  <p>So far, so good.</p>
  
  <p>But I have to use a <code>match="*"</code> rule on the output template, and although I can get the child elements using <code>"*[1]"</code> and <code>"*[2]"</code>, I cannot find them using <code>"a"</code> and <code>"b"</code> - I just get an empty result.</p>
  
  <p>The positional syntax works as a workaround, but it's rather fragile and I would like to change it back to working on the element names. Also, it's not very readable.</p>
  
  <p>I did suspect that it might be a namespace problem (<code>&lt;x&gt;</code>, <code>&lt;a&gt;</code> and <code>&lt;b&gt;</code> are not defined in the original schema for the input or output documents), but as far as I can see there is no namespace decoration when the elements are selected using "*".</p>
  
  <p>Just in case it's important, I am using xsltproc under cygwin (libxml 20902, libxslt 10128 and libexslt 817).</p>
  
  <p>Any ideas on what I might be doing wrong, or tips on debugging?</p>
  
  <p>(*- <em>I have to use XSLT 1.0 because it's designed to run in a web browser</em>.)</p>
  
  <hr>
  
  <p>EDIT: Added examples, as requested</p>
  
  <p>Input test.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;?xml-stylesheet href="test.xsl" type="text/xsl" ?&gt;
  
  &lt;books&gt;
      &lt;book&gt;
          &lt;title&gt;Diaspora&lt;/title&gt;
          &lt;author&gt;Greg Egan&lt;/author&gt;
      &lt;/book&gt;
  
      &lt;book&gt;
          &lt;title&gt;2001&lt;/title&gt;
          &lt;author&gt;Arthur C Clarke&lt;/author&gt;
      &lt;/book&gt;
  
      &lt;book&gt;
          &lt;title&gt;Eon&lt;/title&gt;
          &lt;author&gt;Greg Bear&lt;/author&gt;
      &lt;/book&gt;
  &lt;/books&gt;
  </code></pre>
  
  <p>Transform test.xslt:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns="http://www.w3.org/1999/xhtml"
                                  xmlns:exslt="http://exslt.org/common"
                                  xmlns:xalan="http://xml.apache.org/xalan"
                                  xmlns:msxslt="urn:schemas-microsoft-com:xslt"
                                  exclude-result-prefixes="xsl msxslt exslt xalan"&gt;
  &lt;!--    extension-element-prefixes="exslt"&gt; --&gt;
  
      &lt;xsl:template match="books"&gt;
          &lt;!-- Generate list --&gt;
          &lt;xsl:variable name="list"&gt;
              &lt;xsl:apply-templates select="book" mode="phase1"/&gt;
          &lt;/xsl:variable&gt;
  
          &lt;html&gt;
              &lt;head&gt;
                  &lt;title&gt;Books&lt;/title&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;xsl:choose&gt;
                      &lt;xsl:when test="function-available('msxslt:node-set')"&gt;
                          &lt;xsl:apply-templates select="msxslt:node-set($list)" mode="process-list"/&gt;
                      &lt;/xsl:when&gt;
                      &lt;xsl:when test="function-available('exslt:node-set')"&gt;
                          &lt;xsl:apply-templates select="exslt:node-set($list)" mode="process-list"/&gt;
                      &lt;/xsl:when&gt;
                      &lt;xsl:when test="function-available('xalan:nodeset')"&gt;
                          &lt;xsl:apply-templates select="xalan:nodeset($list)"  mode="process-list"/&gt;
                      &lt;/xsl:when&gt;
                      &lt;xsl:otherwise&gt;
                          &lt;xsl:apply-templates select="$list" mode="process-list"/&gt;
                      &lt;/xsl:otherwise&gt;
                  &lt;/xsl:choose&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="book" mode="phase1"&gt;
          &lt;!-- Actual transformation is more involved --&gt;
          &lt;xsl:element name="x"&gt;
              &lt;xsl:element name="a"&gt;
                  &lt;b&gt;
                      &lt;xsl:value-of select="author/text()"/&gt;
                  &lt;/b&gt;
              &lt;/xsl:element&gt;
              &lt;xsl:element name="b"&gt;
                  &lt;i&gt;
                      &lt;xsl:value-of select="title/text()"/&gt;
                  &lt;/i&gt;
              &lt;/xsl:element&gt;
          &lt;/xsl:element&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="*" mode="process-list"&gt;
          &lt;p&gt;
              [&lt;xsl:value-of select="*[1]"/&gt;]
              [&lt;xsl:value-of select="*[2]"/&gt;]
              [&lt;xsl:value-of select="a"/&gt;]
              [&lt;xsl:value-of select="b"/&gt;]
          &lt;/p&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Output (same output from both msxslt and xsltproc):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;&lt;title&gt;Books&lt;/title&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;p&gt;
              [Greg Egan]
              [Diaspora]
              []
              []
          &lt;/p&gt;&lt;p&gt;
              [Arthur C Clarke]
              [2001]
              []
              []
          &lt;/p&gt;&lt;p&gt;
              [Greg Bear]
              [Eon]
              []
              []
          &lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>