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

Associating javascript with XSL and XML

Subject: Associating javascript with XSL and XML
From: Rob Belics <rob_belics@xxxxxxxxxxx>
Date: Tue, 05 Jan 2010 06:01:14 -0600
 Associating javascript with XSL and XML
>From what I've been able to find so far, there is no direct way to start
up javascript from XML or XSL without the (x)html namespace being
invoked. Not that there's anything wrong with that, I guess, but I seem
to have found inconsitencies among browsers when displaying the contents
of the xml. 

This markup and javascript just pops up with an alert box and displays a
link with a red background. This works in all browsers:

XML:
<?xml version="1.0"?>
<?xml-stylesheet href="3.xsl" type="text/xsl" ?>

<item>
  <link>www.google.com</link>
  <desc>Search Engine</desc>
</item>

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

While this only works in Firefox 3.5.6:

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

I just woke up and hoping beyond hope I'm not mixing things up. I
noticed that moving the script tags to the bottom makes Chrome expand
the link clickable area to the full size of the browser viewport.

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.