xsl-list
[Top] [All Lists]

[xsl] Pure XPath Question

2011-07-24 12:26:07
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(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
 'faa')]/ancestor::chapter/@name

while this returns a count of 2.

/data/volume/chapter/section/@name[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','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>
.........
--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>