You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by st...@outerthought.org on 2003/10/06 22:00:08 UTC
[WIKI-UPDATE] WebDAVCMS WebDAVTODO WebDAVAuthenticMetadata WebDAVWYSIWYG GT2003RealBlocks WebDAVAuthentic WebDAVRTE Mon Oct 6 22:00:07 2003
Page: http://wiki.cocoondev.org/Wiki.jsp?page=WebDAVCMS , version: 3 on Mon Oct 6 19:27:06 2003 by GuidoCasper
+ If you follow the "step5" sample you may notice that the sample starts mixing concerns.\\
+ The "business logic" starts creeping into the XSLT Stylesheets.
+
+ To see how Cocoon's flow layer helps you to "gain back control" have a look at the flowsample\\
+ of the WebDAV block.
Page: http://wiki.cocoondev.org/Wiki.jsp?page=WebDAVTODO , version: 7 on Mon Oct 6 19:27:55 2003 by GuidoCasper
-
- !Flowscript
-
- Document the flowscript sample
-
- * [Flowscript|WebDAVFlowscript]
Page: http://wiki.cocoondev.org/Wiki.jsp?page=WebDAVAuthenticMetadata , version: 1 on Mon Oct 6 19:21:39 2003 by GuidoCasper
New page created:
+ First, for each XML file within the "repo" folder create an acompaning file with a ".meta" extension like the "step4" example is doing:
+
+ {{{
+ <?xml version="1.0" encoding="UTF-8"?>
+ <metapage>
+ <author>me</author>
+ <category>catb</category>
+ <state>edited</state>
+ </metapage>
+ }}}
+
+ Add 2 additional match nodes to your pipeline:
+
+ {{{
+ <map:match pattern="page/**">
+ <map:aggregate element="aggregation" label="content">
+ <map:part src="cocoon:/raw/{1}"/>
+ <map:part src="cocoon:/meta/{1}"/>
+ </map:aggregate>
+ <map:serialize type="xml"/>
+ </map:match>
+ <map:match pattern="meta/**">
+ <map:generate src="{global:staging}repo/{1}.meta"/>
+ <map:serialize type="xml"/>
+ </map:match>
+ }}}
+
+ Now create 2 additional files within the "authentic" folder, aggregation.xsd (the XML schema)
+
+ {{{
+ <?xml version="1.0" encoding="UTF-8"?>
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:element name="aggregation">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="page" minOccurs="1" maxOccurs="1"/>
+ <xs:element ref="metapage" minOccurs="1" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="page">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="title"/>
+ <xs:element ref="content"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="content">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="para" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="title" type="xs:string"/>
+ <xs:element name="para">
+ <xs:complexType mixed="true">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element ref="image" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element ref="link" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="emphasis">
+ <xs:complexType mixed="true"/>
+ </xs:element>
+ <xs:element name="image">
+ <xs:complexType>
+ <xs:attribute name="href" type="xs:string" use="required"/>
+ <xs:attribute name="height" type="xs:long"/>
+ <xs:attribute name="width" type="xs:long"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="link">
+ <xs:complexType mixed="true">
+ <xs:attribute name="href" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="metapage">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="author" minOccurs="1" maxOccurs="1"/>
+ <xs:element ref="category" minOccurs="1" maxOccurs="1"/>
+ <xs:element ref="state" minOccurs="1" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="author" type="xs:string"/>
+ <xs:element name="category" type="xs:string"/>
+ <xs:element name="state" type="xs:string"/>
+ </xs:schema>
+ }}}
+
+ and aggregation.sps (the authetic-specific stylesheet)
+
+ {{{
+ <?xml version="1.0" encoding="UTF-8"?>
+ <structure version="2" schemafile="aggregation.xsd" workingxmlfile="" templatexmlfile="">
+ <nspair prefix="xs" uri="http://www.w3.org/2001/XMLSchema"/>
+ <template>
+ <match overwrittenxslmatch="/"/>
+ <children>
+ <template>
+ <match match="aggregation"/>
+ <children>
+ <template>
+ <match match="metapage"/>
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </template>
+ <newline/>
+ <newline/>
+ <template>
+ <match match="page"/>
+ <children>
+ <template>
+ <match match="title"/>
+ <children>
+ <xpath allchildren="1">
+ <styles color="#0000A0" font-size="larger" font-weight="bold" text-decoration="underline"/>
+ </xpath>
+ </children>
+ </template>
+ <template>
+ <match match="content"/>
+ <children>
+ <template>
+ <match match="para"/>
+ <children>
+ <paragraph paragraphtag="p">
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </paragraph>
+ </children>
+ </template>
+ </children>
+ </template>
+ </children>
+ </template>
+ </children>
+ </template>
+ </children>
+ </template>
+ <template>
+ <match match="author"/>
+ <children>
+ <text fixtext="Author: "/>
+ <field ownvalue="1">
+ <properties size="19" value=""/>
+ </field>
+ <newline/>
+ <newline/>
+ </children>
+ </template>
+ <template>
+ <match match="category"/>
+ <children>
+ <text fixtext="Category: "/>
+ <select ownvalue="1">
+ <properties size="0"/>
+ <selectoption description="Cat A" value="cata"/>
+ <selectoption description="Cat B" value="catb"/>
+ <selectoption description="Cat C" value="catc"/>
+ </select>
+ <newline/>
+ <newline/>
+ </children>
+ </template>
+ <template>
+ <match match="emphasis"/>
+ <children>
+ <xpath allchildren="1">
+ <styles font-weight="bold"/>
+ </xpath>
+ </children>
+ </template>
+ <template>
+ <match match="image"/>
+ <children>
+ <image>
+ <properties border="0"/>
+ <imagesource>
+ <xpath value="@href"/>
+ </imagesource>
+ </image>
+ </children>
+ </template>
+ <template>
+ <match match="link"/>
+ <children>
+ <link>
+ <hyperlink>
+ <xpath value="@href"/>
+ </hyperlink>
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </link>
+ </children>
+ </template>
+ <template>
+ <match match="metapage"/>
+ <children>
+ <newline/>
+ <template>
+ <match match="author"/>
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </template>
+ <newline/>
+ <template>
+ <match match="category"/>
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </template>
+ <newline/>
+ <template>
+ <match match="state"/>
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </template>
+ <newline/>
+ </children>
+ </template>
+ <template>
+ <match match="page"/>
+ <children>
+ <xpath allchildren="1"/>
+ </children>
+ </template>
+ <template>
+ <match match="state"/>
+ <children>
+ <text fixtext="State: "/>
+ <select ownvalue="1">
+ <properties size="0"/>
+ <selectoption description="New" value="new"/>
+ <selectoption description="Edited" value="edited"/>
+ <selectoption description="Reviewed" value="reviewed"/>
+ <selectoption description="Released" value="released"/>
+ </select>
+ <newline/>
+ <newline/>
+ </children>
+ </template>
+ </structure>
+ }}}
+
+ Now change your "file2html.xsl" stylesheet to reference these files instead of "content.xsd" and "content.sps".
+
+ {{{
+ <?xml version="1.0"?>
+ <xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:param name="file"></xsl:param>
+ <xsl:param name="sitemapURI"></xsl:param>
+ <xsl:param name="requestURI"></xsl:param>
+ <xsl:param name="serverName"></xsl:param>
+ <xsl:param name="serverPort"></xsl:param>
+
+ <xsl:template match="/page">
+ <html>
+ <body>
+ <OBJECT id="objPlugIn"
+ Classid="clsid:46987108-BA64-4fd1-A947-1BF7DA938FC0" width="700" height="500">
+ <xsl:attribute name="CodeBase">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>authentic/AuthenticBrowserEdition.cab</xsl:attribute>
+ <PARAM NAME="LicKey" VALUE="<YOUR LICENSE KEY>"/>
+ <PARAM NAME="LicServer">
+ <xsl:attribute name="VALUE">http://<xsl:value-of select="$serverName"/></xsl:attribute>
+ </PARAM>
+ <PARAM NAME="XMLDataURL">
+ <xsl:attribute name="VALUE">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>raw/<xsl:value-of select="$file"/></xsl:attribute>
+ </PARAM>
+ <PARAM NAME="XMLDataSaveURL">
+ <xsl:attribute name="VALUE">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>write/<xsl:value-of select="$file"/></xsl:attribute>
+ </PARAM>
+ <PARAM NAME="SPSDataURL">
+ <xsl:attribute name="VALUE">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>authentic/aggregation.sps</xsl:attribute>
+ </PARAM>
+ <PARAM NAME="SchemaDataURL">
+ <xsl:attribute name="VALUE">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>authentic/aggregation.xsd</xsl:attribute>
+ </PARAM>
+ <PARAM NAME="EntryHelpersEnabled" VALUE="TRUE"/>
+ <PARAM NAME="EntryHelperWindows" VALUE="3"/>
+ </OBJECT>
+ <br/>
+ <input type="button" name="submit1" value="Save" onClick="objPlugIn.SavePOST()"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ </xsl:stylesheet>
+ }}}
+
+ Now you already can edit your meta data together with your XML document.
+ Adjust your "stream2write.xsl" stylesheet to separate the data and metadata down the pipeline again:
+
+ {{{
+ <?xml version="1.0"?>
+ <xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:req="http://apache.org/cocoon/request/2.0"
+ xmlns:source="http://apache.org/cocoon/source/1.0">
+
+ <xsl:param name="file"></xsl:param>
+
+ <xsl:template match="/aggregation">
+ <page>
+ <xsl:apply-templates/>
+ </page>
+ </xsl:template>
+
+ <xsl:template match="page">
+ <source:write create="true">
+ <source:source><xsl:value-of select="$file"/></source:source>
+ <source:fragment>
+ <xsl:copy-of select="."/>
+ </source:fragment>
+ </source:write>
+ </xsl:template>
+
+ <xsl:template match="metapage">
+ <source:write create="true">
+ <source:source><xsl:value-of select="$file"/>.meta</source:source>
+ <source:fragment>
+ <xsl:copy-of select="."/>
+ </source:fragment>
+ </source:write>
+ </xsl:template>
+
+ </xsl:stylesheet>
+ }}}
+
+ Adjust your sitemap to exclude your ".meta" files from folder traversal like the "step4" sample is doing.
+
Page: http://wiki.cocoondev.org/Wiki.jsp?page=WebDAVWYSIWYG , version: 2 on Mon Oct 6 19:11:49 2003 by GuidoCasper
- * [RichEdit|WebDAVRichEdit]
+ * [RTE|WebDAVRTE]
Page: http://wiki.cocoondev.org/Wiki.jsp?page=GT2003RealBlocks , version: 4 on Mon Oct 6 19:03:13 2003 by AndreasHochsteger
- * How do we trace and debub dependencies?
? ^
+ * How do we trace and debug dependencies?
? ^
- (The blcok deployer reports on it's job)
? -
+ (The block deployer reports on it's job)
? +
Page: http://wiki.cocoondev.org/Wiki.jsp?page=WebDAVAuthentic , version: 4 on Mon Oct 6 19:20:46 2003 by GuidoCasper
- This works nice, but how am I supposed to edit my meta data you might ask.
+ This works nice, but how am I supposed to edit my meta data you might ask.\\
? ++
- Well, for once you can put a second form above or below the editing area.
+ Well, for once you can put a second form above or below the editing area.\\
? ++
Page: http://wiki.cocoondev.org/Wiki.jsp?page=WebDAVRTE , version: 1 on Mon Oct 6 19:14:15 2003 by GuidoCasper
New page created:
+ !!!RTE
+
+ RTE is a portability layer over the "designMode" attribute of IE and Mozilla's Midas API.
+
+ This tutorial shows you how to extends the "step4" sample of Cocoon's WebDAV block with RTE for WYSIWYG editing.
+
+ First copy the complete "step4" folder to "step6".
+
+ Within the "step6" folder create another folder named "rte".
+ Download the [rte.zip|http://www.kevinroth.com/rte/demo.htm] and extract it into this folder.
+
+ Adjust file2html.xsl to look like the following:
+
+ {{{
+ <xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:param name="file"></xsl:param>
+ <xsl:param name="sitemapURI"></xsl:param>
+ <xsl:param name="requestURI"></xsl:param>
+ <xsl:param name="serverName"></xsl:param>
+ <xsl:param name="serverPort"></xsl:param>
+ <xsl:template match="/page">
+ <html>
+ <head>
+ <title>Cross-Browser Rich Text Editor</title>
+ <style type="text/css">
+ .btnImage {cursor: pointer; cursor: hand;}
+ </style>
+ <base>
+ <xsl:attribute name="href">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>rte/</xsl:attribute>
+ </base>
+ </head>
+ <body>
+ <form method="post">
+ <xsl:attribute name="action"><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>write/<xsl:value-of select="$file"/></xsl:attribute>
+ <iframe id="testFrame" style="position: absolute; visibility: hidden; width: 0px; height: 0px;"/>
+ <p>Author:<br />
+ <input name="author" type="text" size="30" maxlength="30" value="{metapage/author}" />
+ </p>
+ <p>Category:<br />
+ <input name="category" type="text" size="30" maxlength="30" value="{metapage/category}" />
+ </p>
+ <p>State:<br />
+ <input name="state" type="text" size="30" maxlength="30" value="{metapage/state}" />
+ </p>
+ <p>Title:<br />
+ <input name="title" type="text" size="30" maxlength="30" value="{page/title}" />
+ </p>
+ <hr/>
+ <script language="JavaScript" type="text/javascript">
+ <xsl:attribute name="src"><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>rte/browserdetect.js</xsl:attribute>
+ </script>
+ <script language="JavaScript" type="text/javascript">
+ <xsl:attribute name="src"><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>rte/richtext.js</xsl:attribute>
+ </script>
+ <script language="JavaScript" type="text/javascript">
+ <xsl:comment>
+ function submitForm() {
+ try {
+ document.getElementById('para').value = document.getElementById('edit').contentWindow.document.body.innerHTML;
+ }
+ catch (e) {
+ document.getElementById('para').value = document.getElementById('edit').value;
+ }
+
+ document.getElementById('editor').submit();
+ }
+ Start();
+ //</xsl:comment>
+ </script>
+ <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
+ <iframe id="edit" width="510px" height="200px">
+ <xsl:attribute name="src">http://<xsl:value-of select="$serverName"/>:<xsl:value-of select="$serverPort"/><xsl:value-of select="substring-before($requestURI, $sitemapURI)"/>para/<xsl:value-of select="$file"/></xsl:attribute>
+ </iframe>
+ <textarea id="para" name="para" style="position: absolute; visibility: hidden; width: 0px; height: 0px;">abc</textarea>
+ <p><input type="submit" value="Submit" onclick="submitForm()"/></p>
+ </form>
+ </body>
+ </html>
+ </xsl:template>
+ </xsl:stylesheet>
+ }}}
+
+ Change all contents to contain only a single "para" element.
+
+ Within the richtext.js file uncomment this line
+
+ {{{
+ // document.writeln('<iframe id="edit" width="510px" height="200px"></iframe>');
+ }}}
+
+ and change the timeout to be called after 1000 ms
+
+ {{{
+ setTimeout("enableDesignMode()", 1000);
+ }}}
+
+ add the following match node to the sitemap
+
+ {{{
+ <map:match pattern="para/**">
+ <map:generate src="{global:staging}repo/{1}"/>
+ <map:transform src="{global:staging}styles/file2para.xsl"/>
+ <map:serialize type="html"/>
+ </map:match>
+ }}}
+
+ and adjust the "repo/**" match node to look like this:
+
+ {{{
+ <map:match pattern="repo/**">
+ <map:aggregate element="page" label="content">
+ <map:part src="cocoon:/page/{1}"/>
+ <map:part src="cocoon:/metapage/{1}"/>
+ </map:aggregate>
+ <map:transform src="{global:staging}styles/file2html.xsl">
+ <map:parameter name="file" value="{1}"/>
+ <map:parameter name="requestURI" value="{request:requestURI}"/>
+ <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
+ <map:parameter name="serverName" value="{request:serverName}"/>
+ <map:parameter name="serverPort" value="{request:serverPort}"/>
+ </map:transform>
+ <map:serialize type="html"/>
+ </map:match>
+ }}}
+
+ Create a file2para.xsl stylesheet
+
+ {{{
+ <?xml version="1.0"?>
+ <xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="/page">
+ <html>
+ <xsl:copy-of select="content/para/node()"/>
+ </html>
+ </xsl:template>
+ </xsl:stylesheet>
+ }}}
+
+ Declare the HTMLTransformer at the beginning of the sitemap
+
+ {{{
+ <map:transformers default="xalan">
+ <map:transformer name="html" src="org.apache.cocoon.transformation.HTMLTransformer">
+ <jtidy-config>jtidy-config.txt</jtidy-config>
+ </map:transformer>
+ </map:transformers>
+ }}}
+
+ "jtidy-config.txt" has to be created with the following content:
+
+ {{{
+ output-xhtml: no
+ tidy-mark: no
+ }}}
+
+ Modify the writing pipeline to contain the HTMLTransformer:
+
+ {{{
+ <map:match pattern="write/**">
+ <map:generate type="request" label="content"/>
+ <map:transform src="{global:staging}styles/request2doc.xsl"/>
+ <map:transform type="html">
+ <map:parameter name="tags" value="para"/>
+ </map:transform>
+ <map:transform src="{global:staging}styles/doc2write.xsl">
+ <map:parameter name="file" value="{global:staging}repo/{1}"/>
+ </map:transform>
+ <map:transform type="write-source"/>
+ <map:serialize type="xml"/>
+ </map:match>
+ }}}
+
+ As a last step you have to modify the "doc2write.xsl" stylesheet
+
+ {{{
+ <?xml version="1.0"?>
+ <xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:req="http://apache.org/cocoon/request/2.0"
+ xmlns:source="http://apache.org/cocoon/source/1.0">
+ <xsl:param name="file"></xsl:param>
+ <xsl:template match="request/parameters">
+ <page>
+ <source:write create="true">
+ <source:source><xsl:value-of select="$file"/></source:source>
+ <source:path>page</source:path>
+ <source:fragment>
+ <title><xsl:value-of select="title"/></title>
+ <content>
+ <xsl:for-each select="content/para">
+ <para>
+ <!--the following line is the one to change-->
+ <xsl:copy-of select="html/body/node()"/>
+ </para>
+ </xsl:for-each>
+ </content>
+ </source:fragment>
+ </source:write>
+ <source:write create="true">
+ <source:source><xsl:value-of select="$file"/>.meta</source:source>
+ <source:path>metapage</source:path>
+ <source:fragment>
+ <author><xsl:value-of select="author"/></author>
+ <category><xsl:value-of select="category"/></category>
+ <state><xsl:value-of select="state"/></state>
+ </source:fragment>
+ </source:write>
+ </page>
+ </xsl:template>
+ </xsl:stylesheet>
+ }}}
+
+ Finally add the following match node to the sitemap.
+
+ {{{
+ <map:match pattern="rte/**">
+ <map:read src="{global:staging}rte/{1}"/>
+ </map:match>
+ }}}
+