Here is an example.

XML Schema:

<xsd:complexType name="ModelType">
      <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                  <xsd:attribute name="id" type="xsd:int" use="required">
                  </xsd:attribute>
            </xsd:extension>
      </xsd:simpleContent>
</xsd:complexType>

JiBX Binding:

<mapping abstract="true" type-name="tns:ModelType" 
class="common.model.ModelType">
    <value style="text" get-method="getString" set-method="setString"/>
    <value style="attribute" name="id" get-method="getId" set-method="setId"/>
</mapping>

Java Class:

package common.model;
import java.io.Serializable;
public class ModelType implements Serializable
{
    private String string;
    private int id;

    public String getString() {
        return string;
    }
    public void setString(String string) {
        this.string = string;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
}

________________________________
From: Rajiv Verma [mailto:raji...@gmail.com]
Sent: Thursday, September 03, 2009 10:21 AM
To: jibx-users@lists.sourceforge.net
Subject: [jibx-users] Binding question

I have a binding question for you guys.
I have a xml tag which contains an attribute and has a value too. Something like
<Message>
...
<type remove="true">Person</type>
...
<Message>

I know structures and attributes vs elements but none of what I know seems to 
fit this scenario.
Please help me out with this.

Thanks,

________________________________
STATEMENT OF CONFIDENTIALITY:



The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify WHI Solutions immediately at g...@whisolutions.com,
and destroy all copies of this message and any attachments.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to