This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: pass value between xml and javascript
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] pass value between xml and javascript
- From: "Max Dunn" <maxdunn at siliconpublishing dot com>
- Date: Sun, 9 Sep 2001 14:26:03 -0700
- Organization: Silicon Publishing
- Reply-To: xsl-list at lists dot mulberrytech dot com
What does the start of your XSLT stylesheet look like? You want to use
the correct namespace:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
NOT the old namespace:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
which has no place in XSLT...
Regards,
Max
http://www.siliconpublishing.com
-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of Chen Wang
Sent: Sunday, September 09, 2001 4:48 PM
To: xsl-list@lists.mulberrytech.com
Subject: RE: [xsl] pass value between xml and javascript
Thanks, Jen,
I use IE 6, I think it is msxml3 supported. I also tried as described
in
the page you referred, such as using xminst stuff, but the code I am
using
still does not work. Javascript seems still work, because if I put
directly
the id instead of {cityid}, the function will work. Here is part of the
code, can you tell me what is wrong?
Here is the code in xsl:
...
<head>
<script language="javascript">
function WM_toggle(id){
if (document.all){
if(document.all[id].style.display == 'none'){
document.all[id].style.display = 'block';
} else {
document.all[id].style.display = 'none';
}
} else if (document.getElementById){
if(document.getElementById(id).style.display == 'none'){
document.getElementById(id).style.display = 'block';
} else {
document.getElementById(id).style.display = 'none';
}
}
}
</script>
</head>
<body>
...
<!--menu part-->
<xsl:for-each select="placetogo/urbanspace">
<a href="#" onclick="WM_toggle('{cityid}'); return false"><xsl:value-of
select="placename"/></a> <br />
</xsl:for-each>
</p>
...
<!--content part-->
<xsl:for-each select="placetogo/urbanspace">
<p align="center" class="main" style="display: none"><xsl:attribute
name="id"><xsl:value-of select="cityid"/></xsl:attribute>
<xsl:value-of select="placename"/> <br />
<img><xsl:attribute name="src"><xsl:value-of
select="photo/@img"/></xsl:attribute></img> <br />
<xsl:value-of select="country"/>
</p>
</xsl:for-each>...
In xml, it looks like this:
<?xml version="1.0" ?>
<placetogo>
<urbanspace>
<cityid>ba</cityid>
<placename>Bacelona</placename>
<continent>Europe</continent>
<country>Spain</country>
<photo img="barcelona.jpg" />
<description>Barcelona is a city where architecture and urbanism are
one.</description>
</urbanspace>
<urbanspace>
<cityid>hk</cityid>
<placename>Hong Kong</placename>
<continent>Asia</continent>
<country>China</country>
<photo img="hong_kong.jpg" />
<description>Hong Kong is one of the greatest maritime cities there
has
ever been---noisy, boisterous, cluttered, and vibrant. </description>
</urbanspace>
So, in the menu part, the code will read in the city name from xml and
the
city name is a link which when it is clicked it will toggle the
correspondent paragraph under content part. I assume that
WM_toggle('{cityid}') will read in 'ba' and 'hk' for bacelona, and hong
kong
link respectively, but the code does not work. When I clicked the link,
it
has error like: document.all[...].style is null or not an object.
Hi Chen,
> Of course it will not work for above line. But how to get that id
> between <cityid> into the WM_toggle function? I also tried this: <a
> href="#" onclick="WM_toggle('{cityid}'); return false">..</a>, but
> it did not work either.
The above should generate some HTML that looks like:
<a href="#" onclick="WM_toggle('id'); return false">..</a>
If it doesn't, then you are probably using MSXML2 rather than MSXML3.
MSXML2 doesn't support XSLT, but rather a Microsoft-specific variant
which doesn't implement attribute value templates (the {}s). You can
find out more about the difference from the MSXML FAQ at
http://www.netcrucible.com/.
If that's what the transformation's producing but the Javascript
doesn't work, then there's something wrong with the Javascript, not
the XSLT.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list