title: XSLT applied to XML doc with xmlns attribute
body: <p>I'm applying an XSLT stylesheet to the following XML file:</p>
  
  <pre><code>&lt;top xmlns="http://www.foo.com/bar"&gt;
      &lt;elementA /&gt;
      &lt;elementB /&gt;
      &lt;contents&gt;
          &lt;contentitem&gt;
                  &lt;id&gt;3&lt;/id&gt;
                  &lt;moretags1 /&gt;
                  &lt;moretags2 /&gt;
          &lt;/contentitem&gt;
          &lt;contentitem&gt;
                  &lt;id&gt;2&lt;/id&gt;
                  &lt;moretags1 /&gt;
                  &lt;moretags2 /&gt;
          &lt;/contentitem&gt;
          &lt;contentitem&gt;
                  &lt;id&gt;1&lt;/id&gt;
                  &lt;moretags1 /&gt;
                  &lt;moretags2 /&gt;
          &lt;/contentitem&gt;
      &lt;/contents&gt;
  &lt;/top&gt;
  </code></pre>
  
  <p>Here's my current XSLT file (performs a simple sort):</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:doc="http://www.foo.com/bar"&gt;
   &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt;
  &lt;!--                                                --&gt;
   &lt;xsl:strip-space elements="*"/&gt;
  &lt;!--                                                --&gt;
    &lt;xsl:template match="node()|@*"&gt;
      &lt;xsl:copy&gt;
        &lt;xsl:apply-templates select="node()|@*"/&gt;
      &lt;/xsl:copy&gt;
    &lt;/xsl:template&gt;
  &lt;!--                                                --&gt;
    &lt;xsl:template match="contents"&gt;
      &lt;xsl:copy&gt;
        &lt;xsl:apply-templates select="@*"/&gt;
        &lt;xsl:apply-templates select="contentitem"&gt;
          &lt;xsl:sort select="id" data-type="number"/&gt;
        &lt;/xsl:apply-templates&gt;
      &lt;/xsl:copy&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Problem is, I do not know exactly how to use the 'doc:' namespace prefix with the xsl:template and xsl:apply-templates tags.</p>
  
  <p>Right now, the XML document is copied as-is, so I believe the first xsl:template block is being applied. However, the items are unsorted, so I think the problem lies in the second xsl:template.</p>
  
  <p>I should note that if I remove the xmlns attributes from both files, the transformation works properly.</p>
  
  <p>Any suggestions?</p>
  
  <p>(question is based on <a href="https://stackoverflow.com/questions/572854/how-to-sort-a-subelement-of-xml-with-xslt">this example</a>)</p>