Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: XQuery with Java resources Date: Thu, 5 May 2016 10:47:09 -0400 Organization: Aioe.org NNTP Server Lines: 89 Message-ID: References: <7f023e94-584a-404f-902d-644e9e53c559@googlegroups.com> NNTP-Posting-Host: ANasIS7Js9OyLQwgloeBLQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:34255 On 5/5/2016 9:06 AM, Eric Douglas wrote: > On Wednesday, May 4, 2016 at 8:05:38 PM UTC-4, Arne Vajhøj wrote: >> You will not benefit from an XML database for that. >> >> Your choices must be: >> >> you want to map between objects and XML files => use JAXB >> >> you just want to write and read XML files => use JAXP (DOM or SAX) >> or StAX > > Right? Our application currently stores all data in flat mkeyed > files > (http://documentation.basis.com/BASISHelp/WebHelp/usr/mkeyed_files.htm). > > We have an in house tool outside the application which is only used > by developers, but we want the data to be edited independently and > shared by multiple developers (merge changes using SourceTree), so > I'm thinking of moving the data for that tool, currently also in > mkeyed format, to an XML format (so it appears as plain text for > merge tools). A merge tool would need to be XML aware to merge XML files. But you certainly have a lot of tools to choose from when going XML. > So I wanted to find the simplest, most logical way to access that > file/record/field type data in XML. First is the question of do we > simply store everything as tag data: > value or is there a pratical reason > for tag attributes: key="0001">value or is there anything else > we should know about the data syntax to put in from the start so we > don't have to rewrite a bunch of files? The discussion about elements vs attributes is a classic discussion. There are some objective guidance like: - elements allow complex data aka sub elements, attributes do not - elements allow repeats, attributes do not - attributes takes much less space than elements But then there is the more "what is the rigth way" aspects. I would suggest: - use elements for core data - use attributes for auxiliary data Example:
bla bla bla bla bla
Street, city and zip are the core of address. That the address has been verified is just some second level additional information about the address. > Then there's the question do we need binding? > https://docs.oracle.com/javase/tutorial/jaxb/intro/ os just the basic > XML API? https://docs.oracle.com/javase/tutorial/jaxp/ As already stated then JAXB or not must depend on whether you want to use object to XML file mapping or not. > Then do we choose a model (SAX, DOM, or StAX?) or (can we have / do > we want) multiple methods accessing the same XML data using different > models for different reasons? You can use different methods for different purposes. But it will require your developers to be familiar with multiple methods. I would tend to say: * avoid SAX unless you need to parse large files very fast * use StAX for very basic reading and writing * use DOM in case you need advanced processing of XML * consider one of the third party DOM's on top of standard W3C DOM as they are often easier to use > Getting back to the thread topic, would our use of XML for text data > files for local application benefit from XQuery? > https://docs.oracle.com/database/121/ADXDK/adx_j_xqj.htm#ADXDK99930 DOM and XPath should do it. Arne