Solved

Removing empty lines in XSL

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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 …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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