This may be close to duplicate of the question here. But this is not the same. After reading the above answer I know what code must be added for my scenario, but I am unable to figure out where to put it. This is my current xsd
file
<tns:element name="WSO2Lanka">
<tns:complexType>
<tns:sequence>
<tns:element name="Employees" type="EmployeeBaseType">
</tns:element>
</tns:sequence>
</tns:complexType>
</tns:element>
<tns:complexType name="EmployeeBaseType">
<tns:sequence>
<tns:element name="Employee" type="EmployeType">
</tns:element>
</tns:sequence>
</tns:complexType>
<tns:complexType name="EmployeType">
<tns:sequence>
<tns:element name="name" type="nameType">
</tns:element>
<tns:element name="company" type="tns:string"></tns:element>
<tns:element name="position" type="tns:string"></tns:element>
<tns:element name="address" type="addressType"></tns:element>
<tns:element name="tele" type="tns:string"></tns:element>
</tns:sequence>
</tns:complexType>
<tns:complexType name="nameType">
<tns:sequence>
<tns:element name="fname" type="tns:string">
</tns:element>
<tns:element name="lname" type="tns:string">
</tns:element>
</tns:sequence>
</tns:complexType>
<tns:complexType name="addressType">
<tns:sequence>
<tns:element name="city" type="tns:string"></tns:element>
<tns:element name="province" type="tns:string"></tns:element>
</tns:sequence>
</tns:complexType>
and this is what I needed in my xml
file.
<?xml version="1.0" encoding="UTF-8"?>
<WSO2Lanka xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../EmployeeXMLSchema.xsd">
<Employees>
<Employee eid="001">
<name>
<fname>kasun</fname>
<lname>Siyambalapitiya</lname>
</name>
<company>WSO2</company>
<position>intern</position>
<address>
<city>Kuliyapitiya</city>
<province>North Western</province>
</address>
<tele>0715523333</tele>
</Employee>
</Employees>
</WSO2Lanka>
As in the xml
I need to have an attribute for the element Employee
as eid
of the type of ID
I know that the below code is the one to be added, can you please help me to figure this out. Thanks in advance
<tns:complexType>
<tns:simpleContent>
<tns:extension base="tns:ID">
<tns:attribute name="edi" type="tns:ID" use="required"></tns:attribute>
</tns:extension>
</tns:simpleContent>
</tns:complexType>