[xsl] Why is copy-namespaces="no" required?

Subject: [xsl] Why is copy-namespaces="no" required?
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Wed, 18 Nov 2009 13:24:24 +0100
I've come up with a stylesheet which merges 2 XML schemas, copying
only one definition of each type (based on its @name) into the result
document. Both input schemas have exactly the same namespace
definitions. I'm using ssaxonhe9-2-0-2j

<xsl:variable name="db1" select="/" />
<xsl:variable name="db2" select="document($other)" />

<xsl:variable name="db1complex" select="$db1/xs:schema/xs:complexType/@name"
/>
<xsl:variable name="db1simple"  select="$db1/xs:schema/xs:simpleType/@name"
/>

<xsl:template match="/">
  <xsl:result-document href="comcom.xsd">
    <xsl:apply-templates/>
 </xsl:result-document>
</xsl:template>

<xsl:template match="xs:schema">
  <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
    <xsl:copy-of select="@* | *" copy-namespaces="no"/>
    <xsl:copy-of select="$db2/xs:schema/xs:complexType[not(@name =
$db1complex)]" copy-namespaces="no" />
    <xsl:copy-of select="$db2/xs:schema/xs:simpleType[not(@name =
$db1simple)]" copy-namespaces="no" />
  </xsl:element>
</xsl:template>

Why is copy-namespaces="no" required to avoid duplication of namespace
declarations in the copied *Type elements?

Is there a simple way of passing in a list of N pathnames in a param
and perform this merge for all N Schemas in one go? (Right now I'm
using shell glue to execute this repeatedly, and I'd be content with
that, unless it's really simple.)

Best
-W

Current Thread