Re: Global Vs Root Element.

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:

<doc>
 <a>
  <foo some_attr="..."/>
 </a>
 <b>
  <foo another_attr="..."/>
 </b>
 <c>
  <foo some_attr="..."/>
 </c>
</doc>

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">
  </element>
</group>

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

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

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

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

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