Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Removing empty lines in XSL

Posted on 2013-02-05
5
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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 …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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