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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:17:13+00:00 2026-06-05T17:17:13+00:00

Trying to solve an issue for someone else and instead have run into my

  • 0

Trying to solve an issue for someone else and instead have run into my own odd issue which I am sure is simple yet the answer is eluding me!

The XML I have:

<xml>
  <head>
    <info>
      <content>
        <source attribute1="RSC1985s5c1" attribute2="6(17)">
          data1
        </source>
        <cite/>
        <case/>
        (
        <target attribute1="LRC1985s5c1" attribute2="6(17)1">
          3e/191
        </target>
        )
      </content>
      <content>
        <source attribute1="RSC1985s5c1" attribute2="6(17)">
          data2
        </source>
        <cite/>
        <case/>
        (
        <target attribute1="LRC1985s5c4" attribute2="6(17)1">
          4e/54
        </target>
        )
      </content>
    </info>
  </head>
</xml>

With XSLT to combine the two content elements:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="info">
    <xsl:copy>
      <xsl:element name="content">
        <xsl:for-each select="content">
          <xsl:apply-templates select="@*"/>
          <xsl:apply-templates select="node()"/>
        </xsl:for-each>
      </xsl:element>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

This creates:

<?xml version="1.0" encoding="utf-8"?><xml> //Just noticed here too!
  <head>
    <info><content> //Why no new line here?
        <source attribute1="RSC1985s5c1" attribute2="6(17)">
          data1
        </source>
        <cite />
        <case />
        (
        <target attribute1="LRC1985s5c1" attribute2="6(17)1">
          3e/191
        </target>
        )

        <source attribute1="RSC1985s5c1" attribute2="6(17)">
          data2
        </source>
        <cite />
        <case />
        (
        <target attribute1="LRC1985s5c4" attribute2="6(17)1">
          4e/54
        </target>
        )
      </content></info> //And again here?
  </head>
</xml>

The issue highlighted using commenting is what I cannot figure out, why there is no new line between the elements.

Thanks in advance.

  • 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-05T17:17:14+00:00Added an answer on June 5, 2026 at 5:17 pm

    With the provided transformation slightly modified:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
      <xsl:template match="node() | @*">
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
          <xsl:apply-templates select="node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="info">
        <xsl:copy>
          <xsl:element name="content">
            <xsl:for-each select="content">
              <xsl:apply-templates select="@*"/>
              <xsl:apply-templates select="node()"/>
            </xsl:for-each>
          </xsl:element>
        </xsl:copy>
      </xsl:template>
    </xsl:stylesheet>
    

    I get with Saxon 6.5.5 and a number of other XSLT 1.0 processors a well-indented output:

    <xml>
       <head>
          <info>
             <content>
                <source attribute1="RSC1985s5c1" attribute2="6(17)">
              data1
            </source>
                <cite/>
                <case/>
            (
            <target attribute1="LRC1985s5c1" attribute2="6(17)1">
              3e/191
            </target>
            )
          <source attribute1="RSC1985s5c1" attribute2="6(17)">
              data2
            </source>
                <cite/>
                <case/>
            (
            <target attribute1="LRC1985s5c4" attribute2="6(17)1">
              4e/54
            </target>
            )
          </content>
          </info>
       </head>
    </xml>
    

    Some XSLT processors may still produce unwanted-indentation — there is no strict standard in the W3C XSLT 1.0 recommendation how exactly indentation should be performed.

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

Sidebar

Related Questions

I am trying to solve an issue when using a Castle ActiveRecord TransactionScope which
I'm trying to solve an issue with makefile. I have a main.cpp and then
The issue I am trying to solve is that I have a folder with
for quite a while I have been trying to solve an issue with a
I have been trying to solve this issue for a day now and have
I have trying to solve an issue with my Spec tests and I get
I have run into an interesting issue using PHP's date() function. Haven't had any
I have a rather complicated issue that I am trying to solve in PHP
I'm trying to solve an issue where a script crashes with little-to-no error information
I've been trying to solve this issue for a long time, and nothing seems

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.