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

RE: Including javascript functions in XSL Stylesheet

Subject: RE: Including javascript functions in XSL Stylesheet
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Thu, 24 Feb 2000 15:11:16 -0700
x9
> "Attribute value should begin with a quote".

XML markup characters in your JavaScript are not properly escaped. Your XSL
document is still XML and must be well-formed. There are various ways of
going about it, but they all have drawbacks. An external file is the best
place to put that stuff because it's hard to make JavaScript be well-formed.

This method relies on the XSL processor supporting
disable-output-escaping...

<xsl:text disable-output-escaping="yes"><![CDATA[
<!-- Java Script function
function getIndex(thisForm, buttonLabel) {

	arrElmnts = thisForm.elements
	
	for(i = 0; i < arrElmnts.length; i++) {
	
		if( arrElmnts[i].value == buttonLabel ) {
			return i		
		}

	}

	return -1
}
]]></xsl:text>


This method creates a comment node, but will fail if the JavaScript contains
"--" (which is not allowed in a comment)...

<xsl:comment><![CDATA[
<!-- Java Script function
function getIndex(thisForm, buttonLabel) {

	arrElmnts = thisForm.elements
	
	for(i = 0; i < arrElmnts.length; i++) {
	
		if( arrElmnts[i].value == buttonLabel ) {
			return i		
		}

	}

	return -1
}
]]></xsl:comment>


This method has the same restriction (and please pardon my mailer wrapping
the long line)...

<xsl:comment>Java Script function&#xA;function getIndex(thisForm,
buttonLabel) {&#xA;&#xA;&#x9;arrElmnts = thisForm.elements&#xA;&#x9;for(i =
0; i &lt; arrElmnts.length; i++) {&#xA;&#xA;&#x9;&#x9;if( arrElmnts[i].value
== buttonLabel ) {&#xA;&#xA;&#x9;&#x9;&#x9;return
i&#xA;&#x9;&#x9;}&#xA;&#xA;&#x9;}&#xA;&#xA;&#x9;return
-1&#xA;}</xsl:comment>


 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.