I am transforming some XML using XSLT and Saxon like this:
Source sourceXML = new StreamSource(...);
Source sourceXSLT = new StreamSource(...);
System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
TransformerFactory transFact = TransformerFactory.newInstance();
Templates cachedXSLT = transFact.newTemplates(sourceXSLT);
Transformer transformer = cachedXSLT.newTransformer();
transformer.setOutputProperty("indent", "no");
transformer.transform(sourceXML, new StreamResult(System.out));
The stylesheet is a generated using MapForce and changed frequently. While the transformation works in general it prefixes all elements with the namespace n. This is presumably due to the following line in the stylesheet:
<xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/>
Since the MapForce tool does not show this prefix in it's preview it's probably very easy to change this in the transformer. Can somebody point me in the right direction? Or do I need to do some (manual) preprocessing on the stylesheet in order to get rid of it?
The stripped down version of the stylesheet looks like this:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n="..." xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:grp="http://www.altova.com/Mapforce/grouping" exclude-result-prefixes="fn grp xs xsi xsl" xmlns="...">
<xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
...
</xsl:template>
</xsl:stylesheet>