W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2002

Re: I am having a problem with using XSD & XSL in the same document

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 24 Oct 2002 10:09:07 +0100
Message-ID: <901210120511.20021024100907@jenitennison.com>
To: xmlschema-dev@w3.org, "vze3y7w8" <boris.kortiak@verizon.net>
CC: boris@kortiak.com

Hi Boris,

> Would changing:
> <FamilyTree xmlns="http://www.kortiak.com/namespace"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.kortiak.com/namespace
> FamilyTree.xsd">
> To:
> <FamilyTree xsi:schemaLocation="http://www.kortiak.com/namespace
> FamilyTree.xsd">
> Also, resolve the problem? I really do not think I need the
> namespace at this point; I just want the XSD to work. Unless, of
> course, best practices would suggest that one create a namespace
> when possible to avoid future confusions. (I know, I know, try it
> and see, just kind of busy tonight. I will do it tomorrow, promise!)

No, for two reasons. First, the xsi:schemaLocation attribute indicates
what schema should be used to validate elements in a particular
namespace. The xsi:schemaLocation attribute:


says "Look for element declarations for elements in the namespace
'http://www.kortiak.com/namespace' in FamilyTree.xsd". If you don't
have the default namespace declaration on your document element, then
the elements in your XML document aren't in that namespace, so the
schema won't be used for them.

To point to a schema to be used for elements in no namespace (as your
elements would be because there's no default namespace declaration),
you should use xsi:noNamespaceSchemaLocation:

<FamilyTree xsi:noNamespaceSchemaLocation="FamilyTree.xsd">

That will get the processor to look at FamilyTree.xsd for the

But then the second problem comes into play. Each schema is tied to a
particular "target namespace". Your schema probably looks like:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

The targetNamespace attribute indicates the namespace for all the
things that are declared or defined at the top level of the schema,
such as elements, complex types and attribute groups. In the above
case, the elements that the schema declares are those in the namespace

If you want to change this so that the schema has no target namespace,
then remove the targetNamespace attribute and remove the default
namespace declaration, so you end up with:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

With these two changes, you should be able to use the schema to
validate your XML document without the namespace declaration.



Jeni Tennison
Received on Thursday, 24 October 2002 05:09:33 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:58 UTC