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

Re: Associating javascript with XSL and XML

Subject: Re: Associating javascript with XSL and XML
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 05 Jan 2010 13:49:36 +0100
Re:  Associating javascript with XSL and XML
Rob Belics wrote:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<h:script type="text/javascript">
alert('hello');
</h:script>
<h:style type="text/css">
a{background-color:red}
</h:style>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="item">
<h:a href="{link}"><xsl:value-of select="desc"/></h:a>
</xsl:template>
</xsl:stylesheet>

Whether you directly write (X)HTML or whether your stylesheet is supposed to generate (X)HTML I would strongly suggest to aim at valid documents (i.e. html, head, body, and script and style where they belong). In the text/html world you might get way with not having any html or head or body elements and just throwing fragments of documents at the browser but I don't think this is a good idea in the case of X(HT)ML to expect the browser to guess what you want and add html or head or body element as needed.



What I'm trying to do is start up javascript and be able to manipulate
the DOM in the browser without having to rely on anything related to
HTML. I don't have any aversion to HTML, it just feels like I'm adding
extraneous elements.

Well if you want to use script then you need an element the browser recognizes as having script code, so with HTML that is the 'script' element in no namespace, with XHTML it is the 'script' element in the XHTML namespace http://www.w3.org/1999/xhtml, with SVG it is the 'script' element in the SVG namespace. Browsers like Mozilla or Opera might even recognize the XHTML script element inside mixed namespace XML documents.


--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

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.