cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frédéric Glorieux <>
Subject Re: How to remove namespace declarations and prefixes?
Date Wed, 17 Jul 2002 14:26:22 GMT
For the same problem I'm using this pure XSL solution

    <xsl:template match="*" priority="-1" mode="copy">
        <xsl:element name="{name()}">
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates mode="copy"/>
    <xsl:template match="text()" mode="copy">
        <xsl:value-of select="normalize-space(.)"/>

The weight on performance could be balanced by finer handling of nodes.

----- Original Message -----
From: "Lai, Harry" <>
To: <>
Sent: Monday, July 01, 2002 4:54 PM
Subject: RE: How to remove namespace declarations and prefixes?

> Hi Richard,
> I also had this same problem.  I did some reading, and according to
> Kay's XSLT Programmer's Reference:
> "The xsl:exclude-result-prefixes and exclude-result-prefixes attributes
> apply only to namespace nodes copied from the stylesheet using literal
> result elements.  They do not affect namespace nodes copied from the
> document using <xsl:copy> or <xsl:copy-of>: there is no way of suppressing
> these."
> Unfortunately, since xslt's will often have a catch-all template matcher
> copy elements it doesn't transform, this comes up quite a bit.
> So... what I ended up doing was extending the HTMLSerializer (or whatever
> serializer you're using for your pipelines), and overriding the
> startPrefixMapping and endPrefixMapping methods to do nothing, effectively
> removing all namespaces from my HTML.  This also had the added benefit of
> having no performance penalties (and theoretically, a ever-so-slight
> since we no longer process namespaces in our serializer).
> You could make this more general, and use the serializer's configuration
> declare which namespaces you want to exclude, but excluding all worked
> for us, especially since we were outputting HTML.
> Hope that helps!
> Harry

Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message