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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:29:06+00:00 2026-05-15T05:29:06+00:00

I have a xml document on the following format and want to transform it

  • 0

I have a xml document on the following format and want to transform it using a xsl template.

I’m a beginner at xsl transformations and I only need to know how to recurse trough the tree but a solution to the whole problem would be nice.

This is the xml document:

<?xml version="1.0" encoding="UTF-8" ?>
<nodes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <node>
        <type>Parent</type>
        <name>.test</name>
        <node>
            <type>parent</type>
            <name>.test.root</name>
            <node>
                <type>Parent</type>
                <name>.test.root.group</name>
                <node>
                    <type>int</type>
                    <name>.test.root.group.a</name>
                    <value>0</value>
                </node>
                <node>
                    <type>char</type>
                    <name>.test.root.group.b</name>
                    <value>-</value>
                </node>
            </node>
        </node>
        <node>
            <type>parent</type>
            <name>.test.versions</name>
            <node>
                <type>utf-8</type>
                <name>.test.versions.version</name>
                <value>alpha</value>
            </node>
            <node>
                <type>utf-8</type>
                <name>.test.version.extra</name>
                <value>16.5</value>
            </node>
        </node>
    </node>
</nodes>

And this is how I would like the produced html to look like:

    .---------------------------------------------.
    | tree                   | value     | type   |
    |------------------------+-----------+--------|
    | '- test                |           | parent |
    |    |- root             |           | parent |
    |    |  '- group         |           | parent |
    |    |     |- a          | 0         | int    |
    |    |     '- b          | -         | char   |
    |    '- versions         |           | parent |
    |       |- version       | "alpha"   | utf-8  |
    |       '- extra         | 16.5      | utf-8  |
    '---------------------------------------------'
  • 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-15T05:29:06+00:00Added an answer on May 15, 2026 at 5:29 am

    This XSLT will generate a tree like you want:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text" indent="yes"/>
    
      <xsl:template match="/">
        <xsl:apply-templates select="nodes/node">
          <xsl:with-param name="indent" select="''" />
          <xsl:with-param name="parent" select="''" />
        </xsl:apply-templates>
      </xsl:template>
    
      <xsl:template match="node">
        <xsl:param name="indent"/>
        <xsl:param name="parent"/>
    
        <xsl:value-of select="$indent" />
        <xsl:value-of select="substring-after(name/text(), $parent)" />
        <xsl:text>&#xa;</xsl:text>
    
        <xsl:apply-templates select="./node">
          <xsl:with-param name="indent" select="concat($indent, '    |')" />
          <xsl:with-param name="parent" select="name/text()" />
        </xsl:apply-templates>
    
      </xsl:template>
    
    </xsl:stylesheet>
    

    Adding data to next two columns is pretty simple, try to do it by yourself.

    • 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 document that I have to parse using python's minidom:
Suppose I have the following XML Document. <reply success=true>More nodes go here</reply> How to
I have the following Code to display Data from the Database in XML Document
I have the following in my XSL which adds a xmlns to my XML.
I have an XmlDocument object and xml in the format: <?xml version=1.0 encoding=utf-8?> <S
I want to write a stored procedure that queries XML files after I have
I have the following method that I use to serialize various objects to XML.
I am parsing an XML document. I have done this thousands of times before,
I have an array of Car objects and using the following piece of code
Update There is no ready XML parser in Java community which can do NIO

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.