Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: javascipt in xsl not working

From: Chuck Jungmann <NOchuckSPAM@----.--->
To: NULL
Date: 5/9/2006 4:59:00 AM

I didn't mean to be snide about my not thinking of a reason...I should
have said that in my limited experience, I couldn't image a situation
where I couldn't simply pass data in the transform that would be
processed by a javascript function contained in a .js file.

In your case, if you just want to make changes to a group of elements,
I would suggest giving all the elements the same name, then using the
javascript function document.getElementsByName() to collect them to a
nodelist.  hyLink() could be in a script block and look like this:
function hyLink(bDisplay)
{
	var nl = document.getElementsByName("xslName");
	for (var i=0; i<nl.length; i++)
		nl[i].style.display = bDisplay?"none":"";
}

Another strategy I often use is when I need to pass a bunch of
"things" like the ids of elements, I pass the whole group as a
space-separated list in a variable or input field.  When I need to use
the list, I grab it, use String.split(' '), then use a for() loop to
process the resulting array.  In both of these cases, the javascript
can be in the HTML file or in a JS file.

On 8 May 2006 16:50:31 -0700, nx.nine@g... wrote:

>"I don't know it
>this helps, but I can't think of a reason to include executable code
>in a transform that goes into an already-running page with scripts
>already loaded."
>
>if you look in my xsl above, you notice that i generate html elements
>with ID's based on the xml attribute "id", and that onclick they
>trigger hyLink().
>
>hyLink is a function that hides a set of div's based on id, then
>displays the elements that are passed to it as arguements.
>
>function hyLink(){
>var hyArgv = hyLink.arguments;
>var hyArgc = hyArgv.length;
>
><xsl:for-each select="//ec:ml/panel">
>document.getElementById('addr<xsl:value-of
>select="@id"/>Bod').style.display='none';
>document.getElementById('addr<xsl:value-of
>select="@id"/>View').style.display='none';
>document.getElementById('addr<xsl:value-of
>select="@id"/>Sel').style.display='none';
><xsl:if test="child::tab!=''">
><xsl:for-each select="tab">
>document.getElementById('addr<xsl:value-of
>select="@name"/>Con').style.display='none';
></xsl:for-each>
></xsl:if>
><xsl:if test="not(child::tab!='')">
>document.getElementById('addr<xsl:value-of
>select="@id"/>Con').style.display='none';
></xsl:if>
></xsl:for-each>
>
>for (var hyI = 0; hyI &lt; hyArgc; hyI++){
>document.getElementById(hyArgv[hyI]).style.display='';
>}
>}
>
>i have found that the above method is the best way of doing this (in
>firefox anyway) since  i can never be sure of exactly how many panels
>will be drawn at runtime, due to the tabs  being drawn (it's all a web
>front-end to an xml-driven piece of software).
>
>i also have a similar function that is used to clear the text fields i
>generate, and stick info into the appropriate field.
>
>thank you all for the suggestions, i know i'm dipping into javascript,
>but the javascript forums i've posted in so far have either left my
>post unanswered, or given me advice that completely breaks my attempt
>at simple cross-browser functionality.
>
>again thank you guys so much for the bits of help, and sorry if i'm
>going too far off topic



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent