JSP/JAVA Dynamic Client side XSLT

Discussion in 'Java' started by Lincoln Cooper, Sep 9, 2003.

  1. 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.
     
    Lincoln Cooper, Sep 9, 2003
    #1
    1. Advertising

  2. 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.
     
    Lincoln Cooper, Sep 9, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    613
  2. Lincoln Cooper

    JSP/JAVA Dynamic Client side XSLT

    Lincoln Cooper, Sep 9, 2003, in forum: XML
    Replies:
    1
    Views:
    620
    Lincoln Cooper
    Sep 9, 2003
  3. Boss302
    Replies:
    0
    Views:
    1,070
    Boss302
    Nov 21, 2006
  4. Bogdan
    Replies:
    2
    Views:
    667
    Bogdan
    Jun 9, 2008
  5. Zoe Hart
    Replies:
    1
    Views:
    383
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page