[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Data types and xsl:sequence

Subject: [xsl] Data types and xsl:sequence
From: "Jim Neff" <jneff@xxxxxxxxxxxxxxx>
Date: Mon, 24 Jan 2005 16:17:41 -0500


I'm having trouble understanding data types and using the function

I have one common template that I call to create padding in my output

<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), '')"/>

So if I am padding for a text field, I pass in &#x20; 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 '&#x20;' 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.

Jim Neff

Current Thread