1
votes

Is it possible to declare an attribute which is valid on all elements, regardless of scope, without having to define it on every element/type (or having to include some global type within each element/type)?

I'm not sure where in XSD you would define such a thing, hence I suspect it cannot be done.

1

1 Answers

0
votes

XSD 1.0

As you suspect, there is no way in XSD 1.0 to globally declare that an attribute may appear on all elements without in some way adjusting the declarations of those elements.

However, there are some alternatives to repeating a common attribute definition for every element:

  • Define the common attribute, or attribute group, globally and @ref it from every element.
  • Define a common type which includes the common attribute, and extend that type by each type used by every element.

XSD 1.1

In XSD 1.1, you can specify a default attribute group via a defaultAttributes declaration on the xsd:schema element.