Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Georges Schmitz <georges.schmitz@------.-->
To: xsl-list@-----.------------.---
Date: 10/2/2009 3:29:00 PM
Thank you for your explanation. So if ever any other XSLT2 
implementation will see the light of day, one could wait for that 
implementation to behave differently again, because of the maturity of 
type-checking?! I just expected type-checking at run-time, that's why I 
had no clue about what was going on.

Michael Kay wrote:
>> 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. With A I get following error message:
>>
>>   XTTE0570: Required item type of value of variable $global.setup is
>>   document-node(element(global-setup, xs:anyType)); supplied 
>> value has item type xs:string
>>     
>
> Saxon's type checking has improved between the two releases. Saxon 9.2
> recognizes at compile time that if $global.setup.file is a string, then
> trace($global-setup-file, x) will also be a string, and that this is
> inconsistent with your declared type, which is document-node(). In earlier
> releases this error would only have been detected at run-time, and only if
> this branch of the if-then-else were selected. But Saxon's static
> type-checking is not yet perfect: it seems it is failing to spot that if
> trace($global-setup-file, x) is a string, then <xsl:copy-of
> select="trace($global-setup-file, x)"/> will also be a string, and this is
> why you get no compile-time error message for case B. I'll take a look at
> this and try to improve it for the next release.
>   

Well, as I stated in a former mail, I probably reported a wrong 
"observation" here. In fact I could not reproduce case B to work with 
saxon 9.2 :-[ .

> What you really want is to remove the error, of course, and to do that you
> need to ensure that the exception branch of your conditional delivers a
> result that is consistent with the type declaration of the variable.
>
>   

I solved it by a sort of a 2 stage loading

    <xsl:variable name="global.setup.doc"
                        select="if (doc-available($global.setup.file))
                                    then document($global.setup.file)
                                    else
    trace($global.setup.file,'Configuration File $global.setup.filewas
    not readable (missing or not valid)!')" />

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


and then I get:

    Configuration File $global.setup.file.fixed was not readable
    (missing or not valid)! [1]: xs:string:
    ../../xml-resolved/GlobalSetup-resolved.xmlx
    Error on line 57 of profile-filter.xsl:
      XTTE0570: Required item type of value of variable $global.setup is
      document-node(element(global-setup, xs:anyType)); supplied value
    has item type xs:string

which is perfect for me. I have to rely on this "verbosity" in case a 
path or filename setting is wrong because this stylesheet is reused by a 
lot of other stylesheets in a build environment.

Kind regards,
Georges
**********************************************************************************************
IMPORTANT NOTICE / WICHTIGER HINWEIS
This communication contains information which is confidential and may also be privileged. It is for the 
exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any 
distribution, copying or use of this communication or the information in it is strictly prohibited. If you have 
received this communication in error please notify us immediately by email or by telephone and then delete 
this 
email and any copies of it.
Diese E-Mail koennte vertrauliche und/oder rechtlich geschuetzte Informationen enthalten. Wenn Sie nicht 
der richtige Adressat sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den 
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser 
Mail sind nicht gestattet.

HEITEC AG, Werner-von-Siemens-Str. 61, 91052 Erlangen, HRB 7754, RG Fuerth, Vorstandsvorsitzender: 
Richard Heindl, Vorstand: Harald Preiml, Finanzvorstand: Rene-Oliver Rosner, Aufsichtsratsvorsitzender: Dr. 
Lorenz M. Raith, WWW: http://www.heitec.de


--~------------------------------------------------------------------
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@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent