aspose file tools*
The moose likes Servlets and the fly likes converting XML with XSLT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

converting XML with XSLT

Bron Czimes
Ranch Hand

Joined: May 09, 2004
Posts: 44
hey there,

i'm trying to convert an XML document with XSLT and all I'm getting is a blank page (no error msg's or anything).
my code is



sorry, I don't know much about the conversion process for XSLT. am i doing something wrong here?

Ta
Balan Raj
Ranch Hand

Joined: Aug 26, 2003
Posts: 74
Bron,
I dont see you using the "RESULT" of the transformation.

The process is something like



In your case, I dont see "out" being set at all..
Bron Czimes
Ranch Hand

Joined: May 09, 2004
Posts: 44
sorry, i don't think i understand. my XSLT actually creates a web page (sorry, i didn't include my XSLT code before).
so as far as I was aware i'm unable to use out in this context.

my XSLT code is this


does that help any more?
Bron Czimes
Ranch Hand

Joined: May 09, 2004
Posts: 44
btw, i know that I am missing a <tr> tag near the top there, but I have fixed that and I still have the same problem....
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Check the content of the xml (messageDocument) used in the transformation.



If it is correct, try doing the transformation from the command line using the xsl and an xml file.

My xsl is a bit rusty, shouldn't the template contain a forward slash? I could be wrong here.
<xsl:template match="/flight">
[EDIT: As I had suspected, I got this one wrong]


Sheldon Fernandes
[ September 28, 2004: Message edited by: Sheldon Fernandes ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Working code to do what you want is the following:


generateError() is just a method that takes a String and parses that into an HTML template to generate a custom error page.
The XML to be processed and the NAME of the XSL file are passed in as request parameters.
The servlet caches the precompiled XSL sheets in order to speed up performance on subsequent uses of the same XSL (depending on your parser this can make requests after the first one for a particular XSL file up to a hundred times faster according to tests I did).


42
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Hi Bron,

I tried testing your xsl (in xmlspy) using the following xml file.


I ran the transformation as is and it gave me an empty page.
It worked when I put a value in <title></title> element. Check the markup in the head section.

Sheldon Fernandes
Bron Czimes
Ranch Hand

Joined: May 09, 2004
Posts: 44
hi Sheldon,
thankyou for going to so much trouble to work it out. that made it work for me too. i didn't realise that a title was a mandatory item.
thankyou, thankyou, thankyou!!

Bron
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Good Topic, but unfortunately off topic for the Servlets forum. This would be better asked in the XML and related product forum.

Since the question has already been answered correctly, I am just going to close this thread.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: converting XML with XSLT