Altova Mailing List Archives


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

From: tcn@------------- (------ ----)
To:
Date: 8/8/2001 2:36:00 PM
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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.