Tuesday, July 2, 2013

JAXB: Using Command Line XJC tool to generate POJO objects

xjc -p com.generated.xjc -d F:\PROJECT\UP\RESEARCH\_Jersey\restfuljaxb\src\main\resources family.xsd
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) 2010 DIRECTV, Inc. All rights reserved. -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">

    <xsd:complexType name="father">
            <xsd:sequence>
                <xsd:element name="fatherName" type="xsd:string"
                    minOccurs="0" />
                <xsd:element name="dateOfBirth" type="xsd:date"
                    minOccurs="0" />
                <xsd:element name="job" type="xsd:string" minOccurs="0" />
                <xsd:element name="age" type="xsd:int" minOccurs="0" />
            </xsd:sequence>
    </xsd:complexType>
    
    <xsd:complexType name="mother">
        <xsd:sequence>
            <xsd:element name="motherName" type="xsd:string"/>
            <xsd:element name="dateOfBirth" type="xsd:date"/>
            <xsd:element name="job" type="xsd:string"/>
            <xsd:element name="age" type="xsd:int"/>
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:complexType name="children">
        <xsd:sequence>
            <xsd:element name="fullName" type="xsd:string"
                minOccurs="0" />
            <xsd:element name="dateOfBirth" type="xsd:date"
                minOccurs="0" />
            <xsd:element name="job" type="xsd:string" minOccurs="0" />
            <xsd:element name="age" type="xsd:int" minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:element name="family">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="father" type="father"/>
                <xsd:element name="mother" type="mother"/>
                <xsd:element name="children" type="children" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    

</xsd:schema>

No comments:

Post a Comment