title: XML - XSLT - Remove xmlns="" from output XML document
body: <p>I have the following XML input document:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;report xmlns="http://jasperreports.sourceforge.net/jasperreports" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" 
          repName="FirstElementTemp" 
          date="10-05-2001"&gt;
      &lt;element1&gt;
          &lt;subElement&gt;
              SomeData
          &lt;/subElement&gt;
      &lt;/element1&gt;
      &lt;element2&gt;
          &lt;subElement type="2"/&gt;
      &lt;/element2&gt;
  &lt;/report&gt;
  </code></pre>
  
  <p>And with the following XSLT stylesheet, that user @Mads Hansen helped me to build on a similar post I made yesterday, this one:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xpath-default-namespace="http://jasperreports.sourceforge.net/jasperreports"
    xmlns:jsp="http://jasperreports.sourceforge.net/jasperreports"
    exclude-result-prefixes="xs jsp"
    expand-text="yes"
    version="3.0"&gt;
  
  
  &lt;xsl:param name="doc2"  xmlns=""&gt;
      &lt;secondDoc&gt;
      &lt;elementTemps&gt;
          &lt;elemTemp ID="1" name="FirstElementTemp" /&gt;
          &lt;elemTemp ID="2" name="SecondTemplate" /&gt;
      &lt;/elementTemps&gt;
      &lt;elementReps&gt;
          &lt;elemRep tmpID="1" name="FirstElementRep" &gt;
              &lt;value&gt;FIRST DATA&lt;/value&gt;
          &lt;/elemRep&gt;
          &lt;elemRep tmpID="2" name="SecondTemplate"&gt;
              &lt;value&gt;SECOND DATA&lt;/value&gt;
          &lt;/elemRep&gt;
      &lt;/elementReps&gt;
      &lt;/secondDoc&gt;     
    &lt;/xsl:param&gt;
  
  &lt;xsl:output indent="yes" cdata-section-elements="cDataElement"/&gt;
  
    &lt;xsl:mode on-no-match="shallow-copy"/&gt;
  
    &lt;xsl:key name="key1" match="elemTemp" use="@name" xpath-default-namespace=""/&gt;
    &lt;xsl:key name="key2" match="elemRep" use="@tmpID" xpath-default-namespace=""/&gt;
  
   &lt;xsl:template match="report/*[1]"&gt;
      &lt;xsl:variable name="temp" select="key('key1', ../@repName, $doc2)"/&gt;
      &lt;xsl:variable name="rep" select="key('key2', $temp/@ID, $doc2)"/&gt;
      &lt;valueIs&gt;
          &lt;xsl:value-of select="$rep/value" xpath-default-namespace=""/&gt;
      &lt;/valueIs&gt;
      &lt;xsl:next-match/&gt;
  &lt;/xsl:template&gt; 
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I was able to get the desired output XML document I wanted, with just one thing wrong. This the the output I'm getting from it:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;report xmlns="http://jasperreports.sourceforge.net/jasperreports"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
          repName="FirstElementTemp"
          date="10-05-2001"&gt;
      &lt;valueIs xmlns=""&gt;FIRST DATA&lt;/valueIs&gt;
     &lt;element1&gt;
          &lt;subElement&gt;
              SomeData
          &lt;/subElement&gt;
      &lt;/element1&gt;
      &lt;element2&gt;
          &lt;subElement type="2"/&gt;
      &lt;/element2&gt;
  &lt;/report&gt;
  </code></pre>
  
  <p>As you can see, the new element I added, <code>&lt;valueIs&gt;</code> is coming with the <code>xmlns=""</code> attribute. I know that this means that isn't in any namespace, but how can I add that element without the <code>xmlns</code> attribute? What do I need to change in the XSLT stylesheet?</p>
  
  <p>So basically this is the output I want, just to be more clear:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;report xmlns="http://jasperreports.sourceforge.net/jasperreports"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
          repName="FirstElementTemp"
          date="10-05-2001"&gt;
      &lt;valueIs&gt;FIRST DATA&lt;/valueIs&gt;
     &lt;element1&gt;
          &lt;subElement&gt;
              SomeData
          &lt;/subElement&gt;
      &lt;/element1&gt;
      &lt;element2&gt;
          &lt;subElement type="2"/&gt;
      &lt;/element2&gt;
  &lt;/report&gt;
  </code></pre>
  
  <p>I decided to make a separate post to the one I referenced in the beginning, since this is a different problem, </p>
  
  <p>Thank you!</p>
  
  <p>Alexandre Jacinto</p>