Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 597913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:19:56+00:00 2026-05-13T16:19:56+00:00

I have the current structure; Item 1 – Subitem 1 – Subitem 2 –

  • 0

I have the current structure;

Item 1
 - Subitem 1
 - Subitem 2
 - Subitem 3
 - - Sub subitem 1
 - - Sub subitem 2
 - - Sub subitem 3
 - - etc

I have a field that is only defined on “Item 1”. Let’s call it ‘Header’.

When i am on “Item 1” its easy enough to extract this value, but what about when i am on the other items? Is there a way i can go through the tree (up) until i find a field called ‘Header’ and it has a value, and then stop and use this as a reference point in my sub items?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:19:56+00:00Added an answer on May 13, 2026 at 4:19 pm

    If you want to look up the tree and find the closest element that contains a Header attribute with a value, something like this should work.

      <xsl:value-of select="(ancestor::*/@Header[.!=''])[last()]" />
    

    This uses the ancestor axis to look up the tree and the xpath expression looks for any element with a Header attribute who’s value is not empty.

    A second filter is used to evaluate the last one. If there is more than one ancestor that has a @Header with a value, the last one would be the closest to the context node, because the result is in document order.

    EDIT: An alternative way to find the same results, leveraging the fact that ancestor axis returns in reverse document order would be to put the filter criteria in the predicate for the ancestor axis step, select the first one(closest match to the context node), and then step into the @Header:

    <xsl:value-of select="ancestor::*[@Header!=''][1]/@Header" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the current basic structure for each domain object that I need to
I have a XML Structure that looks like this. <sales> <item name=Games sku=MIC28306200 iCat=28
My current problem is that I have a JFrame with a 2x2 GridLayout. And
At my current job we have a CMS system that is .NET/SQL Server based.
I have a model representing a Content item that contains some images. The number
I have a nested simple XML structure that I load with PHP's simpleXML. Some
In my current project we have a large repository of content that was originally
I have this menu structure that is used to navigate through content slider panels.
I have a hierarchical list of objects. Assume that the structure is as follows:
We have a current application where user login credentials are stored in a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.