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

RE: using Javascript in XSL-XML

  • From: "Michael Kay" <mike@s...>
  • To: 'Tomaz Klančnik' <slimt@e...>,<xml-dev@l...>
  • Date: Thu, 9 Nov 2006 18:08:23 -0000

javascript in xsl
> And I want XSL to use this bit of Javascript to 
> collapse/expande or hide/show this <TD><DIV> cell of table.

Actually, I think you just want the XSLT processor to include the Javascript
in the HTML output document, so that the HTML engine can invoke the
JavaScript. It's important to get this distinction straight. The XSLT
processor won't run the Javascript, it will just treat it as data to be
copied to the output.

The reason the Javascript hasn't been copied to the output is that it
appears in an XML comment in the stylesheet, and XML comments in a
stylesheet are stripped. To generate a comment in the result document, use
xsl:comment. But I don't think script sections need to be in comments these
days - that was only done for the benefit of prehistoric browsers.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Tomaz Klančnik [mailto:slimt@e...] 
> Sent: 09 November 2006 15:35
> To: xml-dev@l...
> Subject:  using Javascript in XSL-XML
> 
> my XML file "p1.xml" looks like this:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="ss1.xsl"?> <f1>
> 	<s1>
> some text
> 	</s1>
> 
> 	<s2>
> even some more text
>  </s2>
> 	
> </f1>
> 
> with the XSL "ss1.xsl" like this:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
> 	<xsl:template match="/">
> <style>
> <!--
> #s1 {
> border:1px solid #ccc;
> background:#f2f2f2;
> padding:20px;
> }
> -->
> </style>
> 		<script type="text/javascript">
> 
> function sm(obj) {
> 
> 	var el = document.getElementById(obj);
> 
> 	if ( el.style.display != "none" ) {
> 
> 		el.style.display = 'none';
> 
> 	}
> 
> 	else {
> 
> 		el.style.display = ' ';
> 
> 	}
> 
> }
> 
> </script>
> 		<TABLE STYLE="border:1px solid black">
> 			<tr>
> 				<b>title goes here</b>
> 			</tr>
> 			<TR>
> 				<TD>group 1 <img 
> src="images\plus.gif" onclick="sm('s11')"/>
> 				</TD>
> 				<DIV id="s11">
> 					<TD>
> 						<xsl:copy-of 
> select="document('p1.xml')//f1/s1/."/>
> 					</TD>
> 				</DIV>
> 			</TR>
> 		</TABLE>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> And I want XSL to use this bit of Javascript to 
> collapse/expande or hide/show this <TD><DIV> cell of table.
> 
> but it does not work properly. Can anyone advise me, what to 
> improve in order for XSL to understand this function.
> 
> Thank you very much for your advice.
> 
> 
> 
> ____________________
> http://www.email.si/
> 
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l... List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.