RELAX NG Schema for Paloose Site Pages
Author: Hugh Field-Richards
Date: 2006-08-15T11:45

This is the RELAX NG schema for the XML pages used in the Paloose site. Since the whole site is rooted in XML it is essential that a formal definition is made of the structure to check any changes and created pages before they are processed by the Paloose pipeline. Feel free to change these or use your own. They also make use of Schematron rules to cover the deficiencies of RELAX NG.


Included file: common/common.rng
Included file: common/xinclude.rng
Included file: common/text.rng
Included file: paloose.rng
Included file: pforms.rng

These are the namespaces needed by the Schematron validator.

Schematron
Declare schematron namespace : page:http://www.hsfr.org.uk/Schema/Page
Schematron
Declare schematron namespace : link:http://www.hsfr.org.uk/Schema/Link
Schematron
Declare schematron namespace : list:http://www.hsfr.org.uk/Schema/List
Schematron
Declare schematron namespace : text:http://www.hsfr.org.uk/Schema/Text
Schematron
Declare schematron namespace : i18n:http://apache.org/cocoon/i18n/2.1
Schematron
Declare schematron namespace : paloose:http://www.paloose.org/schemas/Paloose/1.0
Schematron
Declare schematron namespace : pf:http://www.paloose.org/schemas/Forms/1.0

Page Definition

Schema Root
start
element : page:page
refpage.page
<start>
   <element name="page:page">
      <ref name="page.page"/>
   </element>
</start>

Pages are basically metadata (optional) and content. For example

   <page:page>
      <page:meta>
         ...
      </page:meta>
      <page:content>
         ...
      </page:content>
   </page:page>

Note that include statements can occur throughtout the content and around the metadata.

define : page.page
zeroOrMore
refxi.include
optional
zeroOrMore
refxi.include
element : page:content
refcommon.commonAttributes
zeroOrMore
choice
refxi.include
reftext.verticalContent
<define name="page.page">
   <zeroOrMore>
      <ref name="xi.include"/>
   </zeroOrMore>
   <optional>
      <ref name="page.metadata"/>
   </optional>
   <zeroOrMore>
      <ref name="xi.include"/>
   </zeroOrMore>
   <element name="page:content">
      <ref name="common.commonAttributes"/>
      <zeroOrMore>
         <choice>
            <ref name="xi.include"/>
            <ref name="text.verticalContent"/>
         </choice>
      </zeroOrMore>
   </element>
</define>

Page Metadata

Metadata describes the page with information that does not necessarily get output on the body of the page.

define : page.metadata
element : page:meta
refcommon.commonAttributes
interleave
optional
optional
refpaloose.page-hit
<define name="page.metadata">
   <element name="page:meta">
      <ref name="common.commonAttributes"/>
      <interleave>
         <ref name="page.pageTitleElement"/>
         <ref name="page.copyrightElement"/>
         <optional>
            <ref name="page.breadcrumb"/>
         </optional>
         <optional>
            <ref name="paloose.page-hit"/>
         </optional>
      </interleave>
   </element>
</define>

Page Body Title

Titles that appear in title bar of the page consist only of text or translatable text. Note that the latter should only be simple text only. We have to have a Schematron rule here as i18n namespace can contain other tags here which we need to prevent. This sort of thing is so easy in DSD2 :-)

define : page.pageTitleElement
Schematron
Only plain text or i18n namespace allowed within page title.
Context : “page:title
If condition “descendant::*[ namespace-uri() != 'http://apache.org/cocoon/i18n/2.1' ]
then output: Only plain text or i18n namespace allowed within page title.
element : page:title
zeroOrMore
choice
Any text
refi18n.text
<define name="page.pageTitleElement">
   <sch:pattern name="Only plain text or i18n namespace allowed within page title.">
      <sch:rule context="page:title">
         <sch:report test="descendant::*[ namespace-uri() != 'http://apache.org/cocoon/i18n/2.1' ]">Only plain text or i18n namespace allowed within page title.</sch:report>
      </sch:rule>
   </sch:pattern>
   <element name="page:title">
      <zeroOrMore>
         <choice>
            <text/>
            <ref name="i18n.text"/>
         </choice>
      </zeroOrMore>
   </element>
</define>

Copyright Text

Copyright text is pretty much anything. This could be restricted like the page title above.

define : page.copyrightElement
element : page:copyright
zeroOrMore
choice
reftext.verticalContent
reftext.horizontalContent
<define name="page.copyrightElement">
   <element name="page:copyright">
      <zeroOrMore>
         <choice>
            <ref name="text.verticalContent"/>
            <ref name="text.horizontalContent"/>
         </choice>
      </zeroOrMore>
   </element>
</define>

Page Breadcrumb Title

define : page.breadcrumb
Schematron
Only plain text or i18n namespace allowed within breadcrumb title.
Context : “page:breadcrumb
If condition “descendant::*[ namespace-uri() != 'http://apache.org/cocoon/i18n/2.1' ]
then output: Only plain text or i18n namespace allowed within page title.
element : page:breadcrumb
zeroOrMore
choice
Any text
refi18n.text
<define name="page.breadcrumb">
   <sch:pattern name="Only plain text or i18n namespace allowed within breadcrumb title.">
      <sch:rule context="page:breadcrumb">
         <sch:report test="descendant::*[ namespace-uri() != 'http://apache.org/cocoon/i18n/2.1' ]">Only plain text or i18n namespace allowed within page title.</sch:report>
      </sch:rule>
   </sch:pattern>
   <element name="page:breadcrumb">
      <zeroOrMore>
         <choice>
            <text/>
            <ref name="i18n.text"/>
         </choice>
      </zeroOrMore>
   </element>
</define>