[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Simple map and string-length(): unexpected behavio

Subject: Re: Simple map and string-length(): unexpected behavior?
From: "Elisa Beshero-Bondar ebbondar@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 8 Jun 2019 01:18:01 -0000
Re:  Simple map and string-length(): unexpected behavio
Ah! To answer our question according to the w3c XML Schema on datatypes:
the difference is that the zero-argument version of string-length() used in
the simple map operation casts the item to string() before taking its
string-length. When this happens, the lexical form is defined in a
canonicalized way (so that's why 005 gets measured as "5" with a
string-length of 1.

We are further enlightened. :-)
Elisa

On Fri, Jun 7, 2019 at 5:52 PM Elisa Beshero-Bondar ebbondar@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Dear XSL list,
>
> We are perplexed by a discrepancy between applying the string-length()
> function directly to a numerical argument and using simple map to perform
> what we expected would be the same operation. string-length(5) returns an
> error, as expected. oXygen reports: "XPath failed due to: Required item
> type of first argument of fn:string-length() is xs:string; supplied
> expression (5) has item type xs:integer". eXist-db reports: "xs-integer(5)
> is not a sub-type of xs-string".
>
> When we use simple map, though, the behavior is different:
>
> 5 ! string-length() returns a string-length of 1
>
> 05 ! string-length() returns a string-length of 2
>
> 0.5 ! string-length() returns a string-length of 3
>
> 00.5 ! string-length returns a string-length of 3
>
> 05 ! string-length() returns a string-length of 1
>
> Can someone please explain why simple-map does not raise the type error
> that we see when we write the numerical argument directly inside the
> function parentheses?
>
> Thanks for your help!
> Elisa
> --
> Elisa Beshero-Bondar, PhD
> Associate Professor of English
> University of Pittsburgh at Greensburg
> Humanities Division
> 150 Finoli Drive
> Greensburg, PA  15601  USA
> E-mail: ebb8@xxxxxxxx
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2631706> (by
> email <>)
>


-- 
Elisa Beshero-Bondar, PhD
Director, Center for the Digital Text | Associate Professor of English
University of Pittsburgh at Greensburg | Humanities Division
150 Finoli Drive
Greensburg, PA  15601  USA
E-mail: ebb8@xxxxxxxx <ebb8@xxxxxxxx>
Development site: http://newtfire.org

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.