I would like to change namespace in XML file with XSLT based only on namespace-uri without knowing what prefix this namespace has defined. Is it possible?
I get some solution but they work only with small files when I know the input and can setup xsl file kinda manualy.
What I would like to achieve:
INPUT XML:
<?xml version="1.0" encoding="UTF-8"?>
<re:rootElement xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:re="http://something.com/root"
xmlns:ns1="http://something.com/some/schema"
xmlns:cs2="http://something.com/another/schema"
xmlns:ns3="http://something.com/different/schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:import namespace="http://something.com/another/schema" schemaLocation="/schema/location"/>
(multiple nodes below)
XSLT that takes 2 parameters:
<xsl:param name="old_namespace" select="'http://something.com/another/schema'"/>
<xsl:param name="new_namespace" select="'http://something.com/another/schemaNEW'"/>
And output as xml:
<re:rootElement xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:re="http://something.com/root"
xmlns:ns1="http://something.com/some/schema"
xmlns:cs2="http://something.com/another/schemaNEW"
xmlns:ns3="http://something.com/different/schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:import namespace="http://something.com/another/schemaNEW" schemaLocation="/schema/location"/>
(multiple nodes below)
reis not bound to a namespace.namespaceattribute contains a namespace to change? Do you know the structure of the input XML, the possible attributes to change?