On 15/08/2011 22:09, Pradnya Gawade wrote:
My xsl stylesheet is as follows:
<xsl:element name="{name()}" namespace="{namespace-uri()}">
this (and similar lines) generates elements with the same local name and
namespace as the source, but you want to change the namespace.
your sample input is a bit short and doesn't show any elements or
attributes in the namespace with prefix OC: so i'm having to guess a bit
but something like:
chg.xml
<ODM xmlns="old-default-namespace" xmlns:OC="old-oc-namespace-uri"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
FileOID="oc_extn_testD20110809115446-0400" Description="oc_extn_test"
CreationDateTime="2011-08-09T11:54:46-04:00" FileType="Snapshot"
ODMVersion="1.2"
xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.3OC-ODM1-3-0-OC2-0.xsd">
<foo OC:zz="1" a="b"/>
<OC:bar x="y" OC:x="z"/>
</ODM>
chg.xsl
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:olddef="old-default-namespace"
xmlns="new-default-namespace"
xmlns:oldOC="old-oc-namespace-uri"
xmlns:OC="new-oc-namespace-uri"
exclude-result-prefixes="olddef oldOC"
>
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*,node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="olddef:*">
<xsl:element name="{local-name()}" namespace="new-default-namespace-uri">
<xsl:namespace name="OC" select="'new-oc-namespace-uri'"/>
<xsl:apply-templates select="@*,node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="oldOC:*">
<xsl:element name="OC:{local-name()}" namespace="new-oc-namespace-uri">
<xsl:apply-templates select="@*,node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@oldOC:*">
<xsl:attribute name="OC:{local-name()}" namespace="new-oc-namespace-uri">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
$ saxon9 chg.xml chg.xsl
<?xml version="1.0" encoding="UTF-8"?><ODM
xmlns="new-default-namespace-uri" xmlns:OC="new-oc-namespace-uri"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
FileOID="oc_extn_testD20110809115446-0400" Description="oc_extn_test"
CreationDateTime="2011-08-09T11:54:46-04:00" FileType="Snapshot"
ODMVersion="1.2"
xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.3OC-ODM1-3-0-OC2-0.xsd">
<foo OC:zz="1" a="b"/>
<OC:bar x="y" OC:x="z"/>
</ODM>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--