Jump to content

preserve paragraphs


layton
 Share

Recommended Posts

How would I go about preserving paragraphs or line breaks? I can't always control the information contained within an xml node. If somebody inputs two paragraphs in a text node, it would be good to treat it as two paragraphs and not one big one.I've tried wrapping the content in CDATA and using display-output-escaping="yes" but that isn't supported by firefox and I'm looking for a cross-browser solution.I understand that doing server-side transformations may be a good way to go, but unfortunately I don't have access to a dynamic environment. Anything that I do has to be client-side.I don't think the kind of text is really out of scope for xml and there has to be a way of achieving this.Any thoughts would be appreciated.

Link to comment
Share on other sites

I'm not sure I'm seeing the problem. You're having an XML input that may look like

<tag>One paragraphand a line brekAnother paragraphand another line brek</tag>

Right?And you're outputting XHTML I guess?Aren't you essentially asking how to preserve line breaks in XHTML? Is using the <pre> element acceptable?

Link to comment
Share on other sites

  • 1 month later...
Guest printzlau
How would I go about preserving paragraphs or line breaks? I can't always control the information contained within an xml node. If somebody inputs two paragraphs in a text node, it would be good to treat it as two paragraphs and not one big one.
I've done the following with succes:xml-file:
...<text>  <p>first</p>  <p>second</p></text>...

xsl-file:

...<xsl:for-each select="text/p">  <xsl:copy-of select="." /></xsl:for-each>...

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...