-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: About toGenericXML() and toXML()
PostPosted: Thu Nov 13, 2003 8:01 am 
Newbie

Joined: Sun Oct 26, 2003 5:21 pm
Posts: 4
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.


Top
 Profile  
 
 Post subject: About toGenericXML() and toXML()
PostPosted: Tue Nov 18, 2003 5:15 pm 
Newbie

Joined: Sun Oct 26, 2003 5:21 pm
Posts: 4
Anyone can help me ?

Thanks.
Benoit


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 6:38 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
The difference between toXML and toGenericXML is that toGenericXML takes the toXML output and transforms against a stylesheet (Hibernate-generic.xslt I think the file's called). Easiest way to get the output you want is to use toGenericXML() but modify the stylesheet to give the output you want.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 3:06 am 
Newbie

Joined: Mon Nov 10, 2003 9:08 am
Posts: 12
Is it not possible to specify custom stylesheets at run-time? Like articles.xsl when I'm fetching articles, users.xsl for users, etc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.