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.serializers — Warning! not used within this schema file.
define : components.serializers
element : map:serializers
refcomponents.attribute.default
zeroOrMore
<define name="components.serializers">
   <element name="map:serializers">
      <ref name="components.attribute.default"/>
      <zeroOrMore>
         <ref name="serializers.serializer"/>
      </zeroOrMore>
   </element>
</define>
define : serializers.serializer
Schematron
Check the serializer names are unique
Context : “map:serializer
if not condition “count(//map:serializer[@name = current()/@name]) = 1
then output: There should be unique serializer names
element : map:serializer
refcomponent.attributes.common
optional
refcomponent.attribute.cachable
attribute : mime-type
<define name="serializers.serializer">
   <sch:pattern name="Check the serializer names are unique">
      <sch:rule context="map:serializer">
         <sch:assert test="count(//map:serializer[@name = current()/@name]) = 1">There should be unique serializer names</sch:assert>
      </sch:rule>
   </sch:pattern>
   <element name="map:serializer">
      <ref name="component.attributes.common"/>
      <optional>
         <ref name="component.attribute.cachable"/>
      </optional>
      <attribute name="mime-type"/>
      <ref name="serializers.contents"/>
   </element>
</define>
define : serializers.contents
Schematron
doctype-public elements only allowed within HTMLSerializer
Context : “//map:serializer/map:property[ @name = 'doctype-public' ]
If condition “parent::*[ contains( @src, 'TextSerializer' ) ]
then output: doctype-public not allowed in TextSerializer
Context : “//map:serializer/map:property[ @name = 'doctype-system' ]
If condition “parent::*[ contains( @src, 'TextSerializer' ) ]
then output: doctype-public not allowed in TextSerializer
Context : “//map:serializer/map:property[ @name = 'omit-xml-declaration' ]
If condition “parent::*[ contains( @src, 'TextSerializer' ) ]
then output: omit-xml-declaration not allowed in TextSerializer
Context : “//map:serializer/map:property[ @name = 'cdata-encode' ]
If condition “parent::*[ contains( @src, 'TextSerializer' ) ]
then output: cdata-encode not allowed in TextSerializer
zeroOrMore
<define name="serializers.contents">
   <sch:pattern name="doctype-public elements only allowed within HTMLSerializer">
      <sch:rule context="//map:serializer/map:property[ @name = 'doctype-public' ]">
         <sch:report test="parent::*[ contains( @src, 'TextSerializer' ) ]">doctype-public not allowed in TextSerializer</sch:report>
      </sch:rule>
      <sch:rule context="//map:serializer/map:property[ @name = 'doctype-system' ]">
         <sch:report test="parent::*[ contains( @src, 'TextSerializer' ) ]">doctype-public not allowed in TextSerializer</sch:report>
      </sch:rule>
      <sch:rule context="//map:serializer/map:property[ @name = 'omit-xml-declaration' ]">
         <sch:report test="parent::*[ contains( @src, 'TextSerializer' ) ]">omit-xml-declaration not allowed in TextSerializer</sch:report>
      </sch:rule>
      <sch:rule context="//map:serializer/map:property[ @name = 'cdata-encode' ]">
         <sch:report test="parent::*[ contains( @src, 'TextSerializer' ) ]">cdata-encode not allowed in TextSerializer</sch:report>
      </sch:rule>
   </sch:pattern>
   <zeroOrMore>
      <ref name="HTMLSerializer.property"/>
   </zeroOrMore>
</define>
define : HTMLSerializer.property
element : map:property
attribute : name
attribute : value
<define name="HTMLSerializer.property">
   <element name="map:property">
      <attribute name="name">
         <ref name="HTMLSerializer.property.values"/>
      </attribute>
      <attribute name="value"/>
   </element>
</define>
define : HTMLSerializer.property.values
choice
value = "doctype-public"
value = "doctype-system"
value = "HTMLSerializer.encoding"
value = "omitXMLdeclaration"
value = "encoding"
value = "cdata-encode"
<define name="HTMLSerializer.property.values" combine="choice">
   <choice>
      <value>doctype-public</value>
      <value>doctype-system</value>
      <value>HTMLSerializer.encoding</value>
      <value>omitXMLdeclaration</value>
      <value>encoding</value>
      <value>cdata-encode</value>
   </choice>
</define>
serializer.instance — Warning! not used within this schema file.
define : serializer.instance
element : map:serialize
optional
attribute : type
<define name="serializer.instance">
   <element name="map:serialize">
      <optional>
         <attribute name="type"/>
      </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.