Is it a legal way to have the same element with different types



So i have been making a schema files for a single large XML file, that include other schema files , and in this XML file there is an element that is used several time but with different types and have their own schema file. The internet told me that you cant have elements with the same name with different types, so i tried to work around it, and here is what i tried.


Like this.



<ele1 xmlns:xsi="http://ift.tt/ra1lAU"
xsi:noNamespaceSchemaLocation="C:\Users\Desktop\Configuration.xsd">
<ele2>
<Test Name="Timetable" important="no" xsi:type="TimetableType">
<Class>className.something</Class>
</Test>
<Test Name="Database" important="yes" xsi:type="DatabaseType">
<Class>className.something</Class>
<Database>jk</Database>
<PortNr>1<PortNr>
</Test>
</ele2>
</ele1>


and here is it's schema file, this is where the real question lies



<xs:schema elementFormDefault="qualified"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:xs="http://ift.tt/tphNwY">

<xs:include schemaLocation="http://file/C:\Users\Desktop\Timetable.xsd" />
<xs:include schemaLocation="http://file/C:\Users\Desktop\Database.xsd" />

<xs:element name="ele1">
<xs:complexType>
<xs:sequence>
<xs:element name="ele2">
<xs:complexType>
<xs:sequence>
<xs:element name="Test" xsi:type="TimetableType" />
<xs:element name="Test" xsi:type="DatabaseType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>


Is it a legal way to make a schema file, using the xsi:type. For validation program i am using Liquid XML Studio 2014, and it is validating the Configuration file.


No comments:

Post a Comment