How to find "root" element in a schema. Check if an element is referenced [message #590338] |
Wed, 18 August 2004 22:41 |
Gary J 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
|
|
|
Powered by
FUDForum. Page generated in 0.03012 seconds