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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:53:51+00:00 2026-06-18T09:53:51+00:00

I have some simple XML like this… <?xml version=1.0 encoding=UTF-8?> <root> <sentence> <word1>The</word1> <word2>cat</word2>

  • 0

I have some simple XML like this…

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <sentence>
        <word1>The</word1>
        <word2>cat</word2>
        <word3>sat</word3>
        <word4>on</word4>
        <word5>the</word5>
        <word6>mat</word6>
    </sentence>
    <sentence>
        <word1>The</word1>
        <word2>quick</word2>
        <word3>brown</word3>
        <word4>fox</word4>
        <word5>did</word5>
        <word6>nothing</word6>
    </sentence>
</root>

What I want to be able to do is process this with XSLT to create a sentence, like this
The~cat~sat~on~the~mat

(This is a simplified example of what I ultimately want to be able to do, this is just a stumbling block for now).

My XSLT looks like this;

<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output indent="no" />
    <xsl:template match="text()[not(string-length(normalize-space()))]"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="/">
        <xsl:text>&#xa;</xsl:text>
        <xsl:apply-templates />
     </xsl:template>  

    <xsl:template match="/root/sentence">
        <xsl:apply-templates />
        <xsl:text>&#xa;</xsl:text>
    </xsl:template>

    <xsl:template match="word1">
        <xsl:value-of select="text()" />
        ~
    </xsl:template>

    <xsl:template match="word2">
        <xsl:value-of select="text()" />
        ~
    </xsl:template>

    <xsl:template match="word3">
       <xsl:value-of select="text()" />
       ~
    </xsl:template>

    <xsl:template match="word4">
        <xsl:value-of select="text()" />
        ~
    </xsl:template>

    <xsl:template match="word5">
        <xsl:value-of select="text()" />
        ~
    </xsl:template>

    <xsl:template match="word6">
        <xsl:value-of select="text()" />
        ~
    </xsl:template>
</xsl:stylesheet>

If I run the stylesheet over the XML I get each word on a line of it s own, then a tilda on the next line, like this

<?xml version="1.0" encoding="UTF-8"?>
The
        ~
    cat
        ~
    sat
        ~
    on
        ~
    the
        ~
    mat
        ~

The
        ~
    quick
        ~
    brown
        ~
    fox
        ~
    did
        ~
    nothing
        ~

If I remove the tildas I get

Thecatsatonthemat

It looks to me then (and I am new to this XSLT stuff), that the inclusion of a tilda on a new line in the is forcing the new line.

So, how can I force the output from a template to all be on one line? (My final requirement is to do more formatting to the elements, and and spaces to pad elements out – I’ll come to that later).

Thanks in anticipation

  • 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-18T09:53:52+00:00Added an answer on June 18, 2026 at 9:53 am

    Change your ~ to <xsl:text>~</xsl:text>

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

Sidebar

Related Questions

So I have some xml file like this: <?xml version=1.0 encoding=ISO-8859-1?> <root result=0 >
I have a very simple XML datasource structured like this: <datasource> <row> <column>Some text
I have some simple XML which I would like to parse into an array
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
I am new to XML and have been trying some simple examples and they
I have some simple function in Flex in which I would like to send
I have an XML like this <filters extra=filters> <ISP_WebItem FILTER=Farve FILTERNAME=Sort UNITCODE=/> <ISP_WebItem FILTER=Længde
I have some simple data in XML format which I need to convert to

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.