This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
<xsl:copy> and namespaces
- From: "Joeri Belis" <joeri dot belis at nollekens dot be>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 15 Apr 2002 16:08:36 +0200
- Subject: [xsl] <xsl:copy> and namespaces
- Reply-to: xsl-list at lists dot mulberrytech dot com
Can anyone explain the use of namespaces and <xsl:copy>. When my XML file
has no namespaces defined, the stylesheet works perfect. But with the
namespaces added ( like in my example ), the copy failes. How should i copy
when namespaces
are involved. So i have a default namespace ( urn:my-ns ) and a alias for
'o' ( urn:my-o-ns ). The record and all the childeren of record take the
default ns. Why is this interfering in my copy. I have specified the default
namespace aswell in my stylesheet.
Thanks for any feedback
Joeri
XML file
<?xml version="1.0"?>
<record xmlns="urn:my-ns" xmlns:o="urn:my-o-ns">
<field>
test
</field>
</record>
StyleSheet
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:my-ns"
xmlns:o="urn:my-o-ns">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="record"/>
</xsl:template>
<xsl:template match="record">
<xsl:copy>
<xsl:apply-templates select="field"/>
</xsl:copy>
</xsl:template>
<xsl:template match="field">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list