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

Re: Global Vs Root Element.

From: Ian Stokes-Rees <ijs@decisionsoft.com>
Date: Fri, 06 Jul 2001 10:02:29 +0100
Message-ID: <3B457EA5.32142007@decisionsoft.com>
To: Venkateswar Wunnava <wvsvenkat@worldnet.att.net>, wason@mindspring.com, Jeff Rafter <jeffrafter@definedweb.com>, xmlschema-dev@w3.org
I have just realised that another side effect of using groups to wrap single
elements allows one to have multiple elements with the same name made
available for referencing.  Imagine:

  <foo some_attr="..."/>
  <foo another_attr="..."/>
  <foo some_attr="..."/>

You may want the first and third "foo" to be the same and be placed inside "a"
and "c" as references, however also place the second "foo" inside "b" by
reference.  This could be achieved by creating (as always, in pseudo XSDL):

<group name="fooStyleX">
  <element name="foo">
    <attribute name="some_attr">

<group name="fooStyleY">
  <element name="foo">
    <attribute name="another_attr">

<element name="doc">
  <element name="a">
    <group ref="fooStyleX" />

  <element name="b">
    <group ref="fooStyleY" />

  <element name="c">
    <group ref="fooStyleX" />

Ian Stokes-Rees wrote:
> [I missed the first part of this thread, so appologies for any repeated
> information]
> [actually terminology discussion is in the second part of this email]
> Global Elements
> ---------------
> Global elements refer to elements defined as the immediate children of the
> <schema> element in an XSDL document (a schema definition document).  These
> have three purposes:
> 1) to define elements which can be used be reference (i.e. <element
> ref="some_global_element" />) _within_ other element, group, or type
> definitons; and,
> 2) to define elements which can be legal document elements in instance
> documents; and,
> 3) to define elements which can be used in instance documents where the
> document's schema specifies <any> element may exist.
> If you wish to define an element to be used only for <element ref="..."/>
> purposes, the exact same semantics can be achieved by dropping this element in
> a <group> element (I cannot take credit for this -- it was suggested to me on
> this list some months ago).  The following pseudo XML/XSDL gives the general
> idea:
> Instance:
>   <globalEle>
>     <refEle>
>   </globalEle>
> Schema Before:
>   <element name="refEle" type="myType" />
>   <element name="globalEle" >
>     <element ref="refEle" />
>   </element>
> After:
>   <group name="refEle">
>     <element name="refEle" type="myType" />
>   </group>
>   <element name="globalEle" >
>     <group ref="refEle" />
>   </element>
> With the first schema, the following document would be schema valid:
> <refEle />
> But this would not be legal with the second schema.  The only issue then to
> decide on is the naming convention for the group.  There is no name collision
> since groups are in a different space from global element names, so this gives
> the "appearance" of an element ref to "refEle".  I am still undecided about
> how "nice" it is to do this (have groups and elements with the same name).  It
> may not be unreasonable if restricted to _only_ these circumstances.

Ian Stokes-Rees                       DecisionSoft Ltd.
Telephone: +44-1865-203192            http://www.decisionsoft.com
Received on Friday, 6 July 2001 05:01:17 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:52 UTC