質問

i am trying to check the existence of an attribute with Schematron.

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

If there is a "TreeView id" it must allready exist in a "Page id"

So i tried to count the "Page id´s" with the same name as my "Treeview id", they have to be >=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>

What am i doing wrong? Thanks for your hlep!

役に立ちましたか?

解決

how about this rule:

<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>

Hope this helps.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top