You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Smith, Doug" <Do...@fmr.com> on 2000/10/10 00:32:22 UTC

Trouble binding simple type definitions to a namespace

Greetings,

I'm trying to declare a schema, binding type definitions to a namespace via
targetNamespace.

Here's my input doc and grammar:

<Foo xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
	 xmlns="foo"  
	 xsi:schemaLocation="foo http://localhost/foo.xsd">
		<Bar/>
</Foo>

<?xml version="1.0"?>
<schema 
	xmlns="http://www.w3.org/1999/XMLSchema"
	xmlns:f="foo"
	targetNamespace="foo"
>

	<simpleType base="string" name="BarType">
		<maxLength value="7"/>
	</simpleType> 	<element name="Foo" type="f:FooType" />
		
	<complexType name="FooType">
		<element name="Bar" type="f:BarType"/>		
	</complexType>

</schema>

I get the following error when I validate the doc against the schema using
the 10/9 developer snapshot (of Xerces-J 1.2):

org.xml.sax.SAXParseException: Element type "Bar" must be declared.
	java.lang.Throwable(java.lang.String)
	java.lang.Exception(java.lang.String)
	org.xml.sax.SAXException(java.lang.String)
	org.xml.sax.SAXParseException(java.lang.String, org.xml.sax.Locator)
	void
org.apache.xerces.framework.XMLParser.reportError(org.xml.sax.Locator,
java.lang.String, int, int, java.lang.Object [], int)
	void
org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(i
nt, int, int)
	void
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttribute
s(org.apache.xerces.utils.QName, org.apache.xerces.framework.XMLAttrList)
	void
org.apache.xerces.validators.common.XMLValidator.callStartElement(org.apache
.xerces.utils.QName)
	boolean
org.apache.xerces.framework.XMLDocumentScanner.scanElement(org.apache.xerces
.utils.QName)
	boolean
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(bo
olean)
	boolean
org.apache.xerces.framework.XMLDocumentScanner.parseSome(boolean)
	void
org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource)
	void test.SimpleParse.main(java.lang.String [])

If I remove the Bar element from the input document, I get the following,
which leads me to believe Bar is not being bound to the foo namespace:

org.xml.sax.SAXParseException: The content of element type "Foo" is
incomplete, it must match "(Bar)".
	java.lang.Throwable(java.lang.String)
	java.lang.Exception(java.lang.String)
	org.xml.sax.SAXException(java.lang.String)
	org.xml.sax.SAXParseException(java.lang.String, org.xml.sax.Locator)
	void
org.apache.xerces.framework.XMLParser.reportError(org.xml.sax.Locator,
java.lang.String, int, int, java.lang.Object [], int)
	void
org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(i
nt, int, java.lang.String, java.lang.String)
	void
org.apache.xerces.validators.common.XMLValidator.callEndElement(int)
	boolean
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(bo
olean)
	boolean
org.apache.xerces.framework.XMLDocumentScanner.parseSome(boolean)
	void
org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource)
	void test.SimpleParse.main(java.lang.String [])

Am I doing something wrong, or is this a bug in Xerces-J? Is there a
simpleType attribute I need to bind my simple type to the foo namespace?

Thanks.

--Doug Smith