hi! i have a test.xsp and a test.xsl and a elements.xsl
i use tags like <input>, <span>, <div>, .... in my XSP-page. so i write a elements.xsl which defines these tags like (i put the elements.xsl also as attachement) --> <xsl:template match="div"> <div> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </div> </xsl:template> i import these elements.xsl in the testxsl, so all my tags in the xsp-site are defined. is there a possibility to write down this in a logicsheet, so that i have not to import the elements.xsl in the test.xsl and define the logicsheet in the xsp-page? i tried the logicsheet (mylogic.xsl) at http://www.cocooncenter.de/cc/documents/resources/logicsheet/filelist.ht ml it works fine - i want to add a template given above for <div> --> but this doesn't work (no <div> is written out to my page. what's wrong with my logicsheet. greetings, chris
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="form"> <form> <xsl:if test="@name!=''"> <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:if test="@action!=''"> <xsl:attribute name="action"><xsl:value-of select="@action"/></xsl:attribute> </xsl:if> <xsl:if test="@method!=''"> <xsl:attribute name="method"><xsl:value-of select="@method"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </form> </xsl:template> <xsl:template match="div"> <div> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </div> </xsl:template> <xsl:template match="a"> <a> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:if test="@href!=''"> <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute> </xsl:if> <xsl:if test="@name!=''"> <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </a> </xsl:template> <xsl:template match="span"> <span> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </span> </xsl:template> <xsl:template match="p"> <p> <xsl:if test="@align!=''"> <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </p> </xsl:template> <xsl:template match="input"> <input> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@name!=''"> <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:if test="@value!=''"> <xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute> </xsl:if> <xsl:if test="@type!=''"> <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute> </xsl:if> <xsl:if test="@maxlength!=''"> <xsl:attribute name="maxlength"><xsl:value-of select="@maxlength"/></xsl:attribute> </xsl:if> <xsl:if test="@size!=''"> <xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute> </xsl:if> <xsl:if test="@disabled!=''"> <xsl:attribute name="disabled"><xsl:value-of select="@disabled"/></xsl:attribute> </xsl:if> <xsl:if test="@checked!=''"> <xsl:attribute name="checked"><xsl:value-of select="@checked"/></xsl:attribute> </xsl:if> <xsl:if test="@readonly!=''"> <xsl:attribute name="readonly"><xsl:value-of select="@readonly"/></xsl:attribute> </xsl:if> <xsl:if test="@tabindex!=''"> <xsl:attribute name="tabindex"><xsl:value-of select="@tabindex"/></xsl:attribute> </xsl:if> <xsl:if test="@onblur!=''"> <xsl:attribute name="onblur"><xsl:value-of select="@onblur"/></xsl:attribute> </xsl:if> <xsl:if test="@onclick!=''"> <xsl:attribute name="onclick"><xsl:value-of select="@onclick"/></xsl:attribute> </xsl:if> <xsl:if test="@onchange!=''"> <xsl:attribute name="onchange"><xsl:value-of select="@onchange"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </input> </xsl:template> <xsl:template match="select"> <select> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@class!=''"> <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:if test="@name!=''"> <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> </xsl:if> <xsl:if test="@size!=''"> <xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute> </xsl:if> <xsl:if test="@onchange!=''"> <xsl:attribute name="onchange"><xsl:value-of select="@onchange"/></xsl:attribute> </xsl:if> <xsl:if test="@tabindex!=''"> <xsl:attribute name="tabindex"><xsl:value-of select="@tabindex"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </select> </xsl:template> <xsl:template match="img"> <img> <xsl:if test="@id!=''"> <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> </xsl:if> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:if test="@width!=''"> <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute> </xsl:if> <xsl:if test="@height!=''"> <xsl:attribute name="height"><xsl:value-of select="@height"/></xsl:attribute> </xsl:if> <xsl:if test="@src!=''"> <xsl:attribute name="src"><xsl:value-of select="@src"/></xsl:attribute> </xsl:if> <xsl:if test="@border!=''"> <xsl:attribute name="border"><xsl:value-of select="@border"/></xsl:attribute> </xsl:if> <xsl:if test="@alt!=''"> <xsl:attribute name="alt"><xsl:value-of select="@alt"/></xsl:attribute> </xsl:if> <xsl:if test="@onclick!=''"> <xsl:attribute name="onclick"><xsl:value-of select="@onclick"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </img> </xsl:template> <xsl:template match="option"> <option value="{@value}"> <xsl:if test="@selected!=''"> <xsl:attribute name="selected"><xsl:value-of select="@selected"/></xsl:attribute> </xsl:if> <xsl:value-of select="."/> </option> </xsl:template> <xsl:template match="hr"> <hr> <xsl:if test="@style!=''"> <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </hr> </xsl:template> <xsl:template match="script"> <xsl:choose> <xsl:when test="@src!=''"> <script language="JavaScript" src="{@src}"> </script> </xsl:when> <xsl:otherwise> <script language="JavaScript"> <xsl:value-of select="."/> </script> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="link"> <link> <xsl:if test="@rel!=''"> <xsl:attribute name="rel"><xsl:value-of select="@rel"/></xsl:attribute> </xsl:if> <xsl:if test="@href!=''"> <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute> </xsl:if> <xsl:apply-templates/> </link> </xsl:template> </xsl:stylesheet>
<?xml version="1.0"?> <!-- =========================================================== SIMPLE LOGICSHEET EXAMPLE Implements four tags: <date />, <time />, <now /> and <datetime />. Logicsheet URI is: http://hostname/mylogic/1.0 Prefix: mylogic This logicsheet namespace declaration: xmlns:mylogic="http://hostname/mylogic/1.0" According declaration in cocoon.xconf looks like: <builtin-logicsheet> <parameter name="prefix" value="mylogic"/> <parameter name="uri" value="http://hostname/mylogic/1.0"/> <parameter name="href" value="resource://spain/logicsheet/mylogic.xsl"/> </builtin-logicsheet> Author: Konstantin Piroumian Date: 18/11/2001 =========================================================== --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsp="http://apache.org/xsp" xmlns:mylogic="http://hostname/mylogic/1.0" > <xsl:template match="xsp:page"> <xsp:page> <xsl:apply-templates select="@*"/> <!-- Add needed imports --> <xsp:structure> <xsp:include>java.util.Date</xsp:include> <xsp:include>java.text.SimpleDateFormat</xsp:include> </xsp:structure> <!-- Add class-level logic: methods, variables --> <xsp:logic><![CDATA[ public static String formatDate(Date value, String format) { SimpleDateFormat formatter; format = format.trim(); if (format != null && !"".equals(format)) { formatter = new SimpleDateFormat(format); } else { formatter = new SimpleDateFormat(); } return formatter.format(value); } ]]> </xsp:logic> <xsl:apply-templates/> </xsp:page> </xsl:template> <!-- Current Date and Time --> <xsl:template match="mylogic:now"> <xsp:expr> formatDate(new Date(), "dd/MM/yyyy HH:mm:ss") </xsp:expr> </xsl:template> <!-- Current Date --> <xsl:template match="mylogic:date"> <xsp:expr> formatDate(new Date(), "dd/MM/yyyy") </xsp:expr> </xsl:template> <!-- Current Time --> <xsl:template match="mylogic:time"> <xsp:expr> formatDate(new Date(), "HH:mm:ss") </xsp:expr> </xsl:template> <xsl:template match="mylogic:datetime"> <xsp:logic>/* Format attribute is <xsl:value-of select="@format" /> */</xsp:logic> <xsp:expr> formatDate(new Date(), "<xsl:value-of select="@format" />") </xsp:expr> </xsl:template> <!-- ***************** !DO NOT CHANGE! Standard Templates ***************** --> <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 match="@*|*|text()|processing-instruction()"> <xsl:copy> <xsl:apply-templates select="@*|*|text()|processing-instruction()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
--------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>