RELAX NG Schema for Links
Author: Hugh Field-Richards
Date: 2006-08-17T12:30

This is the RELAX NG schema for links (URL clickable links) within the text.

Included file: common.rng

A link surrounds any context except itself. Unless I use the schematron this is going to be very difficult to pick up in XML Schema without a lot of nasty constructions. Note also that the link may not need content - just a bare URL, say. The XSLT would be responsible for showing it as linkable text.

link.linkElement — Warning! not used within this schema file.
define : link.linkElement
Schematron
No nested link tags
Context : “link:link
If condition “ancestor::link:link
then output: No nested link tags
element : link:link
refcommon.commonAttributes
attribute : ref
Any text
zeroOrMore
choice
reftext.horizontalContent
reftext.verticalContent
<define name="link.linkElement">
   <sch:pattern name="No nested link tags">
      <sch:rule context="link:link">
         <sch:report test="ancestor::link:link">No nested link tags</sch:report>
      </sch:rule>
   </sch:pattern>
   <element name="link:link">
      <ref name="common.commonAttributes"/>
      <ref name="link.targetAttribute"/>
      <ref name="link.typeAttribute"/>
      <attribute name="ref">
         <text/>
      </attribute>
      <zeroOrMore>
         <choice>
            <ref name="text.horizontalContent"/>
            <ref name="text.verticalContent"/>
         </choice>
      </zeroOrMore>
   </element>
</define>

Determines whether the link should be displayed when on a browser in a new window.

link.targetAttribute (Combine: choice)
define : link.targetAttribute
optional
attribute : target
Any text
<define name="link.targetAttribute" combine="choice">
   <optional>
      <attribute name="target">
         <text/>
      </attribute>
   </optional>
</define>

Determines whether the link should be displayed when on a browser in a new window.

link.typeAttribute (Combine: choice)
define : link.typeAttribute
attribute : type
choice
value = "uri"
value = "email"
value = "undefined"
value = "glossary"
value = "index"
value = "toc"
value = "bib"
value = "ref"
value = "anchor"
<define name="link.typeAttribute" combine="choice">
   <attribute name="type">
      <choice>
         <value>uri</value>
         <value>email</value>
         <value>undefined</value>
         <value>glossary</value>
         <value>index</value>
         <value>toc</value>
         <value>bib</value>
         <value>ref</value>
         <value>anchor</value>
      </choice>
   </attribute>
</define>