Deteriming if an ElementDeclaration is a Simple or Complex Type [message #591619] |
Wed, 22 September 2004 22:11 |
Gary J Messages: 61 Registered: July 2009 |
Member |
|
|
Hi,
This is probably an obvious one. Given object of type XSDElementDeclaration
I want to easily determine if it is a Simple or Complex Type.
Here's what I'm doing:
// get the element Type definition
XSDTypeDefinition typeDef = xsdElement.getTypeDefinition();
// Get the Complex Content type if it is Complex
XSDParticle particle = typeDef.getComplexType();
// If not null, element must be complex
if(particle != null)
// This is a Complex Element
Reading the JavaDocs it appears I could also do this:
XSDSimpleTypeDefinition type = typeDef.getSimpleType();
The javadocs state this will return the SimpleTypeDefinition if the type is
simple, otherwise it will return the XSDComplexTypeContent. (Maybe I'm
readin that wrong?)
My question is:
Since both SimpleTypeDefinition and XSDParticle implement the
XSDComplexTypeContent interface couldn't I simply do this:
XSDComplexTypeContent type = typeDef.getSimpleType();
and then check it type is an instance of either SimpleTypeDefinition or
XSDParticle to determine if it is simple or complex?
Sorry if this sounds a bit obvious but this is one I've been chewing over
for a while and never got the relationships quite straight in my head.
Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.02756 seconds