[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Changing namespaces
Subject: Re: [xsl] Changing namespaces From: Pradnya Gawade <pradnya.gawade7@xxxxxxxxx> Date: Mon, 15 Aug 2011 18:10:42 -0400 |
Hi David, Thank you for the quick response. I am about to try this out but just thinking that in my case 'oldOC' itself has the value as 'OC' so it may not allow me to declare the 2 namspace declarations with same prefix in the root tag of stylesheet. <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" > I will go through it again but am I understanding your suggestion correctly? Thank you, Pradnya On Mon, Aug 15, 2011 at 5:44 PM, David Carlisle <davidc@xxxxxxxxx> wrote: > 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>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Changing namespaces, David Carlisle | Thread | Re: [xsl] Changing namespaces, David Carlisle |
[xsl] Grouping and then more groupi, Alex Muir | Date | Re: [xsl] Changing namespaces, David Carlisle |
Month |
Keywords