title: XSL output XML with no prefix without using the default namespace?
body: <p>I have an XSL where I need to generate output along the lines of this:</p>
  
  <pre><code>&lt;moo xmlns="http://api.example.com"&gt;
      &lt;foo&gt;1358944586848&lt;/foo&gt;
      &lt;bar&gt;
          &lt;a&gt;1&lt;/a&gt;
          &lt;b&gt;2&lt;/b&gt;
          &lt;c&gt;3&lt;/c&gt;
      &lt;/bar&gt;
  &lt;/moo&gt;
  </code></pre>
  
  <p>I could do it like this:</p>
  
  <pre><code>&lt;xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://api.example.com"&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;xsl:element name="moo"&gt;
              &lt;!-- and so on --&gt;
  </code></pre>
  
  <p>However, I kind of hate using the xsl prefix in my xsl files cause I feel it clutters it up a lot. Selecting with XPath is easy anyways since you can set <code>xpath-default-namespace</code> to whatever you're transforming from if needed. But there is no <code>element-default-namespace</code> available as far as I can see, so how can I generate the wanted output in a good way?</p>
  
  <p>I know I can do this:</p>
  
  <pre><code>&lt;stylesheet version="2.0"
      xmlns="http://www.w3.org/1999/XSL/Transform"&gt;
  
      &lt;template match="/"&gt;
          &lt;element name="moo" namespace="http://api.example.com"&gt;
              &lt;!-- and so on --&gt;
  </code></pre>
  
  <p>But then I have to set this namespace explicitly on every single element I create, or they will end up with the XSL namespace instead. So is there a clean way to create elements with a certain namespace (without a prefix) and not touching the default namespace of the xsl file?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>Figured maybe <code>namespace-alias</code> could do something, but can't figure out how to use it. Tried this, but doesn't seem to make any difference in the output at all:</p>
  
  <pre><code>&lt;stylesheet version="2.0"
      xmlns="http://www.w3.org/1999/XSL/Transform"
  xmlns:out="http://api.example.com"&gt;
  
  &lt;namespace-alias stylesheet-prefix="out" result-prefix=""/&gt;
  
      &lt;template match="/"&gt;
          &lt;element name="out:moo"&gt;
              &lt;!-- and so on --&gt;
  </code></pre>
  
  <p>The <code>namespace-alias</code> thing probably isn't doing what I think it is :p</p>
  
  <p><em><strong>The final solution I used, based on JLRishe's answer</strong></em></p>
  
  <p><em>remove-prefixes.xsl</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;stylesheet version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;template match="/"&gt;
          &lt;variable name="result"&gt;
              &lt;next-match /&gt;
          &lt;/variable&gt;
          &lt;apply-templates select="$result" mode="remove-prefixes" /&gt;
      &lt;/template&gt;
  
      &lt;template match="*" priority="1" mode="remove-prefixes"&gt;
          &lt;element name="{local-name()}" namespace="{namespace-uri()}"&gt;
              &lt;apply-templates select="@* | node()" mode="remove-prefixes" /&gt;
          &lt;/element&gt;
      &lt;/template&gt;
      &lt;template match="@*|node()" mode="remove-prefixes"&gt;
          &lt;copy&gt;
              &lt;apply-templates select="@* | node()" mode="remove-prefixes" /&gt;
          &lt;/copy&gt;
      &lt;/template&gt;
  
  &lt;/stylesheet&gt;
  </code></pre>
  
  <p><em>subject.xsl</em></p>
  
  <pre><code>&lt;!-- snip --&gt;
  &lt;import href="remove-prefixes.xsl" /&gt;
  &lt;!-- snip --&gt;
  </code></pre>