[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    Re: [xsl] Typing Variable as AnyURI - Problem
From:       Michael Kay <mike () saxonica ! com>
Date:       2012-09-13 8:16:57
Message-ID: 50519679.3020006 () saxonica ! com
[Download RAW message or body]


On 13/09/2012 08:47, Ihe Onwuka wrote:
> On Thu, Sep 13, 2012 at 8:31 AM, Michael Kay <mike@saxonica.com> wrote:
>> Your call to xsl:apply-templates is returning a sequence of text nodes. A
>> sequence of text nodes is not a string (nor is an xs:anyURI), and it cannot
>> be converted to a string by calling the string() or xs:anyURI() functions.
>>
> Yes, but what threw me off the scent is that  casting the variable to
> xs:anyURI as in the code example I posted worked.
>
> So whats the difference between what goes when the variable is cast as
> xs:anyURI and what goes on when the variable is typed xs:anyURI
>
>
When an xsl:variable element has content but no "as" attribute, the 
value of the variable will be a document node acting as the root of a 
temporary tree (in 1.0 it was called a "result tree fragment"). A 
document node can be constructed from a sequence of text nodes: they are 
concatenated to form a single child node for the document node. When you 
cast a document node to an atomic type, the first thing that happens is 
that the document node is atomized, which takes the string value as an 
instance of xs:untypedAtomic; the string value of a document node is the 
concatenation of all its descendant text nodes. This xs:untypedAtomic 
value can then be cast to xs:anyURI.

When an xsl:variable element has content and specifies as="xs:anyURI", 
then the system takes the result of evaluating the content, which in 
your case is a sequence of text nodes, and uses the "function conversion 
rules" to attempt to convert this to the required type. The conversions 
allowed by the function conversion rules are weaker than the casting 
rules, but even if the casting rules were used here, casting a sequence 
of text nodes to an xs:anyURI would not work.

Michael Kay
Saxonica

--~------------------------------------------------------------------
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@lists.mulberrytech.com>
--~--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic