Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 10th, 2005, 12:54 PM
Registered User
Join Date: May 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Traversing UP my hierarchy in XPath

Good Afternoon. I am new to Xpath, XSLT and FOP so any help would be greatly appreciated!!!

I have an xml doc with the following structure:

Contract -> Estimate ->itemGroup -> topSecion ->Section -> Item ->Location

In my XSL-FO I am essentially traversing through all locations that are under the root contract. For-each of these locations I then want to check and see if any Item has this location (by comparing a Location element).

My problem is while at the lowest level of Location I need to step up the hierarchy to the itemGroup level to check only those items. I have tried a number of variations but can’t seem to get it quite right.

Any help would be greatly appreciated!!!

The inner loop has been my problem and have tried these options already with no success:

1. <xsl:for-each select=" ancestor-or-self::node()/ancestor-or-self::node()/ancestor-or-self::node()/ancestor-or-self::node()/items">

2. <xsl:for-each select="ancestor::node()/ancestor::node()/ancestor::node()/ancestor::node()/items">

3. <xsl:for-each select="parent::node()/parent::node()/parent::node()/parent::node()/items">

    <xsl:for-each select="./topSections/sections/items/locations">
        <xsl:variable name="locName"><xsl:value-of select="name" /></xsl:variable>

                <fo:block text-align="center">
                    <xsl:value-of select="$locName" />

      <xsl:for-each select="ancestor::node()/ancestor::node()/ancestor::node()/ancestor-or-self::node()/items">

            <fo:block text-align="center">
               <xsl:for-each select="./locations[name=$locName]">
                      <xsl:value-of select="quantity" />


Grant Bryce
Pangaea Systems Inc
email: gbryce@pangaeainc.com
Old May 11th, 2005, 10:02 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

If your context node is Location then
takes you up one level so
will give you all the Location elements assuming the only parent of Location is Item.
Is this what you mean?


Joe (Microsoft MVP - XML)

Similar Threads
Thread Thread Starter Forum Replies Last Post
traversing preceding-sibling in reverse doc order mphare XSLT 3 August 16th, 2007 01:28 PM
Hierarchy Navigation asearle XSLT 0 September 28th, 2006 02:27 AM
traversing a tree based on an array of strings muki XSLT 1 February 16th, 2006 09:54 AM
XML Traversing using Navigator and Iterator classe jasim XML 1 July 18th, 2003 03:29 AM
passing attribute info while traversing nodes Ashley XML 1 June 20th, 2003 07:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.