I'm designing my XML so that every element in it may specify some universal attribute. For example, say the initial XML was:
<RootElement>
<Sub>
...
</Sub>
<Single1/>
<Single2/>
</RootElement>
Then the following is also valid:
<RootElement UniversalAttr="true">
<Sub UniversalAttr="false">
...
</Sub>
<Single1/>
<Single2 UniversalAttr="true"/>
</RootElement>
I need this ability for being able to later filter the XML at runtime, based on the attribute values.
The only method I know is to specify in the schema all the possible places the attribute may appear. So that the following block would appear many many times in the schema:
<optional>
<attribute name="UniversalAttr">
<choice>
<value>true</value>
<value>false</value>
</choice>
</attribute>
</optional>
But I'm looking for a method where I could specify once that this attribute may appear for any element the XML author wishes.
Can this be done?
EDIT: a second best solution would be to be able to define an "ignored" attribute.
my adhoc idea: you can define your universal attribute like
The elements that need the universal attribute reference it