[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Schematron.
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://purl.oclc.org/dsdl/schematron" xmlns:xlink="http://www.w3.org/1999/xlink" queryBinding="xslt2" xmlns="http://purl.oclc.org/dsdl/schematron"> <iso:ns prefix="db" uri="http://docbook.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/docbook'">@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/docbook'">@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/docbook'">@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/docbook'">@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/docbook'">@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/docbook'">@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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]