XML Schema / XSLT / Namespaces / XMLSchema-instance and validation

Hi,

I'm working on a little test project with XML, W3C XML Schema and XSLT,
trying to validate as much as I can, except for data types. Unfortunately
I'm running into a few problems.

I'm using XSV 2.5-2 to validate the XML schema in combination with an XML
document. Xalan C++ 1.6 + Xerces 2.3.0 is used to generate an XHTML document
out of the XML document.

I have some problems with the XMLSchema-instance namespace/schema if using
http://www.w3.org/2001/XMLSchema-instance and
http://www.w3.org/2001/XMLSchema-instance.xsd .

Validation goes well with XSV, but if I try to process the XML document with
Xalan, I'm getting de following message:

Error  at (file Testinput.xml, line 12, column 2): Schema in
http://localhost/Schemas/Test.xsd has a different target namespace from the
one specified in the instance document http://localhost/Schemas/Test.
SAXParseException: Schema in http://localhost/Schemas/Test.xsd has a
different target namespace from the one specified in the instance document
http://localhost/Schemas/Test. (Testinput.xml, line 12, column 2)

I didn't really understand it, but I tried to add
targetNamespace="http://localhost/Schemas/Test" to my XML schema.

XSV's results:

http://localhost/Schemas/Test.xsd:21:3: Invalid per cvc-attribute.1.2:
attribute type check failed for {None}:type: TestType is qualified by an
unimported non-local namespace: None

Xalan's results:

Error  at (file http://www.w3.org/2001/XMLSchema-instance.xsd, line 33,
column 28): The {target namespace} of 'nil' must not match
'http://www.w3.org/2001/XMLSchema-instance'.
SAXParseException: The {target namespace} of 'nil' must not match
'http://www.w3.org/2001/XMLSchema-instance'.
(http://www.w3.org/2001/XMLSchema-instance.xsd, line 33, column 28)

I totally didn't understand XSV's results, so I continued working the Xalan
problem. I've checked http://www.w3.org/2001/XMLSchema-instance and
http://www.w3.org/2001/XMLSchema-instance.xsd , and suprisingly they were
identical! I guessed that this setup wasn't correct, looking at how the
XMLSchema namespace, XMLSchema.dtd and XMLSchema.xsd were setup on the W3C
web server. At that moment I understood why Xalan was complaining, so I put
XMLSchema-instance.xsd on my local web server, created a XMLSchema-instance
RDDL file and changed all references in my documents to that local location.
Suddenly, Xalan was able to process my XML document without errors or
warnings! But the XSV validation error didn't went away, I even got an extra
warning! XVS's results:

http://localhost/Schemas/Test.xsd:1:39: Warning: allowing
{http://localhost/Schemas/XMLSchema-instance}:schemaLocation because it
matched wildcard(##other)

http://localhost/Schemas/Test.xsd:21:3: Invalid per cvc-attribute.1.2:
attribute type check failed for {None}:type: TestType is qualified by an
unimported non-local namespace:Then None

Then I thought: "Let's remove that targetNamespace!". So I did and I runned
XSV again, no error anymore, only the warning remained! And that's exactly
where I got stuck, I couldn't find a way to fix the warning. Maybe anyone
can give me a clue?

Also I thought having XMLSchema-instance locally wasn't that neat. Do I do
something wrong with that namespace/schema or is the setup on the W3C server
just not right?

I'm also a little bit wondering what the real use for targetNamespace is!

I hope you can give me some directions!

Thanks in advance,

Durk



Here are the relevant files:


Test:

_______________________________________________________________________

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
"http://www.w3.org/2001/rddl/rddl-xhtml.dtd">
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:rddl="http://www.rddl.org/"
>

<head>
  <title>Test</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>

<h1>Test</h1>

<rddl:resource
  id="test"
  xlink:arcrole="http://www.rddl.org/purposes#schema-validation"
  xlink:href="http://localhost/Schemas/Test.xsd"
  xlink:role="http://localhost/Schemas/Test"
  xlink:title="Test schema document"
/>

<rddl:resource
  id="xmlschema"
  xlink:title="XML Schema schema document"
  xlink:role="http://www.w3.org/2001/XMLSchema"
  xlink:arcrole="http://www.rddl.org/purposes#schema-validation"
  xlink:href="http://www.w3.org/2001/XMLSchema.xsd"
/>

</body>

</html>

_______________________________________________________________________


Test.xsd:
_______________________________________________________________________

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://localhost/Schemas/XMLSchema-instance"
  xsi:schemaLocation=
                     "
                      http://www.w3.org/2001/XMLSchema
                      http://www.w3.org/2001/XMLSchema.xsd
                      http://localhost/Schemas/XMLSchema-instance
                      http://localhost/Schemas/XMLSchema-instance.xsd
                     "
>

  <xsd:complexType name="TestType">
    <xsd:sequence>
      <xsd:element name="Elem"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="Test" type="TestType"></xsd:element>

</xsd:schema>

_______________________________________________________________________


Test.xslt:
_______________________________________________________________________

<?xml version="1.0" encoding="UTF-8"?>
<xslt:stylesheet
  version="1.0"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:test="http://localhost/Schemas/Test"
  xmlns:xsi="http://localhost/Schemas/XMLSchema-instance"
  xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
  xsi:schemaLocation=
                     "
                      http://localhost/Schemas/Test
                      http://localhost/Schemas/Test.xsd
                      http://localhost/Schemas/XMLSchema-instance
                      http://localhost/Schemas/XMLSchema-instance.xsd
                     "
>

<xslt:output
  method="xml"
  doctype-public="//W3C//DTD XHTML 1.1//EN"
  doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
  encoding="UTF-8"
  indent="yes"
/>

<xslt:template match="/">
  <xslt:apply-templates select="test:Test"/>
</xslt:template>

<xslt:template match="test:Test">
  <p>Elem: <xslt:value-of select="."/></p>
</xslt:template>

</xslt:stylesheet>

_______________________________________________________________________


XMLSchema-instance (you know, the customised version):
_______________________________________________________________________

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
"http://www.w3.org/2001/rddl/rddl-xhtml.dtd">
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:rddl="http://www.rddl.org/"
>

<head>
  <title>XMLSchema-instance</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>

<h1>XMLSchema-instance</h1>

<rddl:resource
  id="xmlschemainstance"
  xlink:arcrole="http://www.rddl.org/purposes#schema-validation"
  xlink:href="http://localhost/Schemas/XMLSchema-instance.xsd"
  xlink:role="http://localhost/Schemas/XMLSchema-instance"
  xlink:title="XMLSchema-instance schema document"
/>

<rddl:resource
  id="xmlschema"
  xlink:title="XML Schema schema document"
  xlink:role="http://www.w3.org/2001/XMLSchema"
  xlink:arcrole="http://www.rddl.org/purposes#schema-validation"
  xlink:href="http://www.w3.org/2001/XMLSchema.xsd"
/>

</body>

</html>

_______________________________________________________________________


Testinput.xml (the actual XML document that uses the Test schema):
_______________________________________________________________________

<?xml version="1.0" encoding="UTF-8"?>
<Test
  xmlns="http://localhost/Schemas/Test"
  xmlns:xsi="http://localhost/Schemas/XMLSchema-instance"
  xsi:schemaLocation=
                     "
                      http://localhost/Schemas/Test
                      http://localhost/Schemas/Test.xsd
                      http://localhost/Schemas/XMLSchema-instance
                      http://localhost/Schemas/XMLSchema-instance.xsd
                     "
>

  <Elem>bla</Elem>

</Test>

_______________________________________________________________________

Received on Tuesday, 4 November 2003 07:09:41 UTC