[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Cold Fusion

Subject: RE: Cold Fusion
From: "Christine Stamatis (s)" <cstamat@xxxxxxx>
Date: Fri, 14 Mar 2003 10:17:13 -0600
christine stamatis
That's exactly what I'm trying to do. My error, I didn't submit my initial
inquiry properly.  I've been given an existing set of xsl/xml files which
render html versions.  I've been asked to tweak the xsl in order to produce
a .cfm rendition.

When I edit the xsl file in XMLSpy, I get the following validation error
message: 

"This file is not well-formed: =expected after (CFIF IsDefined)"

<!DOCTYPE Policy [
	<!ENTITY nbsp "&#160;">
	<!ENTITY reg "&#174;">
	<!ENTITY mdash "&#151;">
	<!ENTITY lf "&#10;">
	<!ENTITY cr "&#13;">
	<!ENTITY trade "&#8482;">
	<!ENTITY copy "&#169;">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:output method="html" encoding="UTF-8" indent="yes"
media-type="text/html"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	<!-- If this is a WebPublisher page the top-level element should 
	always be called 'content"  -->
	<xsl:template match="content">


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


(The following is placed in the bottom of the document)
<cfelse>
	<cflocation url="../../../notify.cfm">
	</cfif>

-----Original Message-----
From: Mike Brown [mailto:mike@xxxxxxxx]
Sent: Thursday, March 13, 2003 5:37 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Cold Fusion

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

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.