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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:35:11+00:00 2026-05-23T00:35:11+00:00

XML: <Root> <Elements> <Element>el1</Element> <Element>el2</Element> </Elements> <Elements> <Element>el1</Element> <Element>el2</Element> </Elements> </Root> Trying to generate

  • 0

XML:

<Root>
  <Elements>
    <Element>el1</Element>
    <Element>el2</Element>
   </Elements>

  <Elements>
    <Element>el1</Element>
    <Element>el2</Element>
   </Elements>
</Root>

Trying to generate to apply two different templates for the same element.

Main template:

<xsl:stylesheet version="1.0">
      <xsl:template match="/Root">
           At root level
             <xsl:apply-templates select="Elements">

             <h1>Render something more</h1>

             <xsl:apply-templates select="Elements" mode="1:Custom">
        </xsl:template>


    <!-- This doesn't render though it is called above-->
      <xsl:template match="Elements"> 
      render something here
      </xsl:template>

    <!-- This renders twice -->
      <xsl:template match="Elements" mode="1:Custom">
      render something else here
      </xsl:template>
</xsl:stylesheet>

If I add mode to the first template, both don’t render.

Also tried:

 <xsl:apply-templates select="Elements" mode="1:Custom" />

with the different template to apply as:

<xsl:apply-templates select="Elements" mode="Different" />

Only one of the two(the first one which has the mode specified is rendered).
i.e

<xsl:template match="Elements">
</xsl:template>

doesn’t render

or
<xsl:template match="Elements" mode="Different" />renders twice.

How should I fix this? Everywhere I researched, it suggests to put a priority on the mode. Must be something simple since so many programmers use it?

  • 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-23T00:35:12+00:00Added an answer on May 23, 2026 at 12:35 am
    <?xml version="1.0"?>
    
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
          <xsl:template match="/Root">
               At root level
                 <xsl:apply-templates select="Elements"/>
    
                 <h1>After first template</h1>
    
                 <xsl:apply-templates select="Elements" mode="Custom"/>
            </xsl:template>
    
          <xsl:template match="Elements">
          <p>First template</p> 
              <xsl:apply-templates select="Element"/>
          </xsl:template>
    
          <xsl:template match="Elements" mode="Custom">
             <p>Second template      </p>
          </xsl:template>
          </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The XML I'm trying to validate is as follows: <root> <element attribute=foo> <bar/> </element>
Trying to use exportDoc.Root.Elements(string).Where(node => !(node.Element(product).HasElements) || node.Element(product).Element(type).Value != product).Remove(); to remove the nodes
I'm trying to get to this result while serializing XML: <Root Name=blah> <SomeKey>Eldad</SomeKey> <Element>1</Element>
I have a merged xml with a root element and multiple item child elements.
I'm interested in assigning the tag name of the root element in an xml
I have an xml that comes in two forms <root> <element1 req=mandatory/> <element2/> <element3/>
I would like to remove all elements from XML except content of element called
I have this XML file : http://dl.dropbox.com/u/10773282/2011/perf.xml It has two Class elements as is
I am generating a xml tree: var root = new XElement(Root); for(int i =0;i<3;i++)
Some API returns me XmlCursor pointing on root of XML Document. I need to

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.