You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Adam Retter <ad...@devon.gov.uk> on 2006/01/05 20:26:36 UTC
Unmarshall / xmlns problem
I am trying to unmarshall an XML document into a JaxME generated object,
I believe I have the Java code correct.
Basically when I try and unmarshall the xml document I get an exception
-
Exception in thread "main" javax.xml.bind.UnmarshalException:
JM_EVENT_UNEXPECTED_CHILD_ELEMENT: Unexpected element:
'{http://exist-db.org/collection-config/1.0}index'
at
org.apache.ws.jaxme.impl.JMUnmarshallerImpl.unmarshal(JMUnmarshallerImpl.java:97)
at testjaxme.main(testjaxme.java:42)
Caused by:
org.xml.sax.SAXParseException: JM_EVENT_UNEXPECTED_CHILD_ELEMENT:
Unexpected element: '{http://exist-db.org/collection-config/1.0}index'
However if I change my XML (see below) so that <index> becomes <index
xmlns=""> then I dont get any exceptions, but I dont understand why I
should need to define a xmlns on the index element, nor do I want to!
What am I doing wrong?
XML
===
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index>
<fulltext default="all" attributes="false" alphanum="false">
<include path="/category/@name"/>
</fulltext>
</index>
</collection>
XML Schema
==========
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://exist-db.org/collection-config/1.0"
targetNamespace="http://exist-db.org/collection-config/1.0"
elementFormDefault="qualified" xml:lang="en" version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="collection">
<xs:complexType>
<xs:sequence>
<xs:element name="index">
<xs:complexType>
<xs:sequence>
<xs:element name="fulltext">
<xs:complexType>
<xs:sequence>
<xs:element name="exclude"
minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute
name="path" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="include"
minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute
name="path" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="default"
use="required">
<xs:simpleType>
<xs:restriction
base="xs:string">
<xs:enumeration
value="all"/>
<xs:enumeration
value="none"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="attributes"
type="xs:boolean" use="required"/>
<xs:attribute name="alphanum"
type="xs:boolean" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="create" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="path"
type="xs:string" use="required"/>
<xs:attribute name="type"
type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org
Re: Unmarshall / xmlns problem
Posted by Adam Retter <ad...@devon.gov.uk>.
Sorry, my mistake - had my ant task for generating the jaxme classes
from schema setup wrongly and so it wasnt actually building new classes
when i changed my schema. Cleaned the project and tried again and its
all working now, thanks for the help and very quick response :-)
On Thu, 2006-01-05 at 21:22 +0100, Jochen Wiedmann wrote:
> Using the attached files, I can't reproduce your problem. (build.xml,
> test.xml, and test.xsd are in one directory, Test.java is in a
> subdirectory src.)
>
>
> Jochen
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org
Re: Unmarshall / xmlns problem
Posted by Jochen Wiedmann <jo...@gmail.com>.
Using the attached files, I can't reproduce your problem. (build.xml,
test.xml, and test.xsd are in one directory, Test.java is in a
subdirectory src.)
Jochen