0

I need to specify a rule in Schematron where I say that every element <xpto> must have attributes x and y and all the other attributes it eventually has must be z or w.

So let's say I have the following element:

<xpto a="abc">

This is a wrong element because, not only does it does it not have the attributes x and y, it also has attribute a which is not one of the valid ones (x,y,z,w).

A valid element would be:

<xpto x="abc" y="cba">

or

<xpto x="abc" y="cba" w="dsa">

I know how to specify mandatory attributes with the @attribute command, I just don't know how to specify that all attributes' name must be in some set, like ('x','y','z','w') in the example given...

4

1 回答 1

0
<sch:pattern>
   <sch:rule context="xpto">
      <sch:assert test="every $attr in @* satisfies $attr/name()=('x','y','z','w')">Error message</sch:assert>
   </sch:rule>
</sch:pattern>
于 2013-03-17T21:33:21.013 回答