shauncrist
Programmer
I've got a document that looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl?>
<FirstEl>
<SecondEl>
</SecondEl>
<Pic id="Pic1">
<PicLoc href="Pic1.gif"/>
</Pic>
<Pic id="Pic2">
<PicLoc href="Pic2.gif"/>
</Pic>
<Pic id="Pic3">
<PicLoc href="Pic3.gif"/>
</Pic>
</FirstEl>
I'm trying to display the pictures using nav buttons. It seems to work the first time I try and change pics, but after that it doesn't. The parameters appear to be changing as I look at the alert, but the pics don't update on the second try. Any ideas? TIA. Here's the XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:msxsl="urn:schemes-microsoft-com:xslt:>
<xsl
aram name="CurPic">1</xsl
aram>
<xsl
aram name="PicName">Slide<xsl:value-of select="$CurSlide"/></xsl
aram>
<xsl:variable name="PicNodes" select="/FirstEl/Pic" />
<xsl:template match="text()" />
<xsl:template match="FirstEl">
<html>
<head>
<title>Picture Gallery</title>
<script language="javascript" for="window" event="onload"><xsl:comment><![CDATA[
source=document.XMLDocument;
style=document.XSLDocument;
]]></xsl:comment></script>
<script language="javascript"><xsl:comment><![CDATA[
function readParms() {
el=window.event.srcElement;
oCurPicParm=document.XSLDocument.selectSingleNode("//xsl
aram[@name='CurPic']");
oCurPicParm.childNodes.item(0).nodeTypedValue = el.name;
alert(oCurPicParm.childNodes.item(0).nodeTypedValue);
data.innerHTML=source.documentElement.transformNode(style);
}
]]></xsl:comment></script>
<span id="data">
<xsl:apply-templates select="Pic" />
</span>
</head>
</html>
</xsl:template>
<xsl:template match="Pic">
<xsl:if test="@id[.=$PicName]">
<body>
<div align="center">
<img align="center" height="480" width="640">
<xsl:attribute name="src">
<xsl:value-of select="PicLoc/@href" />
<xsl:attribute>
</img>
<p />
<xsl:choose>
<xsl:when test="$CurPic > 1">
<img id="CurPic" src="rewind.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:text>1</xsl:text>
</xsl:attribute>
</img>
<img id="CurPic" src="prev.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:value-of select="$CurPic - 1" />
</xsl:attribute>
</img>
</xsl:when>
<xsl
therwise>
<img id="blank" src="blank.gif" align="bottom" border="0" />
<img id="blank" src="blank.gif" align="bottom" border="0" />
</xsl
therwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$CurPic < count($PicNodes)">
<img id="CurPic" src="next.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:value-of select="$CurPic + 1" />
</xsl:attribute>
</img>
<img id="CurPic" src="fastfwd.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:value-of select="count($PicNodes)" />
</xsl:attribute>
</img>
</xsl:when>
<xsl
therwise>
<img id="blank" src="blank.gif" align="bottom" border="0" />
<img id="blank" src="blank.gif" align="bottom" border="0" />
</xsl
therwise>
</xsl:choose>
</div>
</body>
</xsl:if>
</xsl:template>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl?>
<FirstEl>
<SecondEl>
</SecondEl>
<Pic id="Pic1">
<PicLoc href="Pic1.gif"/>
</Pic>
<Pic id="Pic2">
<PicLoc href="Pic2.gif"/>
</Pic>
<Pic id="Pic3">
<PicLoc href="Pic3.gif"/>
</Pic>
</FirstEl>
I'm trying to display the pictures using nav buttons. It seems to work the first time I try and change pics, but after that it doesn't. The parameters appear to be changing as I look at the alert, but the pics don't update on the second try. Any ideas? TIA. Here's the XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:msxsl="urn:schemes-microsoft-com:xslt:>
<xsl
<xsl
<xsl:variable name="PicNodes" select="/FirstEl/Pic" />
<xsl:template match="text()" />
<xsl:template match="FirstEl">
<html>
<head>
<title>Picture Gallery</title>
<script language="javascript" for="window" event="onload"><xsl:comment><![CDATA[
source=document.XMLDocument;
style=document.XSLDocument;
]]></xsl:comment></script>
<script language="javascript"><xsl:comment><![CDATA[
function readParms() {
el=window.event.srcElement;
oCurPicParm=document.XSLDocument.selectSingleNode("//xsl
oCurPicParm.childNodes.item(0).nodeTypedValue = el.name;
alert(oCurPicParm.childNodes.item(0).nodeTypedValue);
data.innerHTML=source.documentElement.transformNode(style);
}
]]></xsl:comment></script>
<span id="data">
<xsl:apply-templates select="Pic" />
</span>
</head>
</html>
</xsl:template>
<xsl:template match="Pic">
<xsl:if test="@id[.=$PicName]">
<body>
<div align="center">
<img align="center" height="480" width="640">
<xsl:attribute name="src">
<xsl:value-of select="PicLoc/@href" />
<xsl:attribute>
</img>
<p />
<xsl:choose>
<xsl:when test="$CurPic > 1">
<img id="CurPic" src="rewind.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:text>1</xsl:text>
</xsl:attribute>
</img>
<img id="CurPic" src="prev.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:value-of select="$CurPic - 1" />
</xsl:attribute>
</img>
</xsl:when>
<xsl
<img id="blank" src="blank.gif" align="bottom" border="0" />
<img id="blank" src="blank.gif" align="bottom" border="0" />
</xsl
</xsl:choose>
<xsl:choose>
<xsl:when test="$CurPic < count($PicNodes)">
<img id="CurPic" src="next.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:value-of select="$CurPic + 1" />
</xsl:attribute>
</img>
<img id="CurPic" src="fastfwd.gif" align="bottom" border="0" onClick="readParms()">
<xsl:attribute name="name">
<xsl:value-of select="count($PicNodes)" />
</xsl:attribute>
</img>
</xsl:when>
<xsl
<img id="blank" src="blank.gif" align="bottom" border="0" />
<img id="blank" src="blank.gif" align="bottom" border="0" />
</xsl
</xsl:choose>
</div>
</body>
</xsl:if>
</xsl:template>