Solved

How to create line break in xsl for text output?

Posted on 2009-07-07
5
2,053 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

815 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

8 Experts available now in Live!

Get 1:1 Help Now