By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

problem whit script in xlst file

P: n/a

Hi, I have a file xml (p.xml) and I use XSLT to trasform p.xml to
XHTML.
this is the xml file:
....
<test label="x">
<itemList>
<testItem oknumber="2" >
....
</testItem>
</itemList>
</test>
.....

and this is the XSLT file:
.....
<xsl:template match="test">
<span>
<xsl:attribute name="class"> test </xsl:attribute>
<span>
<a>
<xsl:attribute name="name"><xsl:value-of
select="@label"/></xsl:attribute>
</a>
</span>
<xsl:call-template name="title"/>
<form>
<xsl:apply-templates/>
</form>
</span>
</xsl:template>

<xsl:template match="itemList">
<span>
<xsl:attribute name="class"> itemList </xsl:attribute>
<xsl:apply-templates/>
</span>
<input type= "button" class="but" value="verifica"
onclick="verify(this);" />

<script language="JavaScript">
function verify(t)
{
alert(t.tagName);
alert(t.parentNode.tagName);

}
</script>

</xsl:template>
....

the alert message should print:
"input"
"form"

In firefox all is ok, while in IE the second alert print "a".
The strange thing is that if the verify function is:
function verify(t)
{
alert(t.tagName);
alert(t.parentNode.tagName);
alert(t.previousSibling.parentNode.tagName);

}

the alert message in IE are:
"input"
"a"
"form"
Why?
I have problems with the DOM only in IE.Someone can help me, plese?
thanks

Jan 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a


stefano wrote:

<xsl:template match="test">
<span>
<xsl:attribute name="class"> test </xsl:attribute>
<span>
<a>
<xsl:attribute name="name"><xsl:value-of
select="@label"/></xsl:attribute>
</a>
</span>
<xsl:call-template name="title"/>
<form>
<xsl:apply-templates/>
</form>
</span>
</xsl:template> <input type= "button" class="but" value="verifica"
onclick="verify(this);" /> In firefox all is ok, while in IE the second alert print "a".


It is hard to tell exactly what goes wrong without seeing a complete
test case isolating the problem but for a start consider having the form
element inside of a div and not of a span. It might be that IE's HTML
parser tries to fix your HTML generated by the stylesheet. That is kind
of a guess to what could be one cause to the oddity you see.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.