Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to constrain set of attributes in xsd

Tags:

xsd

All Please suggest me how to restrict in xsd schema the following:

<root>
  <node action="action1" parameter="1" />
</root>

I need to require attribute "parameter" only if attribute "action" is defined.

Thanks,

like image 531
Dmitriy Sosunov Avatar asked Jan 18 '26 09:01

Dmitriy Sosunov


1 Answers

W3C Schema doesn't have the ability to express conditionally required attributes.

Schematron is a great tool for validating that documents adhere to custom validation scenarios in which content is conditionally required.

You could define those attributes as optional in your schema, and then use Schematron to validate it against those conditional rules.

like image 199
Mads Hansen Avatar answered Jan 21 '26 08:01

Mads Hansen