| Код | package jaxbdemo;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.File;
public class Main {
public static void main(String[] args) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Unmarshaller u = jaxbContext.createUnmarshaller(); Message m = (Message) u.unmarshal(new File("demo.xml")); System.out.println(m.getRequest().getMyRequest().getInfo().getEl2()); } }
|
| Код | // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-325 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2008.08.01 at 09:26:44 AM EEST //
package jaxbdemo;
import java.math.BigDecimal; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType;
/** * <p>Java class for Info complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="Info"> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="El1" type="{http://www.w3.org/2001/XMLSchema}decimal"/> * <element name="El2" type="{http://www.w3.org/2001/XMLSchema}string"/> * </sequence> * </restriction> * </complexContent> * </complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Info", namespace = "http://www.iam.ru/ns", propOrder = { "el1", "el2" }) public class Info {
@XmlElement(name = "El1", namespace = "http://www.iam.ru/ns", required = true) protected BigDecimal el1; @XmlElement(name = "El2", namespace = "http://www.iam.ru/ns", required = true) protected String el2;
/** * Gets the value of the el1 property. * * @return * possible object is * {@link BigDecimal } * */ public BigDecimal getEl1() { return el1; }
/** * Sets the value of the el1 property. * * @param value * allowed object is * {@link BigDecimal } * */ public void setEl1(BigDecimal value) { this.el1 = value; }
/** * Gets the value of the el2 property. * * @return * possible object is * {@link String } * */ public String getEl2() { return el2; }
/** * Sets the value of the el2 property. * * @param value * allowed object is * {@link String } * */ public void setEl2(String value) { this.el2 = value; }
}
|
| Код | // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-325 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2008.08.01 at 09:26:44 AM EEST //
package jaxbdemo;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType;
/** * <p>Java class for anonymous complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="Request"> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="MyRequest" type="{http://www.iam.ru/ns}MyRequest"/> * </sequence> * </restriction> * </complexContent> * </complexType> * </element> * </sequence> * <attribute name="Sender" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /> * <attribute name="Receiver" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /> * <attribute name="DateSend" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /> * </restriction> * </complexContent> * </complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "request" }) @XmlRootElement(name = "Message", namespace = "http://www.iam.ru/ns") public class Message {
@XmlElement(name = "Request", namespace = "http://www.iam.ru/ns", required = true) protected Message.Request request; @XmlAttribute(name = "Sender", required = true) protected String sender; @XmlAttribute(name = "Receiver", required = true) protected String receiver; @XmlAttribute(name = "DateSend", required = true) protected String dateSend;
/** * Gets the value of the request property. * * @return * possible object is * {@link Message.Request } * */ public Message.Request getRequest() { return request; }
/** * Sets the value of the request property. * * @param value * allowed object is * {@link Message.Request } * */ public void setRequest(Message.Request value) { this.request = value; }
/** * Gets the value of the sender property. * * @return * possible object is * {@link String } * */ public String getSender() { return sender; }
/** * Sets the value of the sender property. * * @param value * allowed object is * {@link String } * */ public void setSender(String value) { this.sender = value; }
/** * Gets the value of the receiver property. * * @return * possible object is * {@link String } * */ public String getReceiver() { return receiver; }
/** * Sets the value of the receiver property. * * @param value * allowed object is * {@link String } * */ public void setReceiver(String value) { this.receiver = value; }
/** * Gets the value of the dateSend property. * * @return * possible object is * {@link String } * */ public String getDateSend() { return dateSend; }
/** * Sets the value of the dateSend property. * * @param value * allowed object is * {@link String } * */ public void setDateSend(String value) { this.dateSend = value; }
/** * <p>Java class for anonymous complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="MyRequest" type="{http://www.iam.ru/ns}MyRequest"/> * </sequence> * </restriction> * </complexContent> * </complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "myRequest" }) public static class Request {
@XmlElement(name = "MyRequest", namespace = "http://www.iam.ru/ns", required = true) protected MyRequest myRequest;
/** * Gets the value of the myRequest property. * * @return * possible object is * {@link MyRequest } * */ public MyRequest getMyRequest() { return myRequest; }
/** * Sets the value of the myRequest property. * * @param value * allowed object is * {@link MyRequest } * */ public void setMyRequest(MyRequest value) { this.myRequest = value; }
}
}
|
| Код | // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-325 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2008.08.01 at 09:26:44 AM EEST //
package jaxbdemo;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType;
/** * <p>Java class for MyRequest complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="MyRequest"> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="Info" type="{http://www.iam.ru/ns}Info"/> * </sequence> * </restriction> * </complexContent> * </complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "MyRequest", namespace = "http://www.iam.ru/ns", propOrder = { "info" }) public class MyRequest {
@XmlElement(name = "Info", namespace = "http://www.iam.ru/ns", required = true) protected Info info;
/** * Gets the value of the info property. * * @return * possible object is * {@link Info } * */ public Info getInfo() { return info; }
/** * Sets the value of the info property. * * @param value * allowed object is * {@link Info } * */ public void setInfo(Info value) { this.info = value; }
}
|
| Код | // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-325 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2008.08.01 at 09:26:44 AM EEST //
package jaxbdemo;
import javax.xml.bind.annotation.XmlRegistry;
/** * This object contains factory methods for each * Java content interface and Java element interface * generated in the jaxbdemo package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory {
/** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: jaxbdemo * */ public ObjectFactory() { }
/** * Create an instance of {@link Message.Request } * */ public Message.Request createMessageRequest() { return new Message.Request(); }
/** * Create an instance of {@link Info } * */ public Info createInfo() { return new Info(); }
/** * Create an instance of {@link MyRequest } * */ public MyRequest createMyRequest() { return new MyRequest(); }
/** * Create an instance of {@link Message } * */ public Message createMessage() { return new Message(); }
}
|
|