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 4078228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:38:54+00:00 2026-05-20T17:38:54+00:00

<a> <x/> <m/> <y/> <m/> </a> Inside a template that matches ‘a’, I want

  • 0
 <a>
   <x/>
   <m/>
   <y/>
   <m/>
 </a>

Inside a template that matches ‘a’, I want to match (first) any ‘m’s before ‘y’, and then
separately any ‘m’s after ‘y’.

<xsl:apply-templates select="./m[following::y]"/>

is what I thought of, but I can’t get it to work, and, further, I can’t see how to prevent the template that matches on ‘m’ from being applied in the normal flow as well as in the particular place i want to insert the m-related content.

  • 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-20T17:38:55+00:00Added an answer on May 20, 2026 at 5:38 pm

    Your template looks OK, but are you sure you want to use following? For example, this template:

    <xsl:template match="a">
        <a><xsl:apply-templates select="m[following::y]"/></a>
        <b><xsl:apply-templates select="m[following-sibling::y]"/></b>  
    </xsl:template>
    

    …applied to the following XML:

    <a>
       <x/>
       <m>match</m>
       <y/>
       <m>no match</m>
       <nested>
           <m>match 2</m>
           <y/>
       </nested>
    </a>
    

    …outputs the following result:

    <a>matchno match</a>
    <b>match</b>
    

    The first apply-templates matches <m>no match</m> because following includes all nodes that are after the context node in document order, which includes the nested <y/>.

    The second template matches only siblings.

    For completeness, I’ll add the following template, which matches only those <m> nodes whose immediate following sibling is a <y>:

    <xsl:template match="a">
       <a><xsl:apply-templates select="m[following-sibling::*[1][self::y]]"/></a>
    </xsl:template>
    

    This template outputs the following, given the above XML:

    <a>match</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array set inside a velocity template that contains some paths. The
I have a template for editing a franchise. Inside that template I have two
I want to integrate tweet button inside a jquery template. Am trying the 'tweet
I have an email template that is inside a PHP script. I am using
Is it possible to create a django template that can be used (nested) inside
I'm creating custom control that contain multiple parts. Inside template creation I'm subscribing for
What is the C++ syntax for specializing a template function that's inside a template
I have to edit data inside my template that is use for Ext.Panel. How
I have a template that is rendered inside another GSP. I can't seem to
Inside my template function I have the following code: TypeName myFunction() { TypeName result;

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.