xsl-list
[Top] [All Lists]

Re: [xsl] Typing variables

2012-09-18 04:09:51

As written, the type of the variable is a document node.

If you add an "as" clause, that changes the type. The type that would involve no conversion is a sequence of text nodes: text()+. However, if you specify xs:string+, that should force the conversion of the sequence of text nodes to a sequence of strings.

A sequence of text nodes doesn't always behave the same way as a sequence of strings. For example, xsl:value-of inserts a space between adjacent strings, but not between adjacent text nodes.

Michael Kay
Saxonica

On 18/09/2012 09:59, Ihe Onwuka wrote:
On Tue, Sep 18, 2012 at 9:50 AM, Andrew Welch 
<andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
        <xsl:variable name="val">"<xsl:sequence
select="replace(.,',',
...
If you type $val as xs:string+ you don't get the right result, if you
type it as xs:string it doesn't type check.
Thats because you have a text node (the ") then the xsl:sequence... so
you will always get a sequence of more than 1 item.

If you want to use xs:string, you need to make sure the contents of
the variable is sequence of 1 item.

Yes but my original question was what was the type of

<xsl:variable name="thing">"<xsl:value-of
select="replace(.,',',concat($quot,',',$quot))"/>"</xsl:variable> and
the value of the variable $quot is obvious.

precisely because xs:string+ (although it types checks) wasn't giving
the right result and omitting a type does.

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>