I use Cocoon 2.0.4 for JDK1.3 on Weblogic 7.0 SP1. I need to use Xalan
Extensions to write _javascript in my XSL. I use Xalan 2.5.D1 and the
XercesImpl that comes with it. If I add the xalan.jar, xercesImpl.jar in
my weblogic's classpath the Xalan Extensions work, but the Cocoon's XSP
fail with the following error:
___________________________________________________________
org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
source_xsp: Line 101, column 25: unclosed character literal Line 101,
column 24: illegal start of _expression Line 0, column 0: 2 errors
sender org.apache.cocoon.servlet.CocoonServlet
source Cocoon servlet
stack-trace
org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
source_xsp:
Line 101, column 25: unclosed character literal
Line 101, column 24: illegal start of _expression
Line 0, column 0:
2 errors
I would like to know if there are any changes I would have to make to
cocoon.conf to make this work.
----------------------------------------------------------
As of now I have no logic in XSP at all. The content is not very meaningful since I am only trying to learn the concepts. Actually I need to generate a legal document in PDF. The document mainly consists of "numbered" paragraphs that may or may not be displayed depending on certain criteria.
I need to achieve the following:
1. Show a paragraph after evaluating a criteria
2. Number every paragraph shown continuously in Roman Numerals (I, II, III, IV etc)
I am able to control the visibility of a paragraph. But in order to count the paragraphs I could use some logic in XSP itself, but I wanted to try and see if it were possible to use xsl:number in the xsl style sheet to render the page with the paragraphs numbered. I used xalan:script capability to increment the number to see paragraph numbers.
My weblogic classpath has been set as follows:
set CLASSPATH=D:\xalandoc\bin\xercesImpl.jar;;D:\xalandoc\bin\xml-apis.jar;D:\xalandoc\bin\xalan.jar;D:\xalandoc\bin\bsf.jar;D:\xalandoc\bin\js.jar;%CLASSPATH%;
If this classpath is present xalan:script works, but XSP fails. If this classpath is not present XSP will process but xalan:script fails.
The xercesImpl.jar, xml-apis.jar and xalan.jar are what I downloaded from Xalan2.5.D1. The versions that came with Cocoon 2.0.4 seem to have xalan2.3.1 and xercesImpl2.0.0.
Also I have deployed cocoon in the exploded format. So I have changed the libraries in cocoon\WEB-INF\lib to the latest xalan jar files (the same ones the classpath points to).
I was wondering if there was some configuration to be done in the sitemap or cocoon.xconf to use the new xalan jar files?
Let me paste the contents of the files that I am using:
source.xsp:
<?xml version="1.0"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
xmlns:abc="http://abc.com/1.0" >
<page>
<title>Welcome to ABC Software </title>
<content>
<paragraph>
<visible>1</visible>
<chunk-content>
<title-case> welcome lisa, </title-case> to the ABC Software support website. On this site, you will
be able to submit support requests, track open requests and view
your support contract bills. People are satisfied with our support <formatPercent>99</formatPercent> of the time.
The flat rate for a year is <formatCurrency>6000</formatCurrency>.
</chunk-content>
</chunk-content>
</paragraph>
<paragraph>
<visible>0</visible>
<chunk-content>
<title-case> welcome robin, </title-case> to the ABC Software support website. On this site, you will
be able to submit support requests, track open requests and view
your support contract bills. People are satisfied with our support <formatPercent>99</formatPercent> of the time.
The flat rate for a year is <formatCurrency>6000</formatCurrency>.
</chunk-content>
</paragraph>
<paragraph>
<visible>1</visible>
<chunk-content>
<title-case> welcome mike, </title-case> to the ABC Software support website. On this site, you will
be able to submit support requests, track open requests and view
your support contract bills. People are satisfied with our support <formatPercent>99</formatPercent> of the time.
The flat rate for a year is <formatCurrency>6000</formatCurrency>.
</chunk-content>
</paragraph>
</content>
</page>
</xsp:page>
-------------------------------------------------------------------------------------------------------------------------
abc.xsl (logic sheet for use later when things become more complex)
<?xml version="1.0" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsp="http://apache.org/xsp"
xmlns:abc="http://abc.com/1.0"
version="1.0"
>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="." />
</xsl:template>
</xsl:stylesheet>
-------------------------------------------------------------------------------------------------------------------------
main-pdf.xsl
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:counter="MyCounter"
extension-element-prefixes="counter">
<xalan:component prefix="counter" functions="increment">
<xalan:script lang="_javascript">
var i = 1;
function increment() {
return i++;
}
</xalan:script>
</xalan:component>
<!--************** Title Case Conversion in XSLT ******************-->
<xsl:template name="TitleCase">
<xsl:param name="text" />
<xsl:param name="lastletter" select="' '"/>
<xsl:if test="$text">
<xsl:variable name="thisletter" select="substring($text,1,1)"/>
<xsl:choose>
<xsl:when test="$lastletter=' '">
<xsl:value-of select="translate($thisletter,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$thisletter"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="TitleCase">
<xsl:with-param name="text" select="substring($text,2)"/>
<xsl:with-param name="lastletter" select="$thisletter"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!--*************************************************************-->
<xsl:template match="page">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="page">
page-height="11.7in" page-width="8in"
margin-top="1in" margin-bottom="1in"
margin-left="1in" margin-right="1in">
<fo:region-before extent="3cm" />
<fo:region-body margin-top="3cm" />
<fo:region-after extent="1.5cm" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="all">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference
master-reference="page"
page-position="first" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="all">
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="left" font-size="10pt" font-family="Courier" line-height="14pt">
ESTABLISHMENT COMPLAINT - Page <fo:page-number />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="content">
<xsl:for-each select="paragraph">
<xsl:if test="visible = 1">
<xsl:apply-templates/>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="chunk-content">
<fo:block font-size="12pt" font-family="Times" space-before.optimum="12pt" text-align="left" line-height="24pt">
<xsl:number value="counter:increment()" format="I" />
<xsl:apply-templates />
</fo:block>
</xsl:template>
<xsl:template match="title">
<fo:block font-size="36pt" font-family="Times" space-before.optimum="12pt" text-align="center">
<xsl:apply-templates />
</fo:block>
</xsl:template>
<xsl:template match="upper-case">
<xsl:value-of select="translate(current(),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
</xsl:template>
<xsl:template match="lower-case">
<xsl:value-of select="translate(current(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
</xsl:template>
<xsl:template match="title-case">
<xsl:call-template name="TitleCase">
<xsl:with-param name="text" select="current()"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="formatPercent">
<xsl:value-of select="concat('(',current(),'%)')" />
</xsl:template>
<xsl:template match="formatCurrency">
<xsl:value-of select="concat('$', current())" />
</xsl:template>
</xsl:stylesheet>
-------------------------------------------------------------------------------------------------------------------------Sitemap:
<map:match pattern="letter.pdf">
<map:generate type="serverpages" src="" />
<map:transform type="xslt" src="" />
<map:serialize type="fo2pdf" />
</map:match>
-------------------------------------------------------------------------------------------------------------------------
Thank you!
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
