<?xml version="1.0" encoding="UTF-8"?>

<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
<!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
<!--
   
   Schema for Source Writing Structure
   
   Author:
      Name  : Hugh Field-Richards.
      Email : hsfr@hsfr.org.uk
   
   -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
   -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
   
   Version   Date                   Who    Changes
   ==========================================================================
   
   0.0.0     24th March 2007        HSFR   Created
   
   -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Copyright -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
   
   This software is published under the terms of the LGPL License
   a copy of which has been included with this distribution in the LICENSE file.
   
-->

<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/annotation/1.0"
   xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:sch="http://www.ascc.net/xml/schematron"
   xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
   xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
   xmlns:source="http://apache.org/cocoon/source/1.0"
   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

   <a:documentation>
      <dc:title>RELAX NG Schema for Source Writing</dc:title>
      <dc:creator>Hugh Field-Richards</dc:creator>
      <dc:date>2007-03-24T17:00</dc:date>
      <dc:language>en</dc:language>
   </a:documentation>

   <xhtml:p>The Source Writing XML definition (based on the Cocoon with some minor differences).</xhtml:p>
   <xhtml:hr/>

   <xhtml:p>These are the namespaces needed by the Schematron validator.</xhtml:p>

   <sch:ns prefix="source" uri="http://apache.org/cocoon/source/1.0"/>

   <!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
   <!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->

   <define name="source.write">
      <element name="source:write">
         <optional>
            <attribute name="create">
               <data type="boolean"/>
            </attribute>
         </optional>
         <optional>
            <attribute name="overwrite">
               <data type="boolean"/>
            </attribute>
         </optional>
         <interleave>
            <ref name="source.source"/>
            <optional>
               <ref name="source.path"/>
            </optional>
            <ref name="source.fragment"/>
         </interleave>
      </element>
   </define>

   <!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->

   <define name="source.insert">
      <element name="source:insert">
         <optional>
            <attribute name="create">
               <data type="boolean"/>
            </attribute>
         </optional>
         <optional>
            <attribute name="overwrite">
               <data type="boolean"/>
            </attribute>
         </optional>
         <interleave>
            <ref name="source.source"/>
            <optional>
               <ref name="source.path"/>
            </optional>
            <optional>
               <ref name="source.replace"/>
            </optional>
            <ref name="source.fragment"/>
         </interleave>
      </element>
   </define>

   <!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->

   <define name="source.delete">
      <element name="source:delete">
         <ref name="source.source"/>
      </element>
   </define>

   <!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->
   <!-- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -->

   <define name="source.source">
      <element name="source:source">
         <text/>
      </element>
   </define>

   <define name="source.path">
      <element name="source:path">
         <text/>
      </element>
   </define>

   <define name="source.replace">
      <element name="source:replace">
         <text/>
      </element>
   </define>

   <define name="source.fragment">
      <element name="source:fragment">
         <ref name="source.fragmentElements"/>
      </element>
   </define>

   <define name="source.fragmentElements">
      <zeroOrMore>
         <choice>
            <element>
               <anyName/>
               <ref name="source.fragmentElements"/>
            </element>
            <attribute>
               <anyName/>
            </attribute>
         </choice>
      </zeroOrMore>
   </define>

</grammar>
