Re: [xsl] difficulties with exclude-result-prefixes and xsl:copy

Subject: Re: [xsl] difficulties with exclude-result-prefixes and xsl:copy
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Wed, 08 Aug 2001 22:30:04 GMT
Amy,

>
>My XSL now looks like:
>
><xsl:template match="* | text() | @*">
>  <xsl:copy>
>    <xsl:apply-templates select="* | text() | @*"/>
>  </xsl:copy>
></xsl:template>
><xsl:template match="/xql:result">
>  <xsl:apply-templates select="*" />
></xsl:template>
><xsl:template match="/Aps:ProductStructure/@ino:id" />

This looks for an Aps:ProductStructure which is a child of the root
node.  There is no such node.  Make it either
   <xsl:template match="Aps:ProductStructure/@ino:id" />
or
   <xsl:template match="/xql:result/Aps:ProductStructure/@ino:id" />

or of course what I originally suggested.

And I think I have just realized what you meant by 'getting rid of the
prefixes'.  If you are trying to get rid of the namespace declarations
for ino and xql from the output, then you need to change the way you
copy elements.  Replace the first template with:

<xsl:template match="@*">
  <xsl:copy />
</xsl:template>

<xsl:template match="*">
  <xsl:element name="{name()}" >
    <xsl:apply-templates select="* | text() | @*"/>
  </xsl:element>
</xsl:template>

(tested with Saxon 6.2.2)

Your problem was that when xsl:copy copies an element it copies all
its namespace nodes too.  Using xsl:element instead prevents this.
Notice that XSLT is clever enough to insert the declaration for Aps
because it sees you have used it in the name of an element.

>
>and I'm still getting the same XML results.  What am I doing wrong?
>
>Amy
>
Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread