SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formating pragraphs in XML

    Does anyone here know how to preserve pragraphs in XML and XSL?

    For example, if I have the following XML node:

    Code:
    <body_text>This is my body text. I would like it to be formatted so that all pargraphs are visible when the document is transformed in xhtml.
    
    New pargraph here.</body_text>
    How do I style my XSL template so that the break between xhtml. and New is visible in the final page???

  2. #2
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Hi,

    You may have better luck asking this in the XML section.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not going to be easy without any markup to trigger.

    If you use <xsl:preserve-space elements="body_text"/> you might be able to use string functions to split the string at each line-feed and insert <p> tags, but it's hackish.
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Addict
    Join Date
    Jun 2004
    Location
    UK, London
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The visible in the final page is the issue. HTML linebreaks are not rendered in the output unless the output is wrapped in a PRE tag.

    So, to turn this into HTML linebreaks, you'd need to replace the linebreak character with a BR.

    Examples here:
    http://www.dpawson.co.uk/xsl/sect2/replace.html
    Chris Heilmann
    Blog | Articles | Binaries

  5. #5
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by codepoet
    The visible in the final page is the issue. HTML linebreaks are not rendered in the output unless the output is wrapped in a PRE tag.

    So, to turn this into HTML linebreaks, you'd need to replace the linebreak character with a BR.

    Examples here:
    http://www.dpawson.co.uk/xsl/sect2/replace.html
    Thanks guys, sorry about posting in the wrong forum, I couldn't find an XML section. Could I do it with <p> and </p> tags?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •