You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nathalie Pult <s9...@access.unizh.ch> on 2001/09/19 12:29:17 UTC

disable-output-escaping: bad programming practice?

Hi,
I'm using cocoon-1.8.2 to produce DHTML out of xml rendered with xsl containing 
JavaScript.
In one of the js functions, I have to use the <xsl:text disable-output-
escaping="yes"/> containing <![CATATA[]]> sections to transmit the opening and 
closing <body> and <html> tags separately to the browser.
Unfortunately for me, cocoon puts an xsl-pi <?xslt-next-is-raw formatter-to-dom?
> before the HTML-code that should be sent directly to the browser, that the 
browser (naturally) cannot understand.
Using the disable-output-escaping is (according to the faq) supposed to be bad 
programming practice. Does anybody see in the case of using javascript an other 
solution? Hints or workarounds are very appreciated.

Thank you

Nathalie

xsl stylesheet:
<?xsl version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="no" 
media-type="screen"/>
	<xsl:template match="/">
		<html>
			<head>
					<script language="JavaScript">
					function linkframe() <![CDATA
[{return'<html><head/><body/></html>';}]]>
	
					function mainframe() <xsl:text disable-
output-escaping="yes"><![CDATA[{return '<html><head><link rel="stylesheet" 
type="text/css" href="stylesheet.css"></link></head><body>']]></xsl:text>
				<xsl:call-template name="Header"/>
				<xsl:apply-templates/>
				<xsl:call-template name="Footer"></xsl:call-
template>
				<xsl:text><![CDATA[+'</body></html>';}]]
></xsl:text>
				</script>
			</head>
			<frameset cols="22%,78%" rows="100%" border="1">
				<frame name="linkview" 
src="javascript:parent.linkframe()"/>	
				<frame name="mainview" 
src="javascript:parent.mainframe()"/>
			</frameset>
		</html>
	</xsl:template>
	
	<xsl:template name="Header"> ... </xsl:template>
	<xsl:template name="Footer"> ... </xsl:template>
        [other templates]

</xsl:stylesheet>


HTML-output

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-
html40/strict.dtd">
<html>
	<head>
		<meta content="text/html; charset=iso-8859-1" http-
equiv="Content-Type">
		<script language="JavaScript">
			function linkframe() 
{return'<html><head/><body/></html>';}
	
			function mainframe() <?xslt-next-is-raw formatter-to-
dom?>{return '<html><head>
...</head><body>'+'...'+'</body></html>';}
		</script>
	</head>
	<frameset border="1" cols="22%,78%" rows="100%">
		<frame name="linkview" src="javascript:parent.linkframe()">
		<frame name="mainview" src="javascript:parent.mainframe()">
	</frameset>
</html>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>