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
http://www.saxonica.com/
-----Original Message-----
From: Abel Braaksma Online [mailto:abel(_dot_)online(_at_)xs4all(_dot_)nl]
Sent: 26 July 2006 19:10
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--