RE: using types from an included file in a different namespace

The spec in 4.2.3 says:

The <import> element information item identifies namespaces used in external
references, i.e. those whose .QName. identifies them as coming from a
different namespace (or none) than the enclosing schema document's
targetNamespace. The .actual value. of its namespace [attribute] indicates
that the containing schema document may contain qualified references to
schema components in that namespace.

Note the (synonymous) terms "enclosing schema document" and "containing
schema document". An included document is not part of the
enclosing|containing schema document.

This is a permissive rule: it says that if you import a namespace then you
may refer to names in that namespace. The converse rule, that if you don't
import a namespace then you may not refer to names in that namespace, is in
3.15.3 Schema Representation Constraint: QName resolution (Schema Document):

For a .QName. to resolve to a schema component of a specified kind all of
the following must be true:
...
4 The appropriate case among the following must be true:
4.1 If the .namespace name. of the .QName. is .absent., then one of the
following must be true:
4.1.1 The <schema> element information item of the schema document
containing the .QName. has no targetNamespace [attribute].
4.1.2 The <schema> element information item of the [sic] that schema
document contains an <import> element information item with no namespace
[attribute].
4.2 otherwise the .namespace name. of the .QName. is the same as one of the
following:
4.2.1 The .actual value. of the targetNamespace [attribute] of the <schema>
element information item of the schema document containing the .QName..
4.2.2 The .actual value. of the namespace [attribute] of some <import>
element information item contained in the <schema> element information item
of that schema document.

Which is a very longwinded way of saying "The namespace (or non-namespace)
of the QName must either be the same as the target namespace, or must be
referenced in an xs:import element in the schema document containing the
QName."

So I think Saxon has it right. However, there's a "late binding" theory for
schema components which says that if you can't resolve references when you
first try, then no failure occurs and you keep trying. There's very little
textual evidence to support this theory, so almost anything can be justified
under it, and it might just provide enough wriggle room to enable someone to
claim that it's legal to bind components even though the above rule appears
on the surface to be violated. 

Michael Kay
http://www.saxonica.com/ 




> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Antoli, Leo
> Sent: 27 October 2006 16:20
> To: xmlschema-dev@w3.org
> Subject: using types from an included file in a different namespace
> 
> 
> Hi all,
> Maybe the subject is not very clear but I'll try to explain 
> my question.
> I have a schema file A.xsd including another file B.xsd (so 
> in the same ns as A.xsd), and B.xsd importing F.xsd (so in a 
> differente ns). Can I use types/elements defined in F.xsd from A.xsd?
> 
> It looks like XML Spy allows this, but Saxon produces this error:
> "Cannot reference schema components in namespace http://myns 
> as it has not been imported".
> 
> What behaviour is correct?
> 
> Thanks you.
> 
> Regards,
> Leo. 
> 

Received on Friday, 27 October 2006 17:04:09 UTC