I have a very simple query, which select 3 column ( a, b, and c ),
and apply the result against XMLDataBinder.toGenericXML() and XMLDataBinder.toXML().
Below is the snapshot of the code :
...
Query query = session.createQuery(queryString);
List list = query.list();
Collection coll = (Collection)list;
Databinder binder = session.openDatabinder();
binder.setInitializeLazy(true);
binder.bindAll(coll);
//String xml = binder.toGenericXML();
String xml = binder.toXML();
...
The toGenericXML() gives me this XML :
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-generic datetime="04 November 2003 12:12:00">
<object class="ICcy" package="example.mapping">
<id name="a" type="long">1</id>
<property name="b" type="string"><![CDATA[Hello]]></property>
<property name="c" type="string"><![CDATA[There]]></property>
</object>
</hibernate-generic>
The toXML() gives me this XML :
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-custom datetime="12 November 2003 11:47:28"><ICcy id="N10004"><a>1</a><b>Hello</b><c>There</c></ICcy></hibernate-custom>
It seems that toXML() generate all element in one line, no indentation, as opposed to toGenericXML(). I'm using 2.1 beta6.
If I want to use toXML(), how to format the output so it gives the same format ( i.e. with indentation ) as toGenericXML() ?
Thanks for any help.
|