If you have two adjacent strings in the sequence used to construct an
element node, a space will be inserted between them. So if you do this:
<a>
<xsl:sequence select="'aaa'"/>
<xsl:sequence select="'bbb'"/>
</a>
the result will be
<a>aaa bbb</a>
There are various ways you can avoid this effect, for example:
<a>
<xsl:sequence select="concat('aaa','bbb')"/>
</a>
<a>
<xsl:value-of separator="">
<xsl:sequence select="'aaa'"/>
<xsl:sequence select="'bbb'"/>
</xsl:value-of>
</a>
<a>
<xsl:value-of select="'aaa'"/>
<xsl:value-of select="'bbb'"/>
</a>
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Jim Neff [mailto:jneff(_at_)blockvision(_dot_)com]
Sent: 24 January 2005 21:18
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Data types and xsl:sequence
Greetings,
I'm having trouble understanding data types and using the function
xsl:sequence.
I have one common template that I call to create padding in my output
document:
<xsl:template name="pad-number">
<xsl:param name="max" />
<xsl:param name="char" />
<xsl:sequence select="string-join((for $i in 1 to
xs:integer($max) return
$char), '')"/>
</xsl:template>
So if I am padding for a text field, I pass in   for a
space and if
it's a numeric field I use '0'.
My problem is (and I know this sounds silly) whenever I
change from a text
to a numeric field there is an extra space inserted into the
xsl:sequence
output. This is a space and not the character I am passing into this
template. So, if I use a tilda '~' instead of ' ' I see the
appropriate number of tildas plus a space (hex code 20) in my output.
I do not have this problem when I am not changing from
numeric to text, or
if I have consecutive numerics or consecutive text fields.
Perhaps I am not using the $max variable correctly? I found
the only way to
get it to work is when I specify xs:integer around it because
the portion of
code that calls this template is performing a calculation and
I think the
processor (Saxon 8.something) is creating a mandotory
xs:double whenever a
calculation is performed.
This is probably a logic problem and has nothing to do with
XSLT syntax but
I just thought I'd throw this out here and maybe one of the
gurus on this
list could point me in the right direction.
Thanks,
Jim Neff
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--