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

Pipeline Definitions

map.pipelines — Warning! not used within this schema file.
define : map.pipelines
element : map:pipelines
interleave
oneOrMore
<define name="map.pipelines">
   <element name="map:pipelines">
      <interleave>
         <optional>
            <ref name="pipelines.component-configurations"/>
         </optional>
         <oneOrMore>
            <ref name="pipelines.pipeline"/>
         </oneOrMore>
      </interleave>
   </element>
</define>
define : pipelines.pipeline
element : map:pipeline
optional
attribute : internal-only
refcommon.trueFalseEnum
interleave
oneOrMore
refmatcher.instance
optional
<define name="pipelines.pipeline">
   <element name="map:pipeline">
      <optional>
         <attribute name="internal-only">
            <ref name="common.trueFalseEnum"/>
         </attribute>
      </optional>
      <interleave>
         <oneOrMore>
            <ref name="matcher.instance"/>
         </oneOrMore>
         <optional>
            <ref name="pipelines.handle-errors"/>
         </optional>
      </interleave>
   </element>
</define>
define : pipelines.component-configurations
element : map:component-configurations
interleave
optional
<define name="pipelines.component-configurations">
   <element name="map:component-configurations">
      <interleave>
         <optional>
            <ref name="pipelines.authentication-manager"/>
         </optional>
         <optional>
            <ref name="pipelines.global-variables"/>
         </optional>
      </interleave>
   </element>
</define>
define : pipelines.authentication-manager
element : map:authentication-manager
interleave
zeroOrMore
<define name="pipelines.authentication-manager">
   <element name="map:authentication-manager">
      <interleave>
         <zeroOrMore>
            <ref name="pipelines.handlers"/>
         </zeroOrMore>
      </interleave>
   </element>
</define>
define : pipelines.global-variables
element : map:global-variables
zeroOrMore
<define name="pipelines.global-variables">
   <element name="map:global-variables">
      <zeroOrMore>
         <ref name="pipelines.variable"/>
      </zeroOrMore>
   </element>
</define>
define : pipelines.variable
element : map:variable
attribute : name
attribute : value
<define name="pipelines.variable">
   <element name="map:variable">
      <attribute name="name"/>
      <attribute name="value"/>
   </element>
</define>
define : pipelines.handlers
element : map:handlers
interleave
oneOrMore
<define name="pipelines.handlers">
   <element name="map:handlers">
      <interleave>
         <oneOrMore>
            <ref name="pipelines.handler"/>
         </oneOrMore>
      </interleave>
   </element>
</define>
define : pipelines.handler
element : map:handler
attribute : name
refresource.redirect-to
element : map:authentication
attribute : uri
<define name="pipelines.handler">
   <element name="map:handler">
      <attribute name="name"/>
      <ref name="resource.redirect-to"/>
      <element name="map:authentication">
         <attribute name="uri"/>
      </element>
   </element>
</define>
define : pipelines.handle-errors
element : map:handle-errors
interleave
oneOrMore
<define name="pipelines.handle-errors">
   <element name="map:handle-errors">
      <interleave>
         <oneOrMore>
            <ref name="pipeline.matcher"/>
         </oneOrMore>
      </interleave>
   </element>
</define>

Pipelines used in matchers

There is no sensible way of providing restictions on the pipeline ordering in RELAX-NG. I have had to resort to Schematron rules to do this. Oh for DSD-2, which can do this with no problem at all.

define : pipeline.matcher
Schematron
Check position of pipeline elements
Context : “map:generate
If condition “count( preceding-sibling::* ) > 0 and not ( preceding-sibling::map:parameter )
then output: Generate element must be first in the pipeline
Context : “map:aggregate
If condition “count( preceding-sibling::* ) > 0 and not( preceding-sibling::map:act ) and not ( preceding-sibling::map:parameter )
then output: Aggregate element must be first in the pipeline
Context : “map:call
If condition “count( following-sibling::* ) > 0
then output: call element must be last in the pipeline
Context : “map:redirect-to
If condition “count( following-sibling::* ) > 0 and not( parent::map:handler )
then output: redirect-to element must be last in the pipeline
Context : “map:read
If condition “count( preceding-sibling::* ) > 0 and count( following-sibling::* ) > 0
then output: Read element must be only element in the pipeline
Context : “map:mount
If condition “count( preceding-sibling::* ) > 0 and count( following-sibling::* ) > 0
then output: Mount element must be only element in the pipeline
choice
refresource.mount
refreader.instance
refselector.instance
refaction.instance
refresource.redirect-to
choice
refgenerator.instance
refaggregate.instance
refaction.instance
refselector.instance
zeroOrMore
reftransformer.instance
choice
refresource.call
refresource.redirect-to
refserializer.instance
<define name="pipeline.matcher">
   <sch:pattern name="Check position of pipeline elements">
      <sch:rule context="map:generate">
         <sch:report test="count( preceding-sibling::* ) > 0                and not ( preceding-sibling::map:parameter )">Generate element must be first in the pipeline</sch:report>
      </sch:rule>
      <sch:rule context="map:aggregate">
         <sch:report test="count( preceding-sibling::* ) > 0                and not( preceding-sibling::map:act )                and not ( preceding-sibling::map:parameter )">Aggregate element must be first in the pipeline</sch:report>
      </sch:rule>
      <sch:rule context="map:call">
         <sch:report test="count( following-sibling::* ) > 0">call element must be last in the pipeline</sch:report>
      </sch:rule>
      <sch:rule context="map:redirect-to">
         <sch:report test="count( following-sibling::* ) > 0                and not( parent::map:handler )">redirect-to element must be last in the pipeline</sch:report>
      </sch:rule>
      <sch:rule context="map:read">
         <sch:report test="count( preceding-sibling::* ) > 0 and count( following-sibling::* ) > 0">Read element must be only element in the pipeline</sch:report>
      </sch:rule>
      <sch:rule context="map:mount">
         <sch:report test="count( preceding-sibling::* ) > 0 and count( following-sibling::* ) > 0">Mount element must be only element in the pipeline</sch:report>
      </sch:rule>
   </sch:pattern>
   <choice>
      <group>
         <ref name="resource.mount"/>
      </group>
      <group>
         <ref name="reader.instance"/>
      </group>
      <group>
         <ref name="selector.instance"/>
      </group>
      <group>
         <ref name="action.instance"/>
      </group>
      <group>
         <ref name="resource.redirect-to"/>
      </group>
      <group>
         <choice>
            <ref name="generator.instance"/>
            <ref name="aggregate.instance"/>
            <ref name="action.instance"/>
            <ref name="selector.instance"/>
         </choice>
         <zeroOrMore>
            <ref name="transformer.instance"/>
         </zeroOrMore>
         <choice>
            <ref name="resource.call"/>
            <ref name="resource.redirect-to"/>
            <ref name="serializer.instance"/>
         </choice>
      </group>
   </choice>
</define>
pipeline.select — Warning! not used within this schema file.
define : pipeline.select
choice
refresource.mount
refreader.instance
optional
choice
refgenerator.instance
refaggregate.instance
interleave
optional
refselector.instance
zeroOrMore
optional
reftransformer.instance
optional
choice
refresource.call
refresource.redirect-to
refserializer.instance
<define name="pipeline.select">
   <choice>
      <group>
         <ref name="resource.mount"/>
      </group>
      <group>
         <ref name="reader.instance"/>
      </group>
      <group>
         <optional>
            <choice>
               <ref name="generator.instance"/>
               <ref name="aggregate.instance"/>
            </choice>
         </optional>
         <interleave>
            <optional>
               <ref name="selector.instance"/>
            </optional>
            <zeroOrMore>
               <optional>
                  <ref name="transformer.instance"/>
               </optional>
            </zeroOrMore>
            <optional>
               <choice>
                  <ref name="resource.call"/>
                  <ref name="resource.redirect-to"/>
                  <ref name="serializer.instance"/>
               </choice>
            </optional>
         </interleave>
      </group>
   </choice>
</define>
pipeline.views — Warning! not used within this schema file.
define : pipeline.views
zeroOrMore
reftransformer.instance
choice
refresource.call
refserializer.instance
<define name="pipeline.views">
   <zeroOrMore>
      <ref name="transformer.instance"/>
   </zeroOrMore>
   <choice>
      <group>
         <ref name="resource.call"/>
      </group>
      <group>
         <ref name="serializer.instance"/>
      </group>
   </choice>
</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.