RELAX NG Schema for Paloose Text Elements
Author: Hugh Field-Richards
Date: 2006-08-17T21:15

This is the RELAX NG schema for the horizontal and vertical text elements used in the Paloose site.


Included file: i18n.rng

Included file: link.rng

Included file: list.rng

Included file: graphic.rng

Included file: ../sourceWriting.rng

Emphasis

We can add several degrees of emphasis: weak, normal and strong. How these will appear depends on the style transformation. It can only contain a restricted set of horizontal content (foreignWord, abbrev, note, i18n:* or text).

For example

 <text:p>We can add several levels of <text:emph
      degree="strong">emphasis</text:emph> as we wish by extending the
      attributes.</text:p>
define : text.emphElement
element : text:emph
refcommon.commonAttributes
attribute : degree
choice
value = "weak"
value = "normal"
value = "strong"
interleave
Any text
zeroOrMore
choice
refi18n.text
<define name="text.emphElement">
   <element name="text:emph">
      <ref name="common.commonAttributes"/>
      <attribute name="degree">
         <choice>
            <value>weak</value>
            <value>normal</value>
            <value>strong</value>
         </choice>
      </attribute>
      <interleave>
         <text/>
         <zeroOrMore>
            <choice>
               <ref name="text.foreignWordElement"/>
               <ref name="text.abbrevElement"/>
               <ref name="text.noteElement"/>
               <ref name="i18n.text"/>
               <ref name="text.codeElement"/>
            </choice>
         </zeroOrMore>
      </interleave>
   </element>
</define>

Foreign Word/Phrase

Enclosing a set of words in another language other than the base language for the document. It provides for the language used (lang) and a translation of the word into the the base language (trans). It can only contain a restricted set of horizontal content (emph, abbrev, note, i18n:* or text).

For example

 <text:foreignWord trans="Seize the day" lang="lat">carpe
      diem</text:foreignWord>
define : text.foreignWordElement
element : text:foreignWord
refcommon.commonAttributes
optional
attribute : trans
interleave
Any text
zeroOrMore
choice
refi18n.text
<define name="text.foreignWordElement">
   <element name="text:foreignWord">
      <ref name="common.commonAttributes"/>
      <optional>
         <attribute name="trans"/>
      </optional>
      <interleave>
         <text/>
         <zeroOrMore>
            <choice>
               <ref name="text.emphElement"/>
               <ref name="text.abbrevElement"/>
               <ref name="text.noteElement"/>
               <ref name="i18n.text"/>
            </choice>
         </zeroOrMore>
      </interleave>
   </element>
</define>

Who (used for provenance)

Encloses a person's name. Often used in conjunction with the prov attriribute. It can only contain a restricted set of horizontal content (emph, abbrev, i18n:* or text).

For example

 <text:who>Hugh Field-Richards</text:who>
define : text.whoElement
element : text:who
refcommon.commonAttributes
interleave
Any text
zeroOrMore
choice
refi18n.text
<define name="text.whoElement">
   <element name="text:who">
      <ref name="common.commonAttributes"/>
      <interleave>
         <text/>
         <zeroOrMore>
            <choice>
               <ref name="text.emphElement"/>
               <ref name="text.abbrevElement"/>
               <ref name="i18n.text"/>
            </choice>
         </zeroOrMore>
      </interleave>
   </element>
</define>

Abbreviation

It is useful to isolate what are abbreviations. The full attribute is designed to hold the expanded version of the abbreviation. It can only contain a restricted set of horizontal content (emph, foreignWord, note, i18n:* or text).

For example

 <text:abbrev full="Extensible Markup
      Language">XML</text:abbrev>
define : text.abbrevElement
element : text:abbrev
refcommon.commonAttributes
attribute : full
interleave
Any text
zeroOrMore
choice
refi18n.text
<define name="text.abbrevElement">
   <element name="text:abbrev">
      <ref name="common.commonAttributes"/>
      <attribute name="full"/>
      <interleave>
         <text/>
         <zeroOrMore>
            <choice>
               <ref name="text.emphElement"/>
               <ref name="text.foreignWordElement"/>
               <ref name="text.noteElement"/>
               <ref name="i18n.text"/>
            </choice>
         </zeroOrMore>
      </interleave>
   </element>
</define>

Code

This specifies that this is an inline chunk of code.

For example

 <text:p>The root directory is "<text:code
      type="dir">/Users/</text:code>".</text:p>
define : text.codeElement
element : text:code
refcommon.commonAttributes
attribute : type
choice
value = "tag"
value = "var"
value = "dir"
Any text
<define name="text.codeElement">
   <element name="text:code">
      <ref name="common.commonAttributes"/>
      <attribute name="type">
         <choice>
            <value>tag</value>
            <value>var</value>
            <value>dir</value>
         </choice>
      </attribute>
      <text/>
   </element>
</define>

Note

Notes provide a range of additional text annotations and can appear within selected horizontal content but can contain paragraph and verbatim vertical content. However notes may not contain other notes. What you use and do with the attribute Type values is up for you to decide.

For example

 <text:note type="warning"> <text:p>Apologies to all: there was a
      problem with the download which gave a page not found error. This has been
      fixed.</text:p> </text:note>
define : text.noteElement
Schematron
No nested notes.
Context : “text:note
If condition “ancestor::text:note
then output: No nested notes
element : text:note
refcommon.commonAttributes
attribute : type
choice
value = "caution"
value = "important"
value = "note"
value = "footnote"
value = "warning"
value = "information"
zeroOrMore
<define name="text.noteElement">
   <sch:pattern name="No nested notes.">
      <sch:rule context="text:note">
         <sch:report test="ancestor::text:note">No nested notes</sch:report>
      </sch:rule>
   </sch:pattern>
   <element name="text:note">
      <ref name="common.commonAttributes"/>
      <attribute name="type">
         <choice>
            <value>caution</value>
            <value>important</value>
            <value>note</value>
            <value>footnote</value>
            <value>warning</value>
            <value>information</value>
         </choice>
      </attribute>
      <zeroOrMore>
         <choice>
            <ref name="text.verticalContent"/>
            <ref name="text.horizontalContent"/>
         </choice>
      </zeroOrMore>
   </element>
</define>

Forced newline

There are occasions when a simple forced newline is required.

define : text.forcedLine
element : text:newline
refcommon.commonAttributes
<define name="text.forcedLine">
   <element name="text:newline">
      <ref name="common.commonAttributes"/>
   </element>
</define>

Index entry

These are markers for the LaTeX engine to produce an index.

define : text.indexEntry
element : text:index
refcommon.commonAttributes
attribute : entry
Any text
optional
attribute : see
Any text
optional
attribute : level
choice
value = "main"
value = "normal"
optional
attribute : range
choice
value = "start"
value = "finish"
value = "following"
<define name="text.indexEntry">
   <element name="text:index">
      <ref name="common.commonAttributes"/>
      <attribute name="entry">
         <text/>
      </attribute>
      <optional>
         <attribute name="see">
            <text/>
         </attribute>
      </optional>
      <optional>
         <attribute name="level">
            <choice>
               <value>main</value>
               <value>normal</value>
            </choice>
         </attribute>
      </optional>
      <optional>
         <attribute name="range">
            <choice>
               <value>start</value>
               <value>finish</value>
               <value>following</value>
            </choice>
         </attribute>
      </optional>
   </element>
</define>

Horizontal Content

Define what we mean by horizontal content.

define : text.horizontalContent
interleave
choice
reflink.linkElement
refi18n.text
Any text
<define name="text.horizontalContent">
   <interleave>
      <choice>
         <ref name="text.forcedLine"/>
         <ref name="text.emphElement"/>
         <ref name="text.codeElement"/>
         <ref name="text.whoElement"/>
         <ref name="text.foreignWordElement"/>
         <ref name="text.abbrevElement"/>
         <ref name="text.noteElement"/>
         <ref name="link.linkElement"/>
         <ref name="i18n.text"/>
         <ref name="text.indexEntry"/>
         <text/>
      </choice>
   </interleave>
</define>

Paragraph

A paragraph consists of any horizontal content or character text. It can only contain a restricted set of horizontal content (emph, foreignWord, note, or text).

define : text.pElement
element : text:p
refcommon.commonAttributes
zeroOrMore
<define name="text.pElement">
   <element name="text:p">
      <ref name="common.commonAttributes"/>
      <zeroOrMore>
         <ref name="text.horizontalContent"/>
      </zeroOrMore>
   </element>
</define>

Quotation

Extension of a simple paragraph that contains the author of the quote (who) and the type of quote (para or inline).

define : text.quoteElement
element : text:quote
refcommon.commonAttributes
optional
attribute : who
optional
attribute : ref
attribute : type
choice
value = "para"
value = "inline"
zeroOrMore
<define name="text.quoteElement">
   <element name="text:quote">
      <ref name="common.commonAttributes"/>
      <optional>
         <attribute name="who"/>
      </optional>
      <optional>
         <attribute name="ref"/>
      </optional>
      <attribute name="type">
         <choice>
            <value>para</value>
            <value>inline</value>
         </choice>
      </attribute>
      <zeroOrMore>
         <ref name="text.horizontalContent"/>
      </zeroOrMore>
   </element>
</define>

Group

Group of horizontal or vertical content. It is provided to isolate groups of content for the style engine. In general this is not usually used in ordinary text. It can also contain a reference to an image (img), some alternate text for the image (alt) and a position (left or right).

define : text.groupElement
element : text:group
refcommon.commonAttributes
optional
attribute : img
data : string
optional
attribute : alt
data : string
optional
attribute : pos
choice
value = "left"
value = "right"
zeroOrMore
<define name="text.groupElement">
   <element name="text:group">
      <ref name="common.commonAttributes"/>
      <optional>
         <attribute name="img">
            <data type="string"/>
         </attribute>
      </optional>
      <optional>
         <attribute name="alt">
            <data type="string"/>
         </attribute>
      </optional>
      <optional>
         <attribute name="pos">
            <choice>
               <value>left</value>
               <value>right</value>
            </choice>
         </attribute>
      </optional>
      <zeroOrMore>
         <choice>
            <ref name="text.verticalContent"/>
            <ref name="text.horizontalContent"/>
         </choice>
      </zeroOrMore>
   </element>
</define>

Headings

Simple headings of any level. The level is not restricted.

define : text.headingElement
element : text:heading
refcommon.commonAttributes
attribute : level
data : positiveInteger
interleave
choice
refi18n.text
reflink.linkElement
Any text
<define name="text.headingElement">
   <element name="text:heading">
      <ref name="common.commonAttributes"/>
      <attribute name="level">
         <data type="positiveInteger"/>
      </attribute>
      <interleave>
         <choice>
            <ref name="text.forcedLine"/>
            <ref name="text.emphElement"/>
            <ref name="text.foreignWordElement"/>
            <ref name="text.abbrevElement"/>
            <ref name="i18n.text"/>
            <ref name="link.linkElement"/>
            <text/>
         </choice>
      </interleave>
   </element>
</define>

Introduction

This is a specific grouping of vertical content that can be formatted in a specific style.

define : text.introductionElement
element : text:introduction
refcommon.commonAttributes
zeroOrMore
choice
reflist.listElement
refgraphic.graphicElement
refi18n.text
<define name="text.introductionElement">
   <element name="text:introduction">
      <ref name="common.commonAttributes"/>
      <zeroOrMore>
         <choice>
            <ref name="text.pElement"/>
            <ref name="text.groupElement"/>
            <ref name="text.quoteElement"/>
            <ref name="text.headingElement"/>
            <ref name="list.listElement"/>
            <ref name="graphic.graphicElement"/>
            <ref name="i18n.text"/>
         </choice>
      </zeroOrMore>
   </element>
</define>
define : text.verbatimElement

Verbatim text

Directly reproduced text honouring all spaces and newlines. It can be given a title. Note that any translation of tags into the appropriate angle bracket form is done elsewhere when viewing this type of element. If required we could add emphasis as an allowable tag here to highlight aspects of the text. At present only the group element is allowed inside verbatim.

element : text:verbatim
refcommon.commonAttributes
optional
attribute : title
oneOrMore
interleave
choice
Any text
<define name="text.verbatimElement">
   <xhtml:div>
      <xhtml:h2>Verbatim text</xhtml:h2>
      <xhtml:p>
         <xhtml:code>title</xhtml:code>
      </xhtml:p>
   </xhtml:div>
   <element name="text:verbatim">
      <ref name="common.commonAttributes"/>
      <optional>
         <attribute name="title"/>
      </optional>
      <oneOrMore>
         <interleave>
            <choice>
               <ref name="text.groupElement"/>
               <ref name="text.additionElement"/>
               <ref name="text.deletionElement"/>
               <ref name="text.cmdElement"/>
               <text/>
            </choice>
         </interleave>
      </oneOrMore>
   </element>
</define>
define : text.additionElement

Additions text within verbatim text

Marks when code has been added or changed.

element : text:addition
refcommon.commonAttributes
Any text
<define name="text.additionElement">
   <xhtml:div>
      <xhtml:h2>Additions text within verbatim text</xhtml:h2>
      <xhtml:p>Marks when code has been added or changed.</xhtml:p>
   </xhtml:div>
   <element name="text:addition">
      <ref name="common.commonAttributes"/>
      <text/>
   </element>
</define>
define : text.deletionElement

Deletions text within verbatim text

Marks when code has been deleted.

element : text:deletion
refcommon.commonAttributes
Any text
<define name="text.deletionElement">
   <xhtml:div>
      <xhtml:h2>Deletions text within verbatim text</xhtml:h2>
      <xhtml:p>Marks when code has been deleted.</xhtml:p>
   </xhtml:div>
   <element name="text:deletion">
      <ref name="common.commonAttributes"/>
      <text/>
   </element>
</define>
define : text.cmdElement

User command

Denotes a command at the user prompt in verbatim

element : text:cmd
refcommon.commonAttributes
Any text
<define name="text.cmdElement">
   <xhtml:div>
      <xhtml:h2>User command</xhtml:h2>
      <xhtml:p>Denotes a command at the user prompt in verbatim</xhtml:p>
   </xhtml:div>
   <element name="text:cmd">
      <ref name="common.commonAttributes"/>
      <text/>
   </element>
</define>

Vertical Content

Define what we mean by vertical content for this schema. Extend or restict this in higher schemas.

define : text.verticalContent
interleave
zeroOrMore
choice
refgraphic.graphicElement
reflist.listElement
refsource.write
refsource.insert
refsource.delete
<define name="text.verticalContent">
   <interleave>
      <zeroOrMore>
         <choice>
            <ref name="text.pElement"/>
            <ref name="text.noteElement"/>
            <ref name="text.groupElement"/>
            <ref name="text.quoteElement"/>
            <ref name="text.verbatimElement"/>
            <ref name="graphic.graphicElement"/>
            <ref name="list.listElement"/>
            <ref name="text.introductionElement"/>
            <ref name="text.headingElement"/>
            <ref name="source.write"/>
            <ref name="source.insert"/>
            <ref name="source.delete"/>
            <ref name="text.indexEntry"/>
         </choice>
      </zeroOrMore>
   </interleave>
</define>