Disable Output Escaping - really useful

Subject: Disable Output Escaping - really useful
From: Dylan Walsh <Dylan.Walsh@xxxxxx>
Date: Wed, 22 Mar 2000 11:21:42 -0000
I read on this mailing a while back that certain XSLT processors do not
support disable-output-escaping. It got me wondering, because I have found
that when using XSL I nearly always end up using it for something or
another, so what would I do without it?
 
For example, when began using XSL to create WML (WAP) decks, they required a
WML DOCTYPE declaration. At the time XT did not support creating this using
xsl:output and its doctype-system and doctype-public attributes. So I had to
use output escaping.

Another example is the case below. A loosegrid element in my source XML is
like a table, but it doesn't specify how to lay it out i.e. how many items
are contained in the rows. The idea is that this decision is defered to
stylesheet, which will layout the table according to its target audience
e.g. wide tables for HTML, narrow tables for mobile users of WAP. In the
template for loosegrids below, 5 items are put in each row. When an item is
the 5th, 10th, 15th etc. (using "position() mod 5 =0") it should close this
row and start the next. Unfortunately putting </tr><tr> inside <xsl:if> is
badly formed XML. Hence my use of disable-output-escaping.

Anyone know a way of doing this without disable-output-escaping? Is using
disable-output-escaping like this a bit of a hack?

<!-- A grid where there is no heading row, and hence the no. 
	of columns is not critical. The items are broken up 
	into rows by the stylesheet. -->
  <xsl:template match="loosegrid">
	<table cellpadding="5">
		<tr>
		<xsl:for-each select="item"> 
			<xsl:apply-templates select="." mode="normal"/>
			<xsl:if test="position() mod 5 = 0">
				<!-- 	Want to close this row and open
another, every five rows
					However having a closing </tr>
following by an opening one
					<tr> inside the <xsl:if> would be
improper overlapping
					and hence badly formed XML.
					Cheating here by using output
escaping to get round the
					problem -->
				<xsl:text
disable-output-escaping="yes">&lt;/tr>&lt;tr></xsl:text>
			</xsl:if>
		</xsl:for-each>
		</tr>
	</table><br/>
  </xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread