- From: Michael Kay <mhk@mhk.me.uk>
- Date: Sun, 7 Mar 2004 15:17:00 -0000
- To: "'Mik Lernout'" <mik@futurestreet.org>
- Cc: "'Lingzhi Zhang'" <lzhang@cse.ogi.edu>, "'dev xmlschema'" <xmlschema-dev@w3.org>
I agree with you: it's useful to be able to specify which element declaration you are validating against. I don't think there's anything in XML Schema itself that prevents this, it's a question of whether your chosen schema validator gives you a suitable interface. Michael Kay # -----Original Message----- # From: Mik Lernout [mailto:mik@futurestreet.org] # Sent: 07 March 2004 12:10 # To: Michael Kay # Cc: 'Lingzhi Zhang'; 'dev xmlschema' # Subject: Re: determine root element in the xml from schema # # I do agree with Stephen/Lingzhi Zhang here: in a normal use case of # XMLSchema you will want to confine validation to only one valid # root-element. The only reason to register multiple global elements would # be to be able to use them when importing/including the schema, when # refering to the element from within the schema, ... There is a big # secuity / application integrity aspect that is touched here as well: it # is pretty typical for applications to use XMLSchema for validation and # it would be very easy to bypass this validation completetly by using a # root element that is also registered globally but not "intended" to be # used as a root element. # # Michael: I agree with you that a schema should be able to match more # than one instance document, but I do also believe that it should only be # able to match only one "type" of instance document. If you have a look # at the "Purchase Order Schema" in the primer spec, do you think it is # the intention of the schema writer to be able to validate # "<comment>abc</comment>" as a valid instance of this schema? Or that the # application that will validate this will be constructed to be able to # cope with this instance? # # Maybe I am completely off-base/confused here and this kind of # "unpredictable behaviour" is intended by the creators of the spec, but # then don't we have a serious communication problem in how the spec is # being read by the people who are writing XMLSchema validators and # applications? If this would be the case it would seem for example # logically to be able to mark, when validating, the root-element you wish # to validate against like in: validator.validate(po.xsd, # 'purchaseOrder'). Why isn't this the case? # # How do other people feel about this? # # Mik # # Michael Kay wrote: # # >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 Sunday, 7 March 2004 10:17:06 UTC