jeremy 02/03/17 08:10:26
Modified: src/scratchpad/webapp/mount/editor editor.xmap
src/scratchpad/webapp/mount/editor/editor/docs
bravo-config.xml welcome.xml
src/scratchpad/webapp/mount/editor/editor/stylesheets
dir2editor.xsl editor-alpha-components.xsl
editor-bravo-components.xsl editor-components.xsl
editor-page2html.xsl editor-utils.xsl
file2editor.xsl request2editor.xsl
stream2editor.xsl
Added: src/scratchpad/webapp/mount/editor/editor/docs
schematron-page.xml
src/scratchpad/webapp/mount/editor/editor/stylesheets
editor2writer.xsl schematron-extensions.xsl
schematron-validator2xsl.xsl
schematron-wrappers.xsl
Log:
added Schematron validation to both 'alpha' and 'bravo' editors
Revision Changes Path
1.5 +40 -30
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor.xmap
Index: editor.xmap
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor.xmap,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- editor.xmap 14 Mar 2002 19:59:17 -0000 1.4
+++ editor.xmap 17 Mar 2002 16:10:25 -0000 1.5
@@ -1,4 +1,5 @@
<?xml version="1.0"?>
+
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file">
@@ -14,23 +15,7 @@
src="org.apache.cocoon.generation.XPathDirectoryGenerator"
/>
</map:generators>
- <map:serializers default="html">
-
- <!--
-
- Define an xhtml Serializer
- In case you need people to edit HTML and have
it remain xml well-formed
-
- -->
- <map:serializer name="xhtml" mime-type="text/html"
-
src="org.apache.cocoon.serialization.XMLSerializer" pool-max="128"
- pool-min="32" pool-grow="8"
logger="sitemap.core">
- <doctype-public>-//W3C//DTD XHTML 1.0
Strict//EN</doctype-public>
-
<doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</doctype-system>
- <encoding>UTF-8</encoding>
- </map:serializer>
-
- </map:serializers>
+ <map:serializers default="html"/>
<map:transformers default="xslt">
<!--
@@ -39,7 +24,7 @@
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 source:write tag
- If you are using FileSource, you need to specify a Serializer.
+ NB. If you are using FileSource, you need to specify a
Serializer.
-->
<map:transformer name="sourcewriter" logger="sitemap.transformer.tofile"
@@ -66,8 +51,23 @@
</map:views>
<map:pipelines>
- <map:pipeline internal-only="true">
+ <map:pipeline internal-only="false">
+
+ <!--
+
+ Validating XSLT generator
+
+ Generates a Schematron Validating XSLT
+ from your schematron-[doctype].xml file
+
+ -->
+ <map:match pattern="make-validator(*)">
+ <map:generate
src="editor/docs/schematron-{1}.xml"/>
+ <map:transform
src="editor/stylesheets/schematron-validator2xsl.xsl"/>
+ <map:serialize type="xml"/>
+ </map:match>
+
<!--
Internal pipelines to collect and format the
appropriate content based on the requested behaviour and sub-editor
@@ -90,8 +90,8 @@
<map:match pattern="fetch-dir(*,**/*)">
<map:generate type="xpathdirectory"
src="docs{2}/#/page/title"/>
<map:transform
src="editor/stylesheets/dir2editor.xsl">
- <map:parameter name="sub-editor"
value="{1}"/>
- <map:parameter name="target-path"
value="{2}/"/>
+ <map:parameter name="sub" value="{1}"/>
+ <map:parameter name="target"
value="{2}/"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
@@ -107,8 +107,9 @@
<map:match pattern="fetch-new(*,**)">
<map:generate src="editor/docs/template.xml"/>
<!-- get a template -->
<map:transform
src="editor/stylesheets/file2editor.xsl">
- <map:parameter name="sub-editor"
value="{1}"/>
- <map:parameter name="target-path"
value="{2}"/>
+ <map:parameter name="behaviour"
value="new"/>
+ <map:parameter name="sub" value="{1}"/>
+ <map:parameter name="target"
value="{2}"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
@@ -124,15 +125,19 @@
NB. Do not put a slash at the end of the base
parameter,
the target-path already has the correct ones
-->
+
<map:match pattern="fetch-put(alpha,**)">
<map:act type="request">
<map:parameter name="parameters"
value="true"/>
<map:generate type="stream">
- <map:parameter name="form-name"
value="xml-field"/>
+ <map:parameter name="form-name"
value="{xml-field-name}"/>
</map:generate>
<map:transform
src="editor/stylesheets/stream2editor.xsl">
- <map:parameter
name="sub-editor" value="alpha"/>
- <map:parameter
name="target-path" value="{target-path}"/>
+ <map:parameter name="sub"
value="alpha"/>
+ <map:parameter name="target"
value="{target}"/>
+ </map:transform>
+ <map:transform
src="cocoon:/make-validator(page)"/>
+ <map:transform
src="editor/stylesheets/editor2writer.xsl">
<map:parameter name="base"
value="docs"/>
</map:transform>
<map:transform type="sourcewriter"/>
@@ -155,7 +160,10 @@
<map:match pattern="fetch-put(bravo,**)">
<map:generate type="request"/>
<map:transform
src="editor/stylesheets/request2editor.xsl">
- <map:parameter name="sub-editor"
value="bravo"/>
+ <map:parameter name="sub"
value="bravo"/>
+ </map:transform>
+ <map:transform
src="cocoon:/make-validator(page)"/>
+ <map:transform
src="editor/stylesheets/editor2writer.xsl">
<map:parameter name="base"
value="docs"/>
</map:transform>
<map:transform type="sourcewriter"/>
@@ -175,8 +183,9 @@
<map:match pattern="fetch-*(*,**)">
<map:generate src="docs{3}"/>
<map:transform
src="editor/stylesheets/file2editor.xsl">
- <map:parameter name="sub-editor"
value="{2}"/>
- <map:parameter name="target-path"
value="{3}"/>
+ <map:parameter name="behaviour"
value="{1}"/>
+ <map:parameter name="sub" value="{2}"/>
+ <map:parameter name="target"
value="{3}"/>
<map:parameter name="form-name"
value="xml-field"/><!-- this is only needed by 'alpha' editor -->
</map:transform>
<map:serialize type="xml"/>
@@ -218,12 +227,13 @@
-->
<map:match pattern="*(*)**">
- <map:aggregate element="{1}" label="agg">
+ <map:aggregate element="slash-edit" label="agg">
<map:part
src="editor/docs/{2}-config.xml"/>
<map:part
src="cocoon:/fetch-{1}({2},{3})"/>
</map:aggregate>
<map:transform
src="editor/stylesheets/editor-page2html.xsl"/>
<map:serialize type="xhtml"/>
+ <!--<map:serialize type="xml"/>-->
</map:match>
<!-- generic error handlers -->
1.3 +2 -2
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/bravo-config.xml
Index: bravo-config.xml
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/bravo-config.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bravo-config.xml 14 Mar 2002 19:59:17 -0000 1.2
+++ bravo-config.xml 17 Mar 2002 16:10:25 -0000 1.3
@@ -18,8 +18,8 @@
<notify behaviour="see">Viewing the Document at</notify>
<notify behaviour="dir">Directory Listing of</notify>
- <notes behaviour="new">Please edit the XML, then click the 'Make New
Document' button above</notes>
- <notes behaviour="get">Please edit the XML, then click the 'Save My
Changes' button above</notes>
+ <notes behaviour="new">Please edit the fields, then click the 'Make New
Document' button above</notes>
+ <notes behaviour="get">Please edit the fields, then click the 'Save My
Changes' button above</notes>
<notes behaviour="put">Thanks for using <slash-edit/></notes>
<notes behaviour="see">This is the editor-view of your Document,
internal links are not likely to work correctly.</notes>
<notes behaviour="dir">Please choose a Document to view in the
editor</notes>
1.5 +17 -2
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/welcome.xml
Index: welcome.xml
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/welcome.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- welcome.xml 14 Mar 2002 19:59:17 -0000 1.4
+++ welcome.xml 17 Mar 2002 16:10:25 -0000 1.5
@@ -62,6 +62,8 @@
<para>
You make adjustments to the editor.xmap incase your project's
files do not reside in 'docs'.
</para><para>
+ You make any necessary adjustments to the template and schema
in editor/docs to cope with the structure of the documents you use in your
project (the samples use cocoon's 'simple-page' style).
+ </para><para>
You make any necessary adjustments to the stylesheets in
editor/stylesheets to cope with the structure of the documents you use in your
project (the samples use cocoon's 'simple-page' style).
</para><para>
You make any stylistic adjustments required to how the editors
look.
@@ -71,6 +73,19 @@
That's the plan, anyway!
</para>
</para>
+ <para>
+ Schema Validation
+ <para>
+ <slash-edit/> now uses Schematron to validate
your XML.
+ </para><para>
+ Schematron allows you to write a simple xml file
describing a set of rules your document should follow, and messages to send to
the user when it does'nt.
+ This document gets transformed by Schematron's XSLT
files into an XSLT that does the actual validation on your document. This
process is handled dynamically by an internal pipeline, and gets cached
appropriately.
+ </para><para>
+ When an error in validation occurs, <slash-edit/>
now sends you back a form with some error messages, to try again. It still
needs a lot of cleaning up though!
+ </para><para>
+ Many thanks to Ivelin Ivanov for his assistance in
getting this working.
+ </para>
+ </para>
<para>
<table>
<tr>
@@ -89,7 +104,7 @@
<td></td><td>StreamGenerator</td><td>Generates
XML by parsing a named form field in the Request</td>
</tr>
<tr valign="top">
- <td></td><td>RequestGenerator</td><td>Generates
XMLfrom the form fields in the Request</td>
+ <td></td><td>RequestGenerator</td><td>Generates
XMLfrom the form fields in the Request, it does not Parse, so fields cannot
contain XML.</td>
</tr>
</table>
</para>
@@ -101,7 +116,7 @@
<td>  </td><td>dir</td><td>your-project/edit/<b>dir(sub-editor)</b>/path/to/directory/</td><td>gives
you a directory listing</td>
</tr>
<tr valign="top">
-
<td></td><td>see</td><td>your-project/edit/<b>see(sub-editor)</b>/path/to/file</td><td>lets
you see your page within the editor (it is not going to look the same, outside
the context of your project)</td>
+
<td></td><td>see</td><td>your-project/edit/<b>see(sub-editor)</b>/path/to/file</td><td>lets
you see your page within the editor (it is not going to look the same, outside
the context of your project and links are unlikely to work)</td>
</tr>
<tr valign="top">
<td></td><td>get</td><td>your-project/edit/<b>get(sub-editor)</b>/path/to/file</td><td>converts
the file into an HTML Form for editing</td>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/docs/schematron-page.xml
Index: schematron-page.xml
===================================================================
<?xml version="1.0" ?>
<!--
Schematron schema for the slash-edit
originally copied from work by:
Ivelin Ivanov, [EMAIL PROTECTED]
-->
<schema ns="http://xml.apache.cocoon/page"
xmlns="http://www.ascc.net/xml/schematron">
<title>Schema for <slash-edit/></title>
<pattern name="Page Validation Pattern">
<rule context="page">
<assert test="count(title) > 0">There should be a
title tag.</assert>
<assert test="count(title) < 2">There only should
be one title tag.</assert>
<assert test="count(content) > 0">There should be
one content tag.</assert>
<assert test="count(content) < 2">There only should
be one content tag.</assert>
</rule>
<rule context="title">
<assert test="string-length(.) > 3">The title
should be at least 4 characters.</assert>
<assert test="string-length(.) < 40">The title
should be less than 30 characters.</assert>
<assert test="text() != ' - please write your title
here - '">Your title is a bit boring! ;-)</assert>
</rule>
<rule context="content">
<assert test="para">There should be at least one para
tag.</assert>
<assert test="para[1]/text() != ' - you can put in any
number of paragraphs - '">Oh do try and make your content a little more
interesting! ;-).</assert>
</rule>
</pattern>
</schema>
1.3 +8 -6
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/dir2editor.xsl
Index: dir2editor.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/dir2editor.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dir2editor.xsl 14 Mar 2002 19:59:17 -0000 1.2
+++ dir2editor.xsl 17 Mar 2002 16:10:25 -0000 1.3
@@ -5,14 +5,16 @@
xmlns:dir="http://apache.org/cocoon/directory/2.0"
>
- <xsl:param name="sub-editor"/>
- <xsl:param name="target-path"/>
+ <xsl:param name="sub"/>
+ <xsl:param name="target"/>
<xsl:template match="/">
- <editor sub-editor="{$sub-editor}" target-path="{$target-path}">
- <xsl:copy>
- <xsl:apply-templates select="@*|*"/>
- </xsl:copy>
+ <editor sub="{$sub}">
+ <instance behaviour="dir" target="{$target}">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|*"/>
+ </xsl:copy>
+ </instance>
</editor>
</xsl:template>
<!-- copy anything -->
1.3 +29 -18
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-alpha-components.xsl
Index: editor-alpha-components.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-alpha-components.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- editor-alpha-components.xsl 14 Mar 2002 19:59:17 -0000 1.2
+++ editor-alpha-components.xsl 17 Mar 2002 16:10:25 -0000 1.3
@@ -8,24 +8,35 @@
<!-- your form for editing 'page' doctype content, handles the 'alpha'
sub-editor for 'get' and 'new' behaviours -->
- <xsl:template match="/get/[EMAIL PROTECTED] = 'alpha']/page|/new/[EMAIL
PROTECTED] = 'alpha']/page" mode="sub-editor">
- <form method="post">
- <xsl:attribute name="action"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'put']"/></xsl:attribute>
- <table border="0" cellspacing="0" cellpadding="5"
width="100%">
- <tr>
- <td colspan="2"><textarea
name="{$config/xml-field-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-path" 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="xml-field-name" value="{$config/xml-field-name}"/>
- <input type="submit"
value="{$config/[EMAIL PROTECTED] = $behaviour]}"/>
- </td>
- </tr>
- </table>
- </form>
+ <xsl:template match="[EMAIL PROTECTED]'alpha']/[EMAIL PROTECTED]'get'
or @behaviour='new']/page" mode="sub-editor">
+ <br/>
+ <table bgcolor="#0086B2" border="0" cellspacing="1"
cellpadding="5">
+ <tr>
+ <td class="block-title" colspan="2">Alpha
Editor</td>
+ </tr>
+ <tr>
+ <td bgcolor="white">
+ <form method="post">
+ <xsl:attribute
name="action"><xsl:value-of select="$command-base"/><xsl:value-of
select="$config/[EMAIL PROTECTED] = 'put']"/></xsl:attribute>
+ <table border="0"
cellspacing="0" cellpadding="5" width="100%">
+ <tr>
+ <td
colspan="2"><span class="block-title">File content: </span><br/><textarea
name="{$config/xml-field-name}" rows="20" cols="80" xml:space="preserve"
onchange="changed=true;"><xsl:apply-templates select="."/> </textarea></td>
+ </tr>
+ <tr>
+ <td
valign="middle">
+ <span
class="block-title">Save as: </span><br/><input type="text" name="target"
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="xml-field-name" value="{$config/xml-field-name}"/>
+ <input
class="submit" type="submit" value="{$config/[EMAIL PROTECTED] = $behaviour]}"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </table>
+ <br/>
</xsl:template>
1.3 +31 -20
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-bravo-components.xsl
Index: editor-bravo-components.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-bravo-components.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- editor-bravo-components.xsl 14 Mar 2002 19:59:17 -0000 1.2
+++ editor-bravo-components.xsl 17 Mar 2002 16:10:25 -0000 1.3
@@ -6,26 +6,37 @@
xmlns:source="http://apache.org/cocoon/source/1.0">
<!-- your form for editing 'page' doctype content, handles the 'bravo'
sub-editor for 'get' and 'new' behaviours -->
- <xsl:template match="/get/[EMAIL PROTECTED] = 'bravo']/page|/new/[EMAIL
PROTECTED] = 'bravo']/page" mode="sub-editor">
- <form method="post">
- <xsl:attribute name="action"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'put']"/></xsl:attribute>
- <table border="0" cellspacing="0" cellpadding="5"
width="100%">
- <tr>
- <td><span class="caption">Title</span>
<input name="title" size="40" onchange="changed=true;"
value="{normalize-space(title)}"/></td>
- </tr>
- <tr>
- <td colspan="2"><textarea
name="content" rows="20" cols="80" xml:space="preserve"
onchange="changed=true;"><xsl:apply-templates select="content/*"
mode="bravo"/></textarea></td>
- </tr>
- <tr>
- <td valign="middle">
- <span class="caption">Save
as:</span> <input type="text" name="target-path" value="{$newfile}" size="40"
title="Note: to make a new directory, prepend the filename with a directory
path"/>
- </td>
- <td align="right">
- <input type="submit"
value="{$config/[EMAIL PROTECTED] = $behaviour]}"/>
- </td>
- </tr>
- </table>
- </form>
+ <xsl:template match="[EMAIL PROTECTED]'bravo']/[EMAIL PROTECTED]'get'
or @behaviour='new']/page" mode="sub-editor">
+ <br/>
+ <table bgcolor="#0086B2" border="0" cellspacing="1"
cellpadding="5">
+ <tr>
+ <td class="notes" colspan="2">Bravo Editor</td>
+ </tr>
+ <tr>
+ <td bgcolor="white">
+ <form method="post">
+ <xsl:attribute
name="action"><xsl:value-of select="$command-base"/><xsl:value-of
select="$config/[EMAIL PROTECTED] = 'put']"/></xsl:attribute>
+ <table border="0"
cellspacing="0" cellpadding="5" width="100%">
+ <tr>
+ <td><span
class="block-title">Title: </span><br/><input name="title" size="40"
onchange="changed=true;" value="{normalize-space(title)}"/></td>
+ </tr>
+ <tr>
+ <td
colspan="2"><span class="block-title">Body: </span><br/><textarea
name="content" rows="20" cols="80" xml:space="preserve"
onchange="changed=true;"><xsl:apply-templates select="content/*" mode="bravo"/>
</textarea></td>
+ </tr>
+ <tr>
+ <td
valign="middle">
+ <span
class="block-title">Save as: </span><br/><input type="text" name="target"
value="{$newfile}" size="40" title="Note: to make a new directory, prepend the
filename with a directory path"/>
+ </td>
+ <td
align="right">
+ <input
class="submit" type="submit" value="{$config/[EMAIL PROTECTED] = $behaviour]}"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </table>
+ <br/>
</xsl:template>
<xsl:template match="para" mode="bravo"><!-- also strips 'br' tags, so
they need a CR after them to survive! -->
1.5 +99 -49
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-components.xsl
Index: editor-components.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-components.xsl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- editor-components.xsl 14 Mar 2002 19:59:17 -0000 1.4
+++ editor-components.xsl 17 Mar 2002 16:10:25 -0000 1.5
@@ -8,12 +8,16 @@
<!-- generic behaviour templates -->
- <xsl:template match="/*/editor/*" mode="sub-editor">
+ <xsl:template match="instance/*" mode="sub-editor">
<xsl:apply-templates select="."/>
</xsl:template>
- <xsl:template match="/see/editor/page" mode="sub-editor">
- <xsl:apply-templates mode="editor-view"/>
+ <xsl:template match="[EMAIL PROTECTED]'see']/page" mode="sub-editor">
+ <br/>
+ <table border="0" cellspacing="2" cellpadding="0" width="95%"
bgcolor="white">
+ <tr><td><xsl:apply-templates mode="editor-view"/></td></tr>
+ </table>
+ <br/>
</xsl:template>
@@ -31,9 +35,11 @@
<p><xsl:apply-templates/></p>
</xsl:template>
+
<!-- Displays the directory listing -->
<xsl:template match="dir:directory">
- <table border="0" cellspacing="2" cellpadding="0" width="100%"
bgcolor="white">
+ <br/>
+ <table border="0" cellspacing="2" cellpadding="0" width="95%"
bgcolor="white">
<tr>
<td width="20">
<a href="../" title="{$config/parent-dir/@tip}">
@@ -48,12 +54,13 @@
</tr>
<xsl:apply-templates/>
</table>
+ <br/>
</xsl:template>
<!-- Displays sub-directories -->
<xsl:template match="dir:directory/dir:directory">
<tr>
- <xsl:if test="position() mod 2 = 0"><xsl:attribute
name="bgcolor">#EEFFFF</xsl:attribute></xsl:if>
+ <xsl:if test="position() mod 2 = 0"><xsl:attribute
name="class">row</xsl:attribute></xsl:if>
<td></td>
<td width="20" align="right">
<a href="[EMAIL PROTECTED]/" title="{$config/[EMAIL PROTECTED] =
'dir']/@tip}">
@@ -73,17 +80,17 @@
<!-- Displays files in the directory listing -->
<xsl:template match="dir:file">
<tr>
- <xsl:if test="position() mod 2 = 0"><xsl:attribute
name="bgcolor">#EEFFFF</xsl:attribute></xsl:if>
+ <xsl:if test="position() mod 2 = 0"><xsl:attribute
name="class">row</xsl:attribute></xsl:if>
<td></td>
<td width="20" align="right">
<a title="{$config/[EMAIL PROTECTED] = 'see']/@tip}">
- <xsl:attribute name="href"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'see']/text()"/><xsl:value-of select="$target-path"/><xsl:value-of
select="@name"/></xsl:attribute>
+ <xsl:attribute name="href"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'see']/text()"/><xsl:value-of select="$target"/><xsl:value-of
select="@name"/></xsl:attribute>
<img src="{concat('image/',$config/[EMAIL PROTECTED] = 'see']/@icon)}"
border="0"/>
</a>
</td>
<td width="40%">
<a title="{$config/[EMAIL PROTECTED] = 'see']/@tip}">
- <xsl:attribute name="href"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'see']/text()"/><xsl:value-of select="$target-path"/><xsl:value-of
select="@name"/></xsl:attribute>
+ <xsl:attribute name="href"><xsl:value-of
select="$command-base"/><xsl:value-of select="$config/[EMAIL PROTECTED] =
'see']/text()"/><xsl:value-of select="$target"/><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</td>
@@ -95,56 +102,99 @@
</td>
</tr>
</xsl:template>
+
+ <xsl:template match="validationResult">
+ <br/>
+ <table bgcolor="#0086B2" border="0" cellspacing="1"
cellpadding="5" width="95%">
+ <tr>
+ <td class="notes" colspan="2">Schematron
Validation</td>
+ </tr>
+ <tr>
+ <td bgcolor="white">
+ <table border="0" cellspacing="1"
cellpadding="3">
+ <tr>
+ <td
class="caption">Scheme</td>
+ <td
class="result"><xsl:value-of select="pattern/@name"/></td>
+ </tr>
+ <tr>
+ <td
class="caption">Result</td>
+ <td class="result">
+ <xsl:choose>
+
<xsl:when test="pattern/error"><span class="failure">failure</span></xsl:when>
+
<xsl:otherwise><span class="success">success</span></xsl:otherwise>
+ </xsl:choose>
+ </td>
+ </tr>
+ <xsl:for-each
select="pattern/error">
+ <tr>
+ <td
class="caption"><xsl:value-of select="path"/></td>
+ <td
class="result"><xsl:value-of select="message"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
<!-- outputs the response from WriteableSourceTransformer -->
<xsl:template match="source:write">
- <table border="0" cellspacing="0" cellpadding="5" width="100%">
+ <br/>
+ <table bgcolor="#0086B2" border="0" cellspacing="1"
cellpadding="5" width="95%" class="report">
<tr>
- <td class="caption">Result</td>
- <td class="result">
- <span class="[EMAIL PROTECTED]">
- <xsl:value-of select="@result"/>
- </span>
- </td>
+ <td class="notes" colspan="2">Writing to
Source</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 bgcolor="white">
+ <table bgcolor="white" border="0"
cellspacing="1" cellpadding="3">
+ <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 = 'none'">None taken</xsl:when>
+
<xsl:when test="@action = 'new'">New file created</xsl:when>
+
<xsl:when test="@action = 'overwritten'">Existing file overwritten</xsl:when>
+
<xsl:otherwise>Unknown</xsl:otherwise>
+ </xsl:choose>
+ </td>
+ </tr>
+ <xsl:if test="@serializer">
+ <tr>
+ <td
class="caption">Serializer</td>
+ <td
class="result">
+
<xsl:value-of select="@serializer"/>
+ </td>
+ </tr>
+ </xsl:if>
+ </table>
</td>
</tr>
- <xsl:if test="@action">
- <tr>
- <td class="caption">Action</td>
- <td class="result">
- <xsl:choose>
- <xsl:when test="@action
= 'none'">None taken</xsl:when>
- <xsl:when test="@action
= 'new'">New file created</xsl:when>
- <xsl:when test="@action
= 'overwritten'">Existing file overwritten</xsl:when>
-
<xsl:otherwise>Unknown</xsl:otherwise>
- </xsl:choose>
- </td>
- </tr>
- </xsl:if>
- <xsl:if test="@serializer">
- <tr>
- <td class="caption">Serializer</td>
- <td class="result">
- <xsl:value-of
select="@serializer"/>
- </td>
- </tr>
- </xsl:if>
</table>
+ <br/>
</xsl:template>
</xsl:stylesheet>
1.5 +34 -18
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-page2html.xsl
Index: editor-page2html.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-page2html.xsl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- editor-page2html.xsl 14 Mar 2002 19:59:17 -0000 1.4
+++ editor-page2html.xsl 17 Mar 2002 16:10:25 -0000 1.5
@@ -2,9 +2,13 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:sch="http://www.ascc.net/xml/schematron"
+ xmlns:zvon="http://zvon.org/schematron"
+ xmlns:request="http://xml.apache.org/cocoon/requestgenerator/2.0"
+
>
-
-
+
+
<!--
This is the main Editor Stylesheet
It adapts itself to the particular command being sent in the
structure of the XML.
@@ -17,10 +21,10 @@
<xsl:include href="editor-bravo-components.xsl"/>
<!-- "bravo" sub-editor display templates -->
<!-- add your "sub-editors" here -->
- <xsl:template match="get|new|see|put|dir">
+ <xsl:template match="slash-edit">
<html>
<head>
- <title><xsl:value-of select="$config/@title"/> - <xsl:value-of
select="$config/[EMAIL PROTECTED] = $behaviour]"/> - <xsl:value-of
select="$target-path"/></title>
+ <title><xsl:value-of select="$config/@title"/> - <xsl:value-of
select="$config/[EMAIL PROTECTED] = $behaviour]"/> - <xsl:value-of
select="$target"/></title>
<xsl:if test="$is-form = 'true'">
<script lang="JavaScript"><![CDATA[
var changed = false;
@@ -34,6 +38,7 @@
}
//return false;
}]]>
+ <xsl:if
test="editor/validationResult/pattern/error">changed = true;</xsl:if>
</script>
</xsl:if>
@@ -42,25 +47,30 @@
a:hover{text-decoration:underline;color:red}
body{font-size:12px;font-family:sans-serif,Arial,Tahoma;color:black;background:white;}
h1{font-size:18px;font-weight:bold;font-family:sans-serif,Arial,Tahoma;color:black;background:white;}
- form{font-size:12px;background:#0086B2}
+ form{font-size:12px}
.notify{font-size:15px;background:white;}
.notes{font-size:12px;font-weight:bold;color:white;background:#0086B2}
.result{font-size:12px;color:black;background:white}
.failure{font-size:12px;font-weight:bold;color:red}
- .success{font-size:12px;color:black}
+ .success{font-size:12px;font-weight:bold;color:green}
.caption{font-size:12px;font-weight:bold;color:black;}
- textarea{font-size:12px;font-family :
geneva,arial,sans-serif;}
+
textarea{background-color:#EEFFFF;font-size:12px;font-family :
geneva,arial,sans-serif;border-color:#0086B2;border-width:1px;padding;1px;}
+
input{background-color:#EEFFFF;font-size:12px;font-family :
geneva,arial,sans-serif;font-weight;border-color:#0086B2;border-width:1px;padding-left;3px;}
+
input.submit{background-color:#0086B2;font-size:12px;font-family:geneva,arial,sans-serif;border-color:black;border-width:1px;padding;10px;font-weight:bold;color:white;}
+
.block-title{font-size:12px;font-weight:bold;color:white;background:#0086B2;padding:4px;}
+ .row{background:#EEFFFF;}
+
]]>
</style>
</head>
<body> <center>
- <h1> <xsl:value-of select="$config/@title"/> - site editor
demo</h1>
+ <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 bgcolor="white">
- <td
class="notify"><b><xsl:value-of select="$config/[EMAIL PROTECTED] =
$behaviour]"/>:</b> <xsl:value-of select="$target-path"/></td>
+ <tr>
+ <td
class="notify"><b><xsl:value-of select="$config/[EMAIL PROTECTED] =
$behaviour]"/> : </b> <xsl:value-of select="$target"/></td>
<xsl:apply-templates
select="$config/[EMAIL PROTECTED] = $behaviour]"/>
</tr>
</table>
@@ -68,17 +78,20 @@
</tr>
<tr>
<td bgcolor="white">
+ <center>
+ <xsl:apply-templates
select="editor/validationResult"/>
<xsl:choose>
<!-- add your "sub-editors" here -->
- <xsl:when test="[EMAIL PROTECTED] =
'alpha']"><xsl:apply-templates select="editor/*" mode="sub-editor"/></xsl:when>
- <xsl:when test="[EMAIL PROTECTED] =
'bravo']"><xsl:apply-templates select="editor/*" mode="sub-editor"/></xsl:when>
- <xsl:otherwise>Houston, we have a
problem.</xsl:otherwise>
+ <xsl:when test="[EMAIL PROTECTED] =
'alpha']"><xsl:apply-templates select="editor/instance/*"
mode="sub-editor"/></xsl:when>
+ <xsl:when test="[EMAIL PROTECTED] =
'bravo']"><xsl:apply-templates select="editor/instance/*"
mode="sub-editor"/></xsl:when>
+ <xsl:otherwise><h1
class="failure">Houston, we have a problem.</h1></xsl:otherwise>
</xsl:choose>
+ </center>
</td>
</tr>
<tr>
<td>
- <table border="0" cellspacing="0"
cellpadding="5" width="100%" bgcolor="white">
+ <table border="0" cellspacing="0"
cellpadding="5" width="100%">
<tr>
<td
class="notes"><xsl:apply-templates select="$config/[EMAIL PROTECTED] =
$behaviour]"/></td>
</tr>
@@ -88,9 +101,9 @@
</table>
</center>
- <!-- debug <table>
+ <!-- debug <table>
<tr>
- <td>target-path</td> <td><xsl:value-of
select="$target-path"/></td>
+ <td>target</td> <td><xsl:value-of
select="$target"/></td>
</tr>
<tr>
<td>command-base</td> <td><xsl:value-of
select="$command-base"/></td>
@@ -98,7 +111,10 @@
<tr>
<td>behaviour</td> <td><xsl:value-of
select="$behaviour"/></td>
</tr>
- </table> -->
+ <tr>
+ <td>old-behaviour</td>
<td><xsl:value-of select="$old-behaviour"/></td>
+ </tr>
+ </table> -->
<!-- / debug -->
<p align="center">
@@ -123,7 +139,7 @@
<xsl:if test="$is-form =
'true'"><xsl:text>javascript:exit('</xsl:text></xsl:if>
<xsl:choose>
<xsl:when test="$com =
'new'"><xsl:value-of select="$command-base"/><xsl:value-of
select="$command/text()"/><xsl:value-of select="$newfile"/></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:otherwise><xsl:value-of select="$command-base"/><xsl:value-of
select="$command/text()"/><xsl:value-of select="$target"/></xsl:otherwise>
</xsl:choose>
<xsl:if test="$is-form =
'true'"><xsl:text>');</xsl:text></xsl:if>
1.4 +11 -8
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-utils.xsl
Index: editor-utils.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor-utils.xsl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- editor-utils.xsl 14 Mar 2002 19:59:17 -0000 1.3
+++ editor-utils.xsl 17 Mar 2002 16:10:25 -0000 1.4
@@ -4,17 +4,20 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
- <xsl:variable name="target-path" select="/*/editor/@target-path"/>
- <xsl:variable name="behaviour" select="local-name(/*)"/>
+ <xsl:variable name="sub" select="/slash-edit/editor/@sub"/>
+ <xsl:variable name="target"
select="/slash-edit/editor/instance/@target"/>
+ <xsl:variable name="behaviour"
select="/slash-edit/editor/instance/@behaviour"/>
+ <xsl:variable name="old-behaviour"><xsl:value-of
select="/slash-edit/editor/instance/@old-behaviour"/></xsl:variable><!-- darn!
this is a hack! -->
+ <xsl:variable name="form-name"
select="/slash-edit/editor/instance/@form-name"/>
<!-- the aggregated editor-config document -->
- <xsl:variable name="config" select="/*/config"/>
+ <xsl:variable name="config" select="/slash-edit/config"/>
<!-- the relative base for commands -->
<xsl:variable name="command-base">
- <xsl:if test="$behaviour != 'put'">
+ <xsl:if test="$behaviour != 'put' and $old-behaviour != 'put'">
<xsl:call-template name="find-base">
- <xsl:with-param name="path"><xsl:value-of
select="$target-path"/></xsl:with-param>
+ <xsl:with-param name="path"><xsl:value-of
select="$target"/></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:variable>
@@ -30,9 +33,9 @@
<!-- what to give as the default name of a new file -->
<xsl:variable name="newfile">
<xsl:choose>
- <xsl:when test="$target-path = '/'"><xsl:value-of
select="$target-path"/><xsl:value-of
select="$config/default-new-file"/></xsl:when>
- <xsl:when
test="substring($target-path,string-length($target-path)) = '/'"><xsl:value-of
select="$target-path"/><xsl:value-of
select="$config/default-new-file"/></xsl:when>
- <xsl:when test="$target-path != ''"><xsl:value-of
select="$target-path"/></xsl:when>
+ <xsl:when test="$target = '/'"><xsl:value-of
select="$target"/><xsl:value-of select="$config/default-new-file"/></xsl:when>
+ <xsl:when
test="substring($target,string-length($target)) = '/'"><xsl:value-of
select="$target"/><xsl:value-of select="$config/default-new-file"/></xsl:when>
+ <xsl:when test="$target != ''"><xsl:value-of
select="$target"/></xsl:when>
<xsl:otherwise><xsl:value-of
select="$config/default-new-file"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
1.3 +13 -9
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/file2editor.xsl
Index: file2editor.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/file2editor.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- file2editor.xsl 14 Mar 2002 19:59:17 -0000 1.2
+++ file2editor.xsl 17 Mar 2002 16:10:25 -0000 1.3
@@ -4,18 +4,22 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
- <xsl:param name="sub-editor"/>
- <xsl:param name="target-path"/>
+ <xsl:param name="sub"/>
+ <xsl:param name="target"/>
+ <xsl:param name="behaviour"/>
+ <xsl:param name="form-name"/>
- <xsl:template match="page">
- <editor sub-editor="{$sub-editor}" target-path="{$target-path}">
- <xsl:copy>
- <xsl:apply-templates select="@*|*" mode="copy"/>
- </xsl:copy>
+ <xsl:template match="/">
+ <editor sub="{$sub}">
+ <instance behaviour="{$behaviour}" target="{$target}"
form-name="{$form-name}">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|*"/>
+ </xsl:copy>
+ </instance>
</editor>
</xsl:template>
<!-- copy anything -->
- <xsl:template match="@*|node()" mode="copy"><xsl:copy><xsl:apply-templates
select="@*|node()" mode="copy"/></xsl:copy></xsl:template>
- <xsl:template match="text()" mode="copy"><xsl:value-of
select="."/></xsl:template>
+ <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates
select="@*|node()"/></xsl:copy></xsl:template>
+ <xsl:template match="text()"><xsl:value-of select="."/></xsl:template>
</xsl:stylesheet>
1.3 +39 -44
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/request2editor.xsl
Index: request2editor.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/request2editor.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- request2editor.xsl 14 Mar 2002 19:59:17 -0000 1.2
+++ request2editor.xsl 17 Mar 2002 16:10:25 -0000 1.3
@@ -2,14 +2,15 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:source="http://apache.org/cocoon/source/1.0"
- xmlns:request="http://xml.apache.org/cocoon/requestgenerator/2.0"
+ xmlns:request="http://xml.apache.org/cocoon/requestgenerator/2.0"
>
+ <xsl:param name="sub"/>
+
<!--
This StyleSheet converts the output of the RequestGenerator into the
new 'page'
- then wraps it with 'source:write' tags, so the SourceWritingTransformer
can save it.
+ then wraps it with 'editor' tags.
It looks for double CRs in the submitted text and makes paragraphs from
them using the 'para' tag.
It then looks inside the paragraphs for single CRs and inserts a 'br'
tag if found.
@@ -21,59 +22,53 @@
-->
-
- <xsl:param name="sub-editor"/>
- <xsl:variable name="target-path"
select="/request:request/request:requestParameters/request:[EMAIL PROTECTED] =
'target-path']/request:value"/>
- <xsl:param name="base"/>
-
-
<xsl:template match="/">
-<editor sub-editor="{$sub-editor}" target-path="{$target-path}">
-<source:write src="{concat($base,$target-path)}" xml:space="preserve">
-<page>
- <title><xsl:value-of
select="request:request/request:requestParameters/request:[EMAIL PROTECTED] =
'title']/request:value"/></title>
- <content>
- <xsl:call-template name="cr2para">
- <xsl:with-param name="text"><xsl:value-of
select="translate(request:request/request:requestParameters/request:[EMAIL
PROTECTED] = 'content']/request:value,'	
','')"/></xsl:with-param>
- </xsl:call-template>
- </content>
-</page>
-</source:write>
+<editor sub="{$sub}">
+<instance behaviour="put"
target="{request:request/request:requestParameters/request:[EMAIL PROTECTED] =
'target']/request:value}">
+<page><xsl:text>
+ </xsl:text><title><xsl:value-of
select="request:request/request:requestParameters/request:[EMAIL PROTECTED] =
'title']/request:value"/></title><xsl:text>
+ </xsl:text><content><xsl:text>
+ </xsl:text><xsl:call-template name="cr2para">
+ <xsl:with-param name="text"><xsl:value-of
select="translate(request:request/request:requestParameters/request:[EMAIL
PROTECTED] = 'content']/request:value,'	
','')"/></xsl:with-param>
+ </xsl:call-template>
+ </content><xsl:text>
+</xsl:text></page>
+</instance>
</editor>
</xsl:template>
<!-- convert double CRs to 'para' tags -->
<xsl:template name="cr2para">
- <xsl:param name="text"/>
- <xsl:choose>
- <xsl:when
test="normalize-space(substring-before($text,'

')) != ''">
- <para><xsl:call-template name="cr2br"><xsl:with-param
name="text"><xsl:value-of
select="substring-before($text,'

')"/></xsl:with-param></xsl:call-template></para>
- <xsl:text>
- </xsl:text>
- <xsl:call-template name="cr2para">
- <xsl:with-param name="text"><xsl:value-of
select="substring-after($text,'

')"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="normalize-space($text) != ''">
- <para><xsl:call-template name="cr2br"><xsl:with-param
name="text"><xsl:value-of
select="$text"/></xsl:with-param></xsl:call-template></para>
- </xsl:when>
- </xsl:choose>
+ <xsl:param name="text"/>
+ <xsl:choose>
+ <xsl:when test="normalize-space(substring-before($text,'

')) !=
''">
+ <para><xsl:call-template name="cr2br"><xsl:with-param
name="text"><xsl:value-of
select="substring-before($text,'

')"/></xsl:with-param></xsl:call-template></para>
+ <xsl:text>
+ </xsl:text>
+ <xsl:call-template name="cr2para">
+ <xsl:with-param name="text"><xsl:value-of
select="substring-after($text,'

')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="normalize-space($text) != ''">
+ <para><xsl:call-template name="cr2br"><xsl:with-param
name="text"><xsl:value-of
select="$text"/></xsl:with-param></xsl:call-template></para>
+ </xsl:when>
+ </xsl:choose>
</xsl:template>
<!-- convert single CRs to 'br' tags -->
<xsl:template name="cr2br">
- <xsl:param name="text"/>
- <xsl:choose>
- <xsl:when
test="normalize-space(substring-before($text,'
')) != ''">
+ <xsl:param name="text"/>
+ <xsl:choose>
+ <xsl:when test="normalize-space(substring-before($text,'
')) != ''">
<xsl:value-of
select="normalize-space(substring-before($text,'
'))"/><br/>
<xsl:text>
-</xsl:text>
- <xsl:call-template name="cr2br">
- <xsl:with-param name="text"><xsl:value-of
select="substring-after($text,'
')"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="normalize-space($text) != ''"><xsl:value-of
select="$text"/></xsl:when>
- </xsl:choose>
+</xsl:text>
+ <xsl:call-template name="cr2br">
+ <xsl:with-param name="text"><xsl:value-of
select="substring-after($text,'
')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="normalize-space($text) != ''"><xsl:value-of
select="$text"/></xsl:when>
+ </xsl:choose>
</xsl:template>
1.3 +8 -20
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/stream2editor.xsl
Index: stream2editor.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/stream2editor.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- stream2editor.xsl 14 Mar 2002 19:59:17 -0000 1.2
+++ stream2editor.xsl 17 Mar 2002 16:10:25 -0000 1.3
@@ -2,35 +2,23 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:source="http://apache.org/cocoon/source/1.0"
>
+ <xsl:param name="sub"/>
+ <xsl:param name="target"/>
<!--
- This StyleSheet converts the output of the StreamGenerator into the new
'page'
- then wraps it with 'source:write' tags, so the SourceWritingTransformer
can save it.
-
- NB. the indentation of these templates effects the output document
+ This StyleSheet copies the output of the StreamGenerator into the
'editor'
-->
-
- <xsl:param name="sub-editor"/>
- <xsl:param name="target-path"/>
- <xsl:param name="base"/>
-<xsl:template match="page">
-<editor sub-editor="{$sub-editor}" target-path="{$target-path}">
-<source:write src="{concat($base,$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>
-</source:write>
+<xsl:template match="/">
+<editor sub="{$sub}">
+<instance behaviour="put" target="{$target}">
+<xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
+</instance>
</editor>
</xsl:template>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/editor2writer.xsl
Index: editor2writer.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:zvon="http://zvon.org/schematron"
xmlns:request="http://xml.apache.org/cocoon/requestgenerator/2.0"
>
<xsl:param name="base"/>
<!--
This StyleSheet converts the output of the Validator and wraps it
with 'source:write' tags, so the SourceWritingTransformer can save it
only if there have been no validation errors.
NB. the indentation of these templates effects the output document
NB. it can get tricky to decide which namespaces need to be in which
stylesheet,
to make sure the wrong ones don't end up being written to source
-->
<xsl:template match="editor">
<editor sub="[EMAIL PROTECTED]">
<xsl:choose>
<xsl:when test="validationResult/pattern/error">
<instance behaviour="get" old-behaviour="put"
target="{instance/@target}" form-name="{instance/@form-name}">
<xsl:apply-templates select="instance/*"/>
</instance>
</xsl:when>
<xsl:otherwise>
<instance behaviour="{instance/@behaviour}"
target="{instance/@target}"><source:write
src="{concat($base,instance/@target)}" xml:space="preserve"
xmlns:source="http://apache.org/cocoon/source/1.0">
<xsl:apply-templates select="instance/*"/>
</source:write></instance>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="validationResult"/>
</editor>
</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/schematron-extensions.xsl
Index: schematron-extensions.xsl
===================================================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:aaa="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:zvon="http://zvon.org/schematron">
<xsl:template name="fullPath">
<aaa:template match="*|@*" mode="fullPath">
<aaa:apply-templates select="parent::*" mode="fullPath"/>
<aaa:text>/</aaa:text>
<aaa:if test="count(. | ../@*) = count(../@*)">@</aaa:if>
<aaa:value-of select="name()"/>
<aaa:if test="preceding-sibling::*[name()=name(current())] or
following-sibling::*[name()=name(current())]">
<aaa:text>[</aaa:text>
<aaa:value-of
select="1+count(preceding-sibling::*[name()=name(current())])"/>
<aaa:text>]</aaa:text>
</aaa:if>
</aaa:template>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/schematron-validator2xsl.xsl
Index: schematron-validator2xsl.xsl
===================================================================
<!-- sch:key moved as a child of sch:schema and syntax changed to xslt
usage -->
<!--
This stylesheet is derived from the original work of Miloslav Nic [ [EMAIL
PROTECTED] ]
http://www.zvon.org/xxl/SchematronTutorial/General/contents.html
It is offered in its current form by Ivelin Ivanov [ [EMAIL PROTECTED] ]
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:aaa="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:zvon="http://zvon.org/schematron">
<xsl:import href="schematron-wrappers.xsl"/>
<xsl:import href="schematron-extensions.xsl"/>
<xsl:namespace-alias stylesheet-prefix="aaa" result-prefix="xsl"/>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="outputMethod">xml</xsl:param>
<!-- root of an XML Form document -->
<xsl:variable name="docRoot">/editor/instance/*</xsl:variable>
<xsl:key name="PHASE" match="sch:phase" use="sch:active/@pattern"/>
<xsl:template name="sch-pattern">
<xsl:apply-templates select="/sch:schema/sch:[EMAIL PROTECTED]/sch:[EMAIL
PROTECTED] = current()/@id]"/>
<xsl:apply-templates select="sch:p"/>
<aaa:apply-templates select="." mode="{generate-id(.)}"/>
</xsl:template>
<xsl:template match="sch:pattern">
<xsl:call-template name="patternWrapper"/>
</xsl:template>
<xsl:template match="sch:rule[not(@abstract='yes')]">
<xsl:variable name="md" select="generate-id(parent::sch:pattern)"/>
<aaa:template match="[EMAIL PROTECTED]" mode="{$md}" priority="10">
<xsl:apply-templates select="*|//sch:[EMAIL PROTECTED]'yes' and @id =
current()/sch:extends/@rule]/*"/>
<aaa:apply-templates select="*|@*" mode="{$md}"/>
</aaa:template>
</xsl:template>
<xsl:template match="sch:key" mode="defineKey">
<aaa:key name="[EMAIL PROTECTED]" match="[EMAIL PROTECTED]" use="[EMAIL
PROTECTED]"/>
<!-- <aaa:key name="[EMAIL PROTECTED]"
match="{parent::sch:rule/@context}" use="[EMAIL PROTECTED]"/> -->
</xsl:template>
<xsl:template match="sch:report | sch:assert">
<xsl:variable name="startNOT">
<xsl:if test="self::sch:assert">not(</xsl:if>
</xsl:variable>
<xsl:variable name="endNOT">
<xsl:if test="self::sch:assert">)</xsl:if>
</xsl:variable>
<aaa:if test="[EMAIL PROTECTED]">
<xsl:call-template name="reportAssertWrapper"/>
</aaa:if>
</xsl:template>
<xsl:template match="@*" mode="addAttributes">
<xsl:copy/>
</xsl:template>
<xsl:template match="sch:name">
<xsl:choose>
<xsl:when test="@zvon:fullPath='yes'">
<aaa:apply-templates select="." mode="fullPath"/>
</xsl:when>
<xsl:otherwise><aaa:value-of select="name([EMAIL PROTECTED])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sch:schema">
<aaa:template match="{$docRoot}">
<xsl:call-template name="documentWrapper"/>
<xsl:call-template name="schemaDiagnosticWrapper"/>
</aaa:template>
<xsl:apply-templates select="sch:pattern/sch:rule"/>
</xsl:template>
<xsl:template match="sch:schema" mode="process">
<xsl:apply-templates select="sch:p | sch:pattern[$phase='#ALL'] |
sch:pattern[key('PHASE',@id)/@id = $phase]"/>
</xsl:template>
<xsl:template match="sch:schema" mode="diagnostic">
<xsl:apply-templates select="sch:diagnostics/sch:diagnostic"/>
<xsl:apply-templates select="sch:pattern" mode="diagnostics"/>
</xsl:template>
<xsl:template match="sch:pattern" mode="diagnostics">
<xsl:for-each
select="sch:rule[sch:report/@diagnostics|sch:assert/@diagnostics]">
<aaa:template match="[EMAIL PROTECTED]"
mode="dia_{generate-id(parent::sch:pattern)}" priority="10">
<xsl:for-each select="sch:[EMAIL PROTECTED] | sch:[EMAIL PROTECTED]">
<xsl:variable name="startNOT">
<xsl:if test="self::sch:assert">not(</xsl:if>
</xsl:variable>
<xsl:variable name="endNOT">
<xsl:if test="self::sch:assert">)</xsl:if>
</xsl:variable>
<aaa:if test="[EMAIL PROTECTED]">
<xsl:call-template name='outputDiagnosticAssertReportWrapper'/>
</aaa:if>
</xsl:for-each>
</aaa:template>
</xsl:for-each>
</xsl:template>
<xsl:template name="diagnosticItems">
<xsl:param name="value"/>
<xsl:variable name="start" select="substring-before($value,' ')"/>
<xsl:choose>
<xsl:when test="$start=''">
<aaa:call-template name="diagnostic_{$value}"/>
</xsl:when>
<xsl:otherwise>
<aaa:call-template name="diagnostic_{$start}"/>
<xsl:call-template name="diagnosticItems">
<xsl:with-param name="value" select="substring-after($value,' ')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sch:diagnostic">
<aaa:template name="[EMAIL PROTECTED]">
<xsl:call-template name="diagnosticWrapper"/>
</aaa:template>
</xsl:template>
<xsl:template match="sch:value-of">
<aaa:value-of select="[EMAIL PROTECTED]"/>
</xsl:template>
<xsl:template match="*"/>
<xsl:template name='applyRules'>
<aaa:apply-templates select="{$docRoot}" mode="{generate-id(.)}"/>
</xsl:template>
<xsl:template match="/">
<aaa:stylesheet version="1.0" >
<xsl:for-each select="/sch:schema/namespace::*">
<xsl:variable name="prefix" select="name()"/>
<xsl:if test="not($prefix='xml' or $prefix='')">
<xsl:attribute name="{$prefix}:{$prefix}" namespace="{.}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="/sch:schema/sch:ns">
<xsl:if test="not(@prefix='xml' or @prefix='')">
<xsl:attribute name="[EMAIL PROTECTED]:[EMAIL PROTECTED]"
namespace="[EMAIL PROTECTED]">
<xsl:value-of select="@uri"/>
</xsl:attribute>
</xsl:if>
</xsl:for-each>
<aaa:output method="{$outputMethod}" indent="yes"/>
<xsl:apply-templates select="/sch:schema/sch:key" mode="defineKey"/>
<xsl:apply-templates select="sch:schema"/>
<xsl:for-each select="/sch:schema/sch:pattern">
<aaa:template match="text()" mode="{generate-id()}"/>
<aaa:template match="*|@*" mode="{generate-id()}">
<aaa:apply-templates select="node()|@*" mode="{generate-id()}"/>
</aaa:template>
<aaa:template match="text()" mode="dia_{generate-id()}"/>
<aaa:template match="*|@*" mode="dia_{generate-id()}">
<aaa:apply-templates select="node()|@*" mode="dia_{generate-id()}"/>
</aaa:template>
</xsl:for-each>
<aaa:template match="{$docRoot}" mode="startDiagnostics">
<xsl:for-each select="/sch:schema/sch:pattern">
<aaa:apply-templates select="{$docRoot}" mode="dia_{generate-id(.)}"/>
</xsl:for-each>
</aaa:template>
<xsl:apply-templates select="sch:schema" mode="diagnostic"/>
<xsl:call-template name="fullPath"/>
</aaa:stylesheet>
</xsl:template>
<xsl:template match="sch:dir">
<xsl:call-template name="dirWrapper"/>
</xsl:template>
<xsl:template match="sch:span">
<xsl:call-template name="spanWrapper"/>
</xsl:template>
<xsl:template match="sch:p">
<xsl:call-template name="pWrapper"/>
</xsl:template>
<xsl:template match="@icon">
<xsl:call-template name="iconWrapper"/>
</xsl:template>
<xsl:template match="sch:emph">
<xsl:call-template name="emphWrapper"/>
</xsl:template>
<xsl:template match="sch:title">
<xsl:apply-templates/>
</xsl:template>
<xsl:param name="phase">
<xsl:choose>
<xsl:when test="/sch:schema/@defaultPhase">
<xsl:value-of select="/sch:schema/@defaultPhase"/>
</xsl:when>
<xsl:otherwise>#ALL</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:template match="sch:active">
<xsl:apply-templates select="text() | sch:dir | sch:span | sch:emph"/>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/mount/editor/editor/stylesheets/schematron-wrappers.xsl
Index: schematron-wrappers.xsl
===================================================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:aaa="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:zvon="http://zvon.org/schematron"
>
<!--
Schematron wrappers for the slash-edit
originally copied from work by:
Ivelin Ivanov, [EMAIL PROTECTED]
-->
<!-- root of an XML Form document -->
<xsl:variable name="docRootPrefix">/editor/instance/</xsl:variable>
<xsl:template name="documentWrapper">
<editor>
<aaa:copy-of select="../../@*"/> <!-- copy 'editor' attributes-->
<instance>
<aaa:copy-of select="../@*"/> <!-- copy 'instance' attributes-->
<aaa:copy-of select="."/>
</instance>
<validationResult>
<xsl:apply-templates select="." mode="process"/>
</validationResult>
</editor>
</xsl:template>
<xsl:template name="schemaTitleWrapper">
<xsl:if test="sch:title">
<h2>
<xsl:apply-templates select="sch:title"/>
</h2>
</xsl:if>
</xsl:template>
<xsl:template name="patternWrapper">
<pattern name="[EMAIL PROTECTED]">
<xsl:call-template name="applyRules"/>
</pattern>
</xsl:template>
<xsl:template name="reportAssertWrapper">
<error>
<path>
<aaa:variable name="fpath">
<aaa:apply-templates select="." mode="fullPath"/>
</aaa:variable>
<aaa:value-of select="substring-after($fpath, '{$docRootPrefix}')"/>
</path>
<message>
<xsl:apply-templates/>
</message>
</error>
</xsl:template>
<xsl:template name="patternTitleWrapper">
<tr>
<th class="pattern">
<a name="[EMAIL PROTECTED]"> </a>
<xsl:text>Pattern: </xsl:text>
<span class="patternTitle"><xsl:value-of select="@name"/></span>
</th>
</tr>
</xsl:template>
<xsl:template name="patternSeeWrapper">
<xsl:if test="@see">
<tr>
<td>
<xsl:text>Documentation: </xsl:text>
<a href="[EMAIL PROTECTED]"> see here </a>
</td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template name="pWrapper">
<div>
<xsl:copy-of select="@class|@id"/>
<xsl:apply-templates select="@icon"/>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template name="iconWrapper">
<img src="{.}"/>
</xsl:template>
<xsl:template name="emphWrapper">
<em><xsl:apply-templates/></em>
</xsl:template>
<xsl:template name="spanWrapper">
<span>
<xsl:copy-of select="@class"/>
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template name="dirWrapper">
<span dir="[EMAIL PROTECTED]">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template name="zvonDiagnostics-URI">
</xsl:template>
<xsl:template name="schemaDiagnosticWrapper">
<xsl:choose>
<xsl:when test="parent::*/@zvon:diagnostics-URI">
<!--<saxon:output file="{parent::*/@zvon:diagnostics-URI}">-->
<aaa:apply-templates select="/" mode="startDiagnostics"/>
<!--</saxon:output>-->
</xsl:when>
<xsl:otherwise>
<aaa:message>
<aaa:apply-templates select="/" mode="startDiagnostics"/>
</aaa:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="outputDiagnosticAssertReportWrapper">
<xsl:choose>
<xsl:when test="@zvon:diagnostics-URI">
<!--<saxon:output file="[EMAIL PROTECTED]:diagnostics-URI}">-->
<xsl:call-template name="diagnosticItems">
<xsl:with-param name="value" select="normalize-space(@diagnostics)"/>
</xsl:call-template>
<!--</saxon:output>-->
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="diagnosticItems">
<xsl:with-param name="value" select="normalize-space(@diagnostics)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="diagnosticWrapper">
<xsl:text>
Diagnostics:
</xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]