- From: Michael Kay <mike@saxonica.com>
- Date: Thu, 1 Mar 2007 17:24:38 -0000
- To: "'Boris Kolpackov'" <boris@codesynthesis.com>, <xmlschema-dev@w3.org>
- Cc: "'Dwight Kelly'" <dkelly@yahoo.com>
See section 3.2.6 of Schema Part 1: <quote> Schema Component Constraint: xsi: Not Allowed The {target namespace} of an attribute declaration, whether local or top-level, must not match http://www.w3.org/2001/XMLSchema-instance (unless it is one of the four built-in declarations given in the next section). Note: This reinforces the special status of these attributes, so that they not only need not be declared to be allowed in instances, but must not be declared. It also removes any temptation to experiment with supplying global or fixed values for e.g. xsi:type or xsi:nil, which would be seriously misleading, as they would have no effect. </quote> However, you haven't declared the xsi:type attribute, you have only referenced the declaration. I can't see anything that makes that illegal. It also seems legal to "experiment with supplying a fixed value" for xsi:type, since you can do that on the attribute use, it doesn't have to be on the declaration; and I can't find the rule that says that doing so would have no effect. (Though it's rather circular: you don't know whether xsi:type is constrained until you know what complex type you are validating against, and you don't know that until you have validated xsi:type.) That leaves the question of whether you can reference the declaration as in your example. The specification states that the attribute declaration for xsi:type is present in every schema "by definition", but there's a question mark about whether you need to import the namespace before you can refer to it. (The spec for xs:import says that it enables you to refer to components in a different namespace, but it doesn't actually say that it's an error to refer to components in a different namespace without importing it.) Next question is, if you do an import, without specifying a schema location, can that import fail? All very interesting: yet another can of worms, I suspect. My suspicion is that the WG intended to make ref="xsi:type" illegal but got the words wrong. It wouldn't be the first time. Michael Kay http://www.saxonica.com/" > -----Original Message----- > From: xmlschema-dev-request@w3.org > [mailto:xmlschema-dev-request@w3.org] On Behalf Of Boris Kolpackov > Sent: 01 March 2007 16:28 > To: xmlschema-dev@w3.org > Cc: Dwight Kelly > Subject: Referencing attributes from the XMLSchema-instance namespace > > Hi, > > Microsof's Print Schema[1] has a fragment that looks like so: > > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <xs:complexType name="Type" mixed="true"> > <xs:attribute ref="xsi:type" use="required"/> > </xs:complexType> > > <xs:schema> > > > There is no import declaration for the xsi namespace. I am > wondering whether this is legal or not. I can see three > possible answers actually: (1) this schema is valid, (2) this > schema is invalid but can be made valid by importing a schema > that declares xsi:type: > > > <schema targetNamespace="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://www.w3.org/2001/XMLSchema" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <attribute name="type" type="xs:QName"/> <attribute > name="nil" type="xs:boolean"/> > > </schema> > > > And, finally, (3) referencing attributes from the xsi > namespace in the definition is illegal. > > > [1] http://www.microsoft.com/whdc/xps/printschema.mspx > > > thanks, > -boris > > > -- > Boris Kolpackov > Code Synthesis Tools CC > http://www.codesynthesis.com > Open-Source, Cross-Platform C++ XML Data Binding >
Received on Thursday, 1 March 2007 17:25:04 UTC