You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Eduardo Yánez <ej...@yahoo.com> on 2001/02/22 19:33:19 UTC

Strim white spaces (one approach)

Hi everybody!

As you know, the generated cocoon producers have a lot
of lines like the one:

xspCurrentNode.appendChild(
      document.createTextNode("\n      \n      ")
    );

Well, you can suppress those instructions with the
following (very simple) logic-sheet:

<?xml version="1.0"?>

<xsl:stylesheet
   version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xsp="http://www.apache.org/1999/XSP/Core">

<xsl:strip-space elements="*"/>

<xsl:template match="*|@*|processing-instruction()">
   <xsl:copy><xsl:apply-templates
select="*|@*|text()|processing-instruction()"/></xsl:copy>
</xsl:template>

<xsl:template match="text()"><xsl:value-of
select="normalize-space()"/></xsl:template>

</xsl:stylesheet>

To use simple put the logicsheet PI before the xsp PI:
<?xml version="1.0"?>
<?cocoon-process type="xinclude"?>
<?xml-logicsheet href="cleanup-blanks.xsl"
type="text/xsl"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="****.xsl" type="text/xsl"?>
....

I note better performance in my xsp pages after this
modification in a 2:1 ratio!.

But you can't use CDATA sections and "//" comments in
your java code.

Enjoy!

Regards
Eduardo.


=====
Eduardo Yánez.
IT Manager
Guanoco.com
Tlf: 9512458, 9526906

_________________________________________________________
Do You Yahoo!?
Obtenga su dirección de correo-e gratis @yahoo.com
en http://correo.espanol.yahoo.com