[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Cold Fusion


Subject: Re: [xsl] Cold Fusion
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 13 Mar 2003 16:37:19 -0700 (MST)

Alright, I guess I can try to help, under the assumption that you're trying
to generate CFML with XSLT.

Christine Stamatis (s) wrote:
> <!--- <CFIF IsDefined("URL.sys")> --->

To generate a comment in XSLT, you need to use
<xsl:comment>...</xsl:comment>

> <CFIF IsDefined("Cookie.ChocolateChip")>
> 	<cfinclude template="/CheckLogin.cfm">  
>  <!--- <CFIF #Cookie.ChocolateChip# IS #URL.sys#> --->
> <cfelse>
> 	<cflocation url="../../../register.cfm">
> </cfif>

XSLT is XML. You can't have unclosed, unbalanced tags, and case matters.
CFML's syntax is so far removed from HTML and XML, you will not be able to do
what you want. Consider just the cfif tag: the IsDefined("...") portion cannot
be generated at all, because it is not an attribute.  Even if you adjust your
XSLT, the HTML serializer of an XSLT processor will not know that cfinclude,
cfelse, and cflocation elements are to be written without end tags.

This may be a case for the use of disable-output-escaping, where you write
all your tags as XML character data and then tell the serializer to emit them
without escaping the markup characters "<" and "&":

<xsl:text disable-output-escaping="yes"><![CDATA[
<!--- <CFIF IsDefined("URL.sys")> --->
<CFIF IsDefined("Cookie.ChocolateChip")>
      <cfinclude template="/CheckLogin.cfm">
 <!--- <CFIF #Cookie.ChocolateChip# IS #URL.sys#> --->
<cfelse>
      <cflocation url="../../../register.cfm">
</cfif>
]]></xsl:text>

but this kludgy "solution" is not guaranteed to work at all (its support is
optional and relies on the processor serializing the result tree directly).
See also http://www.dpawson.co.uk/xsl/sect2/N2215.html

My recommendation, if you must use XSLT, is to instead generate something
that you can transform in an external, non-XSLT search-and-replace.

<xsl:processing-instruction target="cfif">
  <xsl:text>IsDefined("Cookie.ChocolateChip")</xsl:text>
</xsl:processing-instruction>
<xsl:text>&#10;&#9;</xsl:text>
<xsl:processing-instruction target="cfinclude">
  <xsl:text>template="/CheckLogin.cfm"</xsl:text>
</xsl:processing-instruction>

will generate

<?cfif IsDefined("Cookie.ChocolateChip")?>
	<?cfinclude template="/CheckLogin.cfm"?>

which you can then do a simple replacement of "<?" and "?>" 
(to "<" and ">") on, outside of XSLT.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

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



Current Thread
Keywords