cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r220256 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/xsltal/ src/blocks/xsltal/conf/ src/blocks/xsltal/java/ src/blocks/xsltal/java/org/ src/blocks/xsltal/java/org/apache/ src/blocks/xsltal/java/org/apache/cocoon/ src/blocks/xsltal/jav...
Date Fri, 22 Jul 2005 07:33:26 GMT
Author: bdelacretaz
Date: Fri Jul 22 00:33:24 2005
New Revision: 220256

URL: http://svn.apache.org/viewcvs?rev=220256&view=rev
Log:
New xsltal block, implements TAL-like syntax for presentation templates.
See http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=112196402613727&w=2

Although this can be used by simply including the tal2xslt.xsl transform in sitemaps,
having a block makes it easier to add samples and make this a "component" instead of
"just an XSLT transform". The xsltal transformer is created by simply configuring the
TraxTransformer with tal2xslt.xsl as its default transform.


Added:
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xmap
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xsamples
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/resources/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/resources/tal2xslt.xsl
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/testdoc.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/xsltal.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/samples.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/sitemap.xmap
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/css-template.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/plain-template.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/cocoon/
    cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/cocoon/XslTalTestCase.java
Modified:
    cocoon/branches/BRANCH_2_1_X/blocks.properties
    cocoon/branches/BRANCH_2_1_X/gump.xml
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/blocks.properties
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/blocks.properties?rev=220256&r1=220255&r2=220256&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/blocks.properties (original)
+++ cocoon/branches/BRANCH_2_1_X/blocks.properties Fri Jul 22 00:33:24 2005
@@ -170,3 +170,4 @@
 #include.block.tour=false
 #-----[dependency]: "webdav" depends on "repository".
 #include.block.webdav=false
+#include.block.xsltal=false

Modified: cocoon/branches/BRANCH_2_1_X/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/gump.xml?rev=220256&r1=220255&r2=220256&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/gump.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/gump.xml Fri Jul 22 00:33:24 2005
@@ -1548,6 +1548,29 @@
     <nag from="Gump &lt;general@gump.apache.org&gt;" to="dev@cocoon.apache.org"/>
   </project>
 
+  <project name="cocoon-block-xsltal" status="unstable" dir="src/blocks/xsltal">
+    <package>org.apache.cocoon</package>
+
+    <description>Process documents with XSLTAL templates</description>
+
+    <ant target="gump-block">
+      <property name="block-name" value="xsltal"/>
+      <property name="version" value="@@DATE@@"/>
+    </ant>
+
+    <depend project="cocoon" inherit="all"/>
+    <depend project="xsltal"/>
+
+    <library name="xsltal"/>
+
+    <work nested="tools/anttasks"/>
+    <home nested="build/cocoon-@@DATE@@"/>
+
+    <jar name="blocks/xsltal-block.jar"/>
+
+    <nag from="Gump &lt;general@gump.apache.org&gt;" to="dev@cocoon.apache.org"/>
+  </project>
+
   <!--
     ********************************************
     ********  COCOON SUPPLIED PROJECTS  ********

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xmap?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xmap (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xmap Fri Jul 22 00:33:24 2005
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+  The xsltal transformer is simply the TraxTransformer with a default-src parameter,
+  to load the standard tal2xslt transform.
+
+  The idea is to hide the (somewhat scary) tal2xslt transform from users, but of
+  course this could be done with a normal <map:transform type="xslt">
+-->
+
+<xmap xpath="/sitemap/components/transformers"
+      unless="transformer[@name='xsltal']">
+
+  <map:transformer name="xsltal"
+    src="org.apache.cocoon.transformation.TraxTransformer"
+    logger="sitemap.transformer.xsltal"
+    pool-max="8"
+  >
+    <default-src>resource://org/apache/cocoon/blocks/xsltal/resources/tal2xslt.xsl</default-src>
+
+    <use-request-parameters>false</use-request-parameters>
+    <use-session-parameters>false</use-session-parameters>
+    <use-cookie-parameters>false</use-cookie-parameters>
+    <!-- Xalan -->
+    <!--transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory-->
+    <!-- XSLTC -->
+    <!--transformer-factory>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</transformer-factory-->
+    <!-- Old (6.5.2) Saxon: -->
+    <!--transformer-factory>com.icl.saxon.TransformerFactoryImpl</transformer-factory-->
+    <!--  New (7.x?) Saxon: -->
+    <transformer-factory>net.sf.saxon.TransformerFactoryImpl</transformer-factory>
+  </map:transformer>
+</xmap>

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xsamples
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xsamples?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xsamples (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/conf/xsltal.xsamples Fri Jul 22 00:33:24
2005
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xsamples xpath="/samples" unless="group[@name='XSLTAL']">
+
+  <group name="XSLTAL">
+    <sample name="XSLTAL Block" href="xsltal/">
+      Examples of the XSLTAL presentation templating block 
+    </sample>
+  </group>
+
+</xsamples>

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/resources/tal2xslt.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/resources/tal2xslt.xsl?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/resources/tal2xslt.xsl
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/java/org/apache/cocoon/blocks/xsltal/resources/tal2xslt.xsl
Fri Jul 22 00:33:24 2005
@@ -0,0 +1,254 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+  Convert an XSLTAL to an XSLT transform.
+
+  This was donated by Christian Stocker from bitflux.ch, we're using the same
+  stuff than they have but it seems easier to keep our own version of it here.
+-->
+
+<xsl:stylesheet version="1.0"  xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:bxf="http://bitflux.org/functions"
xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslout="whatever" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"
xmlns:func="http://exslt.org/functions" extension-element-prefixes="func">
+
+    <xsl:namespace-alias stylesheet-prefix="xslout" result-prefix="xsl"/>
+    <func:function name="bxf:tales">
+        <xsl:param name="path"/>
+        <xsl:choose>
+            <xsl:when test="$path = ''">
+                <func:result select="'node()'"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <func:result select="$path"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </func:function>
+
+    <xsl:template match="/">
+        <xslout:stylesheet version="1.0" exclude-result-prefixes="xhtml bxf tal">
+            <xslout:output encoding="utf-8" method="xml" doctype-public="-//W3C//DTD XHTML
1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
+            <xsl:apply-templates select="//*[@tal:include]" mode="init"/>
+            <xsl:apply-templates select="//*[@tal:match]" mode="init"/>
+            <xsl:apply-templates select="//*[@metal:use-macro]" mode="init"/>
+            <xslout:template match="/">
+
+                <xsl:apply-templates/>
+            </xslout:template>
+            <!--copy all elements -->
+            <xslout:template match="*">
+                <xslout:copy>
+                    <xslout:apply-templates select="@*"/>
+                    <xslout:apply-templates/>
+                </xslout:copy>
+            </xslout:template>
+               <!-- copy all attributes -->
+            <xslout:template match="@*">
+                <xslout:copy-of select="."/>
+            </xslout:template>
+        </xslout:stylesheet>
+
+    </xsl:template>
+
+
+    <xsl:template match="*[@tal:condition]" priority="10">
+        <xslout:if test="{bxf:tales(@tal:condition)}">
+            <xsl:apply-templates/>
+        </xslout:if>
+    </xsl:template>
+
+    <xsl:template match="*[@metal:use-macro]">
+        <xsl:variable name="doc" select="substring-before(@metal:use-macro,'#')"/>
+        <xsl:variable name="path" select="substring-after(@metal:use-macro,'#')"/>
+        <xsl:apply-templates select="document($doc)//*[@metal:define-macro = $path]"/>
+     </xsl:template>
+
+     <xsl:template match="*[@metal:use-macro]" mode="init">
+        <xsl:variable name="doc" select="substring-before(@metal:use-macro,'#')"/>
+        <xsl:variable name="path" select="substring-after(@metal:use-macro,'#')"/>
+        <xsl:apply-templates select="document($doc)//*[@metal:define-macro = $path]" mode="init"/>
+     </xsl:template>
+
+     <xsl:template match="text()" mode ="init">
+        <xsl:if test="ancestor::*[@tal:match]">
+            <xsl:copy/>
+        </xsl:if>
+     </xsl:template>
+
+
+
+    <xsl:template match="@metal:define-macro">
+    </xsl:template>
+    <xsl:template match="*[@tal:content]">
+        <xsl:copy>
+            <xsl:apply-templates select="@*"/>
+            <xsl:call-template name="copy-value-apply">
+                <xsl:with-param name="path" select="@tal:content"/>
+            </xsl:call-template>
+        </xsl:copy>
+    </xsl:template>
+
+
+    <xsl:template match="*[@tal:replace]">
+        <xsl:call-template name="copy-value-apply">
+            <xsl:with-param name="path" select="@tal:replace"/>
+        </xsl:call-template>
+    </xsl:template>
+
+
+    <xsl:template match="*[@tal:repeat]">
+        <xsl:copy>
+            <xsl:apply-templates select="@*"/>
+            <xsl:variable name="v" select="substring-before(@tal:repeat,' ')"/>
+            <xsl:variable name="x" select="substring-after(@tal:repeat,' ')"/>
+            <xslout:for-each select="{bxf:tales($x)}">
+                <xslout:variable name="{$v}" select="."/>
+                <xsl:apply-templates/>
+            </xslout:for-each>
+        </xsl:copy>
+    </xsl:template>
+
+    <xsl:template match="@*">
+        <xsl:if test="namespace-uri() != 'http://xml.zope.org/namespaces/tal'">
+            <xsl:copy-of select="."/>
+        </xsl:if>
+    </xsl:template>
+
+    <xsl:template match="*[@tal:match]"/>
+
+    <xsl:template match="*[@tal:include]" mode="init">
+        <xsl:call-template name="talIncludes">
+            <xsl:with-param name="include" select="@tal:include"/>
+        </xsl:call-template>
+    </xsl:template>
+
+    <xsl:template name="talIncludes">
+        <xsl:param name="include"/>
+        <xsl:choose>
+            <xsl:when test="contains($include,' ')">
+                <xslout:include href="{substring-before($include,' ')}"/>
+                <xsl:call-template name="talIncludes">
+                    <xsl:with-param name="include" select="substring-after($include,'
')"/>
+                </xsl:call-template>
+            </xsl:when>
+            <xsl:otherwise>
+                <xslout:include href="{$include}"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template match="*[@tal:match]" mode="init">
+        <xslout:template match="{@tal:match}">
+            <xsl:apply-templates/>
+        </xslout:template>
+    </xsl:template>
+
+
+      <!-- outputs value-of, copy-of our apply-templates of $path depending on the first
param
+              "/foo/bar" ->             <xsl:value-of select="/foo/bar"/>
+              "text /foo/bar" ->        <xsl:value-of select="/foo/bar"/>
+              "structure /foo/bar" ->   <xsl:copy-of select="/foo/bar"/>
+         -->
+    <xsl:template name="copy-value-apply">
+        <xsl:param name="path"/>
+        <xsl:variable name="mode">
+            <xsl:value-of select="substring-before($path,' ')"/>
+        </xsl:variable>
+        <xsl:variable name="spath">
+            <xsl:value-of select="substring-after($path,' ')"/>
+        </xsl:variable>
+
+        <xsl:choose>
+           <!-- if no mode, use value-of -->
+           <xsl:when test="$path ='structure'">
+                <xslout:apply-templates select="{bxf:tales('')}"/>
+           </xsl:when>
+            <xsl:when test="$mode = ''">
+                <xslout:value-of select="{bxf:tales($path)}"/>
+            </xsl:when>
+            <xsl:when test="$mode = 'text'">
+                <xslout:value-of select="{bxf:tales($spath)}"/>
+            </xsl:when>
+            <xsl:when test="$path = 'structure .'">
+                <xslout:copy>
+                    <xslout:apply-templates select="@*"/>
+                    <xslout:apply-templates select="{bxf:tales('')}"/>
+                </xslout:copy>
+            </xsl:when>
+            <xsl:when test="$mode = 'structure'">
+                <xslout:apply-templates select="{bxf:tales($spath)}"/>
+            </xsl:when>
+        </xsl:choose>
+    </xsl:template>
+
+
+    <xsl:template match="@tal:attributes">
+        <xsl:call-template name="talAttribute">
+            <xsl:with-param name="attr" select="."/>
+        </xsl:call-template>
+    </xsl:template>
+
+    <xsl:template name="talAttribute">
+        <xsl:param name="attr"/>
+        <xsl:choose>
+            <xsl:when test="contains($attr,'; ')">
+
+                <xsl:call-template name="talAttribute">
+                    <xsl:with-param name="attr" select="substring-after($attr,'; ')"/>
+                </xsl:call-template>
+                <xsl:call-template name="outputTalAttribute">
+                    <xsl:with-param name="attr" select="substring-before($attr,'; ')"/>
+                </xsl:call-template>
+            </xsl:when>
+
+            <xsl:otherwise>
+                <xsl:call-template name="outputTalAttribute">
+                    <xsl:with-param name="attr" select="$attr"/>
+                </xsl:call-template>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template name="outputTalAttribute">
+        <xsl:param name="attr"/>
+        <xsl:variable name="name" select="substring-before($attr,' ')"/>
+        <xsl:variable name="value" select="substring-after($attr,' ')"/>
+        <xslout:attribute name="{$name}">
+            <xslout:value-of select="{bxf:tales($value)}"/>
+        </xslout:attribute>
+
+    </xsl:template>
+
+    <xsl:template match="*">
+        <xsl:copy>
+            <xsl:apply-templates select="@*"/>
+            <xsl:apply-templates/>
+        </xsl:copy>
+    </xsl:template>
+
+
+    <xsl:template match="comment()">
+            <xslout:comment>
+                <xsl:value-of select="."/>
+            </xslout:comment>
+     </xsl:template>
+
+
+    <xsl:template match="processing-instruction()">
+            <xslout:processing-instruction name="{name()}">
+                <xsl:value-of select="."/>
+            </xslout:processing-instruction>
+     </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/testdoc.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/testdoc.xml?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/testdoc.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/testdoc.xml Fri Jul 22
00:33:24 2005
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<document>
+  <metadata>
+    <title>This is the XSLTAL test document</title>
+    <abstract>A simple test document for XSLTAL.</abstract>
+  </metadata>
+  <content>
+    <p>First paragraph of the test document.</p>
+    <p>Second paragraph with a link to <a href="http://cocoon.apache.org">Cocoon</a></p>
+  </content>
+</document>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/xsltal.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/xsltal.xml?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/xsltal.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/content/xsltal.xml Fri Jul 22 00:33:24
2005
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<document>
+  <metadata>
+    <title>XSLTAL info</title>
+    <abstract>What is XSLTAL and where to get info.</abstract>
+  </metadata>
+  <content>
+    <h1>What is XSLTAL</h1>
+    <p>
+      XSLTAL is a partial reimplementation of the Zope TAL
+      templating syntax, which requires only an XSLT
+      processor.
+    </p>
+    <p>
+      The tal2xslt transform used internally to implement this
+      was donated to Cocoon by Christian Stocker of bitflux.org, so that
+      we can collaborate on maintaining this and spreading the
+      word.
+    </p>
+    <p>
+      For more information see the
+      <a href="http://wiki.bitflux.org/Templates_TAL">XSLTAL page</a>
+      at bitflux.org.
+    </p>
+  </content>
+</document>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/samples.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/samples.xml?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/samples.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/samples.xml Fri Jul 22 00:33:24
2005
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- CVS $Id: samples.xml 164206 2005-04-22 09:02:05Z bdelacretaz $ -->
+
+<samples name="XSLTAL Block Samples" xmlns:xlink="http://www.w3.org/1999/xlink">
+
+  <group name="Back">
+    <sample name="Back" href="../..">to Cocoon Samples main page</sample>
+    <sample name="Back" href="..">to Cocoon Blocks Samples main page</sample>
+  </group>
+
+  <group name="XSLTAL templates">
+    <sample name="Plain document" href="plain/testdoc.html">
+      testdoc.xml processed by the "plain" template
+    </sample>
+    <sample name="CSS document" href="css/testdoc.html">
+      testdoc.xml processed by the "css" template
+    </sample>
+  </group>
+
+  <group name="XSLTAL info">
+    <sample name="xsltal" href="css/xsltal.html">
+      What is XSLTAL?
+    </sample>
+  </group>
+
+  <group name="Source code">
+    <sample name="plain template" href="raw/templates/plain-template.xml">
+      The "plain" XSLTAL template
+    </sample>
+    <sample name="CSS template" href="raw/templates/css-template.xml">
+      The "css" XSLTAL template
+    </sample>
+    <sample name="input document" href="raw/content/testdoc.xml">
+      The testdoc.xml document
+    </sample>
+  </group>
+</samples>

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/sitemap.xmap?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/sitemap.xmap (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/sitemap.xmap Fri Jul 22 00:33:24
2005
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--+
+    | xsltal block samples sitemap
+    |
+    | CVS $Id: sitemap.xmap 56369 2004-11-02 12:51:29Z cziegeler $
+    +-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <map:pipelines>
+    <map:pipeline>
+      <map:match pattern="">
+        <map:redirect-to uri="welcome"/>
+      </map:match>
+
+      <!-- list of samples -->
+      <map:match pattern="welcome">
+        <map:generate src="samples.xml"/>
+        <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
+          <map:parameter name="contextPath" value="{request:contextPath}"/>
+        </map:transform>
+        <map:serialize/>
+      </map:match>
+
+      <!-- show raw XML content and template files -->
+      <map:match pattern="raw/**">
+        <map:generate src="{1}"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- generate an XSLT transform from an XSLTAL template -->
+      <map:match pattern="get-tal-transform/*.xsl">
+        <map:generate src="templates/{1}-template.xml"/>
+        <map:transform type="xsltal"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- generate HTML by applying an XSLTAL template to XML content -->
+      <map:match pattern="*/**.html">
+        <map:generate src="content/{2}.xml"/>
+        <map:transform src="cocoon:/get-tal-transform/{1}.xsl"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/css-template.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/css-template.xml?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/css-template.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/css-template.xml Fri
Jul 22 00:33:24 2005
@@ -0,0 +1,110 @@
+<?xml version="1.0"?>
+
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+  XSLTAL template for our samples.
+  This one generates a nicer layout based on <div> elements and CSS.
+-->
+
+<html xmlns:tal="http://xml.zope.org/namespaces/tal">
+  <head>
+    <title tal:content="document/metadata/title">Here comes the page title</title>
+
+    <!-- We could of course use an external CSS stylesheet instead of this -->
+    <style type="text/css">
+      body {
+        font-family: Georgia, Verdana, Sans-serif;
+      }
+      p {
+        margin-left: 1em;
+      }
+      a {
+        background-color:#FFFFCC;
+        padding: 2px;
+      }
+      .note {
+        font-size:80%;
+        font-style:italic;
+      }
+      #footer {
+        margin-top: 2em;
+        border-top: solid #CCCCCC 1px;
+      }
+      #title {
+        font-size: 180%;
+        font-variant: small-caps;
+        font-weight: bold;
+      }
+      #sidebar {
+        position:fixed;
+        right:0;
+        top:0;
+        width:20%;
+        font-size:80%;
+        font-style: italic;
+      }
+      #content {
+        margin-right: 25%;
+      }
+      #content div {
+        margin-top: 1em;
+      }
+      #sidebar div {
+        margin-bottom: 2em;
+      }
+      .logo {
+        clear: both;
+      }
+    </style>
+  </head>
+
+  <body>
+    <!-- page structure -->
+    <div id="sidebar" tal:repeat="abs /document/metadata/abstract">
+      <div>
+        <div tal:replace="structure $abs/node()"/>
+      </div>
+      <div>
+        Go <a href="javascript:history.back()">back</a> to previous page.
+      </div>
+    </div>
+
+    <div id="content">
+      <div id="title" tal:content="document/metadata/title">Here comes the page title</div>
+      <div tal:repeat="p /document/content/p">
+        <div>
+          <div tal:replace="structure $p/node()">
+            (this should be replaced by the content of a paragraph)
+          </div>
+        </div>
+      </div>
+    </div>
+
+    <div id="footer">
+      <div class="note">
+        Presentation generated by the css-template.xml XSLTAL template.
+      </div>
+    </div>
+
+    <!-- element matchers -->
+    <div tal:match="a">
+      <a tal:attributes="href @href" tal:content="structure"></a>
+    </div>
+
+  </body>
+</html>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/plain-template.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/plain-template.xml?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/plain-template.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/samples/templates/plain-template.xml Fri
Jul 22 00:33:24 2005
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- Simple XSLTAL template for our samples -->
+
+<html xmlns:tal="http://xml.zope.org/namespaces/tal">
+  <head>
+    <title tal:content="document/metadata/title">Page title</title>
+  </head>
+  <body>
+    <h1 tal:content="document/metadata/title">Page title</h1>
+    <div class="content" tal:repeat="p /document/content/p">
+      <p>
+        <div tal:replace="structure $p/node()">
+          (this should be replaced by the content of a paragraph)
+        </div>
+      </p>
+    </div>
+
+    <div tal:match="a">
+      <img src="http://cocoon.apache.org/favicon.ico" height="16" width="16"/>
+      &#160;
+      <a tal:attributes="href @href" tal:content="structure"></a>
+    </div>
+    <div style="font-size:80%">
+      Presentation generated by the plain-template.xml XSLTAL template.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/cocoon/XslTalTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/cocoon/XslTalTestCase.java?rev=220256&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/cocoon/XslTalTestCase.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/xsltal/test/htmlunit/org/apache/cocoon/XslTalTestCase.java
Fri Jul 22 00:33:24 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon;
+
+/**
+ * Check the xsltal testdoc.html document
+ * @version $Id: $
+ */
+public class XslTalTestCase
+    extends HtmlUnitTestCase
+{
+    static final String pageurl = "/samples/blocks/xsltal/plain/testdoc.html";
+
+    public void testXslTalTestDoc()
+        throws Exception
+    {
+        loadHtmlPage(pageurl);
+
+        final String pageTitle = "This is the XSLTAL test document";
+        assertXPath("/html/head/title", pageTitle);
+        assertXPath("/html/body/div[1]/@class", "content");
+        assertXPath("/html/body/h1[1]", pageTitle);
+        assertXPath("/html/body/p[1]", "First paragraph of the test document.");
+        assertXPath("/html/body/p[2]", "Second paragraph of the test document.");
+    }
+}

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=220256&r1=220255&r2=220256&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Fri Jul 22 00:33:24 2005
@@ -196,6 +196,12 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <action dev="BD" type="add" due-to="Christian Stocker" due-to-email="chregu@bitflux.ch">
+      XSLTAL block added, presentation templating transformer based on the Zope TAL syntax.

+    </action>
+    <action dev="BD" type="update">
+      TraxTransformer: new default-src configuration parameter, used if src is not specified.
  
+    </action>
     <action dev="AN" type="add" fixes-bug="28045" due-to="Jon Evans" due-to-email="jon.evans@misgl.com">
       Added CookieModule as a more convinient way to access cookie values as {cookie:query}
       in alternative to {request:cookies[name='query']/value}.



Mime
View raw message