[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Changing namespaces

Subject: Re: Changing namespaces
From: Pradnya Gawade <pradnya.gawade7@xxxxxxxxx>
Date: Mon, 15 Aug 2011 18:10:42 -0400
Re:  Changing namespaces
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.