XML Schema. How to change ref'ed element name?

I am an XML noob schema and this is my first question. Please forgive my ignorance of standards and etiquette in both.

In the XML Schema file (.xsd), I include another schema (outside my control), which is a kind of de facto standard that my group uses. Inside the external circuit 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> 

This instance was copied in my schema file, which I think is bad practice, and it has been given an abbreviated tiny name. What I'm trying to do is replace the copied code with a link to the original in a different scheme, but I need to keep a tiny name that is already used in existing instance files (also out of my control). I would like to do something like:

 <xsd:element name="TinyName" ref="AnnoyingLongElementNameOfSuffering"/> 

However, the attributes 'name' and 'ref' are mutually exclusive. I cannot override it and enumerate helper elements because they are not globally declared in another schema. I cannot create a derived type because it is defined as an element in another schema, not a type. Alas, none of my searches brought anything useful, apparently because you usually change the name of the element or change another file, none of which is an option for me. There is probably a simple answer, so I look forward to your educational answers.

+6
source share
1 answer

Try:

 <xsd:element name="TinyName" substitutionGroup="AnnoyingLongElementNameOfSuffering"/> 

Also, tell people who support the standard to stop using anonymous complex types (define inline inside elements). There is a reason why most major standards use an approach based on type definitions rather than elements: that you can extract them from these types or reuse them. Your internal standard can easily go for it without losing compatibility: save elements, but assign explicit types to them.

+5
source

Source: https://habr.com/ru/post/887760/


All Articles