cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Lewis <>
Subject Re: Tuning XSP output
Date Thu, 22 Mar 2007 15:52:31 GMT
On Tuesday 20 March 2007 10:20, Tobia wrote:
> Richard Lewis wrote:
> > 1) Stop it from producing empty elements.
> > <duration><esql:get-string column="duration" /></duration>
> I guess you need to put it inside a Java if statement.
> You can wrap it all in a logicsheet, for convenience:
> 	<my:get-element column="duration"/>
> Something like this (untested):
> 	<xsl:template match="my:get-element">
> 	  <xsp:logic>
> 	    if (<esql:get-string column="{@column}"/>.length() > 0) {
> 	      <xsl:element name="{@column}">
> 	        <esql:get-string column="{@column}"/>
> 	      </xsl:element>
> 	    }
> 	  </xsp:logic>
> 	</xsl:template>
> > 2) Some of my fields (e.g. biography) are long textual fields which
> > include line spaces. Is there a way to capture those lines and wrap
> > them up in elements?
> Again untested:
> 	String biography = <esql:get-string column="biography"/>;
> 	for (String para : biography.split("\\n\\s*\\n")) {
> 	  <l><xsp:expr>para</xsp:expr></l>
> 	}
Thanks for these pointers. I'm quite new to XSP and logicsheets and I'm now 
having trouble getting them to work. I've used your code to create the 
following logicsheet (apologies for the verboseness, its just in case the 
problem is here):


<xsl:template match="xsp:page">
    <xsl:apply-templates select="@*" />
    <xsl:apply-templates />

<xsl:template match="sara:get-string">
  <xsl:if test="@exclude-values">
      String exclude[] = <xsl:value-of 
select="@exclude-values" />.split("\\s+");
    String lines[] = <esql:get-string column="{@column}" />.split("\\n");
    if (lines.length > 0) {
    <xsl:element name="{@column}">
      for (int i = 0; i &lt; lines.length; i++) {

<xsl:template match="@*|node()" priority="-1">
    <xsl:apply-templates select="@*|node()" />


And in my XSP I have, for example:

  <sara:get-string column="first_name" tag-name="first" />
  <sara:get-string column="last_name" tag-name="last" />

Both of these files are stored in:

and my Cocoon installation directory is:

and it contains a symlink called 'sara' which points to:
(this directory contains my sitemap.xmap file)

At first I tried to add my logicsheet to the cocoon.xconf file like this:

<target-language name="java">
  <parameter name="prefix" value="sara" />
  <parameter name="uri" value="" />
  <parameter name="href" 
value="file:///home/richard/Documents/sara/maps/sara-logicsheet.xsl" />

But when I made the relevant request, the resultant XML document just 
contained my <sara:get-string> elements verbitum (rather than interpretting 
them). I tried altering the the file: protocol to resource: but it didn't 
make any difference.

So I then tried using the logicsheet processing instruction in my XSP instead:
<?xml-logicsheet href="maps/sara-logicsheet.xsl" ?>

But now it keeps saying that it can't find the sara-logicsheet.xsl file. I've 
tried several different paths. I get: /home/richard/Documents/sara/maps/sara-logicsheet.xsl 
(No such file or directory)

I've even tried:
href="file:///home/richard/Documents/sara/cocoon/maps/sara-logicsheet.xsl" ?>

Does anyone have any ideas why my logicsheet won't work?

Richard Lewis

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message