Total members 11894 |It is currently Thu Nov 21, 2024 6:17 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi everybody

I am using Jaxb integrated in netbeans 6.5.1 to generate java classes from my xml Schema.
I have got the classes but the problem that my schema contains an element with choice elements .This element has to be binded with a getter and a setter to every element in choice
in reference to
but i the class contains just this method
Code:
public List<Object> getContent() {
        if (content == null) {
            content = new ArrayList<Object>();
        }
        return this.content;
    }


I tried to use an external binding file to customize the choice model .
Code:
<jxb:bindings version="2.0"
               xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
               
<jxb:bindings schemaLocation="bib.xsd" node="/schema">
<jxb:globalBindings bindingStyle="modelGroupBinding"/>
<jxb:schemaBindings>
<jxb:package name="poiuu"/>
</jxb:schemaBindings>
</jxb:bindings>
</jxb:bindings>


I get the following problem when generating java code

cvc-complex-type.3.2.2: Attribute 'bindingStyle' is not allowed to appear in element 'jxb:globalBindings'.

Please help me :beg: :beg:




Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time

it seems you can't have attributes in the complex type that have the attribute "bindingStyle" . i think you have to remove it ,

am wondering how the generetad java classes has only :
Code:
public List<Object> getContent() {
        if (content == null) {
            content = new ArrayList<Object>();
        }
        return this.content;
    }


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

I didn't pay attention but my element is a sequence of elements that one of them is a set of choice .What should i do?


Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time

when you generate java class using JAXB from your XSD which contains choices elements , each element will have a class corresponding to it . Does this happened with you .

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

Hello

ALL the elements of the choice have the same type which is access-value that it is a complextype

Code:
<complexType name="access-value"/>


So ,i obtain a class named AccessValue without any attributes or methods


Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time

just generate the JAXB java classes . and GO ON ;)

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

i haven't understood


Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time

I get the class of binded choice :
this is my model choice:
Code:
<element name="ACCESS">
  <complexType>
    <choice>
     <element name="nonident" type="access-value"/>
     <element name="ident-contact" type="access-value"/>
     <element name="other-ident" type="access-value"/>
     <element name="contact-and-other" type="access-value"/>
     <element name="all" type="access-value"/>
     <element name="none" type="access-value"/>
    </choice>
</complexType>
</element>

and access-value is defined in my xsd
Code:
<complexType name="access-value"/>


I get with this 2 classes
Code:
@XmlRootElement(name = "ACCESS")
public class ACCESS {

    protected AccessValue nonident;
    @XmlElement(name = "ident-contact")
    protected AccessValue identContact;
    @XmlElement(name = "other-ident")
    protected AccessValue otherIdent;
    @XmlElement(name = "contact-and-other")
    protected AccessValue contactAndOther;
    protected AccessValue all;
    protected AccessValue none;

    /**
     * Gets the value of the nonident property.
     *
     * @return
     *     possible object is
     *     {@link AccessValue }
     *     
     */
    public AccessValue getNonident() {
        return nonident;
    }

    /**
     * Sets the value of the nonident property.
     *
     * @param value
     *     allowed object is
     *     {@link AccessValue }
     *     
     */
    public void setNonident(AccessValue value) {
        this.nonident = value;
    }

    /**
     * Gets the value of the identContact property.
     *
     * @return
     *     possible object is
     *     {@link AccessValue }
     *     
     */
    public AccessValue getIdentContact() {
        return identContact;
    }

    /**
     * Sets the value of the identContact property.
     *
     * @param value
     *     allowed object is
     *     {@link AccessValue }
     *     
     */
    public void setIdentContact(AccessValue value) {
        this.identContact = value;
    }

    /**
     * Gets the value of the otherIdent property.
     *
     * @return
     *     possible object is
     *     {@link AccessValue }
     *     
     */
    public AccessValue getOtherIdent() {
        return otherIdent;
    }

    /**
     * Sets the value of the otherIdent property.
     *
     * @param value
     *     allowed object is
     *     {@link AccessValue }
     *     
     */
    public void setOtherIdent(AccessValue value) {
        this.otherIdent = value;
    }

    /**
     * Gets the value of the contactAndOther property.
     *
     * @return
     *     possible object is
     *     {@link AccessValue }
     *     
     */
    public AccessValue getContactAndOther() {
        return contactAndOther;
    }

    /**
     * Sets the value of the contactAndOther property.
     *
     * @param value
     *     allowed object is
     *     {@link AccessValue }
     *     
     */
    public void setContactAndOther(AccessValue value) {
        this.contactAndOther = value;
    }

    /**
     * Gets the value of the all property.
     *
     * @return
     *     possible object is
     *     {@link AccessValue }
     *     
     */
    public AccessValue getAll() {
        return all;
    }

    /**
     * Sets the value of the all property.
     *
     * @param value
     *     allowed object is
     *     {@link AccessValue }
     *     
     */
    public void setAll(AccessValue value) {
        this.all = value;
    }

    /**
     * Gets the value of the none property.
     *
     * @return
     *     possible object is
     *     {@link AccessValue }
     *     
     */
    public AccessValue getNone() {
        return none;
    }

    /**
     * Sets the value of the none property.
     *
     * @param value
     *     allowed object is
     *     {@link AccessValue }
     *     
     */
    public void setNone(AccessValue value) {
        this.none = value;
    }

}

and
Code:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "access-value")
public class AccessValue {


}



When I create with my objectFactory an Access element it is ok but i want to attribute the value of one of the access value
I try with all,nonident,none to instanciate an access-value for example:
Code:
AccessValue  all=new  AccessValue();
access. setAll(all);
 

But i can't with ident-contact,other-ident,contact-and-other



Help me


Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time
Post new topic Reply to topic  [ 8 posts ] 

  Related Posts  to : problem with binding a choice model with jaxb
 Choice choiceList popup list of choices     -  
 Unmarshall From XML using JAXB     -  
 XML using JAXB API in java     -  
 update an xml file with jaxb     -  
 insert a namespace in a tag with jaxb     -  
 how to use enum in jaxb unmarshalling     -  
 Re: what is the TCP/IP model?     -  
 update an xml file with jaxb and accessing to its elements     -  
 adding an xmlns attribute xith jaxb     -  
 OSI Model Layers     -  



Topic Tags

Java JAXB, Java XML






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com