|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Unused namespaces (was RE: transform mixing up namespa
> I am using Xalan 1.2. (Another behavior that is annoying, but correct as
> far as I know, is that Xalan will create result documents with unused
> namespace declarations. See an example at the bottom of this email.)
This seems to be the specified behaviour. If nodes in the source document
have associated namespace nodes (which they do in your case) then xsl:copy
and xsl:copy-of will copy the namespace nodes even if they are "unused". I
guess you can see the point: how is the XSLT processor to know that the
namespace is unused (e.g. in attribute values like XPath expressions, or
elsewhere)?
However, I wanted the same behaviour as you do. I ended up using xsl:element
and xsl:attribute instead. This means adding the following templates:
<xsl:template mode="copy-of" match="*">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:apply-templates mode="copy-of"
select="@*|*|text()|processing-instruction()|comment()" />
</xsl:element>
</xsl:template>
<xsl:template mode="copy-of" match="@*">
<xsl:attribute name="{name()}" namespace="{namespace-uri()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:template>
<xsl:template mode="copy-of"
match="text()|processing-instruction()|comment()">
<xsl:copy />
</xsl:template>
and then where I previously had xsl:copy-of using:
<xsl:apply-templates mode="copy-of" select="..." />
instead!
If anybody's got a better solution...
Thanks
-- Gareth
*************************************************************************
The information contained in this message or any of its
attachments may be privileged and confidential and intended
for the exclusive use of the addressee. If you are not the
addressee any disclosure, reproduction, distribution or other
dissemination or use of this communication is strictly prohibited
**************************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








