XSLT, set namespace dynamically and remove name space from output xml
<p>My source xml is:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;PMML version="4.1" xmlns="http://www.dmg.org/PMML-4_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dmg.org/PMML-4_1 pmml-4-1.xsd"&gt;
&lt;Header copyright="(C) Copyright IBM Corp. 1989, 2014."&gt;
    &lt;Application name="IBM SPSS Statistics 23.0" version="23.0.0.0"/&gt;
&lt;/Header&gt;
&lt;GeneralRegressionModel algorithmName="multinomialLogistic" functionName="classification" modelType="multinomialLogistic" targetVariableName="CLASS"&gt;
    &lt;MiningSchema&gt;
        &lt;MiningField missingValueTreatment="asIs" name="CLASS" usageType="predicted"/&gt;
        &lt;MiningField missingValueTreatment="asIs" name="ACTIVE_CUSTOMER" usageType="active"/&gt;
        &lt;MiningField missingValueTreatment="asIs" name="SEGMENT" usageType="active"/&gt;
    &lt;/MiningSchema&gt;
    &lt;ParameterList&gt;
        &lt;Parameter label="Konstanter Term" name="P0000001"/&gt;
        &lt;Parameter label="[ACTIVE_CUSTOMER=0]" name="P0000002"/&gt;
        &lt;Parameter label="[ACTIVE_CUSTOMER=1]" name="P0000003"/&gt;
        &lt;Parameter label="[SEGMENT=0]" name="P00000004"/&gt;
        &lt;Parameter label="[SEGMENT=1]" name="P00000005"/&gt;
    &lt;/ParameterList&gt;
    &lt;ParamMatrix&gt;
        &lt;PCell beta="-167.307903919999" df="1" parameterName="P0000001" targetCategory="1"/&gt;
        &lt;PCell beta="-0.0747629275586869" df="1" parameterName="P0000002" targetCategory="1"/&gt;
        &lt;PCell beta="0.409965797830495" df="1" parameterName="P0000003" targetCategory="1"/&gt;
        &lt;PCell beta="-1.03190717557433" df="1" parameterName="P0000004" targetCategory="1"/&gt;
        &lt;PCell beta="0.904157514089376" df="1" parameterName="P0000005" targetCategory="1"/&gt;
    &lt;/ParamMatrix&gt;
&lt;/GeneralRegressionModel&gt;
&lt;/PMML&gt;
</code></pre>

<p>My output xml is:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Predictors xmlns:ns="some:ns" xmlns:rs="http://www.dmg.org/PMML-4_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;Predictor coefficient="-167.307903919999" name="__INTERCEPT__" value=""/&gt;
  &lt;Predictor coefficient="-0.0747629275586869" name="ACTIVE_CUSTOMER" value="0"/&gt;
  &lt;Predictor coefficient="0.409965797830495" name="ACTIVE_CUSTOMER" value="1"/&gt;
  &lt;Predictor coefficient="" name="SEGMENT" value="0"/&gt;
  &lt;Predictor coefficient="" name="SEGMENT" value="1"/&gt;
&lt;/Predictors&gt;
</code></pre>

<p>I could achieve this with the following xslt:</p>

<pre><code>&lt;xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:ns="some:ns" xmlns:rs="http://www.dmg.org/PMML-4_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"&gt;
  &lt;xsl:output encoding="utf-8" indent="yes" method="xml"/&gt;
  &lt;xsl:strip-space elements="*"/&gt;

  &lt;xsl:key match="rs:ParamMatrix/rs:PCell" name="cell" use="@parameterName"/&gt;
  &lt;xsl:key match="rs:DataDictionary/rs:DataField" name="dataField" use="@name"/&gt;

  &lt;!-- identity transform --&gt;
  &lt;xsl:template match="node()|@*"&gt;
     &lt;xsl:apply-templates select="node()|@*"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="rs:GeneralRegressionModel"&gt;
    &lt;!--MiningSchema--&gt;
    &lt;xsl:apply-templates select="rs:MiningSchema"/&gt;

    &lt;!--RegressionTable for predicted targetVariable targetCategory--&gt;
    &lt;Predictors&gt;
      &lt;xsl:apply-templates select="rs:ParameterList/rs:Parameter"/&gt;
    &lt;/Predictors&gt;

  &lt;/xsl:template&gt;

    &lt;xsl:template match="rs:Parameter[not(contains(@label, '='))][@name='P0000001']"&gt;
    &lt;Predictor coefficient="{key('cell', @name)/@beta}" name="__INTERCEPT__" value=""/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="rs:Parameter[not(contains(@label, '='))][@name!='P0000001']"&gt;
    &lt;Predictor coefficient="{key('cell', @name)/@beta}" name="{@label}" value=""/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="rs:Parameter[contains(@label, '=')]" name="split"&gt;
    &lt;Predictor coefficient="{key('cell', @name)/@beta}" name="{substring-after(substring-before(@label,'='),'[')}" value="{substring-before(substring-after(@label,'='),']')}"/&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:transform&gt;
</code></pre>

<p>This XSLT works. 
However, I have 2 issues:
1. at the beginning of the source xml, there is namespace, such as 'xmlns="http://www.dmg.org/PMML-4_1"', could be other value. The whole document uses only this one namespace. Currently in my xslt, I set namespace as fixed value 'xmlns:rs="http://www.dmg.org/PMML-4_1" ', this is not correct. How do I set namespace dynamically in xslt?</p>

<ol start="2">
<li>once I set namespace in xslt, it shows up in the output xml as well. How do I remove this namespace from output xml?</li>
</ol>

<p>If it´s okay, could you please modify my xslt directly to show me the usage?</p>

<p>Many thanks!!!</p>