How to specify a constant attribute in an XML schema?

Reading the XML Schema specification , I don’t see an easy way to mark the attribute as constant (for example, the <foo bar="baz" />attribute barshould always be baz). The only method I have used so far is to use an enumeration with only one element. Is this the preferred method?

+5
source share
1 answer

<xs:attribute name="bar" type="xs:string" fixed="baz"/> will make the attribute baz constant.

+10
source

All Articles