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

The Archive Base Latest Questions

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

I’m trying to create a positional file out of an XML. I created the

  • 0

I’m trying to create a positional file out of an XML. I created the XSLT and work fine unless the field is filled with spaces. In that case the XSL returns only one space. I’m using MSXML (6.0).

I have tried the following with no luck:

<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="*"/>

<fo:block white-space-collapse="false" white-space-treatment="preserve" >
    <!-- Code here -->
</fo:block>

Here is the XML input, the XSLT and the output.

<Document>
      <Header>
        <Title>Long life to the queen   </Title>
        <Author>Sam Catnip     </Author>
        <Year>1996</Year>
        <Edition>  1</Edition>
        <Price>          12.99</Price>
        <Pages>    1244</Pages>
        <AuthorNotes>                    </AuthorNotes>
        <Abstract>It is a great book  </Abstract>
    </Header>
      <Header>
        <Title>Life and live longer     </Title>
        <Author>Bill Griffin   </Author>
        <Year>2001</Year>
        <Edition>  1</Edition>
        <Price>           2.99</Price>
        <Pages>      44</Pages>
        <AuthorNotes>Yeah, right         </AuthorNotes>
        <Abstract>Wishfull thinking    </Abstract>
    </Header>
</Document>

XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:output method="text"/>
    <xsl:template match="//Document">
        <xsl:for-each select="./Header">
            <xsl:value-of select="./Title"/>
            <xsl:value-of select="./Author"/>
            <xsl:value-of select="./Year"/>
            <xsl:value-of select="./Edition"/>
            <xsl:value-of select="./Price"/>        
            <xsl:value-of select="./Pages"/>
            <xsl:value-of select="./AuthorNotes"/>
            <xsl:value-of select="./Abstract"/>
            <xsl:text>&#13;&#10;</xsl:text>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Output:

Long life to the queen   Sam Catnip     1996  1          12.99    1244It is a great book  
Life and live longer     Bill Griffin   2001  1           2.99      44Yeah, right         Wishfull thinking    

When it should be:

Long life to the queen   Sam Catnip     1996  1          12.99    1244                    It is a great book  
Life and live longer     Bill Griffin   2001  1           2.99      44Yeah, right         Wishfull thinking    

I will really appreciate any idea on how to solve this.

Thanks,

Arty

  • 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-23T23:28:26+00:00Added an answer on May 23, 2026 at 11:28 pm

    Even if you XSLT contains an instruction to preserve the whitespace, it might not have been preserved when your input XML document was parsed before being passed to your XSLT.

    You didn’t specify what language/platform or anything you’re using, so it’s difficult to offer a specific solution, but I know in C# if you read an XML document like this:

    string xmlSource = @"<Document>etc..</Document>";
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xmlSource);
    

    It will already have treated any elements with just space as empty elements, and doc already has that space stripped out before you even try applying a stylesheet.

    In C#, you need to do this:

    XmlDocument doc = new XmlDocument { PreserveWhitespace = true };
    

    when you instantiate it before even loading it. If you’re using a different platform, you’ll need to research how your platform does this.

    A more general solution (albeit a tad cumbersome) is to modify your input XML like this:

    ...
      <AuthorNotes xml:space="preserve">                    </AuthorNotes>
    ...
    

    I think you can apply this to the root element, but I’m not 100% certain of that.

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

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I'm parsing an XML file, the creators of it stuck in a bunch social
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.