Hi David,
The problem is that the compiler generates property names from the
namespace, and the namespace for your wildcard isn't a legal Java
identifier. The enclosed xsd contains a customization that maps your
wildcard to the name "__any".
Regards,
--
Ed Mooney |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201 |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive |fruit flies like
781-442-0459 |Burlington, MA 01803 |a banana. Groucho
David Pettigrew wrote:
> I am new to JAXB and I am having a problem with the following Schema and XML
>
> <xs:element name="mixedstock">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:any namespace="##any" maxOccurs="unbounded"/>
> </xs:choice>
> </xs:complexType>
> </xs:element>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <zb:mixedstock xmlns:zb="http://www.zwiftbooks.com" xsi:schemaLocation="http://www.zwiftbooks.com zwiftbooks.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sb="http://www.slowbooks.com" xsi:noNamespaceSchemaLocation="NoNamespaceBooks.xsd">
> <zb:book>
> <zb:isbn>0-596-00058-8</zb:isbn>
> <zb:title>XML in a Nutshell</zb:title>
> <zb:author>Harold, Elliotte Rusty</zb:author>
> </zb:book>
> <sb:book>
> <sb:isbn>0-000-11111-2</sb:isbn>
> <sb:title>The Fall of The House of Usher</sb:title>
> </sb:book>
> <zb:magazine>
> <zb:title>XML News</zb:title>
> <zb:isbn>9-543-12378-5</zb:isbn>
> </zb:magazine>
> <book>
> <isbn>0-000-11111-2</isbn>
> <title>The Fall of The House of Usher</title>
> </book>
> </zb:mixedstock>
>
>
> The message I get is "Unable to generate a property name from a model group. Customization is required" on the <xs:choice maxOccurs="unbounded"> line.
> I think my schema is too open and that is why it can't be parsed. My mixedstock.xml XML file might have any of the elements (which are defined in multiple schemas) in any order.
> If anyone can elp hat would be great,
> David Pettigrew
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="
http://java.sun.com/xml/ns/jaxb"
jaxb:version="1.0">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings
fixedAttributeAsConstantProperty="true"
collectionType="java.util.Vector"
typesafeEnumBase="xs:NCName"
choiceContentProperty="false"
typesafeEnumMemberName="generateError"
modelGroupAsClass="false"
enableFailFastCheck="false"
generateIsSetMethod="false"
underscoreBinding="asCharInWord"/>
<jaxb:schemaBindings>
<jaxb:package name="primer.myPo"/>
<jaxb:nameXmlTransform>
<jaxb:elementName suffix="Element"/>
</jaxb:nameXmlTransform>
</jaxb:schemaBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="mixedstock">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name="__any"/>
</xs:appinfo>
</xs:annotation>
<xs:any namespace="##any" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>