Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Processing complexTypes derived by extension
Processing complexTypes derived by extension [message #585870] Tue, 20 April 2004 20:03
Adam Ratcliffe is currently offline Adam RatcliffeFriend
Messages: 3
Registered: July 2009
Junior Member

I'm wanting to use the XSD API in building an application that allows a user
to build the messages
for a WSDL operation using a simple wizard-style interface. The initial
version of this application
doesn't need to validate the message created, it just needs to present to
the user text fields for entering
values for elements that have simpleTypes and selection lists for elements
with complexTypes where the
complexType is a base type with extended types. An example of such a base
type is shown below.

<xsd:complexType xmlns:xsd=""
<xsd:extension base="Party">
<xsd:element name="numberOfEmployees" type="xsd:double"
<xsd:element name="businessOrganisation" type="xsd:string"

The code below is based upon an example posted to this group previously. I'm
uncertain how I should extend this to handle the
extension case. An example of how to do this would be great.

public void processType() {

XSDTypeDefinition definition = getTypeDefinition();

if (definition instanceof XSDSimpleTypeDefinition) {
XSDSimpleTypeDefinition xsdSimpleTypeDefinition =
(XSDSimpleTypeDefinition) definition;
// create element
} else {
XSDComplexTypeDefinition xsdComplexTypeDefinition =
(XSDComplexTypeDefinition) definition;
// create element
switch (xsdComplexTypeDefinition.getContentTypeCategory().getValue( )) {
case XSDContentTypeCategory.EMPTY :
case XSDContentTypeCategory.SIMPLE :
XSDSimpleTypeDefinition xsdSimpleTypeDefinition =
// create data
case XSDContentTypeCategory.ELEMENT_ONLY :
case XSDContentTypeCategory.MIXED :
XSDParticle xsdParticle = (XSDParticle)
XSDTerm xsdTerm = xsdParticle.getTerm();
if (xsdTerm instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdTerm;
for (Iterator i = xsdModelGroup.getParticles().iterator();
i.hasNext();) {
XSDParticle childXSDParticle = (XSDParticle);
XSDTerm childTerm = childXSDParticle.getTerm();
if (childTerm instanceof XSDElementDeclaration) {
XSDElementDeclaration elDeclaration =
(XSDElementDeclaration) childTerm;
// create element, call back into function
} else if (xsdTerm instanceof XSDElementDeclaration) {
XSDElementDeclaration elDeclaration = (XSDElementDeclaration)
// create element, call back into function
} else if (xsdTerm instanceof XSDWildcard) {
// process attributes
EList attrs = xsdComplexTypeDefinition.getAttributeUses();
Iterator it = attrs.iterator();
while(it.hasNext()) {
XSDAttributeUse attrUse = (XSDAttributeUse);
XSDAttributeDeclaration attr = attrUse.getAttributeDeclaration()
// create attribute
Previous Topic:short question #2 how to obtain a XSDSchema from a String
Next Topic:Processing complexTypes derived by extension
Goto Forum:

Current Time: Fri Oct 23 12:40:33 GMT 2020

Powered by FUDForum. Page generated in 0.01223 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top