[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] MOXy - [ERROR] Property “Any” is already defined

Hello David,

You can use an external bindings file to rename one of the any properties.


<jxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">

    <jxb:bindings schemaLocation="schema.xsd">
            <jxb:property name="any2" />


XML Schema (schema.xsd)

Below is a simplified version of your XML schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    <xsd:complexType name="foo">
            <xsd:choice minOccurs="1" maxOccurs="1">
                <xsd:any namespace=""
                    minOccurs="1" maxOccurs="unbounded" />
                <xsd:any namespace="http://checklists.nist.gov/sccf/0.1"
                    processContents="skip" minOccurs="1" maxOccurs="unbounded" />


XJC Call

Below is how you make an XJC call that leverages an external binding file.

xjc -b binding.xml schema.xsd

Generated Class (Foo)

package org.example.schema;

import java.util.*;
import javax.xml.bind.annotation.*;
import org.w3c.dom.Element;

@XmlType(name = "foo", propOrder = {
public class Foo {

    @XmlAnyElement(lax = true)
    protected List<Object> any;
    protected List<Element> any2;

    public List<Object> getAny() {
        if (any == null) {
            any = new ArrayList<Object>();
        return this.any;

    public List<Element> getAny2() {
        if (any2 == null) {
            any2 = new ArrayList<Element>();
        return this.any2;

Link to discussion on Stack Overflow:

On 12-11-28 12:48 PM, Chun Tat David Chu wrote:
Hi MOXy Users,

I am trying to create JAXB binding for xccdf-1.1.4.xsd which is a standard schema that can be obtain from http://scap.nist.gov/specifications/xccdf/#resource-1.1.4

I fixed couple occasions where I hit the infamous "[ERROR] Property "value" is already defined" error using an external binding XML, and now I am hitting an error on

    [ERROR] Property "Any" is already defined. Use &lt;jaxb:property> to resolve this conflict.
    line 441 of file:/home/dchu/Playground/Java/eclipselink_moxy/xccdf_1.1.4/xccdf-1.1.4.xsd

    [ERROR] The following location is relevant to the above error
    line 444 of file:/home/dchu/Playground/Java/eclipselink_moxy/xccdf_1.1.4/xccdf-1.1.4.xs

Below is a snippet of the line in the XML schema where the error occurred.
            <xsd:choice minOccurs="1" maxOccurs="1">
              <xsd:any namespace="http://purl.org/dc/elements/1.1/"
                       minOccurs="1" maxOccurs="unbounded"/>
              <xsd:any namespace="http://checklists.nist.gov/sccf/0.1"
                       minOccurs="1" maxOccurs="unbounded"/>

Does anyone knows what could be wrong here and what should I do to resolve this?



eclipselink-users mailing list