|
Subject: GOTCHA! From: "Oren Ben-Kiki" <oren@xxxxxxxxxxxxx> Date: Tue, 12 Jan 1999 20:29:22 +0200 |
For all those who are fighting against the restriction that XSL processors
will emit only valid XML, here's a way out which works at least for XT. I'd
be very interested to know whether it works in other processors and whether
it is a valid trick (it probably isn't).
Suppose you have a rule which goes:
<xsl:template match="...">
<xsl:comment> -->
Whatever I damn please, including <, &!!!
<!-- </xsl:comment>
</xsl:template>
Running this through XT will emit:
<!-- -->
Whatever I damn please, including <, &!!!
<!-- -->
Several notes:
- People who want to generate character entities can do:
<xsl:comment> -->&nobs;<!-- </xsl:comment>
Which will be converted to:
<!-- -->&nobs;<!-- -->
Wrapping this in a CharacterEntity macro is left to the reader :-)
- Suppose I gave up the "-->" and "<!--" in the template. I'd still get
whatever I please, but it would be contained in an XML comment, and the
output would be valid XML. I assume this was the original intent. The fact
that XT hasn't caught it is probably a bug that James will be quick to fix
:-)
- This is actually good enough for me, since the non-XML output I want to
generate is JavaScript code inside HTML documents, and the following is
valid, thanks to old browsers which don't know JavaScript:
<SCRIPT>
<!--
Any JavaScript code. In JavaScript "<!--" starts a comment just until the
end of the line.
// -->
</SCRIPT>
So even if James or the W3C plugs this hole, it is still possible to
generate legal JavaScript code, with "<", ">", "&", and so on.
- This can be adapted to any language which has any comment mechanism: for
example:
// <!--
Any C++ or Java code
// -->
# <!--
Any perl or shell code
# -->
And so on.
Isn't this fun?
Oren Ben-Kiki.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| xslp, Keith Visco | Thread | Re: GOTCHA!, G. Ken Holman |
| RE: Newbie question about latest XS, Lawton, Scott | Date | Re: Standard API to XSL processors, Oren Ben-Kiki |
| Month |