【问题标题】:Count number of attributes with schematron使用 schematron 计算属性数
【发布时间】:2012-12-18 11:45:53
【问题描述】:

我正在尝试使用 Schematron 检查属性是否存在。

<Layout>
<Pages>
    <Page id="id-001" description="Database Sections">  
    </Page>
</Pages>
<TreeViews>
    <TreeView id="id-001" description="">
    </TreeView>
</TreeViews>

如果有一个“TreeView id”,它必须已经存在于一个“Page id”中

所以我尝试计算与“Treeview id”同名的“Page id´s”,它们必须 >=1:

 <?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            queryBinding="xslt2">

   <sch:pattern name="Vote Count">
      <sch:rule context="Layout/TreeViews/Treeview/@name">
         <sch:report test="count(Layout/Pages/Page[@id=current()]) >= 1">
             min. 1
        </sch:report>    
      </sch:rule>
   </sch:pattern>
</sch:schema>

我做错了什么?感谢您的帮助!

【问题讨论】:

    标签: attributes count schematron


    【解决方案1】:

    这条规则怎么样:

    <iso:pattern id="check IDs">
      <iso:rule context="TreeView">
        <iso:assert test="parent::*/parent::*/Pages/Page/@id = @id">
          TreeViews/TreeView/@id = <iso:value-of select="./@id" /> NOT FOUND in Pages
        </iso:assert>
      </iso:rule>       
    </iso:pattern>
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-21
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 2015-11-08
      • 1970-01-01
      • 2021-11-08
      • 2022-01-05
      相关资源
      最近更新 更多