'Effective Content' of a ComplexType in a Schema

mahesh.kanakaraj

Usenet Archive
Joined
Sep 14, 2006
Messages
7
Reaction score
0
Hi All,

I have a confusion in finding the 'effective content' of a complex type definition in a XML Schema.

I shall give you an example situation to clearly explain my problem.

Let's have an element declaration as follows:

<element name = "A" type="A_Type">

which is of type defined by the complexType definition as follows:

<complexType name="A_Type">
<complexContent>
<restriction base="anyType">
<choice>
<element name="One" type="string"/>
<element name="Two" type="string"/>
</choice>
</restriction>
</complexContent>
</complexType>

Now, based on the XML Schema specification [1], finding the effective content for the complex type "A_Type" is what is really confusing me.

The specification says........
<quote>
[...]
2 [Definition:] Let the effective content be the appropriate case among the following:
2.1 If one of the following is true
2.1.1 There is no <group>, <all>, <choice> or <sequence> among the [children];
2.1.2 There is an <all> or <sequence> among the [children] with no [children] of its own excluding <annotation>;
2.1.3 There is a <choice> among the [children] with no [children] of its own excluding <annotation> whose minOccurs [attribute] has the ·actual value· 0; Then the appropriate case among the following:
2.1.4 If the ·effective mixed· is true, then A particle whose properties are as follows:
{min occurs}
1
{max occurs}
1
{term}
A model group whose {compositor} is sequence and whose {particles} is empty.
2.1.5 otherwise empty
2.2 otherwise the particle corresponding to the <all>, <choice>, <group> or <sequence> among the [children]. [...] </quote>

Since for the complex type given above, the conditions 2.1 and 2.2 becomes false, and the condition 2.3 becomes true (since none of the children has 'minoccurs' as '0'), so the calculation of the effective content is done using 2.1.4 or 2.1.5 based on the 'effective mixed' value.

For the complex type declared above 'effective mixed' is false, so
2.1.5 is chosen and the 'effective content' becomes empty.

And as per the specification (quote given below), calculating the 'conent type' of this complex type node...... <quote> [....] 3 Then the value of the property is the appropriate case among the following:
3.1 If the <restriction> alternative is chosen,
then the appropriate case among the following:
3.1.1 If the ·effective content· is empty ,
then empty;
3.1.2 otherwise a pair consisting of
3.1.2.1 mixed - if the ·effective mixed· is true, otherwise elementOnly
3.1.2.2 The ·effective content·.
[....]
</quote>

Since the 'effective content' identified is empty, using 3.1.1, the 'content type' of this complex type becomes empty.

My question comes here..........

Shouldn't the 'content type' of this complex type node be a 'Choice'?

Is my interpretation of the specification
correct? Or where am I going wrong?

Any kind of help would be appreciated.
Thanks in Advance.

Mahesh K U

[1] - "http://www.w3.org/TR/xmlschema-1/#key-efm"
 

usenet

Usenet Archive
Joined
Aug 10, 2000
Messages
1,105
Reaction score
0
On 19 Jun, 08:34, wrote:
....
<complexType name="A_Type">
<complexContent>
<restriction base="anyType">
<choice>
<element name="One" type="string"/>
<element name="Two" type="string"/>
</choice>
</restriction>
</complexContent>
</complexType> ....
2.1.3 There is a <choice> among the [children] with no
[children] of its own excluding <annotation>
whose
minOccurs [attribute] has the ·actual value· 0;
Then the appropriate case among the following:
2.1.4 If the ·effective mixed· is true, then A particle ....
2.1.5 otherwise empty
2.2 otherwise the particle corresponding to the <all>, <choice>, <group> or <sequence> among the [children]. [...] </quote>

XML schema is an appallingly written spec. If I were you I would try and make do with the primer, or a book such as Eric van der Vlist's.

In the case you mention, I think it's ambiguous in 2.1.3 as to what the "whose" refers to. (In fact the spec if rife with these ambiguities, often forcing you to work out what "it's" might refer to from a number of possibilities!)

Clearly the construct you refer to is not empty. Therefore, the only way to interpret 2.1.3 is to infer that the "whose" is referring to the choice element. e.g. it would be better written as:

2.1.3 There is a <choice> among the [children] whose minOccurs [attribute] has the ·actual value· 0 and has no [children] of its own excluding <annotation>.

Then the case you specify invokes 2.1.5 and 3.1.2.2.

The implication is that:

<choice minOccurs="0"></choice> is legal, but
<choice></choice> is illegal.

HTH,

Pete.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,051
Messages
3,104,251
Members
248,135
Latest member
tobystanx

Latest Threads

Top