problem whit script in xlst file

S

stefano

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
 
M

Martin Honnen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top