List Info

Thread: Schematron.




Schematron.
user name
2007-01-28 06:42:21
I took the version 5 schematron file as a basis
and updated to iso Schematron.

I'd fallen foul of using xml:id values and other html files
with the 
same name (OK OK I know it was stupid 

So i added a couple of tests.

Also added a check for duplicate xml:id values (nxml-mode
doesn't show 
that).

Below is the iso schematron file.

See www.schematron.com for appropriate files.

HTH DaveP





<?xml version="1.0"
encoding="utf-8"?>
<iso:schema xmlns:iso="http://pur
l.oclc.org/dsdl/schematron"
	    xmlnslink=
"http://www.w3.org/
1999/xlink"
	    queryBinding="xslt2"
	    xmlns="http:/
/purl.oclc.org/dsdl/schematron">
    <iso:ns prefix="db" uri="http://docbo
ok.org/ns/docbook"/>
    <iso:ns prefix='xlink' uri="http://www.w3
.org/1999/xlink"/>
    <iso:pattern >
       <iso:title >Glossary 'firstterm' type
constraint</iso:title>
       <iso:rule context="db:firstterm[linkend]">
          <iso:assert test="local-name(//*[id=current()/linkend]) = 
'glossentry' and namespace-uri(//*[id=current()/linkend])
= 
'http://docbook.org/ns/d
ocbook'">linkend on firstterm must point to a 
glossentry.</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Footnote reference type
constraint</iso:title>
       <iso:rule context="db:footnoteref">
          <iso:assert test="local-name(//*[id=current()/linkend]) = 
'footnote' and namespace-uri(//*[id=current()/linkend])
= 
'http://docbook.org/ns/d
ocbook'">linkend on footnoteref must point to a 
footnote.</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Glossary 'glossterm' type
constraint</iso:title>
       <iso:rule context="db:glossterm[linkend]">
          <iso:assert test="local-name(//*[id=current()/linkend]) = 
'glossentry' and namespace-uri(//*[id=current()/linkend])
= 
'http://docbook.org/ns/d
ocbook'">linkend on glossterm must point to a 
glossentry.</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Synopsis fragment type
constraint</iso:title>
       <iso:rule
context="db:synopfragmentref">
          <iso:assert test="local-name(//*[id=current()/linkend]) = 
'synopfragment' and namespace-uri(//*[id=current()/linkend])
= 
'http://docbook.org/ns/d
ocbook'">linkend on synopfragmentref must point 
to a synopfragment.</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Glossary 'seealso' type
constraint</iso:title>
       <iso:rule context="db:glossseealso[otherterm]">
          <iso:assert test="local-name(//*[id=current()/otherterm]) = 
'glossentry' and namespace-uri(//*[id=current()/otherterm]) = 
'http://docbook.org/ns/d
ocbook'">otherterm on glossseealso must point 
to a glossentry.</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Glosssary 'see' type
constraint</iso:title>
       <iso:rule context="db:glosssee[otherterm]">
          <iso:assert test="local-name(//*[id=current()/otherterm]) = 
'glossentry' and namespace-uri(//*[id=current()/otherterm]) = 
'http://docbook.org/ns/d
ocbook'">otherterm on glosssee must point to a 
glossentry.</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Glossary term definition
constraint</iso:title>
       <iso:rule context="db:termdef">
          <iso:assert test="count(db:glossterm) =
1">A termdef must 
contain exactly one glossterm</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Element
exclusion</iso:title>
       <iso:rule context="db:annotation">
          <iso:assert
test="not(.//db:annotation)">annotation must
not 
occur in the descendants of annotation</iso:assert>
       </iso:rule>
       <iso:rule context="db:caution">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of caution</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of caution</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of caution</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of caution</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of caution</iso:assert>
       </iso:rule>
       <iso:rule context="db:important">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of important</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of important</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of important</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of important</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of important</iso:assert>
       </iso:rule>
       <iso:rule context="db:note">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of note</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of note</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of note</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of note</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of note</iso:assert>
       </iso:rule>
       <iso:rule context="db:tip">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of tip</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of tip</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of tip</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of tip</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of tip</iso:assert>
       </iso:rule>
       <iso:rule context="db:warning">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of warning</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of warning</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of warning</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of warning</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of warning</iso:assert>
       </iso:rule>
       <iso:rule context="db:caption">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:example)">example must not
occur 
in the descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:figure)">figure must not occur
in 
the descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:sidebar)">sidebar must not
occur 
in the descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:table)">table must not occur in

the descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:task)">task must not occur in
the 
descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of caption</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of caption</iso:assert>
       </iso:rule>
       <iso:rule context="db:example">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of example</iso:assert>
          <iso:assert
test="not(.//db:example)">example must not
occur 
in the descendants of example</iso:assert>
          <iso:assert
test="not(.//db:figure)">figure must not occur
in 
the descendants of example</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of example</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of example</iso:assert>
          <iso:assert
test="not(.//db:table)">table must not occur in

the descendants of example</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of example</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of example</iso:assert>
       </iso:rule>
       <iso:rule context="db:figure">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:example)">example must not
occur 
in the descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:figure)">figure must not occur
in 
the descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:table)">table must not occur in

the descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of figure</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of figure</iso:assert>
       </iso:rule>
       <iso:rule context="db:table">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of table</iso:assert>
          <iso:assert
test="not(.//db:example)">example must not
occur 
in the descendants of table</iso:assert>
          <iso:assert
test="not(.//db:figure)">figure must not occur
in 
the descendants of table</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of table</iso:assert>
          <iso:assert
test="not(.//db:informaltable)">informaltable
must 
not occur in the descendants of table</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of table</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of table</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of table</iso:assert>
       </iso:rule>
       <iso:rule context="db:footnote">
          <iso:assert
test="not(.//db:caution)">caution must not
occur 
in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:epigraph)">epigraph must not
occur 
in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:example)">example must not
occur 
in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:figure)">figure must not occur
in 
the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:footnote)">footnote must not
occur 
in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:important)">important must not

occur in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:indexterm)">indexterm must not

occur in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:note)">note must not occur in
the 
descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:sidebar)">sidebar must not
occur 
in the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:table)">table must not occur in

the descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:task)">task must not occur in
the 
descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:tip)">tip must not occur in the

descendants of footnote</iso:assert>
          <iso:assert
test="not(.//db:warning)">warning must not
occur 
in the descendants of footnote</iso:assert>
       </iso:rule>
       <iso:rule context="db:sidebar">
          <iso:assert
test="not(.//db:sidebar)">sidebar must not
occur 
in the descendants of sidebar</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Cardinality of segments and
titles</iso:title>
       <iso:rule context="db:seglistitem">
          <iso: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</iso:assert>
       </iso:rule>
    </iso:pattern>
    <iso:pattern >
       <iso:title >Root must have
version</iso:title>
       <iso:rule context="/db:para">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:set">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:book">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:dedication">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:colophon">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:appendix">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:chapter">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:part">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:preface">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:section">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:article">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:sect1">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:sect2">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:sect3">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:sect4">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:sect5">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:reference">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:refentry">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:refsection">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:refsect1">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:refsect2">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:refsect3">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:glossary">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule
context="/db:bibliography">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:index">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:setindex">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
       <iso:rule context="/db:toc">
          <iso:assert test="version">The root
element must have a 
version attribute.</iso:assert>
       </iso:rule>
    </iso:pattern>


  <iso:pattern id="idChecks">
      <iso:title>Check for duplicate id
values</iso:title>
      <iso:rule context="*[xml:id]">
        <iso:report test="xml:id=following:/xml:id">Duplicate id 
values found. Value is <iso:value-of select="xml:id"/></iso:report>
      </iso:rule>
  </iso:pattern>

    <iso:pattern id="chunkChecks">
      <iso:title>Check for duplicate
filenames</iso:title>
      <iso:rule context="db:chapter">
        <iso:report test="following::db:chapter/xml:id =

current()/xml:id">Warning: Two chapters with same id
value.
      If chunking this will cause overwritten html
        </iso:report>
      </iso:rule>

      <iso:rule context="db:chapter[xml:id]">
       <iso:report test="concat(xml:id,'.html') =
        descendant::db:link/xlink:href">Warning:
        Chapter has duplicate xml:id value to a linked html
file. If
        chunking and using id values as filenames this will
cause an
        overwritten html file [<iso:value-of
        select="xml:id"/>.html]</iso:report>
      </iso:rule>

      <iso:rule context="db:appendix[xml:id]">
        <iso:report test="concat(xml:id,'.html') =
        descendant::db:link/xlink:href">Warning:
        Appendix has duplicate xml:id value to a linked html
file. If
        chunking and using id values as filenames this will
cause an
        overwritten html file [<iso:value-of
        select="xml:id"/>.html]</iso:report>
      </iso:rule>

    </iso:pattern>
</iso:schema>

regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk


------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


Re: Schematron.
user name
2007-01-28 10:46:26
On 1/28/07, Dave Pawson <davepdpawson.co.uk> wrote:
> I took the version 5 schematron file as a basis
> and updated to iso Schematron.
>
> Below is the iso schematron file.

Ah, nice. I'd been looking around for more real-world
examples.

>     <iso:pattern >
>        <iso:title >Root must have
version</iso:title>
>        <iso:rule context="/db:para">
>           <iso:assert test="version">The root element must have a
> version attribute.</iso:assert>
>        </iso:rule>
>        <iso:rule context="/db:set">

Any reason you chose to enumerate all of these root elements
rather
than just use "/*" ?


Keith

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


Re: Schematron.
user name
2007-01-28 11:10:24
Keith Fahlgren wrote:
> On 1/28/07, Dave Pawson <davepdpawson.co.uk> wrote:
>> I took the version 5 schematron file as a basis
>> and updated to iso Schematron.
>>
>> Below is the iso schematron file.
> 
> Ah, nice. I'd been looking around for more real-world
examples.
> 
>>     <iso:pattern >
>>        <iso:title >Root must have
version</iso:title>
>>        <iso:rule
context="/db:para">
>>           <iso:assert test="version">The root element must have a
>> version attribute.</iso:assert>
>>        </iso:rule>
>>        <iso:rule
context="/db:set">
> 
> Any reason you chose to enumerate all of these root
elements rather
> than just use "/*" ?


I didn't.
I'm guessing it was one of the working group?

The one that is 'odd' is db:para

(also note that the leading / isn't needed!)

Anyone interested, I've put some Schematron documentation
up
at www.dpawson.co.uk/schematron

All in docbook v5, with Bobs v.latest stylesheets... of
course 


regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk


------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )