Oleg,
1)
If I need to check if my first node is equal something,
can I say:
<when:if
select="product/formulary/access-shares/tier[1]/option/access-rate[1]
> 0"/>
or
<when:if
select="product/formulary/access-shares/tier[1]/option/access-rate[position()=1]
> 0"/> ?
You can determine this empirically. Apply the following transform against
the sample XML I posted earlier:
<xsl:template match="/">
<xsl:copy-of select="//rebate1[1] > 0"/>
</xsl:template>
It will probably return "true"; likewise if you use the position() variant.
However, that's the simple answer, because this is one of those
innocuous-looking questions which hides a surprise, and is hard to answer
without context. For example, one may expect the following XSL to produce
"0":
<xsl:template match="/">
<xsl:copy-of select="//rebate1[1]"/>
</xsl:template>
and then be surprised when it produces 001234567888
So, is what you posted syntactically correct? Yes, it is. Does it do what
you intend ... dunno without seeing your data.
Incidentally, what I've usually seen is:
select="foo/bar[position() = 1 and . > 0]"
Which I read as: "foo ... bar ... such that position() = 1 and self-value >
0"
2) When do I use '$' before product ?
$ is used when referring to a variable or parameter. You may have both an
element named <product> and a variable (or param) named product (which,
latter, would be referred to as $product)
Regards,
--A
PS: please post to the list--you'll get more eyes looking at issues, and and
more people who may be able to respond.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/