Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » what are some clean, easy ways to filter XML-based input to a TableViewer object?
what are some clean, easy ways to filter XML-based input to a TableViewer object? [message #1071636] Sat, 20 July 2013 18:38
John Smith is currently offline John SmithFriend
Messages: 3
Registered: July 2013
Junior Member
The code opens an XML document, builds a JAXB object that represents the contents of that document, selects the relevant data (a List field of other JAXB objects), and feeds that List to a Tableviewer.

That works great when the data that goes into the Tableviewer doesn't have to be filtered. But when it needs to be filtered, especially when it needs to be filtered based on several criteria, there doesn't seem to be a straightforward way to do it, and for the sake of not scratching off the JAXB idea altogether and starting over with a different approach, ended up:

building an XPath expression based on the chosen filters
marshalling the JAXB Object whose List field was initially fed to the Tableviewer, as an org.w3c.dom.Document object
running the XPath expression against that object
unmarshalling each Node of the returned NodeList as a JAXB object
building a new List whose elements are those JAXB objects
passing the new List as new input to the Tableviewer.

With all the marshalling/unmarshalling it's obviously not an efficient solution, but it works relatively well as long as the number of element does not exceed ~ 5000.

Had I been using .NET, I would have,

built a DataTable object based on the XML document
filtered the data by running an SQL-like query against the DataTable's default DataView
bound the resulting DataTable to the DataGridView control that displays the data

with that in mind, I would like to know if there is a more elegant and efficient way to accomplish what I am trying to accomplish without having to marshal/unmarshal the JAXB object each time the data needs to be filtered based on a combination of arbitrary criteria. If there is a clean way to do all this filtering in a manner similar to the way I would have done it if I had been using .NET, even if it's in a way that doesn't require the use of JAXB at all, I might still have time to make changes to the code.
Previous Topic:IME
Next Topic:Supporting Multiple Data type entries in Clipboard
Goto Forum:
  


Current Time: Thu Mar 28 12:59:48 GMT 2024

Powered by FUDForum. Page generated in 0.03115 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top