W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2003

Finding root element..

From: Kevin Hanna <kevin@hanna.net>
Date: Fri, 21 Feb 2003 20:33:22 -0500
Message-ID: <3E56D362.4020302@hanna.net>
To: xmlschema-dev@w3.org

Hello all..

I'm writting a utility that will create a simple XHTML form based on an 
XML schema.  Currently I'm adding an empty <root> element in the 
<appinfo> to mark an element as the root element.  So far this has 
served me well because I have also created all the XSD's that are used 
for this util.  But I would like to remove that dependancy now.

The only way I can think of locating the root element in *most* XSDs is 
to iterate through a nodelist of global elements and check for a parent 
element for each until I find one without.

There are at least two occations where this can fail.

1. recursive references ie:
	<xs:element name="foo">
				<xs:element ref="bar"/>
	<xs:element name="bar">
				<xs:element ref="foo"/>

2. orphaned elements (not inteded to be root, but have no parent).

Has anybody come up with a fail proof way to find the root element in 
*any* XSD?
Received on Friday, 21 February 2003 20:31:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:09 UTC