How to add element to existing xsd:complexType?

2.3k Views Asked by At

I have set of schema definitions where one of the file has xsd:ComplexType defined as "FloatingRateCalculation", now I want to extend this type and want to add an element to it and I do not want to disturb the existing schema. I want to create a separate .xsd file where I will include the schema for original "FloatingRateCalculation".

I want to do this so that original schema remains intact which is provided by the Vendor...

1

There are 1 best solutions below

1
On

If the original schema looks like this (Original.xsd)

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio 2012 Developer Edition 10.1.2.4113 (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="FloatingRateCalculation">
        <xs:sequence>
            <xs:element name="Stuff" type="xs:string" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

enter image description here

Then your schema (Extension.xsd) should look something like this

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio 2012 Developer Edition 10.1.2.4113 (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:include schemaLocation=".\Original.xsd" />
    <xs:complexType name="FloatingRateCalculationEx">
        <xs:complexContent>
            <xs:extension base="FloatingRateCalculation">
                <xs:sequence>
                    <xs:element name="MoreStuff" type="xs:string" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

enter image description here