]> granicus.if.org Git - docbook-dsssl/commitdiff
Add s:pattern elements to Schematron rules
authorNorman Walsh <ndw@nwalsh.com>
Thu, 20 Oct 2005 18:33:34 +0000 (18:33 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 20 Oct 2005 18:33:34 +0000 (18:33 +0000)
docbook/relaxng/docbook/src/glossary.rnc
docbook/relaxng/docbook/src/pool.rnc
docbook/relaxng/tools/augment.xsl

index 0ab68be90cdaa87bf02abe69a070b1fd16a4b34a..7d398ea5665d5052a7cc0725e5a57f92440897e9 100644 (file)
@@ -125,11 +125,14 @@ div {
 
    db.glosssee =
       [
-         s:rule [
-            context = "db:glosssee[@otherterm]"
-            s:assert [
-               test = "local-name(//*[@id=current()/@otherterm]) = 'glossentry' and namespace-uri(//*[@id=current()/@otherterm]) = 'http://docbook.org/ns/docbook'"
-               "@otherterm on glosssee must point to a glossentry."
+         s:pattern [
+            name = "Glosssary 'see' type constraint"
+            s:rule [
+               context = "db:glosssee[@otherterm]"
+               s:assert [
+                  test = "local-name(//*[@id=current()/@otherterm]) = 'glossentry' and namespace-uri(//*[@id=current()/@otherterm]) = 'http://docbook.org/ns/docbook'"
+                  "@otherterm on glosssee must point to a glossentry."
+               ]
             ]
          ]
       ]
@@ -158,11 +161,14 @@ div {
 
    db.glossseealso =
       [
-         s:rule [
-            context = "db:glossseealso[@otherterm]"
-            s:assert [
-               test = "local-name(//*[@id=current()/@otherterm]) = 'glossentry' and namespace-uri(//*[@id=current()/@otherterm]) = 'http://docbook.org/ns/docbook'"
-               "@otherterm on glossseealso must point to a glossentry."
+         s:pattern [
+            name = "Glossary 'seealso' type constraint"
+            s:rule [
+               context = "db:glossseealso[@otherterm]"
+               s:assert [
+                  test = "local-name(//*[@id=current()/@otherterm]) = 'glossentry' and namespace-uri(//*[@id=current()/@otherterm]) = 'http://docbook.org/ns/docbook'"
+                  "@otherterm on glossseealso must point to a glossentry."
+               ]
             ]
          ]
       ]
@@ -190,11 +196,14 @@ div {
 
    db.firstterm =
       [
-         s:rule [
-            context = "db:firstterm[@linkend]"
-            s:assert [
-               test = "local-name(//*[@id=current()/@linkend]) = 'glossentry' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
-               "@linkend on firstterm must point to a glossentry."
+         s:pattern [
+            name = "Glossary 'firstterm' type constraint"
+            s:rule [
+               context = "db:firstterm[@linkend]"
+               s:assert [
+                  test = "local-name(//*[@id=current()/@linkend]) = 'glossentry' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
+                  "@linkend on firstterm must point to a glossentry."
+               ]
             ]
          ]
       ]
@@ -222,11 +231,14 @@ div {
 
    db.glossterm =
       [
-         s:rule [
-            context = "db:glossterm[@linkend]"
-            s:assert [
-               test = "local-name(//*[@id=current()/@linkend]) = 'glossentry' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
-               "@linkend on glossterm must point to a glossentry."
+         s:pattern [
+            name = "Glossary 'glossterm' type constraint"
+            s:rule [
+               context = "db:glossterm[@linkend]"
+               s:assert [
+                  test = "local-name(//*[@id=current()/@linkend]) = 'glossentry' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
+                  "@linkend on glossterm must point to a glossentry."
+               ]
             ]
          ]
       ]
@@ -314,11 +326,14 @@ div {
 
    db.termdef =
       [
-         s:rule [
-            context = "db:termdef"
-            s:assert [
-               test = "count(db:glossterm) != 1"
-               "A termdef must contain a glossterm"
+         s:pattern [
+            name = "Glossary term definition constraint"
+            s:rule [
+               context = "db:termdef"
+               s:assert [
+                  test = "count(db:glossterm) != 1"
+                  "A termdef must contain a glossterm"
+               ]
             ]
          ]
       ]
index 0c160d3d7a818b53849ba115810351a5c5587368..670ae640f8f3780d635920a72972f34f1873c339 100644 (file)
@@ -1890,11 +1890,14 @@ div {
 
    db.seglistitem =
       [
-         s:rule [
-            context = "db:seglistitem"
-            s:assert [
-               test = "count(db:seg) = count(../db:segtitle)"
-               "The number of seg elements must be the same as the number of segtitle elements in the parent segmentedlist"
+         s:pattern [
+            name = "Cardinality of segments and titles"
+            s:rule [
+               context = "db:seglistitem"
+               s:assert [
+                  test = "count(db:seg) = count(../db:segtitle)"
+                  "The number of seg elements must be the same as the number of segtitle elements in the parent segmentedlist"
+               ]
             ]
          ]
       ]
@@ -2819,11 +2822,14 @@ div {
 
    db.synopfragmentref =
       [
-         s:rule [
-            context = "db:synopfragmentref"
-            s:assert [
-               test = "local-name(//*[@id=current()/@linkend]) = 'synopfragment' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
-               "@linkend on synopfragmentref must point to a synopfragment."
+         s:pattern [
+            name = "Synopsis fragment type constraint"
+            s:rule [
+               context = "db:synopfragmentref"
+               s:assert [
+                  test = "local-name(//*[@id=current()/@linkend]) = 'synopfragment' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
+                  "@linkend on synopfragmentref must point to a synopfragment."
+               ]
             ]
          ]
       ]
@@ -6639,11 +6645,14 @@ div {
 
    db.footnoteref =
       [
-         s:rule [
-            context = "db:footnoteref"
-            s:assert [
-               test = "local-name(//*[@id=current()/@linkend]) = 'footnote' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
-               "@linkend on footnoteref must point to a footnote."
+         s:pattern [
+            name = "Footnote reference type constraint"
+            s:rule [
+               context = "db:footnoteref"
+               s:assert [
+                  test = "local-name(//*[@id=current()/@linkend]) = 'footnote' and namespace-uri(//*[@id=current()/@linkend]) = 'http://docbook.org/ns/docbook'"
+                  "@linkend on footnoteref must point to a footnote."
+               ]
             ]
          ]
       ]
index 28e081b96c27d97eac8cee69c74eccebf90fbbea..8621adaf664810691eebbf25e958f4f11482994d 100644 (file)
          </xsl:message>
          -->
 
-         <s:rule context="db:{$name}">
-           <s:assert test="not(.//db:{name(.)})">
-             <xsl:value-of select="name(.)"/>
-             <xsl:text> must not occur in the descendants of </xsl:text>
-             <xsl:value-of select="$name"/>
-           </s:assert>
-         </s:rule>
+         <s:pattern name="Element exclusion">
+           <s:rule context="db:{$name}">
+             <s:assert test="not(.//db:{name(.)})">
+               <xsl:value-of select="name(.)"/>
+               <xsl:text> must not occur in the descendants of </xsl:text>
+               <xsl:value-of select="$name"/>
+             </s:assert>
+           </s:rule>
+         </s:pattern>
        </xsl:for-each>
       </xsl:for-each>
 
       </xsl:variable>
 
       <xsl:if test="$isStart &gt; 0">
-       <s:rule context="/db:{$name}">
-         <s:assert test="@version">
-           <xsl:text>The root element must have a version attribute.</xsl:text>
-         </s:assert>
-       </s:rule>
+       <s:pattern name="Root must have version">
+         <s:rule context="/db:{$name}">
+           <s:assert test="@version">
+             <xsl:text>The root element must have a version attribute.</xsl:text>
+           </s:assert>
+         </s:rule>
+       </s:pattern>
       </xsl:if>
 
       <xsl:apply-templates/>