File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parsing and displaying xml data - options?

 
Raj Murthy
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
JuanP barbancho
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Will give that a try.
[ October 28, 2005: Message edited by: Rajiv Rangarajan ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic