W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2004

RE: determine root element in the xml from schema

From: Michael Kay <mhk@mhk.me.uk>
Date: Sun, 7 Mar 2004 00:27:51 -0000
To: "'Lingzhi Zhang'" <lzhang@cse.ogi.edu>, "'dev xmlschema'" <xmlschema-dev@w3.org>
Message-Id: <20040307002756.BB535A1642@frink.w3.org>

You are correct to say that both these instance documents are valid against
this schema.

The word "ambiguity" has a fairly technical meaning when discussing
grammars, and it's not considered an "ambiguity" that more than one instance
document should match the same schema. In fact, it's a rather essential
feature.

But it is sometimes a usability problem that you can't easily constrain what
the document element should be (it can be any element that is globally
declared).

Michael Kay

# -----Original Message-----
# From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org]
# On Behalf Of Lingzhi Zhang
# Sent: 06 March 2004 23:41
# To: dev xmlschema
# Subject: determine root element in the xml from schema
# 
# 
# 
# Hi,
# 
# I am confused of how to determine root element in the xml from a given
# schema. It seems to me there is "ambiguity".
# 
# Say if we have schema like:
# <schema ...>
#     <element name="A">
# 	<complexType>
# 	...
# 	    <element ref="B"/>
# 	...
# 	<complexType>
#     </element>
#     <element name="B"/>
# <schema>
# 
# Either xml:
# <A><B></B></A>
# 
# or xml:
# <B></B>
# 
# would be valid xml against the schema. So either A or B could be root
# element in the xml. By just looking at the schema without looking at xml,
# we can't tell which on would be root element in the xml. However, if a
# user defines that schema, he/she usually means that A is the root. Isn't
# it "ambiguous"?
# 
# Stephen
Received on Saturday, 6 March 2004 19:27:57 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 23:40:23 UTC