RE: Global Vs Root Element.

Jeff--

I agree with you in concept, as a schema may be a fragment.  However (ah
yes, however...), a general rule to use is that:

 The root element can directly or indirectly contain all of the other
elements in the schema (presuming this is a complete schema).

Therefore, the only "true" root element in this schema is <paragraph>.
Indeed, if you create a new XML instance with XML Spy, it will automatically
create an XML instance in which the root is <paragraph>.

If you wanted to make all of the elements potentially root elements, you
could add the <paragraph> element to the complexType's <choice> list.

--Tom

Thomas D. Wason
e-Learning & Meta-Data Consultant
+1 919.839.8187
wason@mindspring.com
http://www.twason.com
1421 Park Drive
Raleigh, North Carolina 27605 USA

< -----Original Message-----
< From: xmlschema-dev-request@w3.org
< [mailto:xmlschema-dev-request@w3.org]On Behalf Of Jeff Rafter
< Sent: Monday, June 11, 2001 12:42 PM
< To: Venkateswar Wunnava
< Cc: xmlschema-dev@w3.org
< Subject: Re: Global Vs Root Element.
<
<
<
< Typically when referring to root elements you are referring to the
< first/outer element within an XML document (aka XML instance).
< For example:
<
< <?xml version="1.0" encoding="UTF-8"?>
< <root>
<   <child/>
< </root>
<
< The element <root> is the root element.  Global elements are referring to
< the element definitions within a schema document that appear as direct
< children of the <schema> element.  Within the schema definition
< there can be
< many global elements:
<
< <xsd:schema xmlns="paragraph" targetNamespace="paragraph"
< xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
< elementFormDefault="qualified">
<   <xsd:element name="paragraph" type="paraType"/>
<   <xsd:element name="bold" type="paraType"/>
<   <xsd:element name="italic" type="paraType"/>
<   <xsd:element name="underlined" type="paraType"/>
< ...
< <xsd:schema>
<
< (Quoting Tom Wason's recent example).  In this sample the elements
< paragraph, bold, italic and underline are all global.  Any of these can be
< used in an XML document as the root (however there is still only one root
< element per XML document).
<
< So the following XML documents would all be okay:
<
< <?xml version="1.0" encoding="UTF-8"?>
< <paragraph xmlns='paragraph'>
<   This is some <bold>text</bold>
< </paragraph>
<
< <?xml version="1.0" encoding="UTF-8"?>
< <bold xmlns='paragraph'>
<   This is some text
< </bold>
<
< <?xml version="1.0" encoding="UTF-8"?>
< <italic xmlns='paragraph'>
<   This is some <bold>text</bold>
< </italic>
<
< In each of these documents a different global element was used as the root
< element in an XML instance.
<
< Hope this helps,
< Jeff Rafter
< Defined Systems
< http://www.defined.net
< XML Development and Developer Web Hosting
<
< ----- Original Message -----
< From: "Venkateswar Wunnava" <wvsvenkat@worldnet.att.net>
< To: <xmlschema-dev@w3.org>
< Sent: Sunday, June 10, 2001 11:44 AM
< Subject: Global Vs Root Element.
<
<
< Hi,
<
<  I am not too familiar with XML. Can some one tell me what is the
< difference
< between Global Elements and Root Elements. From what I understand from
< XMLSchema specification, we cannot impose any cardinality constraints on
< Global Elements. They can occur with multiple instances as top level
< elements. I am confused how they are different from Root Element,
< which can
< be only one element. Thanks in advance.
<
< Best Regards,
<
< Venkateswar.
<
<
<

Received on Monday, 11 June 2001 16:55:48 UTC