Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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
Hi,

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="http://www.w3.org/2001/XMLSchema"
name="Organisation">
<xsd:complexContent>
<xsd:extension base="Party">
<xsd:sequence>
<xsd:element name="numberOfEmployees" type="xsd:double"
minOccurs="0"/>
<xsd:element name="businessOrganisation" type="xsd:string"
minOccurs="0"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

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.

Regards,
Adam
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 :
break;
case XSDContentTypeCategory.SIMPLE :
XSDSimpleTypeDefinition xsdSimpleTypeDefinition =
(XSDSimpleTypeDefinition)
xsdComplexTypeDefinition.getContentType();
// create data
break;
case XSDContentTypeCategory.ELEMENT_ONLY :
case XSDContentTypeCategory.MIXED :
XSDParticle xsdParticle = (XSDParticle)
xsdComplexTypeDefinition.getContentType();
XSDTerm xsdTerm = xsdParticle.getTerm();
if (xsdTerm instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdTerm;
for (Iterator i = xsdModelGroup.getParticles().iterator();
i.hasNext();) {
XSDParticle childXSDParticle = (XSDParticle) i.next();
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)
xsdTerm;
// create element, call back into function
} else if (xsdTerm instanceof XSDWildcard) {
}
break;
}
// process attributes
EList attrs = xsdComplexTypeDefinition.getAttributeUses();
Iterator it = attrs.iterator();
while(it.hasNext()) {
XSDAttributeUse attrUse = (XSDAttributeUse)it.next();
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: Sat Apr 20 02:29:46 GMT 2024

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

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

Back to the top