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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:11:39+00:00 2026-05-17T02:11:39+00:00

I am creating some xsl to transform my xml into text (which will be

  • 0

I am creating some xsl to transform my xml into text (which will be csv eventually). I am using VS2008. When I use the editor to create the xsl, the transformed output is indented as per my xsl. However, if I edit the xsl and remove the formatted whitespaces it outputs correctly – but doing it like this is a nightmare to work with.

Is there some xsl pre-processor commands or markup I can put in to prevent this? I want to ignore any whitespace in my xsl and only output text using <!CDATA[]]> or <xsl:text>.

My XSL is as below – this indents the output

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="text" indent="no"/>
  <!-- @* is all class attributes -->
  <xsl:template match="/">
    <xsl:text>CSV Output</xsl:text>
    <!-- Start of output -->
    <xsl:for-each select="//rows/row">
      <![CDATA[row id=]]><xsl:value-of select="(@id)"/>
    </xsl:for-each>
    <!-- OK, that is the end of the file -->
    <![CDATA[<EOF>]]>
  </xsl:template>
</xsl:stylesheet>

The output of this is as follows:

CSV Output
      row id=0
      row id=1
    <EOF>

However, the following outputs correctly:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="text" indent="no"/>
  <!-- @* is all class attributes -->
  <xsl:template match="/">
    <xsl:text>CSV Output</xsl:text>
    <!-- Start of output -->
    <xsl:for-each select="//rows/row">
<![CDATA[row id=]]><xsl:value-of select="(@id)"/>
</xsl:for-each>
<!-- OK, that is the end of the file -->
<![CDATA[<EOF>]]>
  </xsl:template>
</xsl:stylesheet>

This is output correctly as follows:

CSV Output
row id=0
row id=1
<EOF>

I also want to control where a new line is included. In my xsl I am not telling it to include one.

Please help!!

Thanks,

Andez

  • 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-17T02:11:39+00:00Added an answer on May 17, 2026 at 2:11 am

    The XSLT processor strips white-space text nodes in the template only between XSLT elements.

    So, in

    <xsl:for-each select="//rows/row"> 
      <![CDATA[row id=]]><xsl:value-of select="(@id)"/> 
    </xsl:for-each>
    

    the xsl:for-each element has two white-space text child nodes: One after xsl:value-of, which is stripped; the other before the CDATA section, which is not stripped.

    Bottom line: Use xsl:text elements.

    <xsl:for-each select="//rows/row"> 
      <xsl:text><![CDATA[row id=]]></xsl:text>
      <xsl:value-of select="@id"/> 
    </xsl:for-each>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could use some help creating an XSL template that will take a string
I am working on creating an XSL to format some incoming XML from an
I'm creating some flash game using Adobe AIR. I try to compile it into
I'm creating some basic OO scripts using MySQLi and getting an Undefined Method error
I am creating some PDF reports using iText in Java. According to the requirements,
after creating some menus with simple_list_item_1 (which worked very fine) I tried to replace
I'm creating some images of text in code that need to reflect a CSS
I'm currently creating some sliders in Javascript, for use with touch, and the results
I am creating some images using the canvas. I would like to be able
I'm creating some dialogs using TkInter and need to be able to open a

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.