cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alejandro Raiczyk <alejand...@technisys.com.ar>
Subject RE: double xslt
Date Wed, 30 Aug 2000 14:06:52 GMT
This was sent by Tagunov Anthony, and I'm working on it, but I guess it will
work!

-----------

I guess everyone who tried to chain stylesheets in Cocoon 1.7.4 hit this
problem. I did. Robin Green <greenrd@hotmail.com> said that's a bug in
Cocoon and sent me his
work around that works fine for me, here it is:

===============
package com.itao.util;

import java.util.Dictionary;
import org.apache.cocoon.framework.Director;
import org.apache.cocoon.processor.Processor;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;

public class StylesheetChainProcessor implements Processor {

  public void init (Director director) {
  }

  public Document process (Document doc, Dictionary parameters) {
    NodeList nl = doc.getChildNodes ();
    for (int i = nl.getLength (); i >= 0; i--) {
      Node n = nl.item (i);
      if (n instanceof ProcessingInstruction) {
        ProcessingInstruction pi = (ProcessingInstruction) n;
        if (pi.getTarget ().equals ("xml-stylesheet")) {
          // remove old stylesheet
          doc.removeChild (pi);
          break;
        }
      }
    }
    return doc;
  }

  public boolean hasChanged (Object context) {
    return false; // always does the same thing, so no change
  }
}
===========================(compile this, make a jar of it and put into
$TOMCAT_HOME/lib directory -- that's my way of doing things -AT)=======
put this into cocoon.properties
==================================================================
==processor.type.stylesheet-chain = com.itao.util.StylesheetChainProcessor
==================================================================
in your source .xml file put

<?xml-stylesheet type="text/xsl" href="second.xsl"?>
<?cocoon-process type="xslt"?>
<?cocoon-process type="stylesheet-chain"?>
<?xml-stylesheet type="text/xsl" href="first.xsl"?>
<?cocoon-process type="xslt"?>

Notice that stylesheets must be specified in the reverse order to the order 
in which they should be applied (unlike XSP namespaces, which must be 
specified in the same order).
===============================
After I tried that right away I still had a problem but it was with my .xsl
files. Here's Robin's answer to my second problem:
>  Anyway your problem is probably, you MUST copy ALL processing
instructions 
>  over in the first stylesheet, using:
>
>   <xsl:template match="processing-instruction()">
>     <xsl:copy-of select="."/>
>   </xsl:template>

In fact after that I put a classical

        <xsl:template match="@*|node()" priority="-1">
               <xsl:copy><xsl:apply-templates
		select="@*|node()"/></xsl:copy>
	</xsl:template>
in all my stylesheets (or an apropriate analog to it) and it started working
fine. Thanx to Robin Green!  :))))


-----Mensaje original-----
De: Pierpaolo Vittorini [mailto:pierpaol@leiw.ing.univaq.it]
Enviado el: Martes 29 de Agosto de 2000 12:47 PM
Para: cocoon-users@xml.apache.org
Asunto: double xslt


Hello, I'm new of this list, and I'm trouble because I need to apply two
different and subsequential transformations to an xml document. That is:

              +----+             +----+
  xml_source -|xsl1!-> xml_part -|xsl2|-> html_final, or fo_final
              +----+             +----+

The first transformation applies with no trouble, so the xml_part file
is correct. I mean I've also included

<xsl:processing-instruction name="xml-stylesheet">
  src="xsl2" 
  type="text/xsl"
</xsl:processing-instruction>

in the xsl1 stylesheet...

The problem is that the cocoon servlet does not want to process the
xml_part
document anymore, in order to transform it into the result..... 
I've tought that this could be the (unallowed) piping among servlets....
but
everything should pass via the web server, isn't it??? I'm in big trouble
for
that.....

I'm running cocoon 1.7.4, apache 1.3.12, jserv 1.1.2 on a redhat6.2. jdk is
the sun jdk1.2.

Thanks in advance for your time,
Best regards
  Pierpaolo

-- 
 Dr. Eng. Pierpaolo Vittorini
   PhD Student at the University of L'Aquila - ITALY
   Department of Electrical Engineering


---------------------------------------------------------------------
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