Assuming that I have this XML:
<parameters>
<parameter type="string" isVisible="True" optional="False" id="DealerCode">
<DealerCode>ABCDEF001</DealerCode>
</parameter>
</parameters>
I used a Xml-Schema generator to generate me a basic one. This results in this:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:element name="DealerCode" type="xs:string"/>
<xs:element name="parameter">
<xs:complexType>
<xs:sequence>
<xs:element ref="DealerCode"/>
</xs:sequence>
<xs:attribute type="xs:string" name="type"/>
<xs:attribute type="xs:string" name="isVisible"/>
<xs:attribute type="xs:string" name="optional"/>
<xs:attribute type="xs:string" name="id"/>
</xs:complexType>
</xs:element>
<xs:element name="parameters">
<xs:complexType>
<xs:sequence>
<xs:element ref="parameter"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The naming of the element DealerCode is dependent to the identifier of the parameter element. For example if the parameter has the identifier ZIP
, the sub-element of parameter should also be named that way. How can I achieve this in the Xml-Schema?
Example:
<parameter type="string" isVisible="True" optional="False" id="DealerCode">
<DealerCode>ABCDEF001</DealerCode>
</parameter>
<parameter type="string" isVisible="True" optional="False" id="ZIP">
<ZIP>ABCDEF001</ZIP>
</parameter>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…