Re: [Moderator Action] Why is this schema not valid via XSV?

chuck.han@autodesk.com writes:

<snip/>

> 	<?xml version="1.0" encoding="UTF-8"?>
> 	<fooRoot
> 		xmlns="http://foo"
> 		xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
> 		xsi:schemaLocation="http://foo foo.xsd"
> 	>
> 		<foo>
> 			"hello, world"
> 		</foo>
> 	</fooRoot>
> 
> (XSV reports an error with the element "foo") whereas if I make "foo" a global element (and reference it) in the schema:
> 
> 	...
> 	<schema xmlns:foo="http://foo" targetNamespace="http://foo">
> 		<element name="fooRoot" type="foo:fooRootType"/>
> 		<element name="foo" type="string"/>
> 		<complexType name="fooRootType">
> 			<sequence>
> 				<element ref="foo:foo"/>
> 			</sequence>
> 		</complexType>
> 	</schema>
> 
> the data file does validate.  Perhaps this is related to my lack of understanding on the prefix/qualified namespace concept that I raised with attribute refs...

Yup.  In your instance, both fooRoot and foo are qualified with the
http://foo namespace.  In your schema, foo is declared locally, and so (since you didn't use either 'form="qualified"' on that declaration, or 'elementFormDefault="qualified"' on the schema, the declaration only allows _un_qualified <foo>.  So either change your schema, or change your instance:

<f:fooRoot
	xmlns:f="http://foo"
	xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
	xsi:schemaLocation="http://foo foo.xsd">
	<foo>
		"hello, world"
	</foo>
</f:fooRoot>

The Primer has an excellent discussion of this issue, q.v. [1]

ht

[1] http://www.w3.org/TR/xmlschema-0/
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Tuesday, 31 October 2000 03:37:52 UTC