title: XSL transformation doesn't write namespace before elements
body: <p>I have to update the file content.xml in an odt file.
  I want to obtain the same file content without spaces from elements and without line break.</p>
  
  <p>I tried to use an xsl transormation with the Transformer object in Java, and it partly works.
  For example, having a simple odt, which the content.xml is the following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2"&gt;
      &lt;office:font-face-decls&gt;
          &lt;style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" /&gt;
      &lt;/office:font-face-decls&gt;
      &lt;office:automatic-styles&gt;
  
      &lt;/office:automatic-styles&gt;
      &lt;office:body&gt;
          &lt;office:text&gt;
              &lt;text:p text:style-name="Title"&gt;TODO supply a title&lt;/text:p&gt;
              &lt;text:p text:style-name="Text_20_body"&gt;TODO write content&lt;/text:p&gt;
              &lt;text:h text:style-name="Heading_20_1" text:outline-level="1"&gt;My First Heading&lt;/text:h&gt;
              &lt;text:p text:style-name="First_20_paragraph"&gt;My first paragraph.&lt;/text:p&gt;
          &lt;/office:text&gt;
      &lt;/office:body&gt;
  &lt;/office:document-content&gt;
  </code></pre>
  
  <p>I wrote this xsl file to remove all line breaks, blank spaces between elements, so I want obtain the same XML content serialize in one line.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-15" ?&gt;
  &lt;xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:xalan="http://xml.apache.org/xslt"
                  xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
                  xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
                  xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
                  xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
                  xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
                  xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
                  xmlns:xlink="http://www.w3.org/1999/xlink" 
                  xmlns:dc="http://purl.org/dc/elements/1.1/" 
                  xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
                  xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
                  xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
                  xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
                  xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
                  xmlns:math="http://www.w3.org/1998/Math/MathML" 
                  xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
                  xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
                  xmlns:ooo="http://openoffice.org/2004/office" 
                  xmlns:ooow="http://openoffice.org/2004/writer" 
                  xmlns:oooc="http://openoffice.org/2004/calc" 
                  xmlns:dom="http://www.w3.org/2001/xml-events"
                  xmlns:xforms="http://www.w3.org/2002/xforms" 
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
                  extension-element-prefixes="office style text"
  &gt;
      &lt;xsl:output method="xml" encoding="ISO-8859-15" indent="no"/&gt;
      &lt;xsl:strip-space elements="*" /&gt;
  
  
      &lt;xsl:template match="@*|node()|comment()|processing-instruction()|text()"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select="@*|node()|comment()|processing-instruction()|text()" /&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I used indent="no" and strip-space elements="*" to have no identation, but now my problem is the namespaces.
  The XML which I obtain using this xsl is the following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-15"?&gt;&lt;document-content xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2"&gt;&lt;font-face-decls&gt;&lt;font-face style:font-family-generic="modern" style:font-pitch="fixed" style:name="Courier New" svg:font-family="'Courier New'"/&gt;&lt;/font-face-decls&gt;&lt;automatic-styles/&gt;&lt;body&gt;&lt;text&gt;&lt;p text:style-name="Title"&gt;TODO supply a title&lt;/p&gt;&lt;p text:style-name="Text_20_body"&gt;TODO write content&lt;/p&gt;&lt;h text:outline-level="1" text:style-name="Heading_20_1"&gt;My First Heading&lt;/h&gt;&lt;p text:style-name="First_20_paragraph"&gt;My first paragraph.&lt;/p&gt;&lt;/text&gt;&lt;/body&gt;&lt;/document-content&gt;
  </code></pre>
  
  <p>It's in one line, as I want, but the elements has no namespace prefix.
  Note that it doesn't happen with attributes, which have correct namespaces.</p>
  
  <p>In the xsl I specified to match node, comment and attributes, the namespaces in the <code>&lt;xsl:stylesheet&gt;</code> element and the extension-element-prefixes passing the list of allowed namespaces.
  If I remove the extension-element-prefixes nothing change.</p>
  
  <p>The Java code which use the Transformer object is the following:</p>
  
  <pre><code> public void serializeXML(String filePath, String destinationPath) throws Exception {
      File xmlFile = new File(filePath);
      DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
      Document doc = dBuilder.parse(xmlFile);
      doc.normalizeDocument();
  
      DOMSource domSource = new DOMSource(doc);
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
  
      InputStream is = XMLSerializer.class.getClassLoader().getResourceAsStream("identer.xsl");
  
      Transformer transformer = transformerFactory.newTransformer(new StreamSource(is));
  
      StringWriter sw = new StringWriter();
      StreamResult sr = new StreamResult(sw);
      transformer.transform(domSource, sr);
  
      Result result = new StreamResult(new FileOutputStream(new File(destinationPath)));
  
      transformer.transform(domSource, result);
  
      LOGGER.info(sw.toString());
  }
  </code></pre>
  
  <p>I declare the Transformer object, passing to it the inputStream of the xsl file.
  I don't set any properties because I declare all (in my opinion) is necessary in the xsl file, and after that I tranform the document, saving the result in a file and printing it with a logger.</p>
  
  <p>Can someone help me?</p>
  
  <p>Thank you.</p>