• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

parsing and displaying xml data - options?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

We are working on a system that will get xml feed (through webservice or some other means.. to be decided) and display the results on a browser.

The platform is weblogic 8.1.3, we need to decide on the xml libraries to be used for parsing and displaying of a data, though weblogic offers certain jars for xml based processing we are thinking something more open source would be helpful incase we need to move the code to a different platform.

We are considering apache xerces.jar (for parsing the xml data), with xslt and xalan.jar for the transformations to convert it into html?

What is the latest/best versions of these two?

What are the alternatives to xerces and xalan, if any?

Any inputs on this will be greatly appreciated.

Thanks,
Rajiv
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The latest versions of Xerces and Xalan are at xml.apache.org.

Alternatives would be Suns Crimson for XML and Saxon (on SourceForge) for XSLT.

You'll probably be fine using the Weblogic parser, whichever it is. Just make sure that you code against the JAXP API (which is the Java XML/XSLT/DOM/SAX processing API), and not against classes that may be specific to a particular parser. Then you should have no problems moving your code to use some other parser, because they all support JAXP.
 
Raj Murthy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf,
Thanks for your response.

All,

I am able to read xml, apply xsl and convert it to html.
I have included the code below.

------------------------

-------------------------------------

Couple of notes on the same:

1. I am creating a new StreamReader from string to pass to transform method, not sure
if this is the most efficient way?

2. Rather than write to file, need to return the transform output as a String.

3. I can possibly optimize the xslSource by creating it only once, since this method will be called multiple times, sometimes possibly in a concurrent manner?


Any hints?

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
#1) You could use a BufferedReader instead, but since all data is in memory already, I wouldn't expect a noticeable difference.

#2) You can pass a StringWriter to the StreamResult constructor.

#3) Check out javax.xml.transform.Templates (use TransformerFactory.newTemplates instead of TransformerFactory.newTransformer). It facilitates caching of XSLT transformations, and also guarantees thread-safety.
[ October 26, 2005: Message edited by: Ulf Dittmer ]
 
Raj Murthy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestions.

Here is the modified code(for anyone interested):



Not to prolong this thread, what if i use a JDOMSource instead of streamsource will it help the performance?
Since the calling program has the liberty of passing either xml-string of jdom source.

>>JDOMSource source = new JDOMSource(sourceDoc);

instead-of

>>StreamSource s1 = new StreamSource(new ByteArrayInputStream(strXml.getBytes()));


Cheers
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Let to your administrator the use of parser and use JAXP api.

You weblogic administrator could change the parser and use the fastest that Bea say
 
Raj Murthy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Will give that a try.
[ October 28, 2005: Message edited by: Rajiv Rangarajan ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic