Hi, I'm trying to build a simple custom logicsheet with string conversion functions (sample code attached).
Everything works fine as long as I pass parameters for the Java functions as attributes, but not when passing parameters as content of a custom tag. (tried this for several hours and searched the web for more info, no success) I used the docs and examples from: ...\cocoon-2.0\docs\userdocs\xsp\logicsheet-concepts.html and the [C2] Example Taglib from Gary Clark Tue, 19 Jun 2001 08:13:50 -0700 (seems to be a mailing to this list) Can anybody help ?? (Cocoon2.0 / Tomcat4.0.1 / Win2000 / JDK 1.3) Thanks, Friedrich Schuster ------- xml code --------- <?xml version="1.0"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:vstring="http://alysis.de/vstring/1.0" > <page> --- Not OK: logicsheet:vstring content --- <vstring:change s="hello odd world" oldp="world" > <vstring:param name="newp"> people </vstring:param> </vstring:change> --- OK: same function with logicsheet:vstring attributes --- <vstring:change s="hello odd world" oldp="world" newp="people"/> --- OK simple --- <vstring:xRange/> <vstring:msg/> --- OK xsp:logic --- <xsp:logic> String s2=ViolinStrings.Strings.change("hello welt","welt","old world"); </xsp:logic> <content> <xsp:expr>s2</xsp:expr> </content> </page> </xsp:page> ------------ xsl-Logicsheet code --------------------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsp="http://apache.org/xsp" xmlns:vstring="http://alysis.de/vstring/1.0" > <!-- Top level tag --> <xsl:template match="xsp:page"> <xsp:page> <xsl:apply-templates select="@*"/> <xsp:structure> // you can put <xsp:include> statements in here to import Java classes </xsp:structure> <xsp:logic> // put class-level variable declarations and methods here </xsp:logic> <xsl:apply-templates/> </xsp:page> </xsl:template> <!-- Run initialization code or declare variables before other code runs --> <xsl:template match="xsp:page/*[not(self::xsp:*)]"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsp:logic> // This code ends up inside populateDocument() before any user code </xsp:logic> <xsl:apply-templates/> </xsl:copy> </xsl:template> <!-- vstring:change --> <xsl:template match="vstring:change"> <xsl:variable name="s"> <xsl:call-template name="get-parameter"> <xsl:with-param name="name">s</xsl:with-param> <xsl:with-param name="required">true</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="oldp"> <xsl:call-template name="get-parameter"> <xsl:with-param name="name">oldp</xsl:with-param> <xsl:with-param name="required">true</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="newp"> <xsl:call-template name="get-parameter"> <xsl:with-param name="name">newp</xsl:with-param> <xsl:with-param name="required">true</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="start"> <xsl:call-template name="get-parameter"> <xsl:with-param name="name">start</xsl:with-param> <xsl:with-param name="required">false</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="maxChanges"> <xsl:call-template name="get-parameter"> <xsl:with-param name="name">maxChanges</xsl:with-param> <xsl:with-param name="required">false</xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:variable name="ignoreCase"> <xsl:call-template name="get-parameter"> <xsl:with-param name="name">ignoreCase</xsl:with-param> <xsl:with-param name="required">false</xsl:with-param> </xsl:call-template> </xsl:variable> <!-- non-Strings not implemented! --> <!-- tbd: konvertierung andere Var-Typen, Konvertierung spec.Chars ?? --> <xsp:logic> String vs=ViolinStrings.Strings.change( <xsl:copy-of select="$s"/>, <xsl:copy-of select="$oldp"/>, <xsl:copy-of select="$newp"/> ); </xsp:logic> <xsp:expr>vs</xsp:expr> </xsl:template> <!-- This is the simple vstring: tag --> <xsl:template match="vstring:msg"> Test message </xsl:template> <xsl:template match="vstring:xRange"> <xsp:logic> String s1=ViolinStrings.Strings.xRange('a','d'); </xsp:logic> <content> <xsp:expr>s1</xsp:expr> </content> </xsl:template> <!-- Utility templates --> <!-- --> <!-- DO NOT TOUCH --> <!-- --> <!-- Keep all unknown tags --> <xsl:template match="@*|node()" priority="-1"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- START: util templates from Apache Cocoon Logicsheet Concepts --> <xsl:template name="get-parameter"> <xsl:param name="name"/> <xsl:param name="default"/> <xsl:param name="required">false</xsl:param> <xsl:variable name="prefix"> vstring </xsl:variable> <xsl:variable name="qname"> <xsl:value-of select="concat($prefix, ':param')"/> </xsl:variable> <xsl:choose> <xsl:when test="@*[name(.) = $name]"> "<xsl:value-of select="@*[name(.) = $name]"/>" </xsl:when> <xsl:when test="(*[name(.) = $qname])[@name = $name]"> <xsl:call-template name="get-nested-content"> <xsl:with-param name="content" select="(*[name(.) = $qname])[@name = $name]"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="string-length($default) = 0"> <xsl:choose> <xsl:when test="$required = 'true'"> <xsl:call-template name="error"> <xsl:with-param name="message"> [Logicsheet processor] Parameter '<xsl:value-of select="$name"/>' missing in dynamic tag <<xsl:value-of select="name(.)"/>> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise>""</xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise><xsl:copy-of select="$default"/></xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="get-nested-content"> <xsl:param name="content"/> <xsl:choose> <xsl:when test="$content/*"> <xsl:apply-templates select="$content/*"/> </xsl:when> <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="get-nested-string"> <xsl:param name="content"/> <xsl:choose> <xsl:when test="$content/*"> "" <xsl:for-each select="$content/node()"> <xsl:choose> <xsl:when test="name(.)"> + <xsl:apply-templates select="."/> </xsl:when> <xsl:otherwise> + "<xsl:value-of select="translate(.,'	 ',' ')"/>" </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="error"> <xsl:param name="message"/> <xsl:message terminate="yes"><xsl:value-of select="$message"/></xsl:message> </xsl:template> <!-- END: util templates from Apache Cocoon Logicsheet Concepts --> </xsl:stylesheet> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>