Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to Reuse a locally defined element under the Same Parent Tag

Reply
Thread Tools

How to Reuse a locally defined element under the Same Parent Tag

 
 
nbulchandani@gmail.com
Guest
Posts: n/a
 
      01-03-2013
<xs:complexType name="Team">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Size">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element ref="Size"/>
</xs:sequence>
</xs:complexType>


The element "Size" has local scope , Can't it be reused locally?
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-03-2013
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> <xs:complexType name="Team">
> <xs:sequence>
> <xs:element name="Name" type="xs:string"/>
> <xs:element name="Size">
> <xs:simpleType>
> <xs:restriction base="xs:integer">
> <xs:totalDigits value="1"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element ref="Size"/>
> </xs:sequence>
> </xs:complexType>
>
>
> The element "Size" has local scope , Can't it be reused locally?


Does

<xs:complexType name="Team">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Size" minOccurs="1" maxOccurs="2">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>

help?

That defines the contents of "Team" as a sequence of one "Name" and two
"Size" elements.

It is not quite clear which content you want to allow, of course
suffices to

<xs:complexType name="Team">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Size">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>

define the contents of "Team" as a sequence of one "Name" and one
"Size", there is no need to reference anything.


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
 
nbulchandani@gmail.com
Guest
Posts: n/a
 
      01-04-2013
On Thursday, 3 January 2013 15:48:01 UTC+5:30, Martin Honnen wrote:
> Nikel wrote:
>
> > <xs:complexType name="Team">

>
> > <xs:sequence>

>
> > <xs:element name="Name" type="xs:string"/>

>
> > <xs:element name="Size">

>
> > <xs:simpleType>

>
> > <xs:restriction base="xs:integer">

>
> > <xs:totalDigits value="1"/>

>
> > </xs:restriction>

>
> > </xs:simpleType>

>
> > </xs:element>

>
> > <xs:element ref="Size"/>

>
> > </xs:sequence>

>
> > </xs:complexType>

>
> >

>
> >

>
> > The element "Size" has local scope , Can't it be reused locally?

>
>
>
> Does
>
>
>
> <xs:complexType name="Team">
>
> <xs:sequence>
>
> <xs:element name="Name" type="xs:string"/>
>
> <xs:element name="Size" minOccurs="1" maxOccurs="2">
>
> <xs:simpleType>
>
> <xs:restriction base="xs:integer">
>
> <xs:totalDigits value="1"/>
>
> </xs:restriction>
>
> </xs:simpleType>
>
> </xs:element>
>
> </xs:sequence>
>
> </xs:complexType>
>
>
>
> help?
>
>
>
> That defines the contents of "Team" as a sequence of one "Name" and two
>
> "Size" elements.
>
>
>
> It is not quite clear which content you want to allow, of course
>
> suffices to
>
>
>
> <xs:complexType name="Team">
>
> <xs:sequence>
>
> <xs:element name="Name" type="xs:string"/>
>
> <xs:element name="Size">
>
> <xs:simpleType>
>
> <xs:restriction base="xs:integer">
>
> <xs:totalDigits value="1"/>
>
> </xs:restriction>
>
> </xs:simpleType>
>
> </xs:element>
>
> </xs:sequence>
>
> </xs:complexType>
>
>
>
> define the contents of "Team" as a sequence of one "Name" and one
>
> "Size", there is no need to reference anything.
>
>
>
>
>
> --
>
>
>
> Martin Honnen --- MVP Data Platform Development
>
> http://msmvps.com/blogs/martin_honnen/


Well then , Consider this case when both the "Size" elements are not declared closely :

<xs:complexType name="Team">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Size">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="teamLeads">
<xs:complexType>
<xs:sequence>
<xs:element ref="Size"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>


My Question is aren't local elements referenceable in their own Local Scope?In the above case , "Size" is an element declaration local to the root tag"Team" ; then why can't I reuse the Same Declaration using "ref"? Usually , in other Computer Languages , a local element is reusable in the completeLocal Scope.
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      01-04-2013
(E-Mail Removed) wrote:

> Well then , Consider this case when both the "Size" elements are not declared closely :
>
> <xs:complexType name="Team">
> <xs:sequence>
> <xs:element name="Name" type="xs:string"/>
> <xs:element name="Size">
> <xs:simpleType>
> <xs:restriction base="xs:integer">
> <xs:totalDigits value="1"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="teamLeads">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="Size"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
>
> My Question is aren't local elements referenceable in their own Local Scope?In the above case , "Size" is an element declaration local to the root tag "Team" ; then why can't I reuse the Same Declaration using "ref"? Usually , in other Computer Languages , a local element is reusable in the complete Local Scope.


As far as I understand the schema language you can only reference
globally declared elements (i.e. those declared with xs:element as
direct children of xs:schema).

See http://www.w3.org/TR/xmlschema-1/#cElement_Declarations, it has a
section saying
"the <element> element information item has <complexType> or <group> as
an ancestor and the ref [attribute] is present), the corresponding
schema component is as follows (unless minOccurs=maxOccurs=0, in which
case the item corresponds to no component at all):
Particle Schema Component
Property Representation
{min occurs} The ·actual value· of the minOccurs [attribute], if
present, otherwise 1.
{max occurs} unbounded, if the maxOccurs [attribute] equals unbounded,
otherwise the ·actual value· of the maxOccurs [attribute], if present,
otherwise 1.
{term} The (top-level) element declaration ·resolved· to by the ·actual
value· of the ref [attribute]."

So "_The (top-level) element declaration ·resolved· to by the ·actual
value· of the ref [attribute]._" basically says that reference works
only to top level element declaration (i.e. the ones as direct children
of xs:schema).

--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
nbulchandani@gmail.com
Guest
Posts: n/a
 
      01-07-2013
On Friday, 4 January 2013 16:48:05 UTC+5:30, Martin Honnen wrote:
> Nikel wrote:
>
>
>
> > Well then , Consider this case when both the "Size" elements are not declared closely :

>
> >

>
> > <xs:complexType name="Team">

>
> > <xs:sequence>

>
> > <xs:element name="Name" type="xs:string"/>

>
> > <xs:element name="Size">

>
> > <xs:simpleType>

>
> > <xs:restriction base="xs:integer">

>
> > <xs:totalDigits value="1"/>

>
> > </xs:restriction>

>
> > </xs:simpleType>

>
> > </xs:element>

>
> > <xs:element name="teamLeads">

>
> > <xs:complexType>

>
> > <xs:sequence>

>
> > <xs:element ref="Size"/>

>
> > </xs:sequence>

>
> > </xs:complexType>

>
> > </xs:element>

>
> > </xs:sequence>

>
> > </xs:complexType>

>
> >

>
> >

>
> > My Question is aren't local elements referenceable in their own Local Scope?In the above case , "Size" is an element declaration local to the roottag "Team" ; then why can't I reuse the Same Declaration using "ref"? Usually , in other Computer Languages , a local element is reusable in the complete Local Scope.

>
>
>
> As far as I understand the schema language you can only reference
>
> globally declared elements (i.e. those declared with xs:element as
>
> direct children of xs:schema).
>
>
>
> See http://www.w3.org/TR/xmlschema-1/#cElement_Declarations, it has a
>
> section saying
>
> "the <element> element information item has <complexType> or <group> as
>
> an ancestor and the ref [attribute] is present), the corresponding
>
> schema component is as follows (unless minOccurs=maxOccurs=0, in which
>
> case the item corresponds to no component at all):
>
> Particle Schema Component
>
> Property Representation
>
> {min occurs} The ·actual value· of the minOccurs [attribute], if
>
> present, otherwise 1.
>
> {max occurs} unbounded, if the maxOccurs [attribute] equals unbounded,
>
> otherwise the ·actual value· of the maxOccurs [attribute], if present,
>
> otherwise 1.
>
> {term} The (top-level) element declaration ·resolved· to by the ·actual
>
> value· of the ref [attribute]."
>
>
>
> So "_The (top-level) element declaration ·resolved· to by the ·actual
>
> value· of the ref [attribute]._" basically says that reference works
>
> only to top level element declaration (i.e. the ones as direct children
>
> of xs:schema).
>
>
>
> --
>
>
>
> Martin Honnen --- MVP Data Platform Development
>
> http://msmvps.com/blogs/martin_honnen/


Okay , I get that. But what is the reasoning behind not allowing local elements to be referenced in the Local Scope is my actual question.
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      01-07-2013
(E-Mail Removed) wrote:

> But what is the reasoning behind not allowing local elements to be referenced in the Local Scope is my actual question.


Sorry, I don't know that. If no one else answers here you could try the
mailing list http://www.xml.org/xml-dev/.


--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
nbulchandani@gmail.com
Guest
Posts: n/a
 
      01-08-2013
On Monday, 7 January 2013 18:13:10 UTC+5:30, Martin Honnen wrote:
> Nikel wrote:
>
>
>
> > But what is the reasoning behind not allowing local elements to be referenced in the Local Scope is my actual question.

>
>
>
> Sorry, I don't know that. If no one else answers here you could try the
>
> mailing list http://www.xml.org/xml-dev/.
>
>
>
>
>
> --
>
>
>
> Martin Honnen --- MVP Data Platform Development
>
> http://msmvps.com/blogs/martin_honnen/


Okay , Will Post it there.Thanks!
 
Reply With Quote
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      01-12-2013
Sun, 6 Jan 2013 20:28:12 -0800 (PST), /(E-Mail Removed)/:

> Okay , I get that. But what is the reasoning behind not allowing
> local elements to be referenced in the Local Scope is my actual
> question.


I guess it is as simple as the reason why the global scope
components exists - in order to enable referencing them. How do
imagine referencing a local scope component (which is generally
anonymous)?

--
Stanimir
 
Reply With Quote
 
cmsmcq@blackmesatech.com
Guest
Posts: n/a
 
      02-01-2013
On Sunday, January 6, 2013 9:28:12 PM UTC-7, (E-Mail Removed) wrote:

> Okay , I get that. But what is the reasoning behind not allowing local elements to be referenced in the Local Scope is my actual question.


"Reasoning" may be too strong a word for the process that produced this particular bit of XSD 1.0. It was a long time ago, and I have not consulted any of the written records of WG discussion or decisions (so take this with a grain of salt) but my recollection is that the crucial concept, for most members of the XML Schema working group, was not the distinction between local scope and top-level scope but between the "declare in one place, use inanother place" idiom of top-level element declarations and the "define in-line" idiom of local declarations. I do not recall the idea of referring to a local element coming up at all during the design and specification of XSD 1.0. If it had, it might or might not have attracted support; people were quite happy, I think, with the idea that two local element declarationsfor the same name could have different application info, different nullability, etc., and replacing multiple local declarations with a single local declaration and references would seem to stand in the way of that kind of thing.

The topic did come up during the WG's work on XSD 1.1, when specifying thatany element name could be defined at most once in a given scope would havehelped solve some problems that had arisen in the so-called Element Declarations Consistent constraint. But at that time, the WG was unwilling to break backward compatibility with 1.0 in this area (or most others).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
code reuse and design reuse sailor.gu@gmail.com C Programming 16 02-12-2006 09:09 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Reuse paramter list and reuse connection tshad ASP .Net 5 05-17-2005 12:33 AM
To reuse or not to reuse.... Hylander Java 0 02-26-2004 12:00 AM



Advertisments