]> granicus.if.org Git - docbook-dsssl/commitdiff
Initial checkin of a Schematron Schema for DocBook checking
authorNorman Walsh <ndw@nwalsh.com>
Mon, 9 Apr 2001 14:27:32 +0000 (14:27 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Mon, 9 Apr 2001 14:27:32 +0000 (14:27 +0000)
schema/schematron/.cvsignore [new file with mode: 0644]
schema/schematron/Makefile [new file with mode: 0644]
schema/schematron/README.CVS [new file with mode: 0644]
schema/schematron/docbook.sch [new file with mode: 0644]
schema/schematron/test.xml [new file with mode: 0644]
schema/schematron/testok.xml [new file with mode: 0644]

diff --git a/schema/schematron/.cvsignore b/schema/schematron/.cvsignore
new file mode 100644 (file)
index 0000000..310cde1
--- /dev/null
@@ -0,0 +1 @@
+docbook.xsl
diff --git a/schema/schematron/Makefile b/schema/schematron/Makefile
new file mode 100644 (file)
index 0000000..605b289
--- /dev/null
@@ -0,0 +1,12 @@
+include ../../cvstools/Makefile.incl
+
+FILE=
+
+all: docbook.xsl
+ifneq ($(FILE),)
+       $(XSLT) $(FILE) docbook.xsl
+endif
+
+docbook.xsl: docbook.sch
+       $(XJPARSE) $<
+       $(XSLT) $< $(SCHEMATRON-BASIC) $@
diff --git a/schema/schematron/README.CVS b/schema/schematron/README.CVS
new file mode 100644 (file)
index 0000000..89034f2
--- /dev/null
@@ -0,0 +1,2 @@
+This is the beginning of a Schematron Schema to test the things
+that an XML DTD can't test.
diff --git a/schema/schematron/docbook.sch b/schema/schematron/docbook.sch
new file mode 100644 (file)
index 0000000..5b0085f
--- /dev/null
@@ -0,0 +1,167 @@
+<!DOCTYPE schema PUBLIC "+//IDN sinica.edu.tw//DTD Schematron 1.5//EN"
+                 "file:///share/doctypes/schematron/schematron1-5.dtd" [
+
+<!ENTITY links.exclusion '
+  <assert test="count(.//link) = 0"><name/> contains link</assert>
+  <assert test="count(.//olink) = 0"><name/> contains olink</assert>
+  <assert test="count(.//ulink) = 0"><name/> contains ulink</assert>
+  <assert test="count(.//xref) = 0"><name/> contains xref</assert>
+'>
+
+<!ENTITY ubiq.exclusion '
+  <assert test="count(.//indexterm) = 0"><name/> contains indexterm</assert>
+  <assert test="count(.//beginpage) = 0"><name/> contains beginpage</assert>
+'>
+
+<!ENTITY formal.exclusion '
+   <assert test="count(.//equation) = 0"><name/> contains equation</assert>
+   <assert test="count(.//example) = 0"><name/> contains example</assert>
+   <assert test="count(.//figure) = 0"><name/> contains figure</assert>
+   <assert test="count(.//table) = 0"><name/> contains table</assert>
+'>
+
+<!ENTITY admon.exclusion '
+   <assert test="count(.//warning) = 0"><name/> contains warning</assert>
+   <assert test="count(.//tip) = 0"><name/> contains tip</assert>
+   <assert test="count(.//note) = 0"><name/> contains note</assert>
+   <assert test="count(.//caution) = 0"><name/> contains caution</assert>
+   <assert test="count(.//important) = 0"><name/> contains important</assert>
+'>
+
+]>
+
+<schema xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
+  <title>Schematron 1.5 Schema for DocBook</title>
+
+  <!-- ============================================================ -->
+  <!-- Exclusions                                                   -->
+  <!-- ============================================================ -->
+
+  <pattern name="Nested Footnotes">
+    <rule context="footnote">
+      <assert test="count(.//footnote) = 0">Nested footnotes</assert>
+      &formal.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Nested Admonitions">
+    <rule context="warning|caution|tip|note|important">
+      &admon.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Nested Formal Objects">
+    <rule context="equation|example|figure|table">
+      &formal.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Formal Exclusions">
+    <rule context="legalnotice">
+      &formal.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Highlights Exclusions">
+    <rule context="highlights">
+      &ubiq.exclusion;
+      &formal.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Acronym Exclusion">
+    <rule context="acronym">
+      <assert test="count(.//acronym) = 0"><name/> contains acronym</assert>
+    </rule>
+  </pattern>
+
+  <pattern name="Glossterm Exclusion">
+    <rule context="glossterm">
+      <assert test="count(.//glossterm) = 0"><name/> contains glossterm</assert>
+    </rule>
+  </pattern>
+
+  <pattern name="Ubiq Exclusion">
+    <rule context="biblioentry|bibliomixed|biblioset|bibliomset|screeninfo">
+      &ubiq.exclusion;
+    </rule>
+    <rule context="modespec|subscript|superscript|indexterm">
+      &ubiq.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Blockquote Exclusion">
+    <rule context="blockquote">
+      <assert test="count(.//epigraph) = 0"><name/> contains epigraph</assert>
+    </rule>
+  </pattern>
+
+  <pattern name="Links Exclusion">
+    <rule context="ulink|olink|link">
+      &links.exclusion;
+    </rule>
+  </pattern>
+
+  <pattern name="Remark Exclusion">
+    <rule context="remark">
+      <assert test="count(.//remark) = 0"><name/> contains remark</assert>
+    </rule>
+  </pattern>
+
+  <pattern name="Beginpage Exclusion">
+    <rule context="setinfo|bookinfo|appendixinfo|bibliographyinfo|setindexinfo">
+      <assert test="count(.//beginpage) = 0"><name/> contains beginpage</assert>
+    </rule>
+    <rule context="chapterinfo|glossaryinfo|indexinfo|partinfo">
+      <assert test="count(.//beginpage) = 0"><name/> contains beginpage</assert>
+    </rule>
+    <rule context="prefaceinfo|refentryinfo|refsynopsisdivinfo|refmeta">
+      <assert test="count(.//beginpage) = 0"><name/> contains beginpage</assert>
+    </rule>
+    <rule context="refsect1info|refsect2info|refsect3info">
+      <assert test="count(.//beginpage) = 0"><name/> contains beginpage</assert>
+    </rule>
+    <rule context="sect1info|sect2info|sect3info|sect4info|sect5info|sectioninfo|simplesectinfo">
+      <assert test="count(.//beginpage) = 0"><name/> contains beginpage</assert>
+    </rule>
+  </pattern>
+
+  <pattern name="Indexterm Exclusion">
+    <rule context="index|setindex">
+      <assert test="count(.//indexterm) = 0"><name/> contains indexterm</assert>
+    </rule>
+  </pattern>
+
+  <!-- ============================================================ -->
+  <!-- Glossary Terms                                               -->
+  <!-- ============================================================ -->
+
+  <pattern name="Glossterm Links">
+    <rule context="glossterm[@linkend]">
+      <report test="local-name(id(@linkend)) != 'glossentry'">
+        Warning: <name/> does not point to a glossentry!
+      </report>
+    </rule>
+  </pattern>
+
+  <pattern name="Glossterm Missing Links">
+    <rule context="glossterm">
+      <report test="not(@linkend) and not(parent::glossentry)">
+        Note: <name/> does not have a linkend attribute.
+      </report>
+    </rule>
+  </pattern>
+
+  <!-- test to make sure that every glossterm has a glossterm with
+       the same content that appears in a glossdef somewhere... -->
+  <!--
+  <pattern name="Missing Glossary Definitions">
+    <rule context="glossterm">
+      <assert test="//glossdef/glossterm">
+        Glossterm has no definition.
+      </assert>
+    </rule>
+  </pattern>
+  -->
+
+</schema>
diff --git a/schema/schematron/test.xml b/schema/schematron/test.xml
new file mode 100644 (file)
index 0000000..3fbbac2
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+                  "../../docbook/xml/docbookx.dtd">
+<article>
+<articleinfo>
+<title>Test Article</title>
+</articleinfo>
+
+<para>A paragraph<footnote><para>A footnote<footnote><para>A nested
+footnote</para></footnote></para></footnote></para>
+
+<warning>
+  <para>
+    <note>
+      <para>A note in a warning</para>
+    </note>
+  </para>
+</warning>
+
+<table><title>A Table</title>
+  <tgroup cols="2">
+     <tbody>
+       <row>
+         <entry><para>1</para></entry>
+         <entry><para>2
+<figure><title>A Figure</title>
+<programlisting>foo</programlisting>
+</figure></para></entry></row>
+     </tbody>
+  </tgroup>
+</table>
+
+<para>This is a <glossterm linkend="gt">glossterm</glossterm>.  A
+<glossterm linkend="gloss">glossdef</glossterm> is also a glossterm.
+So is a <glossterm>dinosaur</glossterm>.</para>
+
+<glossary id="gloss">
+<glossentry id='gt'><glossterm>glossterm</glossterm>
+<glossdef><para>A glossary term.</para>
+</glossdef>
+</glossentry>
+<glossentry id='gd'><glossterm>glossdef</glossterm>
+<glossdef><para>A glossary definition.</para>
+</glossdef>
+</glossentry>
+</glossary>
+
+</article>
diff --git a/schema/schematron/testok.xml b/schema/schematron/testok.xml
new file mode 100644 (file)
index 0000000..3cb54e6
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+                  "../../docbook/xml/docbookx.dtd">
+<article>
+<articleinfo>
+<title>Test Article</title>
+</articleinfo>
+
+<para>A paragraph<footnote><para>A footnote</para></footnote></para>
+
+<warning>
+  <para>A warning
+  </para>
+</warning>
+
+<table><title>A Table</title>
+  <tgroup cols="2">
+     <tbody>
+       <row>
+         <entry><para>1</para></entry>
+         <entry><para>2</para></entry></row>
+     </tbody>
+  </tgroup>
+</table>
+
+
+</article>