[xsl] Comparing node for identity using union

Subject: [xsl] Comparing node for identity using union
From: António Mota <amsmota@xxxxxxxxx>
Date: Thu, 13 Jan 2005 21:32:22 +0000
I don't know what's happenend in here, but i was using the union
operator for comparing nodes, following M. Kay sugestion some weeks
ago. It was working OK then, but now it simple stop working. I don't
believe in witches, but as the Spaniards says "que las hay, hay"...

What i was doing was something like this:

	<xsl:param name="pos" select="0"/>
	<xsl:variable name="snode" select="(//Menu)[$pos]"/>
(...)

							<xsl:when test="(count(parent::Menu|$snode)=1)">
								<xsl:text>1</xsl:text>
							</xsl:when>

aplyed to something like

<Menus>
    <Menu>
        <Menu_K>X00043</Menu_K>
        <Titulo>Processos</Titulo>
        <Menu>
            <Menu_K>X00047</Menu_K>
            <Titulo>Caracterizagco</Titulo>
        </Menu>
    </Menu>
    <Menu>
        <Menu_K>X00047</Menu_K>
        <Titulo>Caracterizagco</Titulo>
    </Menu>
    <Menu>
        <Menu_K>X00110</Menu_K>
        <Titulo>Setting's</Titulo>
        <Menu>
            <Menu_K>X00110</Menu_K>
            <Titulo>Setting's</Titulo>
        </Menu>
    </Menu>
</Menus>

In this example when the context node is /Menus/Menu/Menu and $pos=1 i
want the value 1, otherwise something else.

When $pos = 0 i never want that condition true, and everithing was
working OK. But now i only changed the tag names and it's not working
anymore. I run to the debuger i see that

(count(parent::Menu|$snode)=1) is allways true, even when $snode no
node, and even when there is no parent::Menu .

For example, when in  /Menus/Menu/Menu and (//Menu)[0] that condition is true.

I'm completly lost in here, its late and i don't know what to think...

Current Thread