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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:36:10+00:00 2026-06-06T20:36:10+00:00

We have a legacy system that requires a format which is not html but

  • 0

We have a legacy system that requires a format which is not html but is close enough to be confusing. On our shiny front end website we have an instance of CKEditor that allows users to edit this a-bit-like-html-but-not-really format.

The big difference is that our format does not understand <p> tags. It expects new lines to be formatted with <br /> instead. CKEditor can be set to operate in BR mode but, perhaps unsurprisingly, this causes some annoying user interface bugs.

As an alternative, I’m considering allowing it to run in its default P mode and replacing the tags on the server with some XSLT. This is easy enough in the one direction:

Transforming:

<root>
<p>Test</p><p>Test</p><p>Test</p>
<p><b>Test</b></p>
</root>

With:

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>
<!-- Replace `[p]contents[/p]` with `contents[br /]` -->
<xsl:template match="p">
    <xsl:apply-templates/><br/>
</xsl:template>

Results in:

<root>Test<br/>Test<br/>Test<br/><b>Test</b><br/></root>

The question is, have I lost too much information to do the same process in reverse? And if not, what’s the best way of approaching this? Is XSLT even the right option?

  • 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-06T20:36:12+00:00Added an answer on June 6, 2026 at 8:36 pm

    How about:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:key name="k1"
      match="root/node()[not(self::br)]" 
      use="generate-id(following-sibling::br[1])"/>
    
    <xsl:template match="@* | node()">
      <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
    </xsl:template>
    
    <xsl:template match="root">
      <xsl:copy>
        <xsl:apply-templates select="br" mode="wrap"/>
      </xsl:copy>
    </xsl:template>
    
    <xsl:template match="br" mode="wrap">
      <p>
        <xsl:apply-templates select="key('k1', generate-id())"/>
      </p>
    </xsl:template>
    
    </xsl:stylesheet>
    

    With Saxon 6.5.5 that converts

    <root>Test<br/>Test<br/>Test<br/><b>Test</b><br/></root>
    

    into

    <root><p>Test</p><p>Test</p><p>Test</p><p><b>Test</b></p></root>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML document format from a legacy system that I have to
At my place of work we have a legacy document management system that for
I have a legacy Java (not my native language) app that I'm trying to
We have a legacy system that is essentially a glorified telnet interface. We cannot
I currently have a legacy system that uses SPs exclusively for access to the
I have a legacy system that produces XML with timestamps similar to ISO 8601,
I have some data files from a legacy system that I would like to
I've got a legacy system that I'm in the midst of refactoring. I have
I have A Legacy system that runs on a SQL Server 2005. Current table
I have the ability to query a legacy system that returns a .NET DataSet.

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.