I think what the OP wanted was
<xsl:template match="/a">
<xsl:value-of select="(b/c[(_at_)type='pdf'])[1]" />
</xsl:template>
as David B. suggested.
I believe the difference between 1.0 and 2.0 value-of is a red herring
here, as the XPath was simply not correct.
The difference is between
b/c[(_at_)type='pdf'][1]
which is short for child::b/child::c[attribute::type='pdf'][1]
and
(b/c[(_at_)type='pdf'])[1]
which is short for (child::b/child::c[attribute::type='pdf'])[1]
The first expression selects all such c grandchildren that are the first
such children of their b parents (there were several in the sample given);
the second selects only the first such c grandchildren of the entire set of
such c grandchildren.
At 02:14 PM 9/2/2005, Mike wrote:
Prakash>>
<xsl:value-of select="b[c[(_at_)type='pdf']][1]/c/text()"/>
Can you explain how b[c[(_at_)type='pdf']]work? I'm not familiar with that.
Is it v2.0 syntax?
It's perfectly fine 1.0 syntax, just not useful here. It's short for
child::b[child::c[attribute::type='pdf']]
and basically just filters the b children here to those that have such a c
child.
The logic of predicates (the [ ] syntax) is simple: test the expression
given for each node in the node set to which it applies; cast the result,
if necessary, to a Boolean value (this happens implicitly). Keep any node
for which the expression is true; toss any for which it is false.
Inside a predicate, "child::c" tests true for context nodes that have a c
element child; "c[(_at_)type='pdf']" tests true for context nodes that have a c
element child that have a type attribute = 'pdf', etc.
Cheers,
Wendell
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--