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

RE: Copy idiom and overriding namespaces: trying to be

Subject: RE: Copy idiom and overriding namespaces: trying to be smart, finding approaches
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 26 Jul 2006 19:32:59 +0100
name all idioms
I'm not at all sure what you're trying to do here, but

match="*[local-name() = '']

looks all wrong. Every element has a local name.

Michael Kay

> -----Original Message-----
> From: Abel Braaksma Online [mailto:abel.online@xxxxxxxxx] 
> Sent: 26 July 2006 19:10
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Copy idiom and overriding namespaces: trying 
> to be smart, finding approaches
> Dear List,
> Working through some lists of examples online and in books, I 
> found some ways of overriding the target namespace, but 
> strangely enough, all seem to create an explicit name for 
> elements with a namespace prefix that contains a certain 
> namespace. I don't think that is in the true nature of 
> namespace, even more so, because ns prefixes are just 
> placeholders for the namespace and should not be manipulated by hand.
> Actually, I am just looking for the best xslt-minded approach 
> here. The solution below works, but I would like some expert 
> opinion on it. Just using "copy-namespace" does not work, as 
> the namespace fixup process will set the original namespace back.
> Requirement:   Let the calling program decide what the target 
> namespace 
> will be.
> Input:         any document or node
> Parameters:    $target-namespace, a string representing the 
> target namespace
>     <!-- matches all attributes and all elements,
>            except for elements that have a name -->
>     <xsl:template match="*[local-name() = ''] | @*" >
>         <xsl:copy copy-namespaces="no">
>             <xsl:apply-templates select="@* | node()" />
>         </xsl:copy>
>     </xsl:template>
>     <!-- matches only elements that have a name,
>            excluding text nodes, attributes etc -->
>     <xsl:template match="*[local-name() != '']" >
>         <!-- assign namespace -->
>         <xsl:element
>              name="{local-name()}"
>              namespace="{$target-namespace}">
>             <xsl:apply-templates  select="@* | node()" />
>         </xsl:element>
>     </xsl:template>
> Best regards,
> Abel Braaksma
> www.nuntia.nl

Current Thread


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.
First Name
Last Name
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.