Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Deteriming if an ElementDeclaration is a Simple or Complex Type
Deteriming if an ElementDeclaration is a Simple or Complex Type [message #591619] Wed, 22 September 2004 22:11
Gary J is currently offline Gary JFriend
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
Previous Topic:Derivation by restriction
Next Topic:NLS support for XSD
Goto Forum:
  


Current Time: Sat Apr 20 03:23:52 GMT 2024

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

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

Back to the top