xslt - How can I remove namespace prefixes in xml without removing the xmlns tag? -
i trying remove namespace prefixes. have tried couple xslts not seem work (will show why after example).
example current xml output:
<s:body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <ns:getpriceset xmlns:ns="http://abc.org/01/02"> <ns:og> <testelement1 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> <testelement2 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> </ns:og> </ns:getpriceset> </s:body> what want:
<s:body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <getpriceset xmlns="http://abc.org/01/02"> <og> <testelement1 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> <testelement2 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> </og> </getpriceset> </s:body> i tried using both xslts here: how remove namespace prefix leaving namespace value (xslt)?
the problem ns: instead replaced ns0 , ns1 instead of being removed xslts. assume xslt needs further modified.
based on example shared, seems should work?
<xsl:template match="ns:*"> <xsl:element name="{local-name()}" > <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template>
Comments
Post a Comment