Re: [xsl] reading a document into a typed variable

Subject: Re: [xsl] reading a document into a typed variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 30 Sep 2009 16:52:42 +0100
> I don't understand the difference between two ways of loading an XML 
> file into a variable (see A and B below). Case A used to work with old 
> saxon 8.9, but with 9.2 only B is successful.

I would expect B to fail in the case that the file is not there 
(If you have defined $global.setup.file) as in A

you then have effectively

 <xsl:variable name="global.setup"
 as="document-node(element(global-setup))">
    <xsl:copy-of select="$global.setup.file"/>
</xsl:variable>

and the type xs:string doesn't match document-node()


(A) is similar but being a single xpath expression it is perhaps easier
for the system to statically detect the type might be string, not sure.

> If I omit the type declaration in A, the rest of the stylesheet is 
> nevertheless working correctly. So at a certain stage, what saxon sees 
> as a xs:sting is converted into a tree.

If you use xsl:variable with emlement content but no as attribute it
always makes a document node with children the content of the
xsl:variable so

<xsl:variable name="global.setup"/>
   <xsl:copy-of select="trace($global.setup.file,'Configuration 
 File $global.setup.file was not readable (missing or not valid)!')"/>
</xsl:variable>

makes global.setup into a document node with a single text node child,
so it macthes document-node() but not of course
document-node(element(global-setup))


David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread