You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jon Lancelle <jk...@knosys.com> on 2000/07/08 07:39:19 UTC

The last 500 feet are getting to me...

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


Re: The last 500 feet are getting to me...

Posted by Stefano Mazzocchi <st...@apache.org>.
Jon Lancelle wrote:
> 
> I have concluded the Cocoon project approximates a religion! This is the
> greatest stuff to hit the planet yet!

A great new episode of the series: "what users say about it".

A M$ marketing guy would "kill" to have such a thing to place on their
software boxes... if only we had software boxes.

And would make his big boss really happy.... if only we had a big boss
:)

While I hope Cocoon doesn't turn to a religion (which is not technically
wise), I do agree this is the greatest stuff to hit the planet yet.

But to teel you the truth, what you've experienced is just the tip of
the iceberg, stay tune and you'll see great things happening under your
eyes.

Trust me.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------