Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML Schema never-never occurence of declared elements / attributes

Reply
Thread Tools

XML Schema never-never occurence of declared elements / attributes

 
 
Soren Kuula
Guest
Posts: n/a
 
      11-28-2005
Hi,

1) If I have a definition + declaration like
<complexType name="fattype">
<complexContent>
<element name="bar" minOccurs="0" maxOccurs="342"/>
</complexContent>
<attribute name="shanyang"/>
</complexType>

<element name="foo" type="fattype"></element>

and I want to make a derived-by-restriction subtype where the bar
element never appears, is there ANY other way to go than:

<element name="thinfoo">
<complexType><complexContent>
<restriction base="fattype">
<element name="bar" maxOccurs="0"/>
</complexContent>
<attribute name="shanyang" use="prohibited"/>
</complexType>
</element>

OK - my question really is: Looking at the declaration of thinfoo, I
have to make a set of element names that may occur as child elements of
thinfoo in any valid instance document. They don't HAVE to appear, there
just must a the possibility that they do. Now there is an element in the
content model of thinfoo that is declared, but never appears in an
instance, and thus should not be included in my set.

Can any of you guys / girls tell my whether this approach is safe:

Case: E is derived by restriction, or implicitly by extension from anyType:
- I traverse the whole content model of the E declaration recursively.
If I encounter an element with a minOccurs="0" (actual value) attribute,
then I ignore the element and its subelements. Otherwise, if the element
is an element declaration and it has a name, I add the name to my set,
but don't recurse. If it is an element declaration with a ref attribute,
I add it to my set, too.

Case: E is derived by extension (explicitly):
- I traverse the declaration like above. Then, I run the same algorithm
on the type that the base attribute refers to, and add the result of
that to my set.

-- will this get me the right set? Or are there other ways a declared
element may actually never appear in an instance?

And: Are there, likewise, any other way a declared attribute may never
appear, than a use="prohibited" attribute on its declaration?

Can anyone see any reason that I should bother to look at the base
declaration in the case of a derivation by restriction?

Hope there's a Schema expert out there who can help me -- and that some
sort of Medal of Honar may be awarded to those who have read the entire
spec with no nervous breakdowns.

Soren
 
Reply With Quote
 
 
 
 
Henry S. Thompson
Guest
Posts: n/a
 
      12-01-2005
Soren Kuula writes:

Given this (corrected) type definition

<complexType name="fattype">
<sequence>
<element name="bar" minOccurs="0" maxOccurs="342"/>
</sequence>
<attribute name="shanyang"/>
</complexType>

The non-misleading restriction you want is

<element name="thinfoo">
<complexType>
<complexContent>
<restriction base="fattype">
<attribute name="shanyang" use="prohibited"/>
</restriction>
</complexContent>
</complexType>
</element>

This is of course an element useful only as an illustration, as it
must always be empty, with no attributes.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail:
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
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
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
Query : Number of Attributes under an element & atleast 1 occurence of element/Attribute kosaraju.puneeth@gmail.com XML 0 10-26-2005 07:09 AM
schema: different occurence types Th.-Fischer@web.de XML 2 09-01-2005 09:54 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
xml-schema:Uniqueness attributes of differend elements thijs.kupers@gmail.com XML 2 01-03-2005 07:32 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57