Solved

Removing empty lines in XSL

Posted on 2013-02-05
5
190 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
Comment Utility
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
Comment Utility
Thanks Gertone. for the post. I will try out within 2 hours.
0
 

Author Comment

by:Johannne1
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
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.

743 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