The Artima Developer Community
Sponsored Link

Java Community News
How Do You Use XML?

9 replies on 1 page. Most recent reply: Jun 8, 2007 8:53 PM by David Chazin

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

How Do You Use XML? Posted: May 31, 2007 1:21 PM
Reply to this message Reply
Summary
In a recent IBM developerWorks article, Brett McLaughlin notes that the way most developers use XML has changed significantly over the years, possibly losing some flexibility afforded by the early XML APIs. What's your preferred way of interacting with XML data?
Advertisement

Earlier this year, Brett McLaughlin, an O'Reilly editor, and author of that publisher's Java and XML book, asked what tasks XML was really good for. In a new IBM developerWorks article, Low-level or high-level XML APIs?, McLaughlin asks a slightly different question: Once you decided—or are forced—to use XML, how do you prefer to interact with XML data? What APIs do you prefer to use?

I wonder who really does use working XML code these days, and what API (or APIs) they use. Is it true that hundreds, thousands, tens of thousands of you out there still plug away with SAX and DOM, comfortable writing your startProcessingInstruction() method, or have data binding and helper APIs completely taken over? (...)

And arguably more importantly, do you believe you still have the control and power over your XML? I pose this question particularly to programmers who have worked with XML since the early days when SAX was your only option for speedy XML reading, and DOM was the only choice if you wanted to deal with an XML document in object form. Do you find yourself working at a higher level, and are you OK with that? Or have we all become Turbo Pascal programmers while only a select few guys are popping the stack over on their ASM terminals?

What are your preferred XML APIs, and why?


Tim

Posts: 4
Nickname: timmorrow
Registered: Mar, 2003

Re: How Do You Use XML? Posted: May 31, 2007 2:26 PM
Reply to this message Reply
In cases where I'm dealing with large XML documents (100s of thousands of elements) I usually go with a Stax parser to process it in a stream-based fashion.

Where the datasets are small, and I have control over both ends, I mostly use something like XStream or JAXB.

David Eriksson

Posts: 13
Nickname: twogood
Registered: Apr, 2005

Re: How Do You Use XML? Posted: May 31, 2007 11:17 PM
Reply to this message Reply
In PHP I like to use SimpleXML (http://php.net/manual/en/ref.simplexml.php). Is there something similar for Java?

Ivan Lazarte

Posts: 91
Nickname: ilazarte
Registered: Mar, 2006

Re: How Do You Use XML? Posted: Jun 1, 2007 12:18 AM
Reply to this message Reply
I have a variety of home grown solutions... they fall into two major categories

1. "SAXOM" - run across a path, and subparse the fragments into mini doms.
2. XpathResultSet - Imagine being able to get a resultset based on an Xpath expression and then just next() your way through each row to get whatever sub-xpath expression you want. I love this one actually, I'm working to try to open source my implementation.

Then I'll do stax once in a while...

I like programmatic apis. The "generate code and just use it" approach doesn't do it for me.

nes

Posts: 137
Nickname: nn
Registered: Jul, 2004

Re: How Do You Use XML? Posted: Jun 5, 2007 7:52 AM
Reply to this message Reply
SAX. But that was 2 years ago. I haven’t done much Java+XML lately. Currently working at a VB.Net project where interaction with XML is limited to the System.Configuration.ConfigurationManager library. In Python I use ElementTree since it is included in the standard distribution.

Sean Landis

Posts: 129
Nickname: seanl
Registered: Mar, 2002

Re: How Do You Use XML? Posted: Jun 5, 2007 11:59 AM
Reply to this message Reply
As little as possible.

But lately I have been working with RESTful web services and I have found it very useful to un/marshal the XML bodies of POSTs and PUTs using JAXB. What I really like about JAXB is that I no long need to write XSDs. I can build my model with annotated POJOs and if I need an XSD artifact, I can generate it.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: How Do You Use XML? Posted: Jun 5, 2007 3:55 PM
Reply to this message Reply
> As little as possible.
>
> But lately I have been working with RESTful web services
> and I have found it very useful to un/marshal the XML
> bodies of POSTs and PUTs using JAXB. What I really like
> about JAXB is that I no long need to write XSDs. I can
> build my model with annotated POJOs and if I need an XSD
> artifact, I can generate it.

So you've had goo success with generating XSD with JAXB? I've had really bad experiences with the code generated from a schema and the other direction looks a lot more promising.

Sean Landis

Posts: 129
Nickname: seanl
Registered: Mar, 2002

Re: How Do You Use XML? Posted: Jun 5, 2007 5:31 PM
Reply to this message Reply
> So you've had goo success with generating XSD with JAXB?
> I've had really bad experiences with the code generated
> d from a schema and the other direction looks a lot more
> promising.

If it has been a while since you used JAXB, you might want to try it again. It's version 2.1.3 now. XSD to Java seems to work pretty well now too.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: How Do You Use XML? Posted: Jun 6, 2007 6:20 AM
Reply to this message Reply
> > So you've had goo success with generating XSD with
> JAXB?
> > I've had really bad experiences with the code generated
> > d from a schema and the other direction looks a lot
> more
> > promising.
>
> If it has been a while since you used JAXB, you might want
> to try it again. It's version 2.1.3 now. XSD to Java seems
> to work pretty well now too.

It wasn't that it didn't work properly, it's that I think that whole approach is misguided.

David Chazin

Posts: 4
Nickname: dchazin
Registered: Nov, 2003

Re: How Do You Use XML? Posted: Jun 8, 2007 8:53 PM
Reply to this message Reply
Apache XML beans for processing and generating documents. I always create an XML Schema.
SAX for processing extremely large documents that will not fit in memory.
Xalan for XSLT processing.

Flat View: This topic has 9 replies on 1 page
Topic: Adobe Releases Flex 3, AIR, and Flash Betas Previous Topic   Next Topic Topic: Does REST Need WADL?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use