Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34255

Re: XQuery with Java resources

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: XQuery with Java resources
Date 2016-05-05 10:47 -0400
Organization Aioe.org NNTP Server
Message-ID <ngfmde$la3$1@gioia.aioe.org> (permalink)
References (3 earlier) <ngcqob$4dm$2@gioia.aioe.org> <ngd07q$vnm$1@dont-email.me> <7f023e94-584a-404f-902d-644e9e53c559@googlegroups.com> <nge2o6$7uq$1@gioia.aioe.org> <e9e5daad-8552-45fb-929c-a60650b5471d@googlegroups.com>

Show all headers | View raw


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:
> <record><field1>value</field1></record> or is there a pratical reason
> for tag attributes: <record
> key="0001"><field1>value</field1></record> 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:

<address status="verified">
     <street>bla bla bla</street>
     <city>bla</city>
     <zip>bla</zip>
</address>

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

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

XQuery with Java resources Priya Mohan <mmpriya66@gmail.com> - 2016-04-30 08:28 -0700
  Re: XQuery with Java resources Jeff Higgins <jeff@invalid.invalid> - 2016-05-01 00:01 +0000
    Re: XQuery with Java resources Jeff Higgins <jeff@invalid.invalid> - 2016-05-01 19:50 +0000
    Re: XQuery with Java resources Jeff Higgins <jeff@invalid.invalid> - 2016-05-02 22:44 +0000
      Re: XQuery with Java resources Arne Vajhøj <arne@vajhoej.dk> - 2016-05-04 08:42 -0400
        Re: XQuery with Java resources Jeff Higgins <jeff@invalid.invalid> - 2016-05-04 14:16 +0000
          Re: XQuery with Java resources Eric Douglas <e.d.programmer@gmail.com> - 2016-05-04 07:31 -0700
            Re: XQuery with Java resources Jeff Higgins <jeff@invalid.invalid> - 2016-05-04 17:34 +0000
            Re: XQuery with Java resources Arne Vajhøj <arne@vajhoej.dk> - 2016-05-04 20:05 -0400
              Re: XQuery with Java resources Eric Douglas <e.d.programmer@gmail.com> - 2016-05-05 06:06 -0700
                Re: XQuery with Java resources Arne Vajhøj <arne@vajhoej.dk> - 2016-05-05 10:47 -0400
          Re: XQuery with Java resources Arne Vajhøj <arne@vajhoej.dk> - 2016-05-04 20:01 -0400
            Re: XQuery with Java resources Jeff Higgins <jeff@invalid.invalid> - 2016-05-05 21:08 +0000
          Re: XQuery with Java resources Martin Gregorie <martin@address-in-sig.invalid> - 2016-05-05 10:50 +0000

csiph-web