Is there XSD language support or tricks (e.g. via the preprocessor) for defining an alias for an XML element? I would like to alias all the elements in my schema in order to create an option for a more cryptic but network bandwidth-efficient version of our XML documents.
For example, I would like to define a name such as IRQ
to be an alias for the element InterruptRequest
etc.
<xs:element name="InterruptRequest" minOccurs="0">
<xs:complexType>
<xs:attribute name="level" type="xs:unsignedShort" use="required"/>
</xs:complexType>
</xs:element>
So that the following two declarations are equivalent to each other
<!-- Human readable but bandwidth inefficient -->
<InterruptRequest level="22" />
<!-- Cryptic, but comparatively bandwidth efficient -->
<IRQ level="22" />
You can't define two element names to be synonymous, but you can define one as substitutable for the other by means of a substitution group. They will still appear differently to your application, but the validation process will permit one of them to be used everywhere that the content model permits the other.
<element name="a">...
<element name="b" substitutionGroup="a">...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With