W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2001

Re: Global Vs Root Element.

From: Jeff Rafter <jeffrafter@definedweb.com>
Date: Mon, 11 Jun 2001 09:41:55 -0700
Message-ID: <005e01c0f295$6d831550$f181fea9@lazarus>
To: "Venkateswar Wunnava" <wvsvenkat@worldnet.att.net>
Cc: <xmlschema-dev@w3.org>

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 12:42:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:21 GMT