jeremy 02/02/22 14:15:35
Modified: src/scratchpad/webapp/mount/editor README sitemap.xmap
src/scratchpad/webapp/mount/editor/docs welcome.xml
src/scratchpad/webapp/mount/editor/stylesheets
simple-page2html.xsl
Added: src/scratchpad/webapp/mount/editor editor.xmap test.xmap
src/scratchpad/webapp/mount/editor/docs tests.xml xfwt.xml
src/scratchpad/webapp/mount/editor/editor/docs editor.xml
template.xml
src/scratchpad/webapp/mount/editor/editor/images dir.gif
file.gif get.gif new.gif view.gif
src/scratchpad/webapp/mount/editor/editor/stylesheets
editor-components.xsl editor-page2html.xsl
editor-utils.xsl simple-page2html.xsl
stream2xfwt.xsl
src/scratchpad/webapp/mount/editor/tests include-me.xml
make-page.xsl test1.xml test2.xml test3.xml
test4.xml test5.xml
Removed: src/scratchpad/webapp/mount/editor/docs include-me.xml
test1.xml test2.xml test3.xml test4.xml test5.xml
src/scratchpad/webapp/mount/editor/stylesheets
directory2html.xsl make-page.xsl
Log:
Everything moved around to incorporate a new demo file editor
Revision Changes Path
1.2 +5 -0 xml-cocoon2/src/scratchpad/webapp/mount/editor/README
Index: README
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/README,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- README 15 Feb 2002 21:38:59 -0000 1.1
+++ README 22 Feb 2002 22:15:34 -0000 1.2
@@ -29,6 +29,11 @@
BTW, the directory is called 'editor' because that is what I hope to turn it
into, with a few more components.
+To use this in your project, you need to add the 'editor' folder and
'editor.xmap' to your project, and add the 'editor pipelines' from the file
'sitemap.xmap' to your sitemap.
+
+Then you need to develop components for your particular document markup!
+ ie. StyleSheets that understand your documents, editor config for your
forms etc.
+ I'll go into this in more detail at a later date.
Thanks
1.2 +25 -60
xml-cocoon2/src/scratchpad/webapp/mount/editor/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/sitemap.xmap,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sitemap.xmap 15 Feb 2002 21:38:59 -0000 1.1
+++ sitemap.xmap 22 Feb 2002 22:15:34 -0000 1.2
@@ -1,38 +1,10 @@
<?xml version="1.0"?>
-<!-- This sitemap shows what is possible and what is not allowed. -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file"/>
- <map:serializers default="html">
-
- <!-- You can define your own Serializer for FileWritingTransformer to
use-->
-
- <map:serializer
- name="my-xml-serializer"
- mime-type="text/xml"
logger="sitemap.serializer.myxml"
-
src="org.apache.cocoon.serialization.XMLSerializer"
- >
-
<!--<doctype-system>urn:hrc:doc</doctype-system>-->
- <encoding>utf-8</encoding>
- <omit-xml-declaration>no</omit-xml-declaration>
- </map:serializer>
-
- </map:serializers>
- <map:transformers default="xslt">
-
- <!-- Define 'filewriter' as the name for FileWritingTransformer -->
- <!-- You can set up the default Serialiser here -->
- <!-- You can also set it in the invocation tag below -->
- <!-- or place serializer="serializer-name" in the xfwt:write tag -->
- <!-- if you leave it out altogether, 'xml' is used -->
-
- <map:transformer name="filewriter" logger="sitemap.transformer.tofile"
-
src="org.apache.cocoon.transformation.FileWritingTransformer">
- <serializer>my-xml-serializer</serializer>
- </map:transformer>
-
- </map:transformers>
+ <map:serializers default="html"/>
+ <map:transformers default="xslt"/>
<map:readers default="resource"/>
<map:matchers default="wildcard"/>
<map:selectors default="browser"/>
@@ -47,43 +19,36 @@
<map:redirect-to uri="welcome"/>
</map:match>
- <!-- the welcome page -->
- <map:match pattern="welcome">
- <map:generate src="docs/welcome.xml"/>
- <map:transform
src="stylesheets/simple-page2html.xsl"/>
- <map:serialize type="html"/>
- </map:match>
-
- <!-- the tests -->
- <map:match pattern="test*">
- <map:generate src="docs/test{1}.xml"/>
- <map:transform type="cinclude"/> <!-- only here
for test4 -->
- <map:transform type="filewriter"/> <!-- invoke
the filewriter -->
- <map:transform
src="stylesheets/simple-page2html.xsl">
- <map:parameter name="view-source"
value="docs/test{1}.xml"/>
- </map:transform>
- <map:serialize type="html"/>
+<!-- start EDITING PIPELINES -->
+<!-- We mount the Editor SiteMap into the same base as this SiteMap, so the
Editor can reach this SiteMap's files -->
+
+ <!-- slash-edit pipeline -->
+ <!-- edit/, edit/new, edit/get/*, edit/put/* -->
+ <map:match pattern="edit**">
+ <map:mount uri-prefix="edit" src="editor.xmap"
check-reload="yes"/>
</map:match>
- <!-- the results -->
- <map:match pattern="result*">
- <map:generate src="docs/result{1}.xml"/>
- <map:transform
src="stylesheets/simple-page2html.xsl">
- <map:parameter name="view-source"
value="docs/result{1}.xml"/>
- </map:transform>
- <map:serialize type="html"/>
+ <!-- test/result pipeline -->
+ <!-- /test/*, /result/*, result/*/* -->
+ <map:match pattern="*/**">
+ <map:mount uri-prefix="" src="test.xmap"
check-reload="yes"/>
</map:match>
- <!-- the result of test3 -->
- <map:match pattern="**result*">
- <map:generate src="docs/{1}result{2}.xml"/>
- <map:transform
src="stylesheets/simple-page2html.xsl">
- <map:parameter name="view-source"
value="docs/{1}result{2}.xml"/>
- </map:transform>
+<!-- end EDITING PIPELINES -->
+
+ <!-- view page -->
+ <map:match pattern="**">
+ <map:generate src="docs/{1}.xml"/>
+ <map:transform
src="stylesheets/simple-page2html.xsl"/>
<map:serialize type="html"/>
</map:match>
- </map:pipeline>
+ <map:handle-errors>
+ <map:transform
src="context://stylesheets/system/error2html.xsl"/>
+ <map:serialize status-code="500"/>
+ </map:handle-errors>
+
+ </map:pipeline>
</map:pipelines>
</map:sitemap>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor.xmap
Index: editor.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file"/>
<map:serializers default="html">
<!-- You can define your own Serializer for FileWritingTransformer to
use-->
<map:serializer
name="my-xml-serializer"
mime-type="text/xml"
logger="sitemap.serializer.myxml"
src="org.apache.cocoon.serialization.XMLSerializer"
>
<!--<doctype-system>urn:hrc:doc</doctype-system>-->
<encoding>utf-8</encoding>
<omit-xml-declaration>no</omit-xml-declaration>
<indent>2</indent>
</map:serializer>
</map:serializers>
<map:transformers default="xslt">
<!-- Define 'filewriter' as the name for FileWritingTransformer -->
<!-- You can set up the default Serialiser here -->
<!-- You can also set it in the invocation tag below -->
<!-- or place serializer="serializer-name" in the xfwt:write tag -->
<!-- if you leave it out altogether, 'xml' is used -->
<map:transformer name="filewriter" logger="sitemap.transformer.tofile"
src="org.apache.cocoon.transformation.FileWritingTransformer" label="xfwt">
<serializer>my-xml-serializer</serializer>
</map:transformer>
</map:transformers>
<map:readers default="resource"/>
<map:matchers default="wildcard"/>
<map:selectors default="browser"/>
</map:components>
<map:views>
<map:view name="content" from-label="content">
<map:serialize type="xml"/>
</map:view>
<map:view name="xfwt" from-label="xfwt">
<map:serialize type="xml"/>
</map:view>
</map:views>
<map:pipelines>
<map:pipeline internal-only="true">
<!-- internal pipelines, so aggregation can be used
with these components -->
<!-- directory listing, limited to the contents of your project's
'docs' folder -->
<map:match pattern="dir/**">
<map:generate type="directory" src="docs/{1}"/>
<!-- enforce the use of 'docs'-->
<map:serialize type="xml"/>
</map:match>
<!-- parse form data -->
<map:match pattern="stream">
<map:generate type="stream">
<map:parameter name="form-name"
value="content"/>
</map:generate>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
<map:pipeline>
<!-- the default page -->
<map:match pattern="">
<map:redirect-to uri="welcome"/>
</map:match>
<map:match pattern="/">
<map:redirect-to uri="welcome"/>
</map:match>
<map:match pattern="welcome">
<map:generate src="editor/docs/welcome.xml"/>
<map:transform
src="editor/stylesheets/simple-page2html.xsl"/>
<map:serialize type="html"/>
</map:match>
<!-- directory images -->
<map:match pattern="**image/*.gif">
<map:read src="editor/images/{2}.gif"
mime-type="image/gif"/>
</map:match>
<!--
The behaviour pipelines
Beware of the slashes added to the 'target-dir'
parameter.
The stylesheets expect to recieve directory
paths with a slash at either end,
so the Sitemap (who removed then dure to
matching technique) must replace them.
This is not the case for the 'put' behaviour,
the 'target-dir' parameter
arrived complete in a form field, it was not
derived by the sitemap.
Also be careful of the various places where use
of the parent sitemap's 'docs' folder is enforced
-->
<!-- view your site's pages in the editor -->
<map:match pattern="view/**/*">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part src="docs/{1}/{2}"/>
<!-- enforce the use of 'docs'-->
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-file"
value="{2}"/>
<map:parameter name="target-dir"
value="/{1}/"/>
<map:parameter name="behaviour"
value="view"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- view your site's pages in the editor, from root -->
<map:match pattern="view/*">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part src="docs/{1}"/>
<!-- enforce the use of 'docs'-->
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-file"
value="{1}"/>
<map:parameter name="target-dir"
value="/"/>
<map:parameter name="behaviour"
value="view"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the any directory -->
<map:match pattern="dir/**/">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part src="cocoon:/dir/{1}"/>
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-dir"
value="/{1}/"/>
<map:parameter name="behaviour"
value="dir"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the default directory -->
<map:match pattern="dir/">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part src="cocoon:/dir/"/>
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-dir"
value="/"/>
<map:parameter name="behaviour"
value="dir"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- make a new page with a form -->
<map:match pattern="new/**/*">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part
src="editor/docs/template.xml"/>
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-file"
value="{2}"/>
<map:parameter name="target-dir"
value="/{1}/"/>
<map:parameter name="behaviour"
value="new"/>
<map:parameter name="form-name"
value="content"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- make a new page with a form in the root -->
<map:match pattern="new/*">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part
src="editor/docs/template.xml"/>
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-file"
value="{1}"/>
<map:parameter name="target-dir"
value="/"/>
<map:parameter name="behaviour"
value="new"/>
<map:parameter name="form-name"
value="content"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the get a page as a form -->
<map:match pattern="get/**/*">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part src="docs/{1}/{2}"/>
<!-- enforce the use of 'docs'-->
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-file"
value="{2}"/>
<map:parameter name="target-dir"
value="/{1}/"/>
<map:parameter name="behaviour"
value="get"/>
<map:parameter name="form-name"
value="content"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the get a page as a form from the root -->
<map:match pattern="get/*">
<map:aggregate element="root" label="content">
<map:part src="editor/docs/editor.xml"/>
<map:part src="docs/{1}"/>
<!-- enforce the use of 'docs'-->
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter name="target-file"
value="{1}"/>
<map:parameter name="target-dir"
value="/"/>
<map:parameter name="behaviour"
value="get"/>
<map:parameter name="form-name"
value="content"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the post a page from a form -->
<!-- unlike the other matchers, this one receives 'complete' paths ie.
requires no addition of slashes -->
<map:match pattern="put">
<map:act type="request">
<map:parameter name="parameters"
value="true"/>
<map:aggregate element="root"
label="content">
<map:part
src="editor/docs/editor.xml"/>
<map:part src="cocoon:/stream"/>
</map:aggregate>
<map:transform
src="editor/stylesheets/stream2xfwt.xsl">
<map:parameter
name="target-file" value="{target-file}"/>
<map:parameter
name="target-dir" value="docs{target-dir}"/><!-- enforce saving in docs folder
of main project. Do not put a slash after docs, the target-dir already has the
correct ones -->
</map:transform>
<map:transform type="filewriter"/>
<map:transform
src="editor/stylesheets/editor-page2html.xsl">
<map:parameter
name="target-file" value="{target-file}"/>
<map:parameter
name="target-dir" value="{target-dir}"/>
<map:parameter name="behaviour"
value="put"/>
</map:transform>
<map:serialize type="html"/>
</map:act>
</map:match>
<map:handle-errors>
<!--<map:transform
src="context://stylesheets/system/error2html.xsl"/>
<map:serialize status-code="500"/>-->
<map:serialize type="xml" status-code="500"/>
</map:handle-errors>
<map:handle-errors type="404">
<map:transform
src="context://stylesheets/system/error2html.xsl"/>
<map:serialize/>
</map:handle-errors>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1 xml-cocoon2/src/scratchpad/webapp/mount/editor/test.xmap
Index: test.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file"/>
<map:serializers default="html">
<!-- You can define your own Serializer for FileWritingTransformer to
use-->
<map:serializer
name="my-xml-serializer"
mime-type="text/xml"
logger="sitemap.serializer.myxml"
src="org.apache.cocoon.serialization.XMLSerializer"
>
<!--<doctype-system>urn:hrc:doc</doctype-system>-->
<encoding>utf-8</encoding>
<omit-xml-declaration>no</omit-xml-declaration>
<indent>2</indent>
</map:serializer>
</map:serializers>
<map:transformers default="xslt">
<!-- Define 'filewriter' as the name for FileWritingTransformer -->
<!-- You can set up the default Serialiser here -->
<!-- You can also set it in the invocation tag below -->
<!-- or place serializer="serializer-name" in the xfwt:write tag -->
<!-- if you leave it out altogether, 'xml' is used -->
<map:transformer name="filewriter" logger="sitemap.transformer.tofile"
src="org.apache.cocoon.transformation.FileWritingTransformer">
<serializer>my-xml-serializer</serializer>
</map:transformer>
</map:transformers>
<map:readers default="resource"/>
<map:matchers default="wildcard"/>
<map:selectors default="browser"/>
</map:components>
<map:pipelines>
<map:pipeline>
<!-- the tests -->
<map:match pattern="test/4">
<map:generate src="tests/test4.xml"/>
<map:transform type="cinclude"/>
<map:transform type="filewriter"/>
<map:transform
src="stylesheets/simple-page2html.xsl">
<map:parameter name="view-source"
value="tests/test4.xml"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<map:match pattern="test/5">
<map:generate src="tests/test5.xml"/>
<map:transform src="tests/make-page.xsl"/>
<!--<map:transform type="log">
<map:parameter name="logfile"
value="test1.log"/>
<map:parameter name="append"
value="no"/>
</map:transform>-->
<map:transform type="filewriter">
<map:parameter name="serializer"
value="xml"/> <!-- invoke the filewriter with 'xml' serializer -->
</map:transform>
<map:transform
src="stylesheets/simple-page2html.xsl">
<map:parameter name="view-source"
value="tests/test5.xml"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<map:match pattern="test/*">
<map:generate src="tests/test{1}.xml"/>
<map:transform type="filewriter"/>
<map:transform
src="stylesheets/simple-page2html.xsl">
<map:parameter name="view-source"
value="tests/test{1}.xml"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the results -->
<map:match pattern="result/*">
<map:generate src="tests/result{1}.xml"/>
<map:transform
src="stylesheets/simple-page2html.xsl">
<map:parameter name="view-source"
value="tests/result{1}.xml"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
<!-- the result of test3 -->
<map:match pattern="result/*/*">
<map:generate src="tests/{1}/result{2}.xml"/>
<map:transform
src="stylesheets/simple-page2html.xsl">
<map:parameter name="view-source"
value="tests/{1}/result{2}.xml"/>
</map:transform>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
<!-- end of file -->
1.3 +10 -128
xml-cocoon2/src/scratchpad/webapp/mount/editor/docs/welcome.xml
Index: welcome.xml
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/docs/welcome.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- welcome.xml 16 Feb 2002 20:21:41 -0000 1.2
+++ welcome.xml 22 Feb 2002 22:15:35 -0000 1.3
@@ -1,132 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<page>
- <title>FileWritingTransformer</title>
- <content>
-
-
- <para>
- Uses the tag <pre><xfwt:write src="path-to-file"
[serializer="serializer-name"]/></pre>
- in the namespace
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0".
- </para>
-
- <para>
- The contents of this tag are Serialised to file when
the document containing it is transformed by FileWritingTransformer.
- </para>
-
- <para>
- SiteMap:
- </para>
-
- <para>
- FileWritingTransformer is defined using XML like this:
- </para>
-
- <para>
-<pre>
- <map:transformer name="filewriter"
logger="sitemap.transformer.filewriter"
-
src="org.apache.cocoon.transformation.FileWritingTransformer">
- [<serializer>my-xml-serializer</serializer>]
- </map:transformer>
-</pre>
- </para>
-
- <para>
- The default Serializer, if none is specified is 'xml'.
- You can specify the Serializer in 3 different places,
- SiteMap Definition, SiteMap Invocation and in the
'serializer attribute of the '<xfwt:write/>' Tag.
- In the examples, something surrounded by [ and ] is
optional.
- </para>
-
- <para>
- The Serializer you want to use has to be defined
somewhere in the SiteMap hierarchy,
- if you need a special one, set it up how you set up any
other Serializer.
- </para>
-
- <para>
-<pre>
- <map:serializer
- name="my-xml-serializer"
- mime-type="text/xml" logger="sitemap.serializer.myxml"
- src="org.apache.cocoon.serialization.XMLSerializer"
- >
- <encoding>utf-8</encoding>
- <omit-xml-declaration>no</omit-xml-declaration>
- </map:serializer>
-</pre>
- </para>
-
-
- <para>
- In the pipeline, you use XML like this to allow
FileWritingTransformer to do it's job,
- again specifying the Serializer to use here is optional.
- </para>
-
- <para>
-<pre>
- <map:transform type="filewriter">
- [<map:parameter name="serialiser"
value="my-xml-serialiser"/>]
- </map:transform>
-</pre>
- </para>
-
- <para>
- Document:
- </para>
-
- <para>
- Something like this XML Fragment somewhere in the
Document being processed,
- will result in an XML file being written at the
location specified,
- with the <page/> tag as the Document Root.
- </para>
-
- <para>
-<pre>
- <xfwt:write src="docs/result1.xml"
[serializer="my-xml-serializer"]>
- <page>
- <title>FileWritingTransformer Test Result
1</title>
- <content>
- <para>Congratulations!</para>
- </content>
- </page>
- </xfwt:write>
-</pre>
- </para>
-
- <para>
- This XMLFragment (or your equivalent) could have got
into the stream by any means available to the Cocoon2 SiteMap.
- Generation, Transformation, Aggregation, Inclusion etc.
- Again, the serializer attribute is optional.
- </para>
-
- <para>
- Tests: Please run these tests and report any problems.
- </para>
- <para>
- Test 1: <a href="test1">Test 1</a>: the basic test,
makes <a href="result1">Result 1</a>.
- </para>
- <para>
- Test 2: <a href="test2">Test 2</a>: the namespace test,
makes <a href="result2">Result 2</a>, with the XLink namespace used inside.
- </para>
- <para>
- Test 3: <a href="test3">Test 3</a>: the new folder
test, makes <a href="newfolder/result3">Result 3</a>, in a new folder.
- </para>
- <para>
- Test 4: <a href="test4">Test 4</a>: the XInclude test,
makes <a href="result4">Result 4</a>, having XIncluded the content earlier in
the pipeline.
- </para>
- <para>
- Test 5: <a href="test5">Test 5</a>: the XSLT test, a <a
href="../../view-source?filename=mount/editor/stylesheets/make-page.xsl">StyleSheet</a>
makes <a href="result5">Result 5</a>, from parts of <a href="test5">Test 5</a>.
- </para>
-
-
- <para>
- Known Problems:
- </para>
- <para>
- You get double NS declarations if the same NS exists in
the Generated and XIncluded document.
- </para>
- <para>
- The NS declaration for xfwt is always copied to the
output file.
- </para>
- </content>
+ <title>Experimental File Editing Pipelines</title>
+ <content>
+ <para>Please try the <a href="tests">tests</a>
+</para>
+ <para>Please try out the demo file editor <a
href="edit/"><slash-edit/></a>
+</para>
+ <para>This suite uses the <a href="xfwt">FileWritingTransformer</a>
+</para>
+
+ </content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/docs/tests.xml
Index: tests.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page>
<title>FileWritingTransformer Tests</title>
<content>
<para>
Tests: Please run these tests and report any problems.
</para>
<para>
Test 1: <a href="test/1">Test 1</a>: the basic test, makes <a
href="result/1">Result 1</a>.
</para>
<para>
Test 2: <a href="test/2">Test 2</a>: the namespace test, makes <a
href="result/2">Result 2</a>, with the XLink namespace used inside.
</para>
<para>
Test 3: <a href="test/3">Test 3</a>: the new folder test, makes <a
href="result/newfolder/3">Result 3</a>, in a new folder.
</para>
<para>
Test 4: <a href="test/4">Test 4</a>: the XInclude test, makes <a
href="result/4">Result 4</a>, having XIncluded the content earlier in the
pipeline.
</para>
<para>
Test 5: <a href="test/5">Test 5</a>: the XSLT test, a <a
href="../../view-source?filename=mount/editor/stylesheets/make-page.xsl">StyleSheet</a>
makes <a href="result/5">Result 5</a>, from parts of <a href="test/5">Test
5</a>.
</para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/docs/xfwt.xml
Index: xfwt.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page>
<title>FileWritingTransformer</title>
<content>
<para>Please try the <a href="tests">tests</a></para>
<para>
Uses the tag <pre><xfwt:write src="path-to-file"
[serializer="serializer-name"]/></pre>
in the namespace xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0".
</para>
<para>
The contents of this tag are Serialised to file when the document
containing it is transformed by FileWritingTransformer.
</para>
<para>
SiteMap:
</para>
<para>
FileWritingTransformer is defined using XML like this:
</para>
<para>
<pre>
<map:transformer name="filewriter" logger="sitemap.transformer.filewriter"
src="org.apache.cocoon.transformation.FileWritingTransformer">
[<serializer>my-xml-serializer</serializer>]
</map:transformer>
</pre>
</para>
<para>
The default Serializer, if none is specified is 'xml'.
You can specify the Serializer in 3 different places,
SiteMap Definition, SiteMap Invocation and in the 'serializer attribute of
the '<xfwt:write/>' Tag.
In the examples, something surrounded by [ and ] is optional.
</para>
<para>
The Serializer you want to use has to be defined somewhere in the SiteMap
hierarchy,
if you need a special one, set it up how you set up any other Serializer.
</para>
<para>
<pre>
<map:serializer
name="my-xml-serializer"
mime-type="text/xml" logger="sitemap.serializer.myxml"
src="org.apache.cocoon.serialization.XMLSerializer"
>
<encoding>utf-8</encoding>
<omit-xml-declaration>no</omit-xml-declaration>
</map:serializer>
</pre>
</para>
<para>
In the pipeline, you use XML like this to allow FileWritingTransformer to
do it's job,
again specifying the Serializer to use here is optional.
</para>
<para>
<pre>
<map:transform type="filewriter">
[<map:parameter name="serialiser" value="my-xml-serialiser"/>]
</map:transform>
</pre>
</para>
<para>
Document:
</para>
<para>
Something like this XML Fragment somewhere in the Document being
processed,
will result in an XML file being written at the location specified,
with the <page/> tag as the Document Root.
</para>
<para>
<pre>
<xfwt:write src="docs/result1.xml" [serializer="my-xml-serializer"]>
<page>
<title>FileWritingTransformer Test Result 1</title>
<content>
<para>Congratulations!</para>
</content>
</page>
</xfwt:write>
</pre>
</para>
<para>
This XMLFragment (or your equivalent) could have got into the stream by
any means available to the Cocoon2 SiteMap.
Generation, Transformation, Aggregation, Inclusion etc.
Again, the serializer attribute is optional.
</para>
<para>
Known Problems:
</para>
<para>If you have an error while editing an existing file, the file will
probably be trashed by the process.</para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/editor.xml
Index: editor.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<editor title="<slash-edit/>">
<!-- Use this file to modify the text the editor displays -->
<!-- if you want to change the names of the 'behaviours' make the same
changes in the editor.xmap! -->
<!-- Various display strings -->
<title behaviour="new">Make a new Page</title>
<title behaviour="get">Edit a Page</title>
<title behaviour="put">Save Results</title>
<title behaviour="view">View a Page</title>
<title behaviour="dir">Directory Listing</title>
<notify behaviour="new">Making a new File at</notify>
<notify behaviour="get">Editing the File at</notify>
<notify behaviour="put">Results of saving a file at</notify>
<notify behaviour="view">Viewing the File at</notify>
<notify behaviour="dir">Directory Listing of</notify>
<notes behaviour="new">Please edit the XML, then click the 'Make New
File' button below</notes>
<notes behaviour="get">Please edit the XML, then click the 'Save My
Changes' button below</notes>
<notes behaviour="put">Thanks for using <slash-edit/></notes>
<notes behaviour="view">This is the editor-view of your file, internal
links are not likely to work correctly.</notes>
<notes behaviour="dir">Please choose a file to view</notes>
<!-- The commands -->
<command behaviour="new" tip="Make a new File"
icon="new.gif">new</command>
<command behaviour="get" tip="Edit this File"
icon="get.gif">get</command>
<command behaviour="put">put</command>
<command behaviour="view" tip="View this File"
icon="view.gif">view</command>
<command behaviour="dir" tip="View Directory listing"
icon="dir.gif">dir</command>
<!-- text for form buttons -->
<button behaviour="new">Make New File</button>
<button behaviour="get">Save My Changes</button>
<!-- the tools available to each behaviour -->
<tools behaviour="new">
<tool command="dir"/>
<tool command="new"/>
</tools>
<tools behaviour="get">
<tool command="dir"/>
<tool command="new"/>
<tool command="view"/>
</tools>
<tools behaviour="put">
<tool command="dir"/>
<tool command="new"/>
<tool command="get"/>
<tool command="view"/>
</tools>
<tools behaviour="view">
<tool command="dir"/>
<tool command="new"/>
<tool command="get"/>
</tools>
<tools behaviour="dir">
<tool command="new"/>
</tools>
<!-- what to call the parent directory link -->
<parent-dir tip="View Parent Directory listing">..</parent-dir>
</editor>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/template.xml
Index: template.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page>
<title> - please write your title here - </title>
<content>
<para> - you can put in any number of paragraphs - </para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/images/dir.gif
<<Binary file>>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/images/file.gif
<<Binary file>>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/images/get.gif
<<Binary file>>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/images/new.gif
<<Binary file>>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/images/view.gif
<<Binary file>>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-components.xsl
Index: editor-components.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dir="http://apache.org/cocoon/directory/2.0"
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0">
<!-- your form for editing content -->
<xsl:template match="page" mode="form">
<form method="post">
<xsl:attribute name="action"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'put']/text()"/></xsl:attribute>
<table border="0" cellspacing="0" cellpadding="5"
width="100%">
<tr>
<td colspan="2"><textarea
name="{$form-name}" rows="20" cols="80" xml:space="preserve"
onchange="changed=true;"><xsl:apply-templates select="."/></textarea></td>
</tr>
<tr>
<td valign="middle">
<span class="caption">Save
as:</span> <input type="text" name="target-file" value="{$newfile}" size="40"
title="Note: to make a new directory, prepend the filename with a directory
path"/>
</td>
<td align="right">
<input type="hidden"
name="target-dir" value="{$target-dir}"/>
<input type="submit"
value="{$config/[EMAIL PROTECTED] = $behaviour]}"/>
</td>
</tr>
</table>
</form>
</xsl:template>
<!-- supply mode="view" templates for your project's document elements, used
only in view-mode -->
<xsl:template match="page" mode="view">
<div class="page"><xsl:apply-templates mode="view"/></div>
</xsl:template>
<xsl:template match="content" mode="view">
<div class="content"><xsl:apply-templates mode="view"/></div>
</xsl:template>
<xsl:template match="title" mode="view">
<h2><xsl:apply-templates/></h2>
</xsl:template>
<xsl:template match="para" mode="view">
<p><xsl:apply-templates/></p>
</xsl:template>
<!-- output the tools for this page -->
<xsl:template match="tools">
<xsl:for-each select="tool">
<xsl:variable name="com" select="@command"/>
<xsl:variable name="command" select="$config/[EMAIL
PROTECTED] = $com]"/>
<td width="20">
<a title="{$command/@tip}">
<xsl:attribute name="href">
<xsl:if test="$is-form =
'true'"><xsl:text>javascript:exit('</xsl:text></xsl:if>
<xsl:choose>
<xsl:when test="$com =
'dir'"><xsl:value-of select="$command-base"/><xsl:value-of
select="$command/text()"/><xsl:value-of select="$target-dir"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$command-base"/><xsl:value-of
select="$command/text()"/><xsl:value-of select="$target-path"/></xsl:otherwise>
</xsl:choose>
<xsl:if test="$is-form =
'true'"><xsl:text>');</xsl:text></xsl:if>
</xsl:attribute>
<img
src="{concat('image/',$command/@icon)}" border="0"/>
</a>
</td>
</xsl:for-each>
</xsl:template>
<!-- Displays the directory listing -->
<xsl:template match="dir:directory">
<table border="0" cellspacing="0" cellpadding="5" width="100%"
bgcolor="white">
<tr>
<td width="20">
<a href="../" title="{$config/parent-dir/@tip}">
<img src="{concat('image/',$config/[EMAIL PROTECTED] =
'dir']/@icon)}" border="0"/>
</a>
</td>
<td colspan="2">
<a href="../"
title="{$config/parent-dir/@tip}"><b><xsl:value-of
select="$config/parent-dir/text()"/></b></a>
</td>
<td><xsl:value-of select="@date"/></td>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<!-- Displays sub-directories -->
<xsl:template match="dir:directory/dir:directory">
<tr>
<td></td>
<td width="20" align="right">
<a href="[EMAIL PROTECTED]/" title="{$config/[EMAIL PROTECTED] =
'dir']/@tip}">
<img src="{concat('image/',$config/[EMAIL PROTECTED] = 'dir']/@icon)}"
border="0"/>
</a>
</td>
<td>
<a href="[EMAIL PROTECTED]/" title="{$config/[EMAIL PROTECTED] =
'dir']/@tip}"><xsl:value-of select="@name"/></a>
</td>
<td>
<xsl:value-of select="@date"/>
</td>
</tr>
</xsl:template>
<!-- Displays files in the directory listing -->
<xsl:template match="dir:file">
<tr>
<td></td>
<td width="20" align="right">
<a title="{$config/[EMAIL PROTECTED] = 'view']/@tip}">
<xsl:attribute name="href"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'view']/text()"/><xsl:value-of select="$target-path"/><xsl:value-of
select="@name"/></xsl:attribute>
<img src="{concat('image/',$config/[EMAIL PROTECTED] = 'view']/@icon)}"
border="0"/>
</a>
</td>
<td width="60%">
<a title="{$config/[EMAIL PROTECTED] = 'view']/@tip}">
<xsl:attribute name="href"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'view']/text()"/><xsl:value-of select="$target-path"/><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</td>
<td>
<xsl:value-of select="@date"/>
</td>
</tr>
</xsl:template>
<!-- outputs the response from FileWritingTransformer -->
<xsl:template match="xfwt:write">
<table border="0" cellspacing="0" cellpadding="5" width="100%">
<tr>
<td class="caption">Result</td>
<td class="result">
<span class="[EMAIL PROTECTED]">
<xsl:value-of select="@result"/>
</span>
</td>
</tr>
<xsl:if test="@result = 'failed'">
<tr>
<td class="caption">Error</td>
<td class="result">
<span class="[EMAIL PROTECTED]">
<xsl:value-of
select="text()"/>
</span>
</td>
</tr>
</xsl:if>
<tr>
<td class="caption">Source</td>
<td class="result">
<xsl:value-of select="@src"/>
</td>
</tr>
<tr>
<td class="caption">Action</td>
<td class="result">
<xsl:choose>
<xsl:when test="@action =
'new'">New file created</xsl:when>
<xsl:otherwise>Existing file
overwritten</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<tr>
<td class="caption">Serializer</td>
<td class="result">
<xsl:value-of select="@serializer"/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-page2html.xsl
Index: editor-page2html.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dir="http://apache.org/cocoon/directory/2.0"
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0">
<!--
This is the main Editor Stylesheet
It adapts itself to the particular command being sent in the
'behaviour' parameter.
It uses information stored in 'editor/docs/editor.xml' to work
out the commands, static strings etc.
-->
<xsl:include href="editor-utils.xsl"/>
<!-- utility templates and variables -->
<xsl:include href="editor-components.xsl"/>
<!-- special display templates -->
<xsl:template match="root">
<html>
<head>
<title><xsl:value-of select="$config/@title"/> - <xsl:value-of
select="$config/[EMAIL PROTECTED] = $behaviour]"/> - <xsl:value-of
select="title"/></title>
<xsl:if test="$is-form = 'true'">
<script lang="JavaScript"><![CDATA[
<!--
var changed = false;
function exit(to){
if (changed == true) {
if (confirm("Are you sure you
want to loose your changes?")) {
document.location.href
= to;
}
} else {
document.location.href = to;
}
//return false;
}//-->]]>
</script>
</xsl:if>
<style><![CDATA[
<!--
a{text-decoration:none}
a:hover{text-decoration:underline}
body{font-family : sans-serif,Arial,Tahoma;color:black;background-color
: white;}
form{font-size:12px;background:#0086B2}
.notify{font-size:15px;}
.notes{font-size:12px;font-weight:bold;color:white;background:#0086B2}
.result{font-size:12px;color:black}
.failure{font-size:12px;font-weight:bold;color:red}
.success{font-size:12px;color:black}
.caption{font-size:12px;font-weight:bold;color:black;}
textarea{font-size:12px;font-family :
geneva,arial,sans-serif;}
//-->]]>
</style>
</head>
<body> <center>
<h1> <xsl:value-of select="$config/@title"/> - site editor demo</h1>
<table border="0" cellspacing="1" cellpadding="0" bgcolor="#0086B2"
width="90%">
<tr>
<td>
<table border="0" cellspacing="0"
cellpadding="5" width="100%" bgcolor="white">
<tr>
<td
class="notify"><b><xsl:value-of select="$config/[EMAIL PROTECTED] =
$behaviour]"/>:</b> <xsl:value-of select="$target-path"/></td>
<xsl:apply-templates
select="$config/[EMAIL PROTECTED] = $behaviour]"/>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="white">
<xsl:choose>
<xsl:when test="$behaviour = 'new' or
$behaviour = 'get'"><xsl:apply-templates select="page" mode="form"/></xsl:when>
<xsl:when test="$behaviour =
'put'"><xsl:apply-templates select="xfwt:write"/></xsl:when>
<xsl:when test="$behaviour =
'view'"><xsl:apply-templates select="page" mode="view"/></xsl:when>
<xsl:when test="$behaviour =
'dir'"><xsl:apply-templates select="dir:directory"/></xsl:when>
<xsl:otherwise>Houston, we have a
problem.</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<tr>
<td>
<table border="0" cellspacing="0"
cellpadding="5" width="100%" bgcolor="white">
<tr>
<td
class="notes"><xsl:apply-templates select="$config/[EMAIL PROTECTED] =
$behaviour]"/></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
<!-- debug
<table>
<tr>
<td>target-file</td> <td><xsl:value-of
select="$target-file"/></td>
</tr>
<tr>
<td>target-dir</td> <td><xsl:value-of
select="$target-dir"/></td>
</tr>
<tr>
<td>behaviour</td> <td><xsl:value-of
select="$behaviour"/></td>
</tr>
<tr>
<td>form-name</td> <td><xsl:value-of
select="$form-name"/></td>
</tr>
</table> -->
<!-- / debug -->
<p align="center">
<font size="-1">
Copyright © 1999-2002 <a href="http://www.apache.org">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-utils.xsl
Index: editor-utils.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<!-- standard SiteMap parameters -->
<xsl:param name="target-file"/>
<xsl:param name="target-dir"/>
<xsl:param name="behaviour"/>
<xsl:param name="form-name"/>
<!-- the aggregated editor-config document -->
<xsl:variable name="config" select="/root/editor"/>
<!-- the relative base for commands -->
<xsl:variable name="command-base">
<xsl:if test="$behaviour != 'put'">
<xsl:call-template name="find-base">
<xsl:with-param name="dir"><xsl:value-of
select="$target-dir"/></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:variable>
<!-- Do we have a form on this page? -->
<xsl:variable name="is-form">
<xsl:choose>
<xsl:when test="$behaviour = 'get' or $behaviour =
'new'">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- the full target path, including filename, not including 'docs' -->
<xsl:variable name="target-path">
<xsl:value-of select="$target-dir"/><xsl:value-of
select="$target-file"/>
</xsl:variable>
<!-- what to give as the default name of a new file -->
<xsl:variable name="newfile">
<xsl:choose>
<xsl:when test="$target-file != ''"><xsl:value-of
select="$target-file"/></xsl:when>
<xsl:otherwise>new.xml</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- find the command base, relative to the current folder -->
<xsl:template name="find-base">
<xsl:param name="dir"/>
<xsl:param name="prefix"></xsl:param>
<xsl:choose>
<xsl:when test="$dir != ''">
<xsl:call-template name="find-base">
<xsl:with-param
name="dir"><xsl:value-of select="substring-after($dir,'/')"/></xsl:with-param>
<xsl:with-param
name="prefix"><xsl:value-of select="concat($prefix,'../')"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of
select="$prefix"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- copy anything -->
<xsl:template match="@*|node()"
priority="-2"><xsl:copy><xsl:apply-templates
select="@*|node()"/></xsl:copy></xsl:template>
<xsl:template match="text()" priority="-1"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/simple-page2html.xsl
Index: simple-page2html.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0"
>
<!-- this stylesheet is currently only used to display the
editor/edit/welcome page -->
<xsl:template match="page">
<html>
<head>
<title>
<xsl:value-of select="title"/>
</title>
<style><![CDATA[
<!--
a{text-decoration:none}
a:hover{text-decoration:underline}
body{font-family :
sans-serif,Arial,Tahoma;color:black;background-color : white;font-size:12px;}
td{font-family :
sans-serif,Arial,Tahoma;color:black;background-color : white;font-size:12px;}
//-->]]>
</style>
</head>
<body bgcolor="white">
<center>
<h1> <xsl:value-of select="title"/> - site editor demo</h1>
<table border="0" cellspacing="1" cellpadding="0" bgcolor="#0086B2"
width="90%">
<tr>
<td>
<table border="0" cellspacing="0"
cellpadding="5" width="100%" bgcolor="white">
<tr>
<td class="notify"><b>Welcome
to <slash-edit/></b></td>
<td width="20">
<a title="View
Directory listing" href="dir/"><img src="image/dir.gif" border="0"/></a>
</td>
<td width="20">
<a title="Make a new
File" href="new/"><img src="image/new.gif" border="0"/></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="white">
<xsl:apply-templates/>
</td>
</tr>
<tr>
<td>
<table border="0" cellspacing="0"
cellpadding="5" width="100%" bgcolor="white">
<tr>
<td class="notes">Thanks for
trying <slash-edit/></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
<p align="center">
<font size="-1">
Copyright © 1999-2002 <a href="http://www.apache.org">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="para">
<p align="left">
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="para/para">
<blockquote>
<p align="left">
<xsl:apply-templates/>
</p>
</blockquote>
</xsl:template>
<xsl:template match="@*|node()"
priority="-2"><xsl:copy><xsl:apply-templates
select="@*|node()"/></xsl:copy></xsl:template>
<xsl:template match="text()" priority="-1"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/stream2xfwt.xsl
Index: stream2xfwt.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0"
>
<xsl:include href="editor-utils.xsl"/>
<!--
You have to get pretty tricky with your XSL here to make sure
your XML indentation written to file is how you like it
-->
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="page">
<xfwt:write src="{$target-path}" xml:space="preserve">
<page><xsl:copy-of select="@*"/>
<title><xsl:value-of select="title[1]"/></title>
<content><xsl:copy-of select="content/@*"/>
<xsl:for-each select="content[1]/para"><para><xsl:copy-of
select="@*"/><xsl:apply-templates/></para>
</xsl:for-each>
</content>
</page>
</xfwt:write>
</xsl:template>
</xsl:stylesheet>
1.3 +1 -1
xml-cocoon2/src/scratchpad/webapp/mount/editor/stylesheets/simple-page2html.xsl
Index: simple-page2html.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/stylesheets/simple-page2html.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- simple-page2html.xsl 16 Feb 2002 20:21:41 -0000 1.2
+++ simple-page2html.xsl 22 Feb 2002 22:15:35 -0000 1.3
@@ -25,7 +25,7 @@
<xsl:choose>
<xsl:when test="$view-source">
<a>
- <xsl:attribute
name="href">../../view-source?filename=mount/editor/<xsl:value-of
select="$view-source"/></xsl:attribute>
+ <xsl:attribute
name="href">../../../view-source?filename=mount/editor/<xsl:value-of
select="$view-source"/></xsl:attribute>
<xsl:attribute
name="target">xfwt</xsl:attribute>
<xsl:apply-templates/>
</a>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/include-me.xml
Index: include-me.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page xmlns:xl="http://www.w3.org/1999/xlink">
<title>Include me in Test Result 4</title>
<content>
<para>This is an external file that is to be XIncluded by
'test4' to make a new document.</para>
<para>This is an element in the <link xl:to="nowhere">XLink
Namespace</link>.</para>
<para>
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</para><para>
Duis autem vel eum iriure dolor in hendrerit in
vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent
luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</para><para>
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</para><para>
Duis autem vel eum iriure dolor in hendrerit in
vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla
facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent
luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</para><para>
Nam liber tempor cum soluta nobis eleifend option
congue nihil imperdiet doming id quod mazim placerat facer possim assum.
</para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/make-page.xsl
Index: make-page.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0"
>
<xsl:template match="page">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="make-page">
<xfwt:write src="tests/result5.xml" xml:space="preserve">
<page xmlns:xl="http://www.w3.org/1999/xlink">
<title>Result from - <xsl:value-of select="/page/title"/></title>
<content>
<para>This file was assembled by XSLT from elements in <a
href="../../view-source?filename=mount/editor/docs/test5.xml">test5</a></para>
<para>Here are some paragraphs copied from there:
<import>
<xsl:for-each select="/page/content/para">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:for-each>
</import>
</para>
<para>And <link xl:to="nowhere">here</link> is another fake
XLink, for luck</para>
</content>
</page>
</xfwt:write>
</xsl:template>
<xsl:template match="@*|node()" priority="-2">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()" priority="-1"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/test1.xml
Index: test1.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0">
<title>FileWritingTransformer Test Page 1</title>
<content>
<para><b>Test</b>: Basic</para>
<para>This test should have written a file called result1.xml,
in the same directory as this.</para>
<para>The file's content should come from the xml below.</para>
<para>The XML is:</para>
<para>
<pre>
<xfwt:write src="tests/result1.xml">
<page>
<title>FileWritingTransformer Test Result
1</title>
<content>
<para>Congratulations!</para>
</content>
</page>
</xfwt:write>
</pre>
</para>
<xfwt:write src="tests/result1.xml">
<page>
<title>FileWritingTransformer Test Result 1</title>
<content>
<para>Congratulations!</para>
</content>
</page>
</xfwt:write>
<para>Have a <a href="../result/1">look!</a></para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/test2.xml
Index: test2.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0"
>
<title>FileWritingTransformer Test Page 2</title>
<content>
<para><b>Test</b>: Namespace</para>
<para>This test should have written a file called result2.xml,
in the same directory as this.</para>
<para>The file's content should come from the xml below.</para>
<para>The XML is:</para>
<para>
<pre>
<xfwt:write src="tests/result2.xml">
<page xmlns:xl="http://www.w3.org/1999/xlink">
<title>FileWritingTransformer Test Result 2</title>
<content>
<para>Congratulations!</para>
<para><link xl:to="test2">I am in the XLink
NameSpace</link></para>
</content>
</page>
</xfwt:write>
</pre>
</para>
<para>The namespace is: http://www.w3.org/1999/xlink</para>
<xfwt:write src="tests/result2.xml">
<page xmlns:xl="http://www.w3.org/1999/xlink">
<title>FileWritingTransformer Test Result 2</title>
<content>
<para>Congratulations!</para>
<para><link xl:to="test/2">I am in the XLink
NameSpace</link></para>
</content>
</page>
</xfwt:write>
<para>Have a <a href="../result/2">look!</a></para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/test3.xml
Index: test3.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page page="blah"
>
<title>FileWritingTransformer Test Page 3!!!!!</title>
<content>
<para><b>Test</b>: New Folder Test</para>
<para>This test should have written a file called result3.xml,
in a directory that did not originally exist.</para>
<para>The file's content should come from the xml below.</para>
<para>The XML is:</para>
<para>
<pre>
<xfwt:write src="tests/newfolder/result3.xml">
<page>
<title>FileWritingTransformer Test Result 3</title>
<content>
<para>Congratulations!</para>
</content>
</page>
</xfwt:write>
</pre>
</para>
<xfwt:write src="tests/newfolder/result3.xml"
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0">
<page>
<title>FileWritingTransformer Test Result 3</title>
<content>
<para>Congratulations!</para>
</content>
</page>
</xfwt:write>
<para>Have a <a href="../result/newfolder/3">look!</a></para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/test4.xml
Index: test4.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page
xmlns:xfwt="http://apache.org/cocoon/xfwt/1.0"
xmlns:ci="http://apache.org/cocoon/include/1.0"
>
<title>FileWritingTransformer Test Page 4</title>
<content>
<para><b>Test</b>: XInclude Test</para>
<para>This test should have written a file called result4.xml,
with the contents coming from the file <a
href="../../../view-source?filename=mount/editor/tests/include-me.xml"
target="xfwt">include-me.xml</a>.</para>
<para>The file's content is setup from the xml below.</para>
<para>The XML is:</para>
<para>
<pre>
<xfwt:write src="tests/result4.xml">
<ci:include src="tests/include.xml"/>
</xfwt:write>
</pre>
</para>
<xfwt:write src="tests/result4.xml">
<ci:include src="tests/include-me.xml"/>
</xfwt:write>
<para>Have a <a href="../result/4">look!</a></para>
</content>
</page>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/tests/test5.xml
Index: test5.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<page>
<title>FileWritingTransformer Test Page 5</title>
<content>
<para><b>Test</b>: XSLT Test</para>
<para>This test should have written a file called result5.xml,
with the contents being generated by a <a
href="../../../view-source?filename=mount/editor/tests/make-page.xsl"
target="xfwt">StyleSheet</a>.</para>
<para>This also tests setting the serializer from the
invocation of FileWritingTransformer in the SiteMap.</para>
<para>Anyway, the big issue here is that it is tricky to write
XSL that gives you a clean XML indentation in your file. You can probably see
how I have not quite got it right yet ;)</para>
<para>The file's content is setup from the xml below.</para>
<para>The XML is:</para>
<para>
<pre>
<make-page/>
</pre>
</para>
<make-page/>
<para>Have a <a href="../result/5">look!</a></para>
</content>
</page>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]