I try to use XStream to map xml to java object. But here is one bug.
public class Concepts {
List<Concept> conceptList = new ArrayList<Concept>();
}
public class Concept {
String id;
String name;
String table;
List<Child> childList= new ArrayList<Child>();
}
public class Child {
String id;
String name;
String childTable;
String rel;
}
the xml is
<?xml version="1.0" encoding="UTF-8"?>
<concepts>
<concept id="1234" name="student" table="student">
<childList>
<child id="" name="Address" childTable="address" rel="one-to-one"/>
<child id="" name="Score" childTable="score" rel="one-to-many"/>
</childList>
</concept>
<concept id="12343" name="address" table="address"/>
<concept id="123433" name="store" table="score"/>
</concepts>
my mapping is
xstream.alias("concepts", Concepts.class);
xstream.alias("concept", Concept.class);
xstream.alias("child", Child.class);
xstream.useAttributeFor("name", String.class);
xstream.useAttributeFor("id", String.class);
xstream.useAttributeFor("table", String.class);
xstream.useAttributeFor("childTable", String.class);
xstream.useAttributeFor("rel", String.class);
// collection
xstream.addImplicitCollection(Concepts.class, "conceptList","concept", Concept.class);
xstream.addImplicitCollection(Concept.class, "childList", "childList", Child.class); //bug
The last line has bug. it can't map the child arraylist. I don't konw where is the bug.
Thanks.
Try with this...
I thought this must be a one of the way...
public class test {
public class Concepts {
List<Concept> conceptList = new ArrayList<Concept>();
}
public class Concept {
String id;
String name;
String table;
ChildList childList;
}
public class ChildList {
List<Child> childList = new ArrayList<Child>();
}
public class Child {
String id;
String name;
String childTable;
String rel;
}
public static void main(String[] args) {
XStream xstream = new XStream();
xstream.alias("concepts", Concepts.class);
xstream.alias("concept", Concept.class);
xstream.alias("ChildList", ChildList.class);
xstream.alias("child", Child.class);
xstream.aliasAttribute(Concept.class, "id", "id");
xstream.aliasAttribute(Concept.class, "name", "name");
xstream.aliasAttribute(Concept.class, "table", "table");
xstream.aliasAttribute(Child.class, "id", "id");
xstream.aliasAttribute(Child.class, "name", "name");
xstream.aliasAttribute(Child.class, "childTable", "childTable");
xstream.aliasAttribute(Child.class, "rel", "rel");
xstream.addImplicitCollection(ChildList.class, "childList");
xstream.addImplicitCollection(Concepts.class, "conceptList");
Object fromXML = xstream.fromXML(getmess());
for (Concept string : ((Concepts) fromXML).conceptList) {
System.out.println(string.id + " " + string.name + " " + string.table);
if (string.childList != null) {
for (Child string1 : string.childList.childList) {
if (string1 != null) {
System.out.println(" " + string1.id + " " + string1.name + " " + string1.childTable + " " + string1.rel);
}
}
}
}
}
static String getmess() {
return "<concepts>"
+ "<concept id=\"1234\" name=\"student\" table=\"student\">"
+ "<childList>"
+ "<child id=\"1\" name=\"Address\" childTable=\"address\" rel=\"one-to-one\"/>"
+ "<child id=\"2\" name=\"Score\" childTable=\"score\" rel=\"one-to-many\"/>"
+ "</childList>"
+ "</concept>"
+ "<concept id=\"12343\" name=\"address\" table=\"address\"/>"
+ "<concept id=\"123433\" name=\"store\" table=\"score\"/>"
+ "</concepts>";
}
}
Related
Hi I got a below XML string which contain diffgram
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Result xmlns="">
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<DT1 diffgr:id="DT11" msdata:rowOrder="0">
<TEST_NO>93481324345</TEST_NO>
<TEST_DESC>Description1</TEST_DESC>
</DT1>
<DT1 diffgr:id="DT12" msdata:rowOrder="1">
<TEST_NO>93481366454</TEST_NO>
<TEST_DESC>Description2</TEST_DESC>
</DT1>
<DT1 diffgr:id="DT13" msdata:rowOrder="2">
<TEST_NO>934813267783</TEST_NO>
<TEST_DESC>Description3</TEST_DESC>
</DT1>
</NewDataSet>
</diffgr:diffgram>
</Result>
How can I unmarshal this String to java POJO using JAXB ?
Below are the current POJO seems not able to bind by this way.
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"diffgr",
"newDataSet",
"dt"
})
#XmlRootElement(name="Result")
public class Response {
#XmlElement(name = "diffgr:diffgram")
protected String diffgr;
#XmlElement(name = "NewDataSet")
protected String newDataSet;
#XmlElement(name = "DT1")
protected List<Response.DT> dt;
public String getDiffgr() {
return diffgr;
}
public void setDiffgr(String diffgr) {
this.diffgr = diffgr;
}
public String getNewDataSet() {
return newDataSet;
}
public void setNewDataSet(String newDataSet) {
this.newDataSet = newDataSet;
}
public List<Response.DT> getDt() {
if (dt == null) {
dt = new ArrayList<Response.DT>();
}
return this.dt;
}
public void setDt(List<Response.DT> dt) {
this.dt = dt;
}
#Override
public String toString() {
return "Response [diffgr=" + diffgr + ", newDataSet=" + newDataSet + ", dt=" + dt + "]";
}
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"testNo",
"testDesc"
})
public static class DT {
#XmlElement(name = "TEST_NO")
protected String testNo;
#XmlElement(name = "TEST_DESC")
protected String testDesc;
public String getTestNo() {
return testNo;
}
public void setTestNo(String testNo) {
this.testNo = testNo;
}
public String getTestDesc() {
return testDesc;
}
public void setTestDesc(String testDesc) {
this.testDesc = testDesc;
}
#Override
public String toString() {
return "DT [testNo=" + testNo + ", testDesc=" + testDesc + "]";
}
}
}
I'm using the below sample code to unmarshal the String
JAXBContext jaxbContext = JAXBContext.newInstance(Response.class);
Unmarshaller jaxbUnMarshaller = jaxbContext.createUnmarshaller();
Response response = (Response)jaxbUnMarshaller.unmarshal(new StringReader(xml));
When execute there is no any error throwing out while the POJO was empty.
How to unmarshal an XML String contain diffgr to JAVA POJO like this case?
Jackson XML appears not to be able to marshal a XML having a tag with a certain attribute whose name is also being used for the nested children tags ("occ", in the following case).
<root>
<txt occ="1">
<occ id="1">first element</occ>
<occ id="2">second element</occ>
</txt>
<txt occ="2">
<occ id="1">first element</occ>
<occ id="2">second element</occ>
</txt>
</root>
Changing the name of the XmlAttribute "occ" or of the XmlElement "occ" makes it work.
This is how I've annotated my Txt Class:
#XmlAccessorType(XmlAccessType.FIELD)
public class Txt {
#XmlAttribute(name="occ")
private String occ_attr;
#XmlElement(name="occ")
private List<Occ> occ = new ArrayList<Occ>();
//getters and setters not annotated
And this is how I've annotated the Occ class:
public class Occ {
#XmlAttribute
private String id;
#XmlValue
private String value;
//getters and setters not annotated
I wrap them within a root and it worked.
Test class
import java.io.StringReader;
import javax.xml.bind.*;
public class Test {
public static void main(String...args) throws JAXBException {
String text = "<root>\n" +
" <txt occ=\"1\">\n" +
" <occ id=\"1\">first element</occ>\n" +
" <occ id=\"2\">second element</occ>\n" +
" </txt>\n" +
" <txt occ=\"2\">\n" +
" <occ id=\"1\">first element</occ>\n" +
" <occ id=\"2\">second element</occ>\n" +
" </txt>\n" +
"</root>";
JAXBContext jaxbContext = JAXBContext.newInstance(Root.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(text);
Root root = (Root) unmarshaller.unmarshal(reader);
System.out.println(root);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(root, sw);
String xmlContent = sw.toString();
System.out.println(xmlContent);
}
}
Txt class
import java.util.List;
import javax.xml.bind.annotation.*;
#XmlAccessorType(XmlAccessType.FIELD)
public class Txt {
#XmlAttribute(name = "occ")
private String occ_attr;
#XmlElement(name = "occ")
private ArrayList<Occ> occ;
public String getOcc_attr() {
return occ_attr;
}
public void setOcc_attr(String occ_attr) {
this.occ_attr = occ_attr;
}
public List<Occ> getOcc() {
return occ;
}
public void setOcc(ArrayList<Occ> occ) {
this.occ = occ;
}
#Override
public String toString() {
return "Txt [occ_attr=" + occ_attr + ", occ=" + occ + "]";
}
}
Occ class
import javax.xml.bind.annotation.*;
#XmlAccessorType(XmlAccessType.FIELD)
public class Occ {
#XmlAttribute
private String id;
#XmlValue
private String value;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
#Override
public String toString() {
return "Occ [id=" + id + ", value=" + value + "]";
}
}
Root class
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
#XmlRootElement(name = "root")
public class Root {
#XmlElement(name = "txt")
private ArrayList<Txt> txt;
#Override
public String toString() {
return "Root [txt=" + txt + "]";
}
}
prints out:
Root [txt=[Txt [occ_attr=1, occ=[Occ [id=1, value=first element], Occ [id=2, value=second element]]], Txt [occ_attr=2, occ=[Occ [id=1, value=first element], Occ [id=2, value=second element]]]]]
<root>
<txt occ="1">
<occ id="1">first element</occ>
<occ id="2">second element</occ>
</txt>
<txt occ="2">
<occ id="1">first element</occ>
<occ id="2">second element</occ>
</txt>
</root>
Apparently it's an issue of the library. As of today, the issue hasn't been solved yet:
https://github.com/FasterXML/jackson-dataformat-xml/issues/65
I have an XML with the following template:
<tag1 attr1="value1" attr2="value2">
<tag2> text </tag2>
<tag3> another text </tag3>
</tag1>
I want to extract this xml into a POJO that has 2 text fields as String and 2 fields for attributes, but I don't quite understand how to use JacksonXmlText.
First, start from some tutorials. For example, please, take a look on this page: Convert XML to JSON Using Jackson.
Some key points:
Use com.fasterxml.jackson.dataformat.xml.XmlMapper to serialize / deserialize XML
Use annotation from this package com.fasterxml.jackson.dataformat.xml.annotation
Your code could look like below:
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
public class Main {
public static void main(String[] args) throws Exception {
XmlMapper mapper = new XmlMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
Tag1 tag1 = new Tag1();
tag1.setTag2("text");
tag1.setTag3("another text");
tag1.setAttribute1("value1");
tag1.setAttribute2("value2");
String xml = mapper.writeValueAsString(tag1);
System.out.println(xml);
System.out.println(mapper.readValue(xml, Tag1.class));
}
}
#JacksonXmlRootElement(localName = "tag1")
class Tag1 {
private String attribute1;
private String attribute2;
private String tag2;
private String tag3;
#JacksonXmlProperty(isAttribute = true)
public String getAttribute1() {
return attribute1;
}
public void setAttribute1(String attribute1) {
this.attribute1 = attribute1;
}
#JacksonXmlProperty(isAttribute = true)
public String getAttribute2() {
return attribute2;
}
public void setAttribute2(String attribute2) {
this.attribute2 = attribute2;
}
public String getTag2() {
return tag2;
}
public void setTag2(String tag2) {
this.tag2 = tag2;
}
public String getTag3() {
return tag3;
}
public void setTag3(String tag3) {
this.tag3 = tag3;
}
#Override
public String toString() {
return "Tag1{" +
"attribute1='" + attribute1 + '\'' +
", attribute2='" + attribute2 + '\'' +
", tag2='" + tag2 + '\'' +
", tag3='" + tag3 + '\'' +
'}';
}
}
Above code prints:
<tag1 attribute1="value1" attribute2="value2">
<tag2>text</tag2>
<tag3>another text</tag3>
</tag1>
Tag1{attribute1='value1', attribute2='value2', tag2='text', tag3='another text'}
I am trying to Convert XML content into a Java Object using JAXB without using any annotation. My XML file (CustomerDtl.xml) structure is mentioned below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<basePojo>
<customerId>C001</customerId>
<customerList>
<Customer>
<name>Ram</name>
<phoneNo>123445</phoneNo>
</Customer>
<Customer>
<name>Tom</name>
<phoneNo>2332322</phoneNo>
</Customer>
</customerList>
</basePojo>
and my pojos are
BasePojo.java
package pojo;
import java.util.List;
import pojo.Customer;
public class BasePojo {
List<Customer> customerList;
String customerId;
public List<Customer> getCustomerList() {
return customerList;
}
public void setCustomerList(List<Customer> customerList) {
this.customerList = customerList;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
}
Customer.java
package pojo;
public class Customer {
private String name;
private String phoneNo;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNo() {
return phoneNo;
}
public void setPhoneNo(String phoneNo) {
this.phoneNo = phoneNo;
}
}
Below mentioned piece of code I have written to Convert XML content into a Java Object
try {
JAXBContext jc = JAXBContext.newInstance(BasePojo.class);
StreamSource xml = new StreamSource("CustomerDtl.xml");
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<BasePojo> jaxbElementObject = unmarshaller.unmarshal(
xml, BasePojo.class);
BasePojo bPojo = jaxbElementObject.getValue();
System.out.println("id="+bPojo.getCustomerId());
System.out.println("list size="+bPojo.getCustomerList().size());
Iterator iterator = bPojo.getCustomerList().iterator();
while (iterator.hasNext()) {
Customer studentDetails = (Customer) iterator.next();
System.out.println("Print Name:" + studentDetails.getName());
}
} catch (JAXBException e) {
System.out.println("Exception:" + e);
}
And the out put of this code is
id=C001
list size=1
list size=[pojo.Customer#3e3abc88]
Print Customer Name:null
After executing this program it's prints the correct customerId, but it prints the wrong customer list size 1. Although the list size is 1, and the list contains Customer object but when I iterate through the list and try to get different property value of Customer, I am getting null.
Can any one explain me what I need to correct? Using annotation I tried and it is working as expected. Is it not possible without annotation?
In the xml you don't have to specify the class name (Customer) as the child of your list (customerList), just use the list name directly for every element.
So, change the xml like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<basePojo>
<customerId>C001</customerId>
<customerList>
<name>Ram</name>
<phoneNo>123445</phoneNo>
</customerList>
<customerList>
<name>Tom</name>
<phoneNo>2332322</phoneNo>
</customerList>
</basePojo>
Try something like below
try {
XMLInputFactory xif = XMLInputFactory.newFactory();
StreamSource xml = new StreamSource("CustomerDtl.xml");
XMLStreamReader xsr = xif.createXMLStreamReader(xml);
while(xsr.hasNext()) {
if(xsr.isStartElement() && "Customer".equals(xsr.getLocalName())) {
break;
}
xsr.next();
}
JAXBContext jc = JAXBContext.newInstance(Customer.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Customer customer = unmarshaller.unmarshal(xsr, Customer.class).getValue();
System.out.println(customer.getName());
} catch (JAXBException e) {
System.out.println("Exception:" + e);
}
Here you go if you do not want any annotation (with exact xml that you shared).
1) Wrap your list to a wrapper class (to handle customerList)
2) Now as I asked in Comment, if you have "Customer" element, then default "xml" name recognized will be with small c. If you don't want to annotate even that, then handle it while reading it.
After having said so here is an working sample (with runnable main) modifying your BasePojo
package pojo;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.util.Iterator;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.util.StreamReaderDelegate;
import javax.xml.transform.stream.StreamSource;
public class BasePojo {
String customerId;
CustomerList customerList;
public CustomerList getCustomerList() {
return customerList;
}
public void setCustomerList(CustomerList customerListObject) {
this.customerList = customerListObject;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public static void main(String[] args) {
try {
String customerData = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
+ "<basePojo>\n"
+ "<customerId>C001</customerId>\n"
+ "<customerList>\n"
+ " <Customer>\n"
+ " <name>Ram</name>\n"
+ " <phoneNo>123445</phoneNo>\n"
+ " </Customer>\n"
+ "\n"
+ " <Customer>\n"
+ " <name>Tom</name>\n"
+ " <phoneNo>2332322</phoneNo>\n"
+ " </Customer>\n"
+ "</customerList>\n"
+ "</basePojo>";
JAXBContext jc = JAXBContext.newInstance(BasePojo.class);
StringReader reader = new StringReader(customerData);
StreamSource xml = new StreamSource(reader);
XMLInputFactory xif = XMLInputFactory.newFactory();
XMLStreamReader xsr = xif.createXMLStreamReader(new ByteArrayInputStream(customerData.getBytes("UTF-8")));
xsr = new StreamReaderDelegate(xsr) {
#Override
public String getLocalName() {
String localName = super.getLocalName();
if ("Customer".equals(localName)) {
return "customer";
}
return localName;
}
};
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<BasePojo> jaxbElementObject = unmarshaller.unmarshal(xsr, BasePojo.class);
BasePojo bPojo = jaxbElementObject.getValue();
System.out.println("id=" + bPojo.getCustomerId());
System.out.println("list size=" + bPojo.getCustomerList().getCustomer().size());
Iterator iterator = bPojo.getCustomerList().getCustomer().iterator();
while (iterator.hasNext()) {
Customer studentDetails = (Customer) iterator.next();
System.out.println("Print Name:" + studentDetails.getName());
}
} catch (Exception e) {
System.out.println("Exception:" + e);
}
}
}
class CustomerList {
private List<Customer> customer;
public List<Customer> getCustomer() {
return customer;
}
public void setCustomer(List<Customer> customer) {
this.customer = customer;
}
}
How would I go about unmarshalling this XML file structure with JAXB:
<document>
<properties>
<basic>
<property id="generationDate">
<value>20150525</value>
</property>
<property id="hostAddress">
<value>192.168.0.250</value>
</property>
</basic>
</properties>
</document>
Snippet from Java class
import javax.xml.bind.annotation.*;
#XmlRootElement(name = "document")
#XmlAccessorType(XmlAccessType.FIELD)
class PDFDocument {
#XmlID
#XmlAttribute(name = "generationDate")
private String generationDate;
Snippet from Unmarshalling code:
PDFDocument doc = new PDFDocument();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(PDFDocument.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
doc = (PDFDocument) jaxbUnmarshaller.unmarshal(new File(filePath));
} catch (JAXBException ex) {
Logger.getLogger(FileFunctions.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(doc.getGenerationDate());
But i'm not sure how to reference each value of a property.
Ok so basically your Java Object Structure is wrong. You need to analyze the XML and then you need to build the Java Object structure accordingly.
If you look at the XML, you have a Document, and inside the Document you have Properties, inside properties the basic properties and so on.
So similarly you need to have java classes, A Document Class, inside document you need to have properties class, inside that Basic class and so on. I have shown the class structure below, so that you can get an idea.
Document Class -
#XmlRootElement(name = "document")
#XmlAccessorType(XmlAccessType.FIELD)
public class PDFDocument {
#XmlElement(name = "properties")
private DocumentProperty documentProperty;
public DocumentProperty getDocumentProperty() {
return documentProperty;
}
public void setDocumentProperty(DocumentProperty documentProperty) {
this.documentProperty = documentProperty;
}
#Override
public String toString() {
return "PDFDocument{" +
"documentProperty=" + documentProperty + "\n" +
'}';
}
}
Class to Hold Properties -
#XmlRootElement(name = "properties")
#XmlAccessorType(XmlAccessType.FIELD)
public class DocumentProperty {
#XmlElement(name = "basic")
private Basic basic;
public Basic getBasic() {
return basic;
}
public void setBasic(Basic basic) {
this.basic = basic;
}
#Override
public String toString() {
return "DocumentProperty{" +
"basic=" + basic + "\n" +
'}';
}
}
Basic Class -
#XmlRootElement(name = "basic")
#XmlAccessorType(XmlAccessType.FIELD)
public class Basic {
#XmlElementRef
private List<Property> propertyList;
public List<Property> getPropertyList() {
return propertyList;
}
public void setPropertyList(List<Property> propertyList) {
this.propertyList = propertyList;
}
#Override
public String toString() {
return "Basic{" +
"propertyList=" + propertyList + "\n" +
'}';
}
}
Property Class -
#XmlRootElement(name = "property")
#XmlAccessorType(XmlAccessType.FIELD)
public class Property {
#XmlAttribute(name = "id")
private String id;
#XmlElement(name = "value")
private String value;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
#Override
public String toString() {
return "Property{" +
"id='" + id + "\n" +
", value='" + value + "\n" +
'}';
}
}
The Above Class structure works with the XML you provided. But I guess you will have to change this structure since There will be other types of Properties in Document other than Basic Type. In that Case I suggest you to have abstract Document Property class and to extend that to Basic and Other types of Properties.
The Test class -
public class XmlTest {
#Test
public void testXml() throws Exception {
String xml = "<document>" +
" <properties>" +
" <basic>" +
" <property id=\"generationDate\">" +
" <value>20150525</value>" +
" </property>\n" +
" <property id=\"hostAddress\">" +
" <value>192.168.0.250</value>" +
" </property>" +
" </basic>" +
" </properties>" +
"</document>";
try {
JAXBContext jaxbContext = JAXBContext.newInstance(PDFDocument.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
PDFDocument document = (PDFDocument) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(xml.getBytes()));
System.out.println("PDF Document Structure -" +document.toString());
for(Property property : document.getDocumentProperty().getBasic().getPropertyList()) {
if(property.getId().equals("generationDate")){
System.out.println("Generation Date : "+property.getValue());
}
}
} catch (JAXBException ex) {
ex.printStackTrace();
}
}
}
Running the Test class Produces the Following Result.
PDFDocument{
documentProperty=
DocumentProperty{
basic=Basic{
propertyList=[
Property{
id='generationDate
, value='20150525
},
Property{id='hostAddress
, value='192.168.0.250
}]
}
}
}
Hope this Helps.