title: namespace error : Namespace prefix bd on keyword is not defined
body: <p>I have a huge xml file that I would like to split up into individual xml documents; each individual xml file is supposed to have an explicit namespace declaration where applicable as show in the "Desired Output" portion below. However, I keep getting the error "namespace error : Namespace prefix bd on keyword is not defined"</p>
  
  <p>My question is, how can I explicitly tell my XSLT processor where to put namespace declaration in resulting output? I have gone through a couple of tutorials online, but I can't quite figure out how to sort this out.</p>
  
  <p>Partial XSLT Snippet</p>
  
  <pre><code>...
  ...
  &lt;xsl:template match="chapter"&gt;
    &lt;bd:chapter&gt;
      &lt;xsl:apply-templates select="name" /&gt;
      &lt;xsl:apply-templates select="page" /&gt;
    &lt;/bd:chapter&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="name"&gt;
    &lt;bd:name&gt;
      &lt;xsl:value-of select="." /&gt;
    &lt;/bd:name&gt;
  &lt;/xsl:template&gt;
  ...
  ...
  </code></pre>
  
  <p>Desired Output</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;books&gt;
  &lt;bd:book xmlns:bd="http://www.bd.org.za/db" xmlns:cd="http://www.bd.org.za/cd"&gt;
      &lt;bd:name&gt;book01&lt;/bd:name&gt;
      &lt;bd:chapter&gt;
        &lt;cd:name&gt;chapter01&lt;cd:name&gt;
        &lt;bd:page&gt;
      &lt;cd:title&gt;&lt;/cd:title&gt;
      &lt;pd:description&gt;&lt;/pd:description&gt;
        &lt;/bd:page&gt;
      &lt;/bd:chapter&gt;
  &lt;/bd:book&gt;
  ...
  ...
  ...
  &lt;/books&gt;
  </code></pre>
  
  <p><strong>Update #1</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;books&gt;
  &lt;book&gt;
      &lt;name&gt;book01&lt;/name&gt;
      &lt;chapter&gt;
        &lt;name&gt;chapter01&lt;name&gt;
        &lt;page&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;description&gt;&lt;/description&gt;
        &lt;/page&gt;
      &lt;/chapter&gt;
  &lt;/book&gt;
  ...
  ...
  ...
  &lt;/books&gt;
  </code></pre>
  
  <p><strong>Update #2</strong></p>
  
  <p><strong>@polishchuk Update2 give the following result</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;root xmlns:pd="namespace2"&gt;
    &lt;pd:Book xmlns:pd="http://namespace1.org/"&gt;
      &lt;pd_1:Name xmlns:pd="namespace2" xmlns:pd_1="http://namespace1.org/"&gt;A&lt;/pd_1:Name&gt;
      &lt;pd:Description xmlns:pd="namespace2"&gt;A1&lt;/pd:Description&gt;
    &lt;/pd:Book&gt;
    &lt;pd:Book xmlns:pd="http://namespace1.org/"&gt;
      &lt;pd_1:Name xmlns:pd="namespace2" xmlns:pd_1="http://namespace1.org/"&gt;B&lt;/pd_1:Name&gt;
      &lt;pd:Description xmlns:pd="namespace2"&gt;B1&lt;/pd:Description&gt;
    &lt;/pd:Book&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>The only pace I would like the namespaces to appear is within the book node. Please see below</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;root&gt;
    &lt;pd:Book xmlns:pd="http://namespace1.org/"&gt;
      &lt;pd:Name &gt;A&lt;/pd:Name&gt;
      &lt;pd:Description&gt;A1&lt;/pd:Description&gt;
    &lt;/pd:Book&gt;
    &lt;pd:Book xmlns:pd="http://namespace1.org/"&gt;
      &lt;pd:Name&gt;B&lt;/pd_1:Name&gt;
      &lt;pd:Description&gt;B1&lt;/pd:Description&gt;
    &lt;/pd:Book&gt;
  &lt;/root&gt;
  </code></pre>