cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luca Morandini" <luca.morandi...@tin.it>
Subject RE: [Summary] How to remove namespace declarations and prefixes?
Date Mon, 01 Jul 2002 15:47:16 GMT
Reinhard,

good job, this [Summary] method could kickstart a sprawling FAQ archive :)

Many thanks,

--------------------------------------------- 
               Luca Morandini 
               GIS Consultant 
              lmorandini@ieee.org 
http://utenti.tripod.it/lmorandini/index.html 
---------------------------------------------
 

> -----Original Message-----
> From: Reinhard Poetz [mailto:reinhard_poetz@gmx.net]
> Sent: Monday, July 01, 2002 5:15 PM
> To: cocoon-users@xml.apache.org
> Cc: m.batsis@bsnet.gr; HLai@coremetrics.com
> Subject: [Summary] How to remove namespace declarations and prefixes?
> 
> 
> Thank you Harry and Manos!
> 
> I want to provide a summary of this thread - maybe this could be included
> into some docs.
> 
> Problem:
> ********
> 
>  ... I use namespaces and I want to remove them in my result xml ...
> 
> (original mail:
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=102551958020786&w=2)
> 
> 
> Solutions, which NOT work:
> **************************
> exclude-result-prefixes (in the stylesheet)
> [http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=100101165325379&w=2]
> 
> <omit-xml-declaration> (in the sitemap)
> [http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=100084611731795&w=2]
> 
> exclude-prefixes (in the stylesheet)
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=101912408904652&w=2
> 
> 
> 
> Solutions, which WORK:
> **********************
> 
> 1.)
> Harry Lai:
> ----------
> 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 source 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 to 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 speedup since we no longer process namespaces in our
> serializer).
> 
> You could make this more general, and use the serializer's
> configuration to declare which namespaces you want to exclude, but excluding
> all
> worked well for us, especially since we were outputting HTML.
> 
> (complete mail:
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=102553525402606&w=2)
> 
> 2.)
> Manos Batsis:
> -------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
>     <xsl:template match="*">
>       <!-- remove element prefix (if any) -->
>       <xsl:element name="{local-name()}">
>         <!-- process attributes -->
>         <xsl:for-each select="@*">
>           <!-- remove attribute prefix (if any) -->
>           <xsl:attribute name="{local-name()}">
>             <xsl:value-of select="."/>
>           </xsl:attribute>
>         </xsl:for-each>
>         <xsl:apply-templates/>
>       </xsl:element>
>   </xsl:template>
> </xsl:stylesheet>
> 
> (complete mail:
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=102552029221254&w=2)
> 
> Regards,
> Reinhard
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> 

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message