Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help in creating XML Schema  RSS feed

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please help me to write a XML Schema reflecting the following java class structure.
Class Response has a collection of Contact objects.
Class Contact has type and group as its attributes.
Class Phone and Class Email are subclasses of Contact.
Following is a sample XML for the same.


I found difficulty in reflecting the inheritance in the above Java structure, in Schema.
Any help would be highly appreciated.
Thanks
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version = "1.0" encoding = "UTF-8"?>
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema" elementFormDefault = "qualified">
<xsd:element name = "Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Contact" maxOccurs="unbounded" type="ContactType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ContactType">
<xsd:sequence>
<xsd:element name = "Phone" maxOccurs = "1">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base = "xsd:string">
<xsd:attribute name = "group" use="required" type="xsd:integer"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name = "Email" maxOccurs = "1">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base = "xsd:string">
<xsd:attribute name = "group" use="required" type="xsd:integer"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
 
aravind yarram
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!