JSP/JAVA Dynamic Client side XSLT

L

Lincoln Cooper

Hi,

I'm having a problem getting client-side XSLT to work. I'm using IE6
and JAVA/JSP. Obviously, when I use an XML file with the name of the
xsl template embeded in it (as a tag) all works fine.

The problem is that I'm creating the XML dynamically from JAVA classes
(using Betwixt which seems very good) and thus have my XML not as a
file but as a string. When I try and output this String from a JSP,
the browser doesn't recognise that it is an XML file but thinks it's
HTML so I get the values of the tags printed instead of the XSLT.

I've tried the following methods:

1)
String outStr = "<?xml version='1.0'?><?xml-stylesheet type='text/xsl'
href='templ.xsl'?><roottag><name>fred</name></roottag>";
out.print(outStr);


2)
String outStr = "<?xml version='1.0'?><?xml-stylesheet type='text/xsl'
href='templ.xsl'?><roottag><name>fred</name></roottag>";
PrintWriter pw = response.getWriter();
pw.write(outStr);


3)
String outStr = "<?xml version='1.0'?><?xml-stylesheet type='text/xsl'
href='templ.xsl'?><roottag><name>fred</name></roottag>";
response.setContentType("text/xsl");
ServletOutputStream sos = response.getOutputStream();
sos.print(outStr);


Any ideas on the syntax that WILL work???

Thanks!
Lincoln.
 
L

Lincoln Cooper

OK - It works now... the syntax is...


String outStr = "<?xml version='1.0'?><?xml:stylesheet type='text/xsl'
href='templ.xsl'?><roottag><name>fred</name></roottag>";
out.print(outStr);


The stylesheet tag should be "xml:stylesheet" and NOT "xml-stylesheet". Doh!!


Lincoln.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top