title: XSLT not matching element - namespace declarations
body: <p>I'm sure this is a very simple fix, but I'm stumped.  I've got input XML with the following root element, and repeating child  elements:</p>
  
  <pre><code>&lt;modsCollection 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.loc.gov/mods/v3"
      xsi:schemaLocation="
        http://www.loc.gov/mods/v3
        http://www.loc.gov/standards/mods/v3/mods-3-4.xsd"&gt;
    &lt;mods version="3.4"&gt;
              ...
  </code></pre>
  
  <p>I've got an XSLT sheet with the following to match each <code>&lt;mods&gt;</code> node, and kick it out as a separate file named by an <code>&lt;identifier type="local"&gt;</code> element.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;xsl:stylesheet version="2.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns="http://www.loc.gov/mods/v3"&gt;
    &lt;xsl:output method="xml" indent="yes"/&gt;   
  
    &lt;xsl:template match="/modsCollection"&gt;
      &lt;xsl:for-each select="mods"&gt;
        &lt;xsl:variable name="filename" 
            select="concat(normalize-space(
                             identifier[@type='local']),
                           '.xml')" /&gt;
        &lt;xsl:result-document href="{$filename}"&gt;            
          &lt;xsl:copy-of select="."&gt;&lt;/xsl:copy-of&gt;     
        &lt;/xsl:result-document&gt;
      &lt;/xsl:for-each&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>This <em>works</em> if the XML input does not have the xmlns:xsi, xmlns, or xsi:schemaLoaction attributes in the root element.  So, for example, it works on the following:</p>
  
  <pre><code>&lt;modsCollection&gt;   
    &lt;mods version="3.4"&gt;
              ...
  </code></pre>
  
  <p>I know that some of our MODS files have had the prefix included  but I'm unclear why this won't work without the prefix if our XSLT matching is not looking for the prefix.  Any thoughts or advice would be greatly appreciated.</p>