You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Virdi,T.J." <TV...@cerner.com> on 2000/10/27 17:03:08 UTC
Cocoon->XSP->XSL
I am trying to use Cocoon to support distinct user devices as Cocoon
framework is capable to do. Somewhere I am making a mistake and I am not
able to change the XML data by applying XSL stylesheet. I am able to run
example correctly so there is something in my code that is messing things
up. I am calling a FILE1.XML (code to follow) from PDA device. After getting
data from bean, it applies personOut-wml.XSL(Code at the bottom). I would
presume that presentation would change to "Text/wml" but instead I get an
error on PDA device that MIME type "text/plain" not supported. After
debugging, I found data returned to a device (in Hex.) is purely translation
of personOut-wml.XSL in plain text instead of text/wml as I was expecting.
Would someone please tell me what am I doing wrong? Is there something that
I am missing in the code? Your assistance on this is highly appreciated.
Thanks,
TJ
P.S.: I was also wondering if I can dynamically change XSL to a particular
device. For example, in the File1.XML, I have hardcoded personOut-wml.xsl
for media type "wap". Is there any way I can change personOut-wml.xsl as my
default xsl sheet for a wap device and pass personOut2.xsl as a dynamic xsl
sheet to apply for a particular request? Please tell me in anyway I can do
that.
******File1.XML**********
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<?xml-stylesheet href="http://localhost/app/personOut.xsl" type="text/xsl"?>
<?xml-stylesheet href="http://localhost/app/personOut-wml.xsl"
type="text/xsl" media="wap"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:util="http://www.apache.org/1999/XSP/Util"
xmlns:util="http://www.apache.org/1999/XSP/Util"
>
<xsp:structure>
<xsp:include>com.cerner.beans.getPerson</xsp:include>
</xsp:structure>
<!-- retVal below would have data like
<!xml version="1.0" ?><Person><FullName>Temp</FullName></Person>
-->
<xsp:logic>
getPerson personBean = new getPerson();
String retVal = personBean.getPerson(request);
<util:include-expr>retVal</util:include-expr>
</xsp:logic>
<page>
<title>Person's Data</title>
</page>
</xsp:page>
******personOut-wml.xsl**********
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<xsl:processing-instruction
name="cocoon-format">type="text/wml"</xsl:processing-instruction>
<wml>
<card id="Choices" title="Search Result">
<p align="center">
<a href="#data">Person Data</a><br/>
</p>
</card>
<card id="data" title="Person's data">
<p>
Title: <b><xsl:value-of select="title"/></b><br/>
Person Name:<b><xsl:apply-templates select="FullName"/></b><br/>
</p>
<do type="prev" label="Back">
<prev/>
</do>
</card>
</wml>
</xsl:template>
<xsl:template match="FullName">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>