Solved

Removing empty lines in XSL

Posted on 2013-02-05
5
191 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 300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

11 Experts available now in Live!

Get 1:1 Help Now