Binging. xml configuration for binding xml data using jibx

Source: Internet
Author: User
1. Example: & lt; bindingxmlns: ns1 & quot; http: vtebacomservicexmljibx & quot; name & quot; bind & quot; package & quot; comvtebaservicexmljibx & quot; & gt; & lt; namespaceuri & quot; http: v 1. Here is an example: 2. This file is generated using tools provided by jibx. You don't have to write it manually. Of course, you can refer to more than 20 examples provided by jibx for writing. The jibx tool class, org. jibx. binding. generator. BindGen or org. jibx. binding. BindingGenerator can both be in the jibx-tools.jar, and the latter is in the jibx-bind.jar. 3. Command 4. Of course, you can write these commands in the ant script or use the java main method for execution. Use the command line. I use maven and switch to the classes directory under the target folder in the command line. The above java is to run a program-cp is the jar, zip, and other files in the dependent classpath path,-B is the output file name, and is the parameter of the BindGen class. The bind. xml file and jibx. xsd file are generated in the classes directory. Bind. xml is a post-opening file. 5. Then you can use the bind. xml file to enhance the bytecode of the jibx class. There are two ways to use it. One is to use ant. There are many official examples available for your reference. The second is the jibx eclipse maven plug-in. Will be bound automatically. We recommend that you use this. You can download the jibx. xsd file from the Internet and generate a java class based on it. 6. Use package com. vteba. service. xml. jibx; import java. util. list; public class Customer {public Person person Person; public String street; public String city; public String state; public Integer zip; public String phone; public List NameList; public List PersonList; public Person getPerson () {return person;} public void setPerson (Person person) {this. person = person;} public String getStreet () {return street;} public void setStreet (String street) {this. street = street;} public String getCity () {return city;} public void setCity (String city) {this. city = city;} public String getState () {return state;} public void setState (String state) {this. state = state;} public Integer getZip () {return zip;} public void setZip (Integer zip) Export this.zip = zip;} public String getPhone () {return phone ;} public void setPhone (String phone) {this. phone = phone;} public List GetPersonList () {return personList;} public void setPersonList (List PersonList) {this. personList = personList;} public List GetNameList () {return nameList;} public void setNameList (List NameList) {this. nameList = nameList;} public class Person {public int customerNumber; public String firstName; public String lastName; public int getCustomerNumber () {return customerNumber;} public void setCustomerNumber (int customerNumber) {this. customerNumber = customerNumber;} public String getFirstName () {return firstName;} public void setFirstName (String firstName) {this. firstName = firstName;} public String getLastName () {return lastName;} public void setLastName (String lastName) {this. lastName = lastName;} 7. This example already contains the ing of general classes, List List . If the List If it is changed to String [], you do not need to specify the create-type attribute. For more information about the attributes of a file, see the official documentation. Attribute is used as an attribute, and element is used as a child element. For collection, if the name attribute is not specified, the ing xml will not have the outermost element.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.