Ниже приведен XML-код, проанализированный как экземпляр JAXB
<client>
<cl_id>111871</cl_id>
<cl_lf_id>115124</cl_lf_id>
<cl_name>0118</cl_name>
<cl_address>
<address_1>Test Corp</address_1>
<address_2>200 GRANVILLE STREET</address_2>
<address_3></address_3>
<city>Austin</city>
<state_province>TX</state_province>
<zip_postal_code>77777</zip_postal_code>
<country>USA</country>
<phone>111-224-3858</phone>
<file_item_nbr>5</file_item_nbr>
</cl_address>
<file_item_nbr>6</file_item_nbr>
</client>
Ниже приведен XSD для `Client
<xsd:complexType name="client">
<xsd:sequence>
<xsd:element name="cl_id" type="string20" minOccurs="0" maxOccurs="1"/>
<xsd:element name="cl_lf_id" type="string20" minOccurs="1" maxOccurs="1"/>
<xsd:element name="cl_name" type="string120" minOccurs="1" maxOccurs="1"/>
<xsd:element name="cl_address" type="address_info" minOccurs="1" maxOccurs="1"/>
<xsd:element name="client_contact" type="contact_info" minOccurs="0" maxOccurs="1"/>
<xsd:element name="cl_tax_id" type="string20" minOccurs="0" maxOccurs="1"/>
<xsd:element name="file_item_nbr" type="xsd:nonNegativeInteger" minOccurs="1" maxOccurs="1"/>
<xsd:element name="extend_header" type="extend_header" minOccurs="0" maxOccurs="1"/>
<xsd:element name="invoice" type="invoice" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
Ниже приведены JAXB Pojos для вышеуказанного xml
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "client", propOrder = {
"clId",
"clLfId",
"clName",
"clAddress",
"clientContact",
"clTaxId",
"fileItemNbr",
"extendHeader",
})
public class Client {
@XmlElement(name = "cl_id")
protected String clId;
@XmlElement(name = "cl_lf_id", required = true)
protected String clLfId;
@XmlElement(name = "cl_name", required = true)
protected String clName;
@XmlElement(name = "cl_address", required = true)
protected AddressInfo clAddress;
@XmlElement(name = "client_contact")
protected ContactInfo clientContact;
@XmlElement(name = "cl_tax_id")
protected String clTaxId;
@XmlElement(name = "file_item_nbr", required = true)
@XmlSchemaType(name = "nonNegativeInteger")
protected BigInteger fileItemNbr;
@XmlElement(name = "extend_header")
protected ExtendHeader extendHeader;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "address_info", propOrder = {
"address1",
"address2",
"address3",
"city",
"stateProvince",
"zipPostalCode",
"country",
"phone",
"fax",
"fileItemNbr"
})
public class AddressInfo {
@XmlElement(name = "address_1", required = true)
protected String address1;
@XmlElement(name = "address_2")
protected String address2;
@XmlElement(name = "address_3")
protected String address3;
@XmlElement(required = true)
protected String city;
@XmlElement(name = "state_province", required = true)
protected String stateProvince;
@XmlElement(name = "zip_postal_code", required = true)
protected String zipPostalCode;
@XmlElement(required = true)
protected String country;
@XmlElement(required = true)
protected String phone;
protected String fax;
@XmlElement(name = "file_item_nbr", required = true)
@XmlSchemaType(name = "nonNegativeInteger")
protected BigInteger fileItemNbr;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "contact_info", propOrder = {
"contactLname",
"contactFname",
"contactId",
"contactPhone",
"contactFax",
"contactEmail",
"fileItemNbr"
})
public class ContactInfo {
@XmlElement(name = "contact_lname", required = true)
protected String contactLname;
@XmlElement(name = "contact_fname", required = true)
protected String contactFname;
@XmlElement(name = "contact_id")
protected String contactId;
@XmlElement(name = "contact_phone")
protected String contactPhone;
@XmlElement(name = "contact_fax")
protected String contactFax;
@XmlElement(name = "contact_email", required = true)
protected String contactEmail;
@XmlElement(name = "file_item_nbr", required = true)
@XmlSchemaType(name = "nonNegativeInteger")
protected BigInteger fileItemNbr;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "extend_header", propOrder = {
"vendor",
"app",
"sequence",
"date",
"extendData"
})
public class ExtendHeader {
@XmlElement(required = true)
protected String vendor;
protected String app;
protected String sequence;
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar date;
@XmlElement(name = "extend_data", required = true)
protected List<ExtendData> extendData;
}
Может кто-нибудь помочь, как проверить, есть ли у экземпляра Client
вложенное свойство address_1
присутствует или нет, и если оно присутствует, имеет ли вложенное свойство непустое значение или нет?