xsl-list
[Top] [All Lists]

Re: [xsl] Associating javascript with XSL and XML

2010-01-05 06:14:10
Rob Belics wrote:

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>

Is there any difference between those two stylesheets?
What exactly is it that you want to achieve?

--

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--