我是新的schematron,我有以下問題。這是從XHTML文件的片段:實施schematron規則
<div class="provision">
<!-- provision (SECTION) -->
<header>
<!-- headers -->
<div class="desig">
<!-- if provision then header/[email protected]=desig/[email protected]=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
然後header/[email protected]=desig/[email protected]=num
需要和glossary
需要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/[email protected]=desig/[email protected]=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>
任何幫助,將不勝感激。謝謝
哪位不工作?所有的?鑑於你的上下文節點是正確的,測試節點應該是相對的。在做schematron時,我總是從簡單開始。因此,例如,我強迫斷言來證明上下文,並更改我正在驗證的文檔以減少潛在的歧義。除非你有一些非常聰明的工具,否則調試很痛苦。 –
如果我的回答解決了您的問題,您能否將其標記爲正確答案?謝謝 – conorgil