0

Is it possible to use xml schema to express somme rules for other schemas ?

I've read XML Schema to validate XML Schemas? and it's very interesting, but I should want to verify some applicative rules ; for instance, in a schema is there a version number to the xs:schema element ? Is there a use attribute to the xs:attribute element ? Etc.

Is there some good practices for that ?

Thanks.

Community
  • 1
  • 1
Istao
  • 7,425
  • 6
  • 32
  • 39

1 Answers1

0

This is an almost perfect application for Schematron. I can't give you a full schematron for testing that sort of rule but you would be looking at something like:

<pattern id="attribute-checks">
    <rule context="xs:attribute">
        <assert test="@use">All xs:attribute elements must have a use attribute</assert>
    </rule>
</pattern>

Schematron allows you express rules driven for any xml file (obviously, including schemas) that go beyond simple grammar rules. You can use them to extend validation into the level of business rules.

Nic Gibson
  • 7,051
  • 4
  • 31
  • 40
  • Unfortunately, I can't use schematron with `xmllint`, the linux command I use. Anyway, thanks for your help. – Istao Dec 22 '10 at 13:08
  • No, you need something like `xsltproc` as well - schematron is implemented with XSLT. If you're using `xmllint` you should be able to use `xsltproc` as well I would hope :) – Nic Gibson Dec 22 '10 at 13:12