[jdom-interest] Help with <xsl:text disable-output-escaping="yes">
Emmett McLean
emmettwa at onebox.com
Tue Sep 10 10:00:42 PDT 2002
For me, using xalan, it works with output set at both html or xml.
I've been working on a small web application. The design is that
there won't be html. There will only be XSLT which will look a
lot like html. I'm hoping to take the session object and JDOMize
it and then use that as a session variable. So I'd get the data,
put it in a JDOM element to a transform, prompt the data to confirm
what he's entered, and then finish up with emails and database
operations.
Having disable-output-escaping lets me :
1. Have Javascript in the xml,
2. Makes the xsl (html) more maintainable
3. Resolves some issues associated with textareas.
I did read in the archive that someone ran into the same problem
and ended up modifying the source code.
Personally, I think if JDOM is to be taken seriously this is a must.
Here is an example XML and XSL ...
=============
<?xml version = "1.0" encoding="iso-8859-1"?>
<fac-building>
<location>Stoneridge</location>
<name>Jon Smith</name>
<dept>Accounting</dept>
<date>02/22/03</date>
<extension>5244</extension>
<request_type>
<building_mechanics></building_mechanics>
<office_equipment></office_equipment>
<personal_work>
<desk_number/>
</personal_work>
<furniture></furniture>
<common></common>
<relocation>
<desk_from>2055</desk_from>
<desk_to>2088</desk_to>
</relocation>
</request_type>
<text><![CDATA[how now brown cow & this is <> something to do ...]]></text>
<manager_email><![CDATA[emmett.mclean at rhi.com]]></manager_email>
</fac-building>
==============
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:preserve-space elements="*"/>
<xsl:output method='html' encoding='ISO-8859-1' indent="yes"/>
<xsl:template match="/">
<html>
<body bgcolor="#FFFFFF">
<title>Facilities/Building Services Work Request Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<xsl:text disable-output-escaping="yes">
<![CDATA[
<style type="text/css">
<!--
body { font-family: Arial, Verdana, sans-serif; background-color: #FFFFFF}
-->
</style>
]]>
</xsl:text>
<img src="images/facilities_pic.gif" width="55" height="40"/>
<img src="images/facilities.gif" width="304" height ="39"/>
<h2><font color="#003399">Building Services Work Request Form<b></b></font></h2>
<p align="center"><font size="2"><b>One request per form.</b></font></p>
<form name="form" action="/jdomex/Test2" method="post" onSubmit="validate();">
<p align="center">
<!-- select Stoneridge by default -->
<xsl:choose>
<xsl:when test="/fac-building/location='Gibraltor'">
<xsl:text disable-output-escaping="yes"><![CDATA[
<input type="radio" name="location" value="Stoneridge" >Stoneridge</input>
<input type="radio" name="location" value="Gibraltor" checked="true">Gibraltor</input>
<input type="radio" name="location" value="Hopyard">Hopyard</input>
]]></xsl:text>
</xsl:when>
<xsl:when test="/fac-building/location='Hopyard'">
<xsl:text disable-output-escaping="yes"><![CDATA[
<input type="radio" name="location" value="Stoneridge" >Stoneridge</input>
<input type="radio" name="location" value="Gibraltor" >Gibraltor</input>
<input type="radio" name="location" value="Hopyard" checked="true">Hopyard</input>
]]></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes"><![CDATA[
<input type="radio" name="location" value="Stoneridge" checked="true">Stoneridge</input>
<input type="radio" name="location" value="Gibraltor">Gibraltor</input>
<input type="radio" name="location" value="Hopyard">Hopyard</input>
]]></xsl:text>
</xsl:otherwise>
</xsl:choose>
</p>
<hr/>
<hr/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="50%" height="16" align="right">Requestor's Name
<input type="text" name="name" value="{fac-building/name}"/>
</td>
<td width="50%" height="16" >Requestor's Dept
<input type="text" name="dept" value="{fac-building/dept}"/>
</td>
</tr>
<tr valign="top">
<td width="50%" height="16" align="right">Request Date
<input type="text" name="date" value="{fac-building/date}"/>
</td><td></td>
</tr>
<tr valign="top">
<td width="50%" height="16" align="right">Extension
<input type="text" name="extension" value="{fac-building/extension}"/>
</td><td></td>
</tr>
</table>
<p><b><font color="#003399">Check appropriate box below</font></b></p>
<input type="radio" name="request" value="building_mechanics"
checked="{fac-building/request_type/building_mechanics}"/>
Building mechanics (air conditioning, heat, structural, etc.)<br/>
<input type="radio" name="request" value="office_equipment"
checked="{fac-building/request_type/office_equipment}"/>
Office Equipment (faxes, copiers, printers, etc.) <br/>
<input type="radio" name="request" value="personal_work"
checked="{fac-building/request_type/personal_work}"/>
Personal work space: (desk, chair, articulating keyboard, etc.) Desk
#
<input type="text" name="PersonalDesk" size="4"
value="{fac-building/request_type/personal_work/desk_number}"
/><br/>
<input type="radio" name="request" value="furniture"
checked="{fac-building/request_type/furniture}"/>
Furniture<br/>
<input type="radio" name="request" value="common"
checked="{fac-building/request_type/common}"/>
Common area needs (kitchen supplies, restrooms, conference room table,
etc.)<br/>
<i><b>**</b></i>Desk relocation; Desk # From
<input type="text" name="desk_from" size="4"
value="{fac-building/request_type/relocation/desk_from}"/>
To <input type="text" name="desk_to" size="4"
value="{fac-building/request_type/relocation/desk_to}"/>
<br/>
<i><b>**<a href="/forms/corp-telecom.pdf">Requires Telecom Form</a></b>
</i>(can be found on BobNet under IT Forms.)<br/>
<input type="radio" name="request" value="Other"/>Other
<input type="text" name="other" size="50"/><p/>
<p><font size="2"><b><i>
** All Telecom forms are to be sent to Network Services
for processing. Any Telecom forms sent to Facilities will be forwarded
to Network Services.
</i></b></font></p>
<p><b><font color="#003399">Describe the nature of your request</font></b><br/>
<textarea name="text" cols="60" rows="5">
<xsl:value-of select="/fac-building/text"/>
</textarea>
</p>
<p align="center"><b><font size="2">This form requires supervisor/manager
approval.
In lieu of authorizing signature, the form must be sent from the supervisor's/manager's
mailbox.</font></b></p>
<p>Department Manager's e-mail address:
<input type="text" name="manager_email" size="30" value="{fac-building/manager_email}"/>
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit"
onClick="MM_validateForm('Requestor Name','','R','Requestor Dept','','R','Date','','R');return
document.MM_returnValue"/>
</p>
</form>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--
Emmett McLean
emmettwa at onebox.com - email
(866) 841-9139 x1160 - voicemail/fax
---- Laurent Bihanic <laurent.bihanic at atosorigin.com> wrote:
> Hi,
>
> disable-output-escaping only applies when the XSLT processor outputs
> the
> result as XML ou HTML. It does not apply when the output is a SAX event
> flow
> as it is the case when you use JDOMResult.
> JDOM receives a sequence of characters and, when requested to ouput
> the
> document as XML, performs the escaping so that the output XML represents
> the
> actual JDOM document content. In your case, this content is text.
>
> The only way JDOM could reproduce Xalan behaviour would be for XMLOutputter
> to
> interpret the <?javax.xml.transform.disable-output-escaping?> PI.
> Opinions?
>
> Laurent
>
>
> Emmett McLean wrote:
> > Hi,
> >
> > It appears what disable-output-escaping works in xalan
> > but not in JDOM. I wonder you know of a way to enable it?
> >
> > I have an XSLT which works fine with an XML file if I
> > do the transformation on the command line using xalan.
> >
> > However, when I do the transform in JDOM the following code
> > which works OK in xalan ...
> >
> > <xsl:text disable-output-escaping="yes">
> > <![CDATA[
> > <style type="text/css">
> > <!--
> > body { font-family: Arial, Verdana, sans-serif; background-color:
> #FFFFFF}
> > -->
> > </style>
> > ]]>
> > </xsl:text>
> >
> > Gets rendered in JDOM as ...
> >
> > <?javax.xml.transform.disable-output-escaping?>
> >
> > <style type="text/css">
> > <!--
> > body { font-family: Arial, Verdana, sans-serif; background-color:
> #FFFFFF}
> > -->
> > </style>
> >
> >
> > In otherwords the disable-output-escaping tag fails.
> >
> > I can email both the xsl and xml if someone would like to experiment.
> >
> > Thanks,
> >
> > em
>
>
More information about the jdom-interest
mailing list