WhidbeyTomas
07-17-2007, 08:18 AM
Good morning (evening, afternoon)! I am completely ignorant of xsl. I use xml with Flash, but I am working on a project that uses xml and xsl to populate html.
My interface has glossary terms that when clicked on cause a definition to show. The problem is that to remove the definition, the user has to click on the definition, and no one thinks of that. I would like to turn the term into a toggle switch.
I have done this with actionScript, but I don't even know what this language is, let alone how it works.
Can anyone tell me if this is possible? The code below seems to call the show function. So I tried writing a shoHide function, whick did not work. But if I can simply turn the following line into a toggle, I don't need a function:
onMouseOver="cursorhandon('{$nameid}')" onclick="show('{$termid}')" ID="{$nameid}"><xsl:value-of select="$defterm" /></span>
Here are the functions that are called:
function show(ID) {document.getElementById(ID).className="show";}
function hide(ID) {document.getElementById(ID).className="hide";}
This code applies the style "show" and tells the browser to get and display the content (I think). The line that follows tells the browser to apply the "hide" style to the content (display:none;).
So...it would seem that a toggle that says "click_its visible=click_its not visible," would do the trick.
If someone can tell me how this kind of statement is written, if it is possible, I'd be grateful.
Here is the full xsl template (what ever that is):
<xsl:template match="w:p">
<xsl:variable name="infostyle" select="w:pPr/w:pStyle/@w:val" />
<div class="{$infostyle}">
<xsl:for-each select="w:r">
<xsl:choose>
<xsl:when test="w:rPr/w:rStyle/@w:val='keyterm'">
<xsl:variable name="termid" select="generate-id()" />
<xsl:variable name="nameid" select="concat('t',generate-id())" />
<xsl:variable name="defterm" select="w:t/text()" />
<span class="terminline" onMouseOver="cursorhandon('{$nameid}')" onclick="show('{$termid}')" ID="{$nameid}"><xsl:value-of select="$defterm" /></span>
<span ID="{$termid}" onMouseOver="cursorhandon('{$termid}')" class="hide" onclick="hide('{$termid}')"><xsl:value-of select="document('../content/terms.xml')/w:wordDocument/w:body/wx:sect[w:p[1]/w:r/w:t=$defterm]/w:p[2]" /></span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="w:t/text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div>
<xsl:apply-templates />
</xsl:template>
My interface has glossary terms that when clicked on cause a definition to show. The problem is that to remove the definition, the user has to click on the definition, and no one thinks of that. I would like to turn the term into a toggle switch.
I have done this with actionScript, but I don't even know what this language is, let alone how it works.
Can anyone tell me if this is possible? The code below seems to call the show function. So I tried writing a shoHide function, whick did not work. But if I can simply turn the following line into a toggle, I don't need a function:
onMouseOver="cursorhandon('{$nameid}')" onclick="show('{$termid}')" ID="{$nameid}"><xsl:value-of select="$defterm" /></span>
Here are the functions that are called:
function show(ID) {document.getElementById(ID).className="show";}
function hide(ID) {document.getElementById(ID).className="hide";}
This code applies the style "show" and tells the browser to get and display the content (I think). The line that follows tells the browser to apply the "hide" style to the content (display:none;).
So...it would seem that a toggle that says "click_its visible=click_its not visible," would do the trick.
If someone can tell me how this kind of statement is written, if it is possible, I'd be grateful.
Here is the full xsl template (what ever that is):
<xsl:template match="w:p">
<xsl:variable name="infostyle" select="w:pPr/w:pStyle/@w:val" />
<div class="{$infostyle}">
<xsl:for-each select="w:r">
<xsl:choose>
<xsl:when test="w:rPr/w:rStyle/@w:val='keyterm'">
<xsl:variable name="termid" select="generate-id()" />
<xsl:variable name="nameid" select="concat('t',generate-id())" />
<xsl:variable name="defterm" select="w:t/text()" />
<span class="terminline" onMouseOver="cursorhandon('{$nameid}')" onclick="show('{$termid}')" ID="{$nameid}"><xsl:value-of select="$defterm" /></span>
<span ID="{$termid}" onMouseOver="cursorhandon('{$termid}')" class="hide" onclick="hide('{$termid}')"><xsl:value-of select="document('../content/terms.xml')/w:wordDocument/w:body/wx:sect[w:p[1]/w:r/w:t=$defterm]/w:p[2]" /></span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="w:t/text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</div>
<xsl:apply-templates />
</xsl:template>