aspose file tools*
The moose likes Beginning Java and the fly likes Help with approach to XSLT transformation of XML received via http Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with approach to XSLT transformation of XML received via http" Watch "Help with approach to XSLT transformation of XML received via http" New topic
Author

Help with approach to XSLT transformation of XML received via http

Terry Chambers
Greenhorn

Joined: May 11, 2009
Posts: 17
I need a little guidance on a Java problem I am tackling. I hope you can spare a moment for some advice.

I am working with a server that outputs some complex XML over http(s). By complex I mean that a lot of the items contain attributes.

I have a need to build a servlet that will be able to receive this XML content via http(s) and then be able to apply a given XSLT against it, which creates HTML output.

I am reading through a book called "Java and XSLT" (O'Reilly) which provides examples, but they also use very small XML files that are simple and usually created by the user via a web page.


At a high level, I believe the approach is to simply:

Fetch a given URL and store it as an XML object.
Load an XSLT file into memory.
Apply the XSLT to the XML and then display the results back to the user.


Can you help me fill in the gaps of what else I would need to do. I don't know if I need to create classes to for each of the XML elements in the XML file. In the examples I am seeing, it seems that is what they are doing.

Thanks for any advice you can offer.

Terry
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Well, your first step should be to gain familiarity with the process. So first write some code which gets its source XML from a file and transforms it the way you would like. Then read the Java Networking Tutorial to find out how you can get an InputStream which points to your HTTP resource. Feed that InputStream to your XML parser and you're about done.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The content or complexity of the XML in question doesn't affect the process: transforms are transforms.
Terry Chambers
Greenhorn

Joined: May 11, 2009
Posts: 17
Thanks for the advice. The basic concept was too simple and the books made it more complex than it needed to be.

I've got it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help with approach to XSLT transformation of XML received via http