473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XML databinding question

Can anybody suggest possible databinding options which would bind(map)
xml instance docs(which conforms to some pre-defined xsd) to a
PRE-EXISTING java object (see below example). I looked at xstream which
seems to be a good option for serializing/deserializing objects to xml
and vice-versa(xstream does not care for schemas). Same with JAXB,
Castor or Xmlbeans ..I have not found a way to map the below xml to my
custom java obj?

Any pointers will be very helpful.

TIA,
Guru.

an e.g. would be :
<schema>
<complexType>
<sequence>
<element name="name" type="string" />
<element name="deptid" type="int" />
</sequence>
</complexType>
</schema>
Instance doc:
<employee>
<name>Joe Trader</name>
<deptid>10</deptid>
</employee>
Custom Java obj (with no default const., accessors or mutators):
public class Employee
{
public final String name;
public final int deptid;

public Employee (String name, int deptid) // overloaded const.
{
this.name = name;
this.deptid = deptid;
}

}

Dec 21 '06 #1
1 1293
On Thu, 21 Dec 2006 04:44:30 -0000, <ud********@yahoo.comwrote:
Can anybody suggest possible databinding options which would bind(map)
xml instance docs(which conforms to some pre-defined xsd) to a
PRE-EXISTING java object (see below example). I looked at xstream which
seems to be a good option for serializing/deserializing objects to xml
and vice-versa(xstream does not care for schemas). Same with JAXB,
Castor or Xmlbeans ..I have not found a way to map the below xml to my
custom java obj?
JiBX (http://jibx.sourceforge.net) should be able to map your example with
no problems at all. You should be able to find examples in the
documentation. JiBX works at a lower level than many of the alternative
tools, so it does not need to rely on Java Beans conventions or
reflection. Instead there is an extra build step that injects bytecode
into your classes. This approach has the twin advantages of being
non-invasive (at the source level) and very fast at runtime.

Dan.

--
Daniel Dyer
http://www.uncommons.org
Dec 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Victor Jones | last post by:
I have a general question about the approach towards databinding controls with objects. Apart from the databinding offered by .NET to bind data, it can be extended to have the same behavior with...
0
by: Victor Jones | last post by:
I have a general question about the approach towards databinding controls with objects. Apart from the databinding offered by .NET to bind data, it can be extended to have the same behavior with...
4
by: Jason S | last post by:
I haven't been able to find a clear answer to this and I'm hoping someone could enlighten me. As pertains to databinding a control in a repeating fashion(datagrid, repeater, etc.) what event...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
2
by: Al Smith | last post by:
I kind of understand how the below works, however I am trying to do it at runtime vrs design time. <asp:TextBox id="TextBox1" runat="server" Text='<%# StateList.SelectedItem.Text...
2
by: Shane | last post by:
When I click on the DataBinding in the properties window a list of options open up called Advanced,Tag and Text. I would like to know what Tag and Text are set to? I hope to Bind a text box to a...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
1
by: Zak Lomakus | last post by:
Hi, From my main page (default.aspx) I am calling another .aspx (e.g. otherpage.aspx) page through Javascript using window.showModalDialog. otherpage.aspx has a databoud control (webchart),...
0
by: rb | last post by:
I'm struggling with (probably) basic things using SqlDataSource and DataList. Here's the problem: I need to read the resultset returned by SqlDataSource to perform actions related to visual...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.