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

  • SEARCH
  • Home
  • 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 7554945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:28:15+00:00 2026-05-30T11:28:15+00:00

I have the following XML: <system-folder> <system-folder> <system-page> <display-name>One</display-name> </system-page> </system-folder> <system-folder> <system-page> <display-name>Two</display-name>

  • 0

I have the following XML:

<system-folder>
    <system-folder>
        <system-page>
            <display-name>One</display-name>
        </system-page>
    </system-folder>
    <system-folder>
        <system-page>
            <display-name>Two</display-name>
        </system-page>
    </system-folder>
    <system-folder current="true">
        <system-page>
            <display-name>Three</display-name>
        </system-page>
        <system-page>
            <display-name>Four</display-name>
        </system-page>
        <system-page>
            <display-name>Five</display-name>
        </system-page>
    </system-folder>
</system-folder>

And the following code works as expected:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:for-each select="//system-folder[@current="true"]/..//system-page">
            Current: <xsl:value-of select="display-name"/><br/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

And returns what I expected:

Current: One
Current: Two
Current: Three
Current: Four
Current: Five

But when I try to get the previous items using:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
       <xsl:for-each select="//system-folder[@current="true"]/..//system-page">
           Previous: <xsl:value-of select="preceding-sibling::*[1]/display-name"/><br/>
           Current: <xsl:value-of select="display-name"/><br/><br/>
       </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

I get:

Previous: 
Current: One

Previous: <-- Why is this missing?
Current: Two

Previous: <-- Why is this missing?
Current: Three

Previous: Three
Current: Four

Previous: Four
Current: Five

Why are the two items above missing? It looks to me that the preceding-sibling isn’t getting out of the folder. How can I resolve that?

A lot of thanks to whoever can help me – I’ve been stuck on it for too long 🙁

  • 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-30T11:28:17+00:00Added an answer on May 30, 2026 at 11:28 am

    You seem to be confusing the preceding:: axis with the preceding-sibling:: axis.

    What you want is:

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <xsl:for-each select=
            "//system-folder[@current='true']/..//system-page">
              Previous: <xsl:value-of select=
              "preceding::system-page[1]/display-name"/>
                <br/>
                Current: <xsl:value-of select="display-name"/>
                <br/>
                <br/>
            </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the provided XML document:

    <system-folder>
        <system-folder>
            <system-page>
                <display-name>One</display-name>
            </system-page>
        </system-folder>
        <system-folder>
            <system-page>
                <display-name>Two</display-name>
            </system-page>
        </system-folder>
        <system-folder current="true">
            <system-page>
                <display-name>Three</display-name>
            </system-page>
            <system-page>
                <display-name>Four</display-name>
            </system-page>
            <system-page>
                <display-name>Five</display-name>
            </system-page>
        </system-folder>
    </system-folder>
    

    the wanted, correct result is produced:

          Previous: <br/>
            Current: One<br/><br/>
          Previous: One<br/>
            Current: Two<br/><br/>
          Previous: Two<br/>
            Current: Three<br/><br/>
          Previous: Three<br/>
            Current: Four<br/><br/>
          Previous: Four<br/>
            Current: Five<br/><br/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Xml Configuration <system.serviceModel> <services> <service name=MyService.MyServiceREST behaviorConfiguration=MyServiceTypeBehaviors> <host> <baseAddresses> <add
Say I have the following web.config: <?xml version=1.0 encoding=utf-8?> <configuration> <system.web> <authentication mode=Windows></authentication> </system.web>
I have an application web.xml with the following entry: <error-page> <error-code>404</error-code> <location>/system_files/error/p_notfound.jsp</location> </error-page> However,
I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31/10/2008
I have the following XML (partial) document : <export> <table name=CLIENT> <row> <col name=CODE_CLIENT
I have the following XML code <class name=ContentStreamer> <method name=sendAudio> <criteria>medium</criteria> </method> <method name=sendVideo>
I have generated a class from XSD. The following [System.Xml.Serialization.XmlElementAttribute(mailer, Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public itemOrderMailer[] mailer
I have the following (simplified) XML that I get in a system environment: <?xml
We have in input an XML like following: <R> <MT N=folder V=Folder1\Subfolder1 /> <MT
I have the following XML structure: <?xml version=1.0 ?> <course xml:lang=nl> <body> <item id=787900813228567

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.