Another XML Schema one: Named local declarations, whar are theircontents?

S

Soren Kuula

Hi, if I do:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tg = "http://dongfang.dk/testdata"
targetNamespace="http://dongfang.dk/testdata"
elementFormDefault="qualified">

<complexType name="typename">
<sequence>
<element name="n1" minOccurs="0"/> <!-- q1 -->
<element ref="tg:n2" minOccurs="0"/>
</sequence>
</complexType>

<element name="n1">
<complexType>
<sequence>
<element name="n1" minOccurs="0"/> <!-- q2 -->
<element ref="tg:n2" minOccurs="0"/>
</sequence>
</complexType>
</element>

<element name="n2">
<complexType>
<sequence>
<element name="n1" minOccurs="0"/> <!-- q2 -->
<element ref="tg:n2" minOccurs="0"/>
</sequence>
</complexType>
</element>
</schema>


-- should I expect that the element at <!-- q1 --> somehow gets its
contents declared by the top level n1 declaration -- or should I expect
that its contents remain undefined?
I believe I am clear enough about the one directly below; they refer to
the top level declaration of n2, with contents and all, right?

Does the same thing hold for the ones at q2? (only difference is really
that the type definitions are local, right?)

-- I know that the "tg:typename" type is never actually used, but that
should not affect the answers :)

TNX for any input. I'll play with an implementation of a validator in
the mean time, but, hey, you never know if there is a bug, now that I'm
confused (too?).

Reading the TR and trying to understand it is my last option :)

Søren
 
S

Soren Kuula

-- should I expect that the element at <!-- q1 --> somehow gets its
contents declared by the top level n1 declaration -- or should I expect
that its contents remain undefined?

Sorry I mean undeclared, and therefore, as I remember it, allow any
well-formed contents.

Søren
 
S

Soren Kuula

Soren Kuula wrote:

Well my validator accepts

<n1 xmlns = "http://dongfang.dk/testdata">
<n1>
<skunk/>
</n1>
<n2>
<n1>
<goat/>
</n1>
</n2>
</n1>

so I guess the answer is: When specifying the name only, in a local
element decl, type is not defined - - even if there is a top level
declaration of the same-named element.

I cannot get it to accept:
<n1 xmlns = "http://dongfang.dk/testdata">
<n1>
<skunk/>
</n1>
<n2>
<n1>
<goat/>
</n1>
</n2>
<goat/>
</n1>

(complaint about the last goat --- should obviously complain)

or

<n1 xmlns = "http://dongfang.dk/testdata">
<n1>
<skunk/>
</n1>
<n2>
<n1>
<goat/>
</n1>
<n2>
<skunk/>
</n2>
</n2>
</n1>

(compliant about the last skunk -- not in the content model of n2 REFd
from the content model of n2)...

OK unless this is wrong, I guess it's solved:)

Søren
 
T

Tjerk Wolterink

Soren said:
Hi, if I do:

[cut]



The ref attribute of <xsd:element refers to
another element.

The name attribute of xsd:element declares the name of the element.


so:

<xsd:element name="a">

refers to

<a></a> ( we did not specify type)



<xsd:element ref="a"> is a referention to element whose name is a.

So they are equal.


The ref attribute is here because know you don't have to define
elements more than one time.

Example:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="tree">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="branch"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="branch">
<xsd:complexType>
<xsd:choice>
<xsd:element ref="branch" maxOccurs="unbounded"/>
<xsd:element ref="leaf" maxOccurs="unbounded"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>

<xsd:element name="leaf" type="xsd:string">
</xsd:element>

</xsd:schema>



Example document: (generated):
PS, i dont know why the leafs are between <!-- -->
:


<tree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Untitled1.xsd">
<branch>
<branch>
<branch>
<branch><!--
<leaf>string</leaf>-->
</branch>
<branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch>
<branch>
<branch><!--
<leaf>string</leaf>-->
</branch>
<branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch>
<branch>
<branch>
<branch><!--
<leaf>string</leaf>-->
</branch>
<branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch>
<branch>
<branch><!--
<leaf>string</leaf>-->
</branch>
<branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch><!--
<leaf>string</leaf>-->
</branch>
</tree>
 
C

C. M. Sperberg-McQueen

Soren Kuula said:
Hi, if I do:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tg = "http://dongfang.dk/testdata"
targetNamespace="http://dongfang.dk/testdata"
elementFormDefault="qualified">

<complexType name="typename">
<sequence>
<element name="n1" minOccurs="0"/> <!-- q1 -->
<element ref="tg:n2" minOccurs="0"/>
</sequence>
</complexType>

...

</schema>
-- should I expect that the element at <!-- q1 --> somehow gets
its contents declared by the top level n1 declaration -- or
should I expect that its contents remain undefined?

No, neither undefined nor (as you suggest in a later posting)
undefined. The <element name="n1" .../> is a perfectly
normal declaration: it declares an element named n1 local
to type tg:typename. The type associated with n1 defaults
to anyType.

--C. M. Sperberg-McQueen
World Wide Web Consortium
 
S

Soren Kuula

Hi,
No, neither undefined nor (as you suggest in a later posting)
undefined. The <element name="n1" .../> is a perfectly
normal declaration: it declares an element named n1 local
to type tg:typename. The type associated with n1 defaults
to anyType.

Thanks for the correction. AnyType was the name I missed there.

I knew it was perfectly normal, I just wasn't sure whether it was
associated with the top level n1 declaration in any way.

Søren
 
H

Henry S. Thompson

Regardless of context, a declaration of the form

<xs:element name="n1"/>

is equivalent to

<xs:element name="n1" type="xs:anyType"/>

So _all three_ of the locally declared elements 'n1' in your schema
have xs:anyType for their type definition.

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: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

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
474,001
Messages
2,570,251
Members
46,850
Latest member
Brightrs

Latest Threads

Top