[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Pure XPath Question


Subject: [xsl] Pure XPath Question
From: Philip Vallone <philip.vallone@xxxxxxxxxxx>
Date: Sun, 24 Jul 2011 13:25:41 -0400

Hi List

I have a xpath expression that searches a xml file for the word 'faa'. Using
pure xpath 1.0, I want to be able to search each section element that has the
word 'faa' in the name attribute. I want to return the @name of the ancestor
chapter/@name for each section.

This expression only returns a count of 1

/data/volume/chapter/section/@name[contains(translate(.,'ABCDEFGHIJKLMNOPQRST
UVWXYZ','abcdefghijklmnopqrstuvwxyz'), 'faa')]/ancestor::chapter/@name

while this returns a count of 2.

/data/volume/chapter/section/@name[contains(translate(.,'ABCDEFGHIJKLMNOPQRST
UVWXYZ','abcdefghijklmnopqrstuvwxyz'), 'faa')]

I understand why I am not getting the desired result, but not sure how to get
it.

Desired result:

Chapter 1. Handbook Organization, Use, and Revision
Chapter 1. Handbook Organization, Use, and Revision

Is this possible with using a single xpath expression?

Sample XML

<data xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<volume name="Volume 1. General Guidance &amp; Information">
		<chapter name="Chapter 1. Handbook Organization, Use, and Revision">
			<section name="Section 1. General Handbook Information"
href="PICDetail.aspx?docId=68F139A1864A15A08525734F0076674E"/>
			<section name="Section 2. Definitions"
href="PICDetail.aspx?docId=ED04745B863890958525734F0076652D"/>
			<section name="Section 3. FAA Acronyms and Abbreviations"
href="PICDetail.aspx?docId=3B21BD11F2DA78BF8525734F0076652E"/>
			<section name="Section 4. FAA Computer Databases (CHG 34 - 9/26/08)"
href="PICDetail.aspx?docId=E68EF79E32195DD58525734F0076652F"/>
		</chapter>
	</volume>
</data>
.........


Current Thread
Keywords