Tried some more, and this works...

[JSP file]

<%@taglib uri="apache-xsl" prefix="xsl" %><%! 
String style ="";
String content = "";
%><%
if (request.getHeader("Accept").indexOf("text/vnd.wap.wml") >= 0) {
        style = "/wml.xsl";
        content = "text/vnd.wap.wml";
}
else {
        style = "/html.xsl";
        content = "text/html";
}
response.setContentType(content);
%><xsl:InsertWithXSL url="/raw.xml" xsl="<%= style %>" />



[wml.xsl]

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" 
        indent="yes" 
        omit-xml-declaration="no" 
        doctype-system ="http://www.wapforum.org/DTD/wml_1.1.xml" 
        doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
        media-type="text/vnd.wap.wml"
        />

<xsl:template match="/">

<wml>
    <card id="card1" title="raw.xml as WML">
         <p><xsl:value-of select="."/></p>
</card>
</wml>

</xsl:template>

</xsl:stylesheet>
 

[raw.xml]

<?xml version="1.0"?>
<doc>My name is KEV</doc>


You get the idea.....

        Kev
>  -----Original Message-----
> From:         [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]] 
> Sent: 29 June 2000 14:40
> To:   Orion-Interest
> Subject:      RE: XSL Transforms and the XSLServlet
> 
> Hi David.
> 
> I'm fighting this issue too.  Only difference is that I tried to do it
> using JSP.
> 
> [First I must say that I am new to JSP and Orion.]
> 
> I'm finding that if I put WML in a .jsp file, the return type was
> text/html.
> So, OK, I set the MIME type for WAP and all is well (notice no line feed 
> after the JSP directive):
> 
> <% response.setContentType("text/vnd.wap.wml");%><?xml version="1.0"?>
> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
> "http://www.wapforum.org/DTD/wml_1.1.xml">
> <wml>
> ....
> 
> 
> BUT... if the JSP does any form of XSL transform I have been unable to 
> return the correct type.
> 
> My only solution with JSP so far has been to detect the agent type and 
> then perform a forward to static page.
> 
> For example, I could NOT get the following .jsp to work:
> (it seem to always give text/html even when the content is wml)
> 
> <%@taglib uri="apache-xsl" prefix="xsl" %><% 
> if (request.getHeader("Accept").indexOf("text/vnd.wap.wml") > 0) {
> %><% 
> response.setContentType("text/vnd.wap.wml");
> %><xsl:InsertWithXSL url="/raw.xml" xsl="/wml.xsl" /><%
>  } else { 
> %><% 
> response.setContentType("text/html");
> %><xsl:InsertWithXSL url="/raw.xml" xsl="/html.xsl" /><%
>  } %>
> 
> 
> Lastly, here is some XSL that should set the content type 
> (according to the spec).  I just don't see how it can - it is 
> simply transforming the body, not playing with the headers.  
> Maybe it would work for client side XSL.
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" 
>       indent="yes" 
>       omit-xml-declaration="no" 
>       doctype-system ="http://www.wapforum.org/DTD/wml_1.1.xml" 
>       doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
>       media-type="text/vnd.wap.wml"
>       />
> 
> 
> I you figure this out, please mail back to the list.  Tomorrow I try
> servlets 
> rather than JSP.
> 
> 
>       Kev
> 
>        -----Original Message-----
>       From:   [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]] 
>       Sent:   29 June 2000 12:41
>       To:     Orion-Interest
>       Subject:        XSL Transforms and the XSLServlet
>       Importance:     High
> 
>       Hi,
> 
>       I'm using OrionRC1 (heard there were difficulties with RC2 and the
> final release) with a servlet that generates XML and decides which
> stylesheet to use (a web one or a wap one) depending on the user-agent
> type passed in the httpservletrequest.
> 
>       This works fine, except that the XSLServlet has a defaultcontenttype
> parameter, which means ALL the output from it comes out as that
> content-type.
> 
>       Default is "text/html", and using that my WAP phone won't view the
> page (even though it REALLY is WML), because it doesn't recognise
> "text/html" as a valid content-type that it can handle.
> 
>       And if I set the default content type for the XSLServlet to be
> "text/vnd.wap.wml" my phone gets the pages OK, but now my browser
> obviously doesn't play!!!
> 
>       Is there a way to specify content-type within the XSL stylesheet
> itself (or elsewhere)???
> 
>       Or, can someone tell me more about what was covered briefly in the
> orion docs about orion being able to "automatically" use the right
> stylesheet for WEB or WAP???
> 
> 
>       Thanks very much,
> 
>       David Middleton
>       [EMAIL PROTECTED]

winmail.dat

Reply via email to