users@jaxb.java.net

Re: DTD generation of (#PCDATA | field)*

From: M.Ismail <mohammed.hany_at_gmail.com>
Date: Wed, 23 Jun 2010 10:16:09 -0700 (PDT)

No its automatically generated.

However, I even tried to edit the generated code manually :

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "value","field"
})
@XmlRootElement(name = "request")
public class Request {

    @XmlValue
    protected String value;
    
    @XmlElement(required = true)
    protected List<Field> field;

    public List<Field> getField()
    {
            return field;
    }
    
    public void setFields(List<Field> fields)
    {
            this.field = fields;
    }
    
    public String getvalue() {
        return value;
    }

    
    public void setvalue(String value) {
        this.value = value;
    }

}


But I got the following runtime exception:

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of
IllegalAnnotationExceptions
If a class has @XmlElement property, it cannot have @XmlValue property.
        this problem is related to the following location:
                at protected java.lang.String com.Ji.Request.value
                at com.Ji.Request
                at public com.Ji.Request com.Ji.ObjectFactory.createRequest()
                at com.Ji.ObjectFactory
        this problem is related to the following location:
                at protected java.util.List com.Ji.Request.field
                at com.Ji.Request
                at public com.Ji.Request com.Ji.ObjectFactory.createRequest()
                at com.Ji.ObjectFactory



M.Ismail wrote:
>
> Sorry, I missed the closing tag. Yes you're right.
>
> Thanks
>
>
> Wolfgang Laun-2 wrote:
>>
>> Would you please confirm the XML?
>> <application>
>> <request>cmd -i 1 -p 1 -s -a
>> <field name="phone">255685082753</field>
>> * </request>*
>> *</application>*
>>
>> On 23 June 2010 14:55, M.Ismail <mohammed.hany_at_gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I just want to try custom binding but I don't know what to search for to
>>> do
>>> the following:
>>>
>>> <application>
>>> <request>cmd -i 1 -p 1 -s -a
>>> <field name="phone">255685082753</field>
>>> <application>
>>>
>>> notice that the request element has both a #PCDATA and a request element
>>> value. How to define this in custom jaxb binding? I've tried customizing
>>> the
>>> type using javaType to Object but it didn't work.
>>>
>>> thanks
>>>
>>>
>>>
>>>
>>>
>>> M.Ismail wrote:
>>> >
>>> > Hi,
>>> >
>>> > I have a DTD schema that is defined as:
>>> >
>>> > <?xml version="1.0" encoding="UTF-8"?>
>>> > <!ELEMENT application (request | response)>
>>> > <!ELEMENT request (#PCDATA | field)*>
>>> > <!ELEMENT field (#PCDATA)>
>>> > <!ATTLIST field
>>> > name CDATA #REQUIRED
>>> >>
>>> > <!ELEMENT response (number? | record* | error?)>
>>> > <!ELEMENT number (#PCDATA)>
>>> > <!ELEMENT record (field)+>
>>> > <!ELEMENT error (#PCDATA)>
>>> >
>>> >
>>> > I want to generate the following xml for example:
>>> > <application>
>>> > <request>cmd -i 1 -p 1 -s -a
>>> > <field name="phone">255685082753</field>
>>> > <field name="username">user</field>
>>> >
>>> > </request>
>>> > </application>
>>> >
>>> > However I'm having trouble dealing with the element: <!ELEMENT request
>>> > (#PCDATA | field)*>
>>> >
>>> > because the signature of the request.setValue is:
>>> > public void setvalue(String value) {
>>> > this.value = value;
>>> > }
>>> >
>>> > How can I set its value to both a PCDATA and multiple fields?
>>> >
>>> > Thanks,
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/DTD-generation-of-%28-PCDATA-%7C-field%29*-tp28916598p28971440.html
>>> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>>
>>>
>>
>>
>
>

-- 
View this message in context: http://old.nabble.com/DTD-generation-of-%28-PCDATA-%7C-field%29*-tp28916598p28974555.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.