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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:24:11+00:00 2026-05-28T08:24:11+00:00

Given the following XML: <root> <StepFusionSet name=SF1> <StepFusionSet name=SF2> </StepFusionSet> </StepFusionSet> <StepFusionSet name=SF10> </StepFusionSet>

  • 0

Given the following XML:

<root>
  <StepFusionSet name="SF1">
      <StepFusionSet name="SF2">
      </StepFusionSet>
  </StepFusionSet>
  <StepFusionSet name="SF10">
  </StepFusionSet>
</root>

The following C# code :

        XPathDocument doc = new XPathDocument("input.xml");
        var nav = doc.CreateNavigator();

        var item = nav.Select("//StepFusionSet[@name]");
        while (item.MoveNext())
        {
            Debug.WriteLine(item.Current.GetAttribute("name", item.Current.NamespaceURI));
        }

Gives me the output :

SF1
SF2
SF10

But the following XSLT file :

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="//StepFusionSet">
    <xsl:call-template name="a"/>
  </xsl:template>

  <xsl:template name="a">
      <xsl:apply-templates select="@name"/>
  </xsl:template>
</xsl:stylesheet>

(called by C# code:)

        XslTransform xslt = new XslTransform();
        xslt.Load("transform.xslt");
        XPathDocument doc = new XPathDocument("input.xml");
        MemoryStream ms = new MemoryStream();

        xslt.Transform(doc, null, ms);

Gives me the output :

SF1
SF10

What I’m doing wrong in my XSLT file?

  • 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-28T08:24:12+00:00Added an answer on May 28, 2026 at 8:24 am

    Consider your first template…

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

    …as applied to your SF1 and (nested) SF2 elements:

    <StepFusionSet name="SF1">
      <StepFusionSet name="SF2">
      </StepFusionSet>
    </StepFusionSet>
    

    The template matches your outer SF1 element; however, it then needs to be reapplied to the children of the matched element in order to match your inner SF2.

    This can be achieved by embedding a recursive <xsl:apply-templates/> inside your second template definition:

    <?xml version="1.0" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="//StepFusionSet">
        <xsl:call-template name="a"/>
      </xsl:template>
    
      <xsl:template name="a">
        <xsl:apply-templates select="@name"/>
        <xsl:apply-templates/>
      </xsl:template>
    
    </xsl:stylesheet>
    

    Alternatively, you can use an <xsl:for-each> element to select all your <StepFusionSet> elements (including nested ones such as SF2):

    <?xml version="1.0" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
      <xsl:output method="xml" indent="yes"/>
      <xsl:template match="/">
        <xsl:for-each select="//StepFusionSet">
          <xsl:value-of select="@name"/>
        </xsl:for-each>
      </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following XML markup: <root xmlns=Demo> <child name=foo/> </root> and an XPathNavigator positioned
Given an input xml file with following structure: <root> <record row=1 col=1 val=1 />
Given the following XML 'template': <Request module=CRM call=list_service_features id={ID}> <block name=auth> <a name=username format=text>{USERNAME}</a>
Given the following xml document <root> <childnode0/> <childnode2/> <!--Comment1--> <childnode3/> <childnode4/> <!--Comment2--> </root> I
Given the following XML example we could imagine a schema defining Root as containing
Given the following XML: <root> <a> <b>Correct</b> </a> <a> <b>Correct</b> </a> <a> <b>Oh no!</b>
Given the following Xml fragment: <root> <sheetData> <row r=1 /> <row r=2 /> <row
Given the following XML, <root> <property> <programs> <program>1</program> <program>5</program> </programs> <tool> </tool> </property> <property>
Given the following XML: <cfsavecontent variable=xml> <root> <parent> <child>I'm the first</child> <child>Second</child> <child>3rd</child> </parent>
Lets assume a xml file named data.xml with following content: <root> <record> <id>1</id> <name>test

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.