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

The Archive Base Latest Questions

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

Not too sure how I should properly describe the issue, but what I’m facing

  • 0

Not too sure how I should properly describe the issue, but what I’m facing is the following. I have quite some whitespace content in files that was originally html. I want to remove this and the easiest way to deal with this is using an identity template and add the following

    <xsl:template match="text()">
    <xsl:value-of select="normalize-space(.)"/>
</xsl:template>

Works fine, but a bit too well. Assume following example :

<p>    some content with whitespaces and a <a href="some_link">link</a> and some <strong>text</strong>

If I use the identity template my result of course
looks like

 <p>some content with whitespaces and a<a href="some_link">link</a>and some<strong>text</strong>

but I’d like to preserve the whitespace in front of my a and strong tags (or basically any tag within a ‘final’ string. Since these content can be in quite some tags (divs, anchors, whatever) building exceptions might work but would become pretty complex as I would need to have a template-match loop for all tags that can live inside another one and add spaces again after initial cleanup.

Any easier way to approach this ?

Thanks in advance again !

  • 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-29T12:06:51+00:00Added an answer on May 29, 2026 at 12:06 pm

    Perhaps

    <xsl:template match="text()">
      <xsl:value-of select="concat(
        if (starts-with(., ' ') and preceding-sibling::node()[1][self::*]) then ' ' else '',
        normalize-space(.),
        if (ends-with(., ' ') and following-sibling::node()[1][self::*]) then ' ' else '')"/>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not too sure what's going on here but I'm trying to echo a
I'm just not too sure the proper way of doing this. I basically have
I was reading the doc, but I am still not too sure. Its says
I just got a site to manage, but am not too sure about the
I'm not too sure what is going on here, but sometimes a particular file
Not too sure what's going on here as this doesn't seem like standard practise
Not too sure how to formulate my question and I hope that this is
Not too sure if I'm doing this right. It looks a bit more convoluted
At the moment I not too sure where my problem is. I can draw
Not really too sure how to word this question, therefore if you don't particularly

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.