Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Removing empty lines in XSL

Posted on 2013-02-05
5
Medium Priority
?
201 Views
Last Modified: 2013-02-11
I have the following xsl code in using  <xsl:stylesheet version="1.1"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">



<xsl:template name="ABC">ABC|<xsl:value-of select="."/>|      
</xsl:template>


value is read in a GUI screen and stored usign above ABC.
The value read is used to form a segment in a message that would have
ABC|text entered

Problem is when the user enters no text and a carriage return because this eventually causes a problem in a gateway.

example:
Entered text1. <carriage return>
Carriage return.
Entered text2. <carriage return>

The result is:

ABC|Entered text1. <carriage return>
ABC|Carriage return.
ABC|Entered text2. <carriage return>

I would want the result to be:

ABC|Entered text1. <carriage return>
ABC|Entered text2. <carriage return>
0
Comment
Question by:Johannne1
  • 2
  • 2
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 38860859
make two templates

<xsl:template name="ABC[normalize-space(.)]">ABC|<xsl:value-of select="."/>|      
</xsl:template>
<xsl:template name="ABC[not(normalize-space(.))]"/>
0
 

Author Comment

by:Johannne1
ID: 38861301
Thanks Gertone. for the post. I will try out within 2 hours.
0
 

Author Comment

by:Johannne1
ID: 38862086
Hi Gertorne,
So far I could not get this to work. I will have to try again tomorrow evening.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 1200 total points
ID: 38863024
Ah, I see, for one reason or another you have named templates where I expected matching templates

Try this instead

    <xsl:template name="ABC">
        <xsl:if test="normalize-space(.)">
            <xsl:text>ABC|</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>|</xsl:text>
        </xsl:if>
    </xsl:template>
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

926 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