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
components.selectors — Warning! not used within this schema file.
define : components.selectors
element : map:selectors
attribute : default
refdata.componentName
zeroOrMore
<define name="components.selectors">
   <element name="map:selectors">
      <attribute name="default">
         <ref name="data.componentName"/>
      </attribute>
      <zeroOrMore>
         <ref name="selectors.selector"/>
      </zeroOrMore>
   </element>
</define>
define : selectors.selector
Schematron
Context : "map:selector"
if not condition "count(//map:selector[@name = current()/@name]) = 1"
then output: There should be unique selector names
element : map:selector
attribute : name
attribute : src
choice
value = "resource://lib/selection/BrowserSelector"
value = "resource://lib/selection/RequestParameterSelector"
value = "resource://lib/selection/MobileSelector"
value = "resource://lib/selection/RegexpSelector"
value = "resource://lib/selection/VariableSelector"
value = "resource://lib/selection/ResourceExistsSelector"
interleave
optional
<define name="selectors.selector">
   <sch:pattern name="Check the identities are unique within a category">
      <sch:rule context="map:selector">
         <sch:assert test="count(//map:selector[@name = current()/@name]) = 1">There should be unique selector names</sch:assert>       </sch:rule>
   </sch:pattern>
   <element name="map:selector">
      <attribute name="name"/>
      <attribute name="src">
         <choice>
            <value>resource://lib/selection/BrowserSelector</value>             <value>resource://lib/selection/RequestParameterSelector</value>             <value>resource://lib/selection/MobileSelector</value>             <value>resource://lib/selection/RegexpSelector</value>             <value>resource://lib/selection/VariableSelector</value>             <value>resource://lib/selection/ResourceExistsSelector</value>          </choice>
      </attribute>
      <interleave>
         <optional>
            <ref name="BrowserSelector.contents"/>
         </optional>
         <optional>
            <ref name="RequestParameterSelector.contents"/>
         </optional>
      </interleave>
   </element>
</define>
define : BrowserSelector.contents
Schematron
Context : "//*[ local-name() = 'map:browser' ]"
If condition "parent::*[ not( contains( @src, 'BrowserSelector' ) ) ]"
then output: browser element only allowed in BrowserSelector
interleave
zeroOrMore
<define name="BrowserSelector.contents">
   <sch:pattern name="browser elements only allowed within BrowserSelector">
      <sch:rule context="//*[ local-name() = 'map:browser' ]">
         <sch:report test="parent::*[ not( contains( @src, 'BrowserSelector' ) ) ]">browser element only allowed in BrowserSelector</sch:report>       </sch:rule>
   </sch:pattern>
   <interleave>
      <zeroOrMore>
         <ref name="selector.browser"/>
      </zeroOrMore>
   </interleave>
</define>
define : selector.browser
Schematron
Context : "browser"
if not condition "count(//browser[@useragent = current()/@useragent]) = 1"
then output: There should be unique user agent names
element : map:browser
attribute : name
attribute : useragent
<define name="selector.browser">
   <sch:pattern name="Check the names of browsers are unique">
      <sch:rule context="browser">
         <sch:assert test="count(//browser[@useragent = current()/@useragent]) = 1">There should be unique user agent names</sch:assert>       </sch:rule>
   </sch:pattern>
   <element name="map:browser">
      <attribute name="name"/>
      <attribute name="useragent">
         <ref name="browser.userAgents"/>
      </attribute>
   </element>
</define>
define : browser.userAgents
choice
value = "MSIE"
value = "MSPIE"
value = "HandHTTP"
value = "AvantGo"
value = "DoCoMo"
value = "Opera"
value = "Lynx"
value = "Java"
value = "Nokia"
value = "UP"
value = "Wapalizer"
value = "Mozilla/5"
value = "Netscape6/"
value = "Mozilla"
value = "Safari"
value = "iPhone"
<define name="browser.userAgents">
   <choice>
      <value>MSIE</value>       <value>MSPIE</value>       <value>HandHTTP</value>       <value>AvantGo</value>       <value>DoCoMo</value>       <value>Opera</value>       <value>Lynx</value>       <value>Java</value>       <value>Nokia</value>       <value>UP</value>       <value>Wapalizer</value>       <value>Mozilla/5</value>       <value>Netscape6/</value>       <value>Mozilla</value>       <value>Safari</value>       <value>iPhone</value>    </choice>
</define>
define : RequestParameterSelector.contents
Schematron
Context : "//*[ local-name() = 'parameter-name' ]"
If condition "parent::*[ contains( @src, 'RegexpSelector' ) or contains( @src, 'VariableSelector' ) or contains( @src, 'MobileSelector' ) or contains( @src, 'ResourceExistsSelector' ) ] "
then output: parameter-name element only allowed in RequestParameterSelector
interleave
zeroOrMore
element : map:parameter-name
Any text
<define name="RequestParameterSelector.contents">
   <sch:pattern name="parameter-name elements only allowed within RequestParameterSelector">
      <sch:rule context="//*[ local-name() = 'parameter-name' ]">
         <sch:report test="parent::*[ contains( @src, 'RegexpSelector' ) or contains( @src, 'VariableSelector' ) or                 contains( @src, 'MobileSelector' ) or  contains( @src, 'ResourceExistsSelector' ) ] ">parameter-name element only allowed in RequestParameterSelector</sch:report>       </sch:rule>
   </sch:pattern>
   <interleave>
      <zeroOrMore>
         <element name="map:parameter-name">
            <text/>
         </element>
      </zeroOrMore>
   </interleave>
</define>
selector.instance — Warning! not used within this schema file.
define : selector.instance
element : map:select
attribute : type
optional
refcommon.element.parameter
oneOrMore
<define name="selector.instance">
   <element name="map:select">
      <attribute name="type"/>
      <optional>
         <ref name="common.element.parameter"/>
      </optional>
      <oneOrMore>
         <ref name="selector.when"/>
      </oneOrMore>
      <ref name="selector.otherwise"/>
   </element>
</define>
define : selector.when
element : map:when
attribute : test
refpipeline.select
<define name="selector.when">
   <element name="map:when">
      <attribute name="test"/>
      <ref name="pipeline.select"/>
   </element>
</define>
define : selector.otherwise
element : map:otherwise
optional
refpipeline.select
<define name="selector.otherwise">
   <element name="map:otherwise">
      <optional>
         <ref name="pipeline.select"/>
      </optional>
   </element>
</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.