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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:43:17+00:00 2026-06-01T03:43:17+00:00

I have a simple task that I can’t find a solution for, and I’m

  • 0

I have a simple task that I can’t find a solution for, and I’m new enough to xsl that I don’t how to go about it. I have a list of nodes, and at the first occurrence of the nodes I would like to print a header. E.g.:

xml excerpt

<data>
    <subdata1>value1.1</subdata1>
    <subdata2>value1.2</subdata2>
</data>
<data>
    <subdata1>value2.1</subdata1>
    <subdata2>value2.2</subdata2>
</data>
<data>
    <subdata1>value3.1</subdata1>
    <subdata2>value3.2</subdata2>
</data>

I would like the output to be something like:

Subdata1    Subdata2
value1.1    value2.1
value2.1    value2.2
value3.1    value2.3

There will be stuff before the first “data” node, so I don’t think I can just print it out ahead of time. I was thinking of an if statement with a flag that would be set the first time it finds data, but my implementation wasn’t working. Any ideas on how to do this?

Thanks!

  • 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-06-01T03:43:18+00:00Added an answer on June 1, 2026 at 3:43 am

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="data[1]">
      <xsl:text>subdata1&#9;subdata2</xsl:text>
      <xsl:apply-templates select="../data" mode="process"/>
     </xsl:template>
    
     <xsl:template match="data" mode="process">
      <xsl:value-of select="concat('&#xA;', subdata1, '&#9;',subdata2)"/>
     </xsl:template>
    
     <xsl:template match="data"/>
    </xsl:stylesheet>
    

    when applied on the following XML document (the provided XML fragment, wrapped into a single top element to become a well-formed XML document):

    <t>
        <data>
            <subdata1>value1.1</subdata1>
            <subdata2>value1.2</subdata2>
        </data>
        <data>
            <subdata1>value2.1</subdata1>
            <subdata2>value2.2</subdata2>
        </data>
        <data>
            <subdata1>value3.1</subdata1>
            <subdata2>value3.2</subdata2>
        </data>
    </t>
    

    produces the wanted, correct result:

    subdata1    subdata2
    value1.1    value1.2
    value2.1    value2.2
    value3.1    value3.2
    

    Explanation: Appropriate use of templates and modes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple task, but I cannot find any solution. I have
I have a simple web control (TaskList) that can have children (Task) which inherit
I am surprised that I can't find the answer to this simple task. I
I know zero javascript, and have one simple task: Find all text in the
I have no idea how to do this simple task. LightSwitch's Solution Explorer is
I'm trying to do a simple task with jQuery: I have a list of
I have this simple Ant task that lists all '.png' files in a folder:
I have a simple task of adding a paragraph that has some formatted text
It's very simple task, but somewhere is a mistake.. I can't find out it.
This is a simple question, and a seemingly simple task but I can't find

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.