user3418847
user3418847

Reputation: 93

I need a schematron rule that enforces the existance of an attribute only if another attribute exists first.

I am trying to write a schematron rule as such: The owner attribute exists only if the name attribute exists. For example:

<business name="n1" owner="o1" />

the owner attribute can only exist if the name attribute exists. Thanks!

Upvotes: 2

Views: 766

Answers (1)

kjhughes
kjhughes

Reputation: 111491

You can assert that either both @owner and @name exists, or @owner does not:

<rule context="business">
  <assert test="(@owner and @name) or not(@owner)">
    The owner attribute requires the name attribute.
  </assert>
</rule>

Upvotes: 2

Related Questions