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

converting XML with XSLT

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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....
 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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).
 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic