#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    1
    Rep Power
    0

    Inserting Line Breaks in XSL?


    I'm developing an XSL to transform XML data into a text format. I need to force it to insert line breaks, but it's not working. No matter how many line breaks I insert it doesn't help.

    This would be between two tags. Is there a way to force XSLT to insert a line break between two tags without putting text in there?

    jb.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Dallas, Texas
    Posts
    138
    Rep Power
    11
    This will work for you:

    Code:
    <xsl:template match="Element" attr1="blah" attr2="blah">
       <xsl:value-of select="ChildA"/>
       <xsl:text><xsl:value-of select="ChildB"/><xsl:text> 
       <xsl:text><xsl:value-of select="ChildC_etc..."/><xsl:text>
    </xsl:template>
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    206
    Rep Power
    11
    I had the same problem and I found a solution.
    I don't know if it is the best but it works.
    I define a variable:
    Code:
    <xsl:variable name="newline">
    <xsl:text>
    </xsl:text>
    </xsl:variable>
    This variable you could you in your program.
    e.g.:
    Code:
    <xsl:value-of select="$newline"> <!-- line break in output file -->
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    191
    Rep Power
    49
    you can also use


    Code:
    <xsl:value-of select="concat(.,'&amp;#xA;')"/>
    Helmut Hagemann Germany

    fallen to the bottom of the facts?
    I reach my hand and we go together


    wer lesen und google kann ist klar im Vorteil
    who read and google is able is clear in the advantage
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0
    This seems most appropriate:
    Code:
    <xsl:text xml:space="preserve">
    </xsl:text>
    or
    Code:
    <xsl:text xml:space="preserve">& #10;</xsl:text>
    (without the space of course, but DevShed's forum engine doesn't allow me to show that)

IMN logo majestic logo threadwatch logo seochat tools logo