cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Lancelle <...@knosys.com>
Subject The last 500 feet are getting to me...
Date Sat, 08 Jul 2000 05:39:19 GMT
I have concluded the Cocoon project approximates a religion! This is the
greatest stuff to hit the planet yet!

My journey up the Learning Pass this past two weeks has begun to result
in some neat stuff. The light bulb has lit.

The last 500 feet of the trek has stalled at the use of parameters
passed back from the client to the server. I can use them in
<xsp:if(when)> tags, I can spit them back to the client, but I can't
seem to do things with them regarding <xsp:...> tags.

My current dilemma has to do with the use of <xsp:...> in .xsl files. I
can use them in .xml files no prob, including the correct functioning of
<xsp:logic> blocks of Java code.

In attempting to create an .xml file - to be further processed - in the
domain of an .xsl file though, things fall apart. I keep getting an
error 'org.apache.xalan.xslt.XSLProcessorException: Warning: can't
output text before document element!  Ignoring...'

For instance, the plan is to construct an sql statement by first
changing the values of the client parameters passed. I have created
simple logic blocks to convert a string to lower case and return the
length of the string. They work when the xml page is not generated by a
stylesheet.

(SORRY FOR THE FORMATTING SNAFU)
*******************************************************
This works in an xml file:


<?cocoon-process type="xsp"?>

<xsp:page
  language="java"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:request="http://www.apache.org/1999/XSP/Request"
  xmlns:util="http://www.apache.org/1999/XSP/Util"
>

<xsp:logic>

    private String lowercase(String S) {
 return S.toLowerCase();
    }

    private String uppercase(String S) {
 return S.toUpperCase();
    }

    private String str_length(String S) {
        String x = "" + S.length();
 return x;
    }

</xsp:logic>

<page>
 <title>First XSP Page</title>
 <author>
  <name>Stefano Mazzocchi</name>
  <address>stefano@apache.org</address>
 </author>

 <p>Hi, I'm your first XSP page ever.</p>

 <p>I've been <xsp:expr>str_length("TEST")</xsp:expr> requested
<util:counter/> times.</p>

etc...

*********************************************************************
But in an .xsl file, I keep getting the above error...

<?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:param name="title"/>
<xsl:param name="composer"/>


    <xsl:template match="Z-form">

 <xsl:processing-instruction
name="cocoon-process">type="xsp"</xsl:processing-instruction>

     <xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
 <xsl:processing-instruction name="xml-stylesheet">href="mSearch.xsl"
type="text/xsl"</xsl:processing-instruction>

 <xsp:Z-search
 language="java"
 xmlns:xsp="http://www.apache.org/1999/XSP/Core"
 xmlns:request="http://www.apache.org/1999/XSP/Request"
 xmlns:util="http://www.apache.org/1999/XSP/Util"
 >

 <xsp:logic>

     private String lowercase(String S) {
  return S.toLowerCase();
     }

     private String uppercase(String S) {
  return S.toUpperCase();
     }

     private String str_length(String S) {
         String x = "" + S.length();
  return x;
     }

 </xsp:logic>

 <Z-search>

     <xsl:copy-of select="title"/>
     <xsl:copy-of select="contact"/>
     <xsl:copy-of select="field"/>

     <xsl:choose>
  <xsl:when test="$title and $composer">
      <sel-dispFields
str="folio,title,composer,style,description,yearcopy,publisher"/>
      <sel-from str="orchestral"/>
      <sel-where str="*"/>
      <sel-order str="composer,title"/>
      </xsl:when>
  <xsl:when test="$title">
      <sel-dispFields
str="folio,title,composer,style,description,yearcopy,publisher"/>
      <sel-from str="orchestral"/>
      <sel-where
str="(_left(lcase(title),&gt;xsp:expr&lt;str_length($title)&gt;/xsp:expr&lt;)='&gt;xsp:expr&lt;lowercase($title)&gt;/xsp:expr&lt;')"/>

      <sel-order str="title"/>
  </xsl:when>
  <xsl:when test="$composer">
      <sel-dispFields
str="folio,title,composer,style,description,yearcopy,publisher"/>
      <sel-from str="orchestral"/>
      <sel-where str="(_left(lcase(composer),1)='s')"/>
      <sel-order str="composer"/>
         </xsl:when>
     </xsl:choose>

 </Z-search>

 </xsp:Z-search>

</xsl:template>

etc...


Thanks for the look,

Jon Lancelle

Mime
View raw message