[xsl] Hello and quick question

Subject: [xsl] Hello and quick question
From: "Corey Snow" <Corey.Snow@xxxxxxxxxxxxxx>
Date: Mon, 6 Jan 2003 17:53:53 -0600
Hi all- good to be back on the list; I got bounced from my old job and
haven't been in a position to collect a lot of email in that time.

I have a quick question for you XSLT-guru types: How can I obtain the
first node of a set of nodes that meets a given set of criteria? In my
case, I have an XML document that contains zero or more nodes in a
particular element, like so:

<ROOT>
<Client>
... Various elements here ...
<Contacts>

<Contact ContactId='5'>
... Contact information ...
<IsReferrer>1</IsReferrer>
</Contact>

<Contact ContactId='10'>
... Contact information ...
<IsReferrer>0</IsReferrer>
</Contact>

<Contact ContactId='25'>
... Contact information ...
<IsReferrer>1</IsReferrer>
</Contact>

</Client>
</ROOT>

I have no real control over the order of these elements, and what I need
to be able to do is obtain the first Contact element which has zero
('0') in the IsReferrer element. Actually, I need to get the value of a
child element (ContactFirstName) of this element.

I can do something like:
/ROOT/Client/Contacts/Contact[IsReferrer='0']/ContactFirstName but that
returns a node-set, not a single node. I assume I need to do something
with the position() function, but I'm not sure how to go about it.

Thanks in advance for any assistance,

Corey M. Snow, Delivery Consultant
Logical- http://www.us.logical.com
Phone: (360) 491-7774
Cell: (360) 481-2563
"We are the music makers, and we are the dreamers of dreams."

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread