I'm an XML Schema noob, and this is my first Stack Overflow question. Please forgive my ignorance of standards and etiquette in both.
In an XML Schema file (.xsd), I'm including another schema (outside of my control) that represents a sort of de facto standard my group is using. Within the external schema is a complex element with a long name:
<xs:element name="AnnoyingLongElementNameOfSuffering">
<xs:complexType>
<xs:sequence>
...sub-elements galore...
</xs:sequence>
</xs:complexType>
</xs:element>
In my schema file, the element in question was copied, which I consider bad practice, and it was given an abbreviated, tiny name. What I'm trying to do is replace the copied code with a reference to the original in the other schema, but I need to maintain the tiny name, which is already used in existing instance files (also outside of my control). I'd like to do something like:
<xsd:element name="TinyName" ref="AnnoyingLongElementNameOfSuffering"/>
However, the 'name' and 'ref' attributes are mutually exclusive. I can't re-define it and re-list the sub elements, because they're not declared globally in the other schema. I can't make a derived type, because it's defined as an element in the other schema not a type. Alas, none of my searches have yielded anything helpful, presumably because you'd normally change the element name or modify the other file, neither of which is an option for me. There's probably a simple answer, so I look forward to your enlightening responses.
Try:
<xsd:element name="TinyName" substitutionGroup="AnnoyingLongElementNameOfSuffering"/>
Also, tell the people who are maintaining the standard to stop using anonymous complex types (define inline within elements). There is a reason why most big standards use an approach based on defining types rather than elements: so that you can derive from the types or reuse them. Your internal standard could easily migrate to this without losing compatibility: keep the elements, but assign them explicit types.
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