W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2003

Re: Error in Validating with Schema and in generating sample XML from it !!! Schema is valid in XML Spy 5.0 . Namespace problems.

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 24 Jul 2003 15:38:31 +0100
Message-ID: <81484154931.20030724153831@jenitennison.com>
To: "Catalin VLAD" <catalin@ean.ro>
CC: xmlschema-dev@w3.org

Hi Catalin,

> This files was all validated with Schema by XML Spy 5.0.

XML Spy's XSD implementation is not conformant. You should send them a
bug report.

> When I try to validate this XML file with JAXP1.2
> I got this ERROR: (file:test.xml: 7, 28): cvc-complex-type.2.4.a: Invalid
> content starting with element 'core:additionalItemName'.
> One of '{"":additionalItemName, "http://www.example.com/fmcg":itemName}' is
> expected.
> It seems that the parser expects 'additionalItemName' instead of
> 'core:additionalItemName'.
> Why ? I think the namespace is OK.(Also I tryed with Castor and JAXB and
> seems to have the same error).

The <additionalItemName> element is declared with a local declaration
in 3.xsd. When you declare an element locally, the namespace for the
element is either the target namespace for the schema or no namespace;
it depends on the "form" for the element declaration. Since you have
no form attribute on the <xs:element> element declaration, the "form"
comes from the elementFormDefault attribute on the <xs:schema>
element. In this case, it's 'unqualified', which means that the
<additionalItemName> element is in no namespace.

If you want the <additionalItemName> element to be in the core
namespace (the target namespace for 3.xsd), then you should set the
elementFormDefault attribute on the <xs:schema> element to
'qualified' or add a 'form' attribute to the <xs:element> element with
the value 'qualified'.

> Can I write a simple XSD file(just 1 file - not 3 files as above)
> that validate my XML file ?

Not to give you good validation; part of the design of XSD dictates
that elements in different namespaces must be declared in different
files.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Thursday, 24 July 2003 10:38:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:39 GMT