Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » How to find "root" element in a schema. Check if an element is referenced
How to find "root" element in a schema. Check if an element is referenced [message #590338] Wed, 18 August 2004 22:41
Gary J is currently offline Gary JFriend
Messages: 61
Registered: July 2009
Member
Hi,

I have a schema loaded into an XSDSchema model which consists of a lot of
element definitions of which only one is the root element for my document.

In this case all the elements are defined "globally" (sorry if that's the
incorrect term) and then referenced in other element definitions. For
example: <xs:element ref="title" /> where "title" is declared elsewhere.

I understand that there need not be a concept of a root element since schema
simply defines elements that can be present in a document. In this
particular case the schema defines a single document and there really is a
root element. The "root" element should be the only one which is not
referred to by anything else. Does this sound resonable?

I process the schema by fetching all the Element Declarations:

EList elements = schema.getSchema().getElementDeclarations()

and processing each one.

for (Iterator iter = elements.iterator(); iter.hasNext(); )
{
XSDElementDeclaration element = (XSDElementDeclaration)iter.next();

// Check if this is the root element
boolean flag = isReferenced(element, schema);
}

Assuming that this is the correct approach how can I easily find out if a
given element is referenced by another element in the schema? In other
words I need an isReferenced() method.

Does anyone have any ideas or am I so far off track it isn't funny?

Thanks

Gary
Previous Topic:[newbie] org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'schema' not found. (myprotocol://h
Next Topic:Traversing a schema
Goto Forum:
  


Current Time: Fri Apr 26 07:07:52 GMT 2024

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

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

Back to the top