Re: Global Vs Root Element.

That is a great analysis Tom, I am impressed. I see the point, the problem
with multipe root elements as a result of "includes". Assuming that we can
designate a root element, do you think a feature like, the root  element in
the topmost Schema in the "including" hierachiey prevails, in the event of
this ambiguity due to multiple "root" elements. That way each schema in the
hierachy has un-ambiguous root element and still will not conflict in the
event of multiple herarchical inclusions. Just thinking.........

Also you brought up a nice point on sub-schemas . Interestingly, I am trying
to model a  set of very complex  data, as re-usable database of  instance
libraries that collaborate to form different combinations of larger
datasets. Larger Schemas - Sub Schemas ........  Having designed more than
two dozens of complex Schemas in last couple of weeks I see the power and
elegance of XMLSchema specification. Though I intended to use each of the
sub-schema by itself for instances of it, I have a large containing schema
that has a complex combination/collection of these sub-schema elements in
it. You are quite right this is no trivial task. It has exactly the scenario
that you described, having multiple global elements from different
sub-schemas, multiple includes as part of transitive include statements some
times etc. However, by intution I have followed a pattern which I now learn
to be called "Venetian Blind pattern". Here most of my types are global type
definitions for maximum reuse, cohesiveness etc. You are right this is the
excellent path for controlled extensions, re-usage and other such
mechanisms. Though I appreciated global type definitions I some how
refrained from global element declarations in these sub-schemas because of
this root element ambiguity and moved them into wrapper schemas that include
these sub-schemas and just contain global / root elements. I re-used the
sub-Schemas in other larger schemas that have their own root element. I did
not re-use the these wrappers Schemas. That way I avoided global elements
Having read your analysis I realize I cannot avoid global elements always,
some time they are handy.....

Thanks for your time and for the good educative analysis.

Best Regards,

Venkateswar
----- Original Message -----
From: "Tom Wason" <wason@mindspring.com>
To: "Venkateswar Wunnava" <wvsvenkat@worldnet.att.net>; "Jeff Rafter"
<jeffrafter@definedweb.com>
Cc: <xmlschema-dev@w3.org>
Sent: Tuesday, June 12, 2001 6:42 AM
Subject: RE: Global Vs Root Element.


> Venkateswar--
>
> Yes, it would sometimes be nice if one could designate an element as the
> "root".  I am encouraged that XML Spy can deduce the logical "root"
element,
> although this can become ambiguous when another schema is imported or
> included.  Good schema design should make the root logically apparent.  It
> is probably not possible to make a specification that forces "good
design".
> Better we all have an awareness of the issues that constitute good design.
>
> In XML-Schema an element does not "know" what its "parent(s)" is (are),
> consequently, a declaration of "root" would imply that the element "knows"
> its parent, namely, "none".  A root element in one schema may be a child
> when it is imported or included into another.  One should consider each
> schema as potentially part of another schema.  Often libraries of schemas
> will be created.  A key here is reuse of schemas and their components.
One
> may wish to use fragments of another schema in your schema.  The fragment
> may not start at the root.  On the other hand, if the fragment does start
at
> the root, then including or importing that external root element could end
> up with a schema that has more than one root element if "root" can be
> declared by an element.  Thus, at best is root only local to the
particular
> schema that includes it.  It would seem that schema design also includes
> design of the library of (sub) schemas.  In this way, one can harmonize
all
> of the schemas within a domain.  This is not a trivial exercise.
>
> You speak of limiting the use of global elements.  Overriding elements
> through the use of substitutionGroup can be used to create controlled
> extensions.  I have been working with a situation (IMS) in which
extensions
> are normal.  A controlled extension through an override requires access to
> elements and their types, hence they must be global.  In other
circumstances
> I can see that you might want to prevent the overriding of elements.
There
> is probably no general rule on global versus local definitions of
> components; it is a function of the particular application.  Generally I
> will use a "global" definition as it provides for reuse, future evolution
> and controlled extension.  That one can tailor XSDs to this level is one
of
> the strengths of XML-Schema.
>
> Your thoughtful comments are stimulating.
>
> Regards,
>   --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: Venkateswar Wunnava [mailto:wvsvenkat@worldnet.att.net]
> < Sent: Tuesday, June 12, 2001 2:40 AM
> < To: wason@mindspring.com; Jeff Rafter
> < Cc: xmlschema-dev@w3.org
> < Subject: Re: Global Vs Root Element.
> <
> <
> < That is a good suggestion Tom.
> <
> <  But I suppose XMLSpy is doing more ingenuine check above and beyond
what
> < XMLSchema Spec., stipulates. I suppose XMLScema specificatoin should
have
> < given a way to specify one of the global elements as root element in the
> < form of a constraint, (some thing, XMLSpy is trying to infer). I
> < personally
> < do not like to hang around more than one global elements within a Schema
> < unless I cannot do away with it. Particularly, because I do not want my
> < Parser to punt on me by validating an instance that has a
> < particular global
> < element as a root element while I really did not intend to make it one,
> < which, can be solved by a mechanism to specify one of those
> < global elements
> < as root element. I do not understand why this piece is being left so
loose
> < in the spec., while all possible forms of neat mechanisms have
> < been provided
> < in XMLSchema specification. Is there any specific reason for doing that,
> < which I am missing?
> <
> < Best Regards,
> <
> < Venkateswar.
> <
> < ----- Original Message -----
> < From: "Tom Wason" <wason@mindspring.com>
> < To: "Jeff Rafter" <jeffrafter@definedweb.com>; "Venkateswar Wunnava"
> < <wvsvenkat@worldnet.att.net>
> < Cc: <xmlschema-dev@w3.org>
> < Sent: Monday, June 11, 2001 1:53 PM
> < Subject: 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 Wednesday, 13 June 2001 03:52:11 UTC