Eddy C wrote:
[color=blue]
> Hi,
>
> I'm trying to get the value of another node using the position of
> another node or the name of the tag.[/color]
For the difference between tags and elements, see the XML FAQ at
http://xml.silmaril.ie/authors/makeup/
[color=blue]
> Such that the current node is one of the contacts child nodes sec or
> prim
> and doing
> <xsl:value-of select="//cust[seq = position()]/name"/>
>
>
> Should return jon for the prim tag and peter for the sec tag, but
> fails as position() appears to resolve to the position of cust not the
> contacts node[/color]
In cust[...position()...], the value of position() refers to the position of
the cust among its siblings, starting at 1.
[color=blue]
> alternatively I would like to do something like
>
> <xsl:value-of select="//cust[seq = [name()='prim' then 0 else
> 1]]/name"/>[/color]
This is not a well-formed document. I assume you meant to use </name>
after jon and peter.
If so, cust[position()=seq+1]/name will return jon and peter.
[color=blue]
> <custs>
> <cust>
> <seq>0</seq>
> <name>jon</seq>
> </cust>
> <cust>
> <seq>1</seq>
> <name>peter</seq>
> </cust>
> <contacts>
> <prim>
> <message>hello</message>
> </prim>
> <sec>
> <message>hello</message>
> </sec>
> </contacts>
> </custs>[/color]
I'm not clear what you want from this. Are you trying to access the
message belonging to each name, or the name belonging to each message?
///Peter