I looked at the XML Schema 1.1 structures spec at,
http://www.w3.org/TR/xmlschema11-1/#sec-no-xsi (section 3.2.6.4 xsi:
Not Allowed), and here's my further analysis of this issue.

The spec says:

<quote>
  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 in consequence of the rule just given must not be declared.

  Note: It is legal for Attribute Uses that refer to xsi: attributes
to specify default or fixed value constraints (e.g. in a component
corresponding to a schema document construct of the form <xs:attribute
ref="xsi:type" default="xs:integer"/>), but the practice is not
recommended; including such attribute uses will tend to mislead
readers of the schema document, because the attribute uses would have
no effect
</quote>

The quoted section above makes me believe that the test suite example
that I've cited is incorrect, and it seems we don't require change in
Xerces implementation to meet the conditions of the cited test case.

On Sun, Jan 9, 2011 at 10:12 AM, Mukul Gandhi <[email protected]> wrote:
> Hello,
>   The XML Schema 1.1 test suite (on w3.org site) specifies the
> following schema test.
>
> [1]
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>
>   <!-- xsi:noNamespaceSchemaLocation can be made mandatory -->
>
>   <xs:element name="root">
>        <xs:complexType>
>            <xs:simpleContent>
>                <xs:extension base="xs:decimal">
>                    <xs:attribute ref="xsi:noNamespaceSchemaLocation"
> use="required"/>
>                </xs:extension>
>            </xs:simpleContent>
>       </xs:complexType>
>   </xs:element>
>
> </xs:schema>
>
> The test says that the above schema should be valid. But Xerces-J
> 2.11.0 reports the above schema as invalid and following error is
> produced by Xerces, when I attempt to do a schema validation test:
>
> complex010.xsd:10:82:src-resolve.4.2: Error resolving component
> 'xsi:noNamespaceSchemaLocation'. It was detected that
> 'xsi:noNamespaceSchemaLocation' is in namespace
> 'http://www.w3.org/2001/XMLSchema-instance', but components from this
> namespace are not referenceable from schema document 'complex010.xsd'.
> If this is the incorrect namespace, perhaps the prefix of
> 'xsi:noNamespaceSchemaLocation' needs to be changed. If this is the
> correct namespace, then an appropriate 'import' tag should beadded to
> 'complex010.xsd'.
>
> complex010.xsd:10:82:src-resolve: Cannot resolve the name
> 'xsi:noNamespaceSchemaLocation' to a(n) 'attribute declaration'
> component.
>
> Here are few questions and thoughts:
> 1. Does Xerces looks non compliant according to this test?
> 2. Xerces doesn't allow an attribute declaration whose targetNamespace
> is http://www.w3.org/2001/XMLSchema-instance. So it seems we can't do
> currently for example with Xerces,
>
> [2]
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>                   targetNamespace="http://www.w3.org/2001/XMLSchema-instance";>
>
>    <xs:attribute name="noNamespaceSchemaLocation" type="xs:anyURI" />
>
> </xs:schema>
>
> and import this schema in the test suite schema [1] to solve this use-case.
>
> Do we have a schema somewhere on web (perhaps on www.w3.org site),
> from where we can import the definitions of namespace
> http://www.w3.org/2001/XMLSchema-instance instead of users writing a
> schema like [2] to provide these definitions themselves?
>
> 3. Interestingly the following schema using XML Schema 1.1 assertions
> seem to solve the problem for this use case,
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>
>     <!-- xsi:noNamespaceSchemaLocation can be made mandatory -->
>
>     <xs:element name="root">
>         <xs:complexType>
>             <xs:simpleContent>
>                  <xs:extension base="xs:decimal">
>                        <xs:assert test="@xsi:noNamespaceSchemaLocation" />
>                  </xs:extension>
>             </xs:simpleContent>
>         </xs:complexType>
>     </xs:element>
>
> </xs:schema>
>
> Any thoughts please.




-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to