I’m sure this should be very simple – but I’m having trouble with context!
Example XML:
<test>
<HtlSeg>
<SegNum>1</SegNum>
<StartDt>20130624</StartDt>
<NumNights>2</NumNights>
<Conf>28618</Conf>
</HtlSeg>
<CommentInfo>
<CommentNum>1</CommentNum>
<SegMatch>28618</SegMatch>
<Comment>THIS IS A TEST</Comment>
</CommentInfo>
<CommentInfo>
<CommentNum>2</CommentNum>
<SegMatch>28618</SegMatch>
<Comment>HOTEL BOOKED</Comment>
</CommentInfo>
<CommentInfo>
<CommentNum>3</CommentNum>
<SegMatch>28618</SegMatch>
<Comment>NON REFUNDABLE</Comment>
</CommentInfo>
<CommentInfo>
<CommentNum>4</CommentNum>
<SegMatch>1459</SegMatch>
<Comment>CAR BOOKING</Comment>
</CommentInfo>
<CommentInfo>
<CommentNum>5</CommentNum>
<SegMatch>1528</SegMatch>
<Comment>AIR BOOKING</Comment>
</CommentInfo>
<CommentInfo>
<CommentNum>6</CommentNum>
<SegMatch>1528</SegMatch>
<Comment>NON REFUNDABLE</Comment>
</CommentInfo>
<CommentInfo>
<CommentNum>7</CommentNum>
<SegMatch>1528</SegMatch>
<Comment>NON SMOKING</Comment>
</CommentInfo>
In an XSLT my context node is the <HtlSeg>.
I am tryin to access the <CommentInfo> nodes where the <SegMatch> node equals the <Conf> node of the <HotelSeg>.
The xpath I’ve tried is following-sibling::CommentInfo[SegMatch=Conf]/Comment
However doesn’t return anything. I think I’ve lost context from the <HotelSeg> when using the `Conf’ in the xpath – but Im sure this must be possible in a simple Xpath without having to declare variables??
Cheers
Darren
Use the
current()method