Solved

How to create line break in xsl for text output?

Posted on 2009-07-07
5
2,050 Views
Last Modified: 2013-11-18
I want to know how to insert a line breaks in the below xsl template:

the required output format is like this:
ORDER=text|text|text
ACCOUNT=text|text|text etc....
EXTRA=text|text|text
LINE=ORDER=text|text|text
LINE=ORDER=text|text|text


------------------------------------------------------
Current format shows up like this:
ORDER=text|text|text ACCOUNT=ORDER=text|text|textEXTRA=text|text|textLINE=ORDER=text|text|textLINE=ORDER=text|text|text

Any assistance on this would be great.

<files>

        <file active="true" ftp="true" ftpdelete="true" ftppath="/webspace/httpdocs/osexp/" filename="OS%realorderid%.leo" path="/export">

            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">

<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes" media-type="text/plain" omit-xml-declaration="yes"/>

 

       

            <xsl:template match="/">

              <xsl:for-each select="orders/order">

                <xsl:text>ACCOUNT=</xsl:text><xsl:value-of select="customer_group_code"/>

				

<xsl:text>

</xsl:text>

<xsl:text>ORDER=</xsl:text><xsl:value-of select="po_number"/><xsl:text>|</xsl:text><xsl:value-of select="created_at"/><xsl:text>|</xsl:text><xsl:text>OS</xsl:text><xsl:value-of select="increment_id"/><xsl:text>ADDRESS</xsl:text><xsl:value-of select="shipping/company"/><xsl:text>|</xsl:text><xsl:value-of select="shipping/street1"/><xsl:text>|</xsl:text><xsl:value-of select="shipping/street2"/><xsl:text>|</xsl:text><xsl:value-of select="shipping/city"/><xsl:text>|</xsl:text><xsl:value-of select="shipping/postcode"/><xsl:text>|</xsl:text><xsl:value-of select="shipping/telephone"/><xsl:text>|</xsl:text><xsl:value-of select="shipping/country_id"/><xsl:text>EXTRA=</xsl:text><xsl:value-of select="shipping/firstname"/><xsl:value-of select="shipping/lastname"/><xsl:text>|</xsl:text><xsl:value-of select="customer_email"/><xsl:for-each select="items/item"><xsl:text>LINE=</xsl:text><xsl:value-of select="qty_ordered"/><xsl:text>|</xsl:text><xsl:text>2500</xsl:text><xsl:text>|</xsl:text><xsl:value-of select="sku"/><xsl:text>|</xsl:text><xsl:value-of select="name"/><xsl:text>|</xsl:text><xsl:text>|</xsl:text><xsl:text>|</xsl:text><xsl:value-of select="price"/>

                </xsl:for-each>

<xsl:text>LINE=</xsl:text><xsl:text>1</xsl:text><xsl:text>|</xsl:text><xsl:text>1</xsl:text><xsl:text>|</xsl:text><xsl:text>KFIRELAND</xsl:text><xsl:text>|</xsl:text><xsl:text>DHL Shipping</xsl:text><xsl:text>|</xsl:text><xsl:text>|</xsl:text><xsl:text>|</xsl:text><xsl:value-of select="base_shipping_amount"/>

              </xsl:for-each>

            </xsl:template>

          </xsl:stylesheet>

        </file>

      </files>

Open in new window

0
Comment
Question by:DavidO84
  • 3
  • 2
5 Comments
 

Author Comment

by:DavidO84
ID: 24799345
I did attempt a line break using:
<xsl:text>
</xsl:text>

but no joy...
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 24799359
<xsl:text>&#10;</xsl:text>
or
<xsl:text>&#13;&#10;</xsl:text>


<xsl:text>
</xsl:text>
should work as well, but maybe your XSLT gets processed one way or another before parsing, my suggestions are safer
0
 

Author Closing Comment

by:DavidO84
ID: 31600879
Excellent Gertone  worked a perfectly! I know it might be simple to you but this was a complete answer for someone who is a novice in regard to xslt creation. Thanks again!
0
 

Author Comment

by:DavidO84
ID: 24799599
Also just to note the i was using <xsl:text>&#13;</xsl:text> but as you mention the XSLT may go true some processing that I have overlook...anyhow the second solution <xsl:text>&#13;&#10;</xsl:text> solved my problem.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24800914
welcome
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now