473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Sep 3 '05 #1
6 1473
-- 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
Sep 3 '05 #2
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
Sep 4 '05 #3
Soren Kuula wrote:
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>
Sep 4 '05 #4
Soren Kuula <do******@dongfang.dk> writes:
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
Sep 4 '05 #5
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
Sep 4 '05 #6
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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Sep 5 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wayne Shook | last post by:
I'm using the .NET IDE and I have an XML file that I'm trying to validate against an XML schema on my local drive. the noNamespaceSchemaLocation attribute has been modified to what I think is...
9
by: Stanimir Stamenkov | last post by:
Using Xerces2 Java I'm trying to validate a CSV data following an XNI example <http://xml.apache.org/xerces2-j/xni-config.html#examples>. The CSV scanner generates XML tree events like: <csv>...
4
by: Gordon Burditt | last post by:
What's the easiest way to copy a row from one table to another (with the same schema), without knowing in advance the number and types of the columns? The problem: I have several sets of tables...
2
by: Vitali Gontsharuk | last post by:
Hi! I can't find an answer to the following question: does the "import" command in XML Schema import also element declarations? Or only type definitions? As far as I understood, the first takes...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
1
by: mflll | last post by:
How does one say in one schema that one wants an element defined in another schema. For example, I want to include in the Employee definition, an Address element defined in the schema...
0
by: Drew Greenwell | last post by:
Hello, Can anyone tell me how to write a schema for something like this? Im trying to write a webhelp setup and decided to go with a book chapter theme but i need to constrain this template to...
11
by: emailscotta | last post by:
Below I declared a basic object literal with 2 methods. The "doSomething" method is call from the "useDoSomething" method but the call is only sucessful if I use the "this" keyword or qualify the...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.