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

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Daniel
  • 95
  • 8

1 Answers1

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>
Max Toro
  • 28,282
  • 11
  • 76
  • 114
  • every $x in ./attribute::*/name() satisfies $x=('x','y','z','w') This worked for me. But thank you very much :) – Daniel Mar 18 '13 at 01:47
  • @Daniel The `every` operator is what I couldn't remember, see my updated answer. – Max Toro Mar 18 '13 at 02:51