Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with approach to XSLT transformation of XML received via http

 
Terry Chambers
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21149
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The content or complexity of the XML in question doesn't affect the process: transforms are transforms.
 
Terry Chambers
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic