Good morning. I have an XML file which contains lists of warning and errors from a build output. I have successfully been able to write XSL to iterate over the separate lists of warnings and errors to have them display in my browser. What I'd like to do next would be to add a bit of javascript in order to add a link/button to be able to toggle the display of the warnings. I can't get it to work properly.
here is the relvant code (trimmed down to what I hope are the essentials)
<xsl:template match="/">
<xsl:variable name="messages" select="/cruisecontrol//buildresults//message" />
<xsl:variable name="warning.messages" select="$messages[(contains(text), 'warning ')) or @level='Warning']" />
<xsl:variable name="warning.messages.count" select="count($warning.messages)" />
<xsl:if test="$warning.messages.count > 0">
<script type="text/javascript">
function toggleWarnings() {
eDiv = document.getElementById("warnings");
tDiv = document.getElementById("warningsTitle");
if ( eDiv.style.display == "none" ) {
eDiv.style.display = "inline";
tDiv.innerText = "Hide Warnings";
} else {
tDiv.innerText = "View Warnings";
eDiv.style.display = "none";
}
}
</script>
<table>
<tr> <td>
<a href="javascript:void()" onclick="javascript:toggleWarnings(); return false;">
<span id="warningsTitle">View Warnings</span>
</a>
</td> </tr>
<xsl:for-each select="$warning.messages">
<tr> <td class="warning" id="warnings" style="display: none;">
<xsl:value-of select="."/>
</td> </tr>
</xsl:for-each>
</table>
The problemt that I have is that only one warning is ever displayed after hitting the "view warnings" link. My problem is that I know enough HTML, XSL, and javascript to be slightly dangerous and the combination is proving that I don't know enough :-)
Is there an easy way for me to iterate over XSL elements, display then in a table and also be able to hide all of those elements under a link toggle?
Thanks.