我是 schematron 的新手,我有以下问题。这是来自 xhtml 文件的片段:
<div class="provision">
<!-- provision (SECTION) -->
<header>
<!-- headers -->
<div class="desig">
<!-- if provision then header/div@class=desig/span@class=num required -->
<span class="num">1.</span>
</div>
<h1 class="title">prov-title</h1>
</header>
<p class="prov">para-prov-level</p>
<p class="prov">para-prov-level</p>
<div class="glossary">
<!-- glossary -->
<!-- glossary requires dl -->
<dl>
<!-- dl should have dt, and at least one dd -->
<dt> term </dt>
<dd>definition</dd>
<dt> term </dt>
<dd>definition</dd>
</dl>
</div>
<div class="level-1-grp">
<!-- SUBSECTION -->
<header>
<div class="desig">
<span class="num">(1)</span>
</div>
</header>
<p class="level-1">para-level-1</p>
<div class="level-2-grp">
<header>
<div class="desig">
<span class="num">(a)</span>
</div>
</header>
<p class="level-2">para-level-2</p>
</div>
<div class="level-2-grp">
<header>
<div class="desig">
<span class="num">(b)</span>
</div>
</header>
<p class="level-2">para-level-2</p>
</div>
<p class="level-1">para-level-1</p>
</div>
<p class="prov">para-prov-level</p>
</div>
我想创建一个规则来检查是否有provision
then header/div@class=desig/span@class=num
required 和 glossary
requires dl
。我一直在尝试这样但它不起作用:
<iso:pattern id="structure-provision">
<iso:title>Testing for Provision structure...</iso:title>
<iso:rule context="*:div[@class='provision']">
<iso:assert test="self::*:header/div[@class ='desig']/*:span[@class='num']">if provision then header/div@class=desig/span@class=num required</iso:assert>
</iso:rule>
</iso:pattern>
<!--glossory structure -->
<iso:pattern id="structure-glossory">
<iso:title>Testing for Provision structure...</iso:title>
<iso:rule context="*:div[@class='glossory']">
<iso:assert test="self::*:dl">glossary requires dl</iso:assert>
<iso:assert test="self::*:dl/dt">dl should have a dt</iso:assert>
</iso:rule>
</iso:pattern>
任何帮助,将不胜感激。谢谢