RELAX NG Schema for Paloose Sitemaps
Author: Hugh Field-Richards
Date: 2011-08-03T12:15

This is the RELAX NG schema for the Paloose sitemaps. They are very similar to Cocoon sitemaps, but with enough differences to make it worth formalising separately. Any bug reports, help, suggestions, new task schemas etc to me, Hugh Field-Richards (hsfr@hsfr.org.uk).

The documentation is designed to be processed by the rng2xhtml.xsl pretty-printing processor available from the author.

Schematron
Declare schematron namespace : map = http://apache.org/cocoon/sitemap/1.0

Actions

components.actions — Warning! not used within this schema file.
define : components.actions
element : map:actions
zeroOrMore
<define name="components.actions">
   <element name="map:actions">
      <zeroOrMore>
         <ref name="actions.action"/>
      </zeroOrMore>
   </element>
</define>
define : actions.action
Schematron
Check the identities are unique within a category
Context : “map:action
if not condition “count(//map:action[@name = current()/@name]) = 1
then output: There should be unique action names
element : map:action
attribute : name
attribute : src
choice
value = "resource://lib/acting/SendMailAction"
value = "resource://lib/acting/CookiesAction"
value = "resource://lib/acting/AuthAction"
value = "resource://lib/acting/LoginAction"
value = "resource://lib/acting/LogoutAction"
interleave
optional
<define name="actions.action">
   <sch:pattern name="Check the identities are unique within a category">
      <sch:rule context="map:action">
         <sch:assert test="count(//map:action[@name = current()/@name]) = 1">There should be unique action names</sch:assert>
      </sch:rule>
   </sch:pattern>
   <element name="map:action">
      <attribute name="name"/>
      <attribute name="src">
         <choice>
            <value>resource://lib/acting/SendMailAction</value>
            <value>resource://lib/acting/CookiesAction</value>
            <value>resource://lib/acting/AuthAction</value>
            <value>resource://lib/acting/LoginAction</value>
            <value>resource://lib/acting/LogoutAction</value>
         </choice>
      </attribute>
      <interleave>
         <optional>
            <ref name="SendMailAction.declaration"/>
         </optional>
      </interleave>
   </element>
</define>

SendMailAction

define : SendMailAction.declaration
interleave
zeroOrMore
<define name="SendMailAction.declaration">
   <interleave>
      <zeroOrMore>
         <ref name="SendMailAction.parameters"/>
      </zeroOrMore>
   </interleave>
</define>
define : SendMailAction.parameters
Schematron
smtp elements only allowed within SendMailAction
Context : “//*[ local-name() = 'smtp-host' ]
If condition “parent::*[ not( contains( @src, 'SendMailAction' ) ) ]
then output: smtp-host only allowed in SendMailAction
Context : “//*[ local-name() = 'smtp-user' ]
If condition “parent::*[ not( contains( @src, 'SendMailAction' ) ) ]
then output: smtp-user only allowed in SendMailAction
Context : “//*[ local-name() = 'smtp-password' ]
If condition “parent::*[ not( contains( @src, 'SendMailAction' ) ) ]
then output: smtp-password only allowed in SendMailAction
Schematron
Only one of SendMailAction nested elements allowed of each type
Context : “//map:action[ contains( @src, 'SendMailAction' ) ]
If condition “count( smtp-host ) > 1
then output: Only 1 smtp-host element allowed here
Context : “//map:action[ contains( @src, 'SendMailAction' ) ]
If condition “count( smtp-user ) > 1
then output: Only 1 smtp-user element allowed here
Context : “//map:action[ contains( @src, 'SendMailAction' ) ]
If condition “count( smtp-password ) > 1
then output: Only 1 smtp-password element allowed here
interleave
element : smtp-host
Any text
element : smtp-user
Any text
element : smtp-password
Any text
<define name="SendMailAction.parameters">
   <sch:pattern name="smtp elements only allowed within SendMailAction">
      <sch:rule context="//*[ local-name() = 'smtp-host' ]">
         <sch:report test="parent::*[ not( contains( @src, 'SendMailAction' ) ) ]">smtp-host only allowed in SendMailAction</sch:report>
      </sch:rule>
      <sch:rule context="//*[ local-name() = 'smtp-user' ]">
         <sch:report test="parent::*[ not( contains( @src, 'SendMailAction' ) ) ]">smtp-user only allowed in SendMailAction</sch:report>
      </sch:rule>
      <sch:rule context="//*[ local-name() = 'smtp-password' ]">
         <sch:report test="parent::*[ not( contains( @src, 'SendMailAction' ) ) ]">smtp-password only allowed in SendMailAction</sch:report>
      </sch:rule>
   </sch:pattern>
   <sch:pattern name="Only one of SendMailAction nested elements allowed of each type">
      <sch:rule context="//map:action[ contains( @src, 'SendMailAction' ) ]">
         <sch:report test="count( smtp-host ) > 1">Only 1 smtp-host element allowed here</sch:report>
      </sch:rule>
      <sch:rule context="//map:action[ contains( @src, 'SendMailAction' ) ]">
         <sch:report test="count( smtp-user ) > 1">Only 1 smtp-user element allowed here</sch:report>
      </sch:rule>
      <sch:rule context="//map:action[ contains( @src, 'SendMailAction' ) ]">
         <sch:report test="count( smtp-password ) > 1">Only 1 smtp-password element allowed here</sch:report>
      </sch:rule>
   </sch:pattern>
   <interleave>
      <element name="smtp-host">
         <text/>
      </element>
      <element name="smtp-user">
         <text/>
      </element>
      <element name="smtp-password">
         <text/>
      </element>
   </interleave>
</define>
define : action.instance
Schematron
SendMailAction
Context : “//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/SendMailAction']/@name]
If condition “not( map:parameter[ @name = 'from' ] )
then output: Missing "from" parameter in SendMailAction instance.
If condition “not( map:parameter[ @name = 'to' ] )
then output: Missing "to" parameter in SendMailAction instance.
If condition “not( map:parameter[ @name = 'subject' ] )
then output: Missing "subject" parameter in SendMailAction instance.
If condition “not( map:parameter[ @name = 'body' ] )
then output: Missing "body" parameter in SendMailAction instance.
Schematron
AuthAction
Context : “//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/AuthAction']/@name]
If condition “not( map:parameter[ @name = 'handler' ] )
then output: Missing "handler" parameter in AuthAction instance.
Schematron
LoginAction
Context : “//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/LoginAction']/@name]
If condition “not( map:parameter[ @name = 'handler' ] )
then output: Missing "handler" parameter in LoginAction instance.
If condition “not( map:parameter[ @name = 'username' ] )
then output: Missing "username" parameter in LoginAction instance.
If condition “not( map:parameter[ @name = 'password' ] )
then output: Missing "password" parameter in LoginAction instance.
Schematron
LogoutAction
Context : “//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/LogoutAction']/@name]
If condition “not( map:parameter[ @name = 'handler' ] )
then output: Missing "handler" parameter in LogoutAction instance.
element : map:act
attribute : type
zeroOrMore
element : map:parameter
attribute : name
attribute : value
refpipeline.act
<define name="action.instance">
   <sch:pattern name="SendMailAction ">
      <sch:rule context="//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/SendMailAction']/@name]">
         <sch:report test="not( map:parameter[ @name = 'from' ] )">Missing "from" parameter in SendMailAction instance.</sch:report>
         <sch:report test="not( map:parameter[ @name = 'to' ] )">Missing "to" parameter in SendMailAction instance.</sch:report>
         <sch:report test="not( map:parameter[ @name = 'subject' ] )">Missing "subject" parameter in SendMailAction instance.</sch:report>
         <sch:report test="not( map:parameter[ @name = 'body' ] )">Missing "body" parameter in SendMailAction instance.</sch:report>
      </sch:rule>
   </sch:pattern>
   <sch:pattern name="AuthAction ">
      <sch:rule context="//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/AuthAction']/@name]">
         <sch:report test="not( map:parameter[ @name = 'handler' ] )">Missing "handler" parameter in AuthAction instance.</sch:report>
      </sch:rule>
   </sch:pattern>
   <sch:pattern name="LoginAction ">
      <sch:rule context="//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/LoginAction']/@name]">
         <sch:report test="not( map:parameter[ @name = 'handler' ] )">Missing "handler" parameter in LoginAction instance.</sch:report>
         <sch:report test="not( map:parameter[ @name = 'username' ] )">Missing "username" parameter in LoginAction instance.</sch:report>
         <sch:report test="not( map:parameter[ @name = 'password' ] )">Missing "password" parameter in LoginAction instance.</sch:report>
      </sch:rule>
   </sch:pattern>
   <sch:pattern name="LogoutAction ">
      <sch:rule context="//map:act[@type = //map:actions/map:action[@src='resource://lib/acting/LogoutAction']/@name]">
         <sch:report test="not( map:parameter[ @name = 'handler' ] )">Missing "handler" parameter in LogoutAction instance.</sch:report>
      </sch:rule>
   </sch:pattern>
   <element name="map:act">
      <attribute name="type"/>
      <zeroOrMore>
         <element name="map:parameter">
            <attribute name="name"/>
            <attribute name="value"/>
         </element>
      </zeroOrMore>
      <ref name="pipeline.act"/>
   </element>
</define>

Pipelines used in actions

define : pipeline.act
zeroOrMore
choice
refaggregate.instance
refgenerator.instance
reftransformer.instance
refserializer.instance
refreader.instance
refresource.mount
refselector.instance
refresource.call
refresource.redirect-to
<define name="pipeline.act">
   <zeroOrMore>
      <choice>
         <ref name="aggregate.instance"/>
         <ref name="generator.instance"/>
         <ref name="transformer.instance"/>
         <ref name="serializer.instance"/>
         <ref name="reader.instance"/>
         <ref name="resource.mount"/>
         <ref name="selector.instance"/>
         <ref name="resource.call"/>
         <ref name="action.instance"/>
         <ref name="resource.redirect-to"/>
      </choice>
   </zeroOrMore>
</define>

Copyright

Copyright (c) 2006 – 2009 Hugh Field-Richards

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

For a copy of the GNU General Public License write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.