1

Topic: Gaps before <xsl:value-of select = ""/>

Good afternoon!
Prompt, please, how it is possible to avoid gaps before value of an element - &lt;xsl:value-of select = ""/&gt;?
It is necessary to avoid here it (1/5), should be - (1/5)

&lt;xsl:if test = "znam_avg! =999999"&gt;
&lt;td&gt; &lt;xsl:value-of select = "val_avg"/&gt;
&lt;xsl:if test = "flag_minus =-1"&gt; (-1 / &lt;xsl:value-of select = "znam_avg"/&gt;) &lt;/xsl:if&gt;
&lt;xsl:if test = "flag_minus=1"&gt; (1 / &lt;xsl:value-of select = "znam_avg"/&gt;) &lt;/xsl:if&gt;
&lt;/td&gt;
&lt;/xsl:if&gt;

Example turned out lists on a screen.
Thanks!

2

Re: Gaps before <xsl:value-of select = ""/>

&lt;? xml version = "1.0" encoding = "utf-8"?&gt;
&lt;root&gt;
&lt;item
znam_avg = "123"
val_avg = "456"
flag_minus = "-1"/&gt;
&lt;item
znam_avg = "789"
val_avg = "abc"
flag_minus = "1"/&gt;
&lt;/root&gt;
&lt;? xml version = "1.0" encoding = "utf-8"?&gt;
&lt;xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"&gt;
&lt;xsl:output method = "xml"/&gt;
&lt;xsl:template match = "/root"&gt;
&lt;root&gt;
&lt;xsl:for-each select = "item"&gt;
&lt;xsl:if test = "znam_avg! =999999"&gt;
&lt;td&gt;
&lt;xsl:value-of select = "val_avg"/&gt;
&lt;xsl:if test = "flag_minus =-1"&gt;
&lt;xsl:value-of select = "' (-1 / '"/&gt;
&lt;xsl:call-template name = "left-trim"&gt;
&lt;xsl:with-param name = "string" select = "znam_avg"/&gt;
&lt;/xsl:call-template&gt;
&lt;xsl:value-of select = "') '"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test = "flag_minus=1"&gt;
&lt;xsl:value-of select = "' (1 / '"/&gt;
&lt;xsl:call-template name = "left-trim"&gt;
&lt;xsl:with-param name = "string" select = "znam_avg"/&gt;
&lt;/xsl:call-template&gt;
&lt;xsl:value-of select = "') '"/&gt;
&lt;/xsl:if&gt;
&lt;/td&gt;
&lt;/xsl:if&gt;
&lt;/xsl:for-each&gt;
&lt;/root&gt;
&lt;/xsl:template&gt;
&lt;! - trim-left recursive template-&gt;
&lt;xsl:template name = "left-trim"&gt;
&lt;xsl:param name = "string" select = """/&gt;
&lt;xsl:variable name = "tmp" select = "substring ($string, 1, 1)"/&gt;
&lt;xsl:choose&gt;
&lt;xsl:when test = "$ tmp = ' ' or $tmp = ' &#xA; '"&gt;
&lt;xsl:call-template name = "left-trim"&gt;
&lt;xsl:with-param name = "string" select = "substring-after ($string, $tmp)"/&gt;
&lt;/xsl:call-template&gt;
&lt;/xsl:when&gt;
&lt;xsl:otherwise&gt;
&lt;xsl:value-of select = "$ string"/&gt;
&lt;/xsl:otherwise&gt;
&lt;/xsl:choose&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
&lt;? xml version = "1.0" encoding = "utf-8"?&gt;
&lt;root&gt;
&lt;td&gt; 456 (-1/123) &lt;/td&gt;
&lt;td&gt; abc (1/789) &lt;/td&gt;
&lt;/root&gt;

3

Re: Gaps before <xsl:value-of select = ""/>

Very Pavlovny dream, thanks!!!

4

Re: Gaps before <xsl:value-of select = ""/>

&lt;xsl:if test = "flag_minus =-1"&gt;
&lt;xsl:value-of select = "concat (' (-1 / ', @znam_avg, ') '")/&gt;
&lt;/xsl:if&gt;

5

Re: Gaps before <xsl:value-of select = ""/>

_Vasilisk _;

&lt;? xml version = "1.0" encoding = "windows-1251"?&gt;
&lt;xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"&gt;
&lt;xsl:output method = "xml"/&gt;
&lt;xsl:template match = "/root"&gt;
&lt;root&gt;
&lt;xsl:for-each select = "item"&gt;
&lt;xsl:if test = "znam_avg! =999999"&gt;
&lt;td&gt;
&lt;xsl:value-of select = "val_avg"/&gt;
&lt;xsl:if test = "flag_minus =-1"&gt;
&lt;xsl:value-of select = "concat (' (-1 / ', @znam_avg, ') ')"/&gt;
&lt;/xsl:if&gt;
&lt;xsl:if test = "flag_minus=1"&gt;
&lt;xsl:value-of select = "concat (' (1 / ', @znam_avg, ') ')"/&gt;
&lt;/xsl:if&gt;
&lt;/td&gt;
&lt;/xsl:if&gt;
&lt;/xsl:for-each&gt;
&lt;/root&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
&lt;? xml version = "1.0" encoding = "utf-8"?&gt;
&lt;root&gt;
&lt;td&gt; 456 (-1/123) &lt;/td&gt;
&lt;td&gt; abc (1/789) &lt;/td&gt;
&lt;/root&gt;

Initial xml as in my previous posting, checked on  XslCompiledTransform.

6

Re: Gaps before <xsl:value-of select = ""/>

Very Pavlovny dream;
You are certainly right. But I recognized that in most XML gaps was not present, and they appear only at transformation.

7

Re: Gaps before <xsl:value-of select = ""/>

_Vasilisk _;
Thanks!!! That is necessary!