[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath expression which checks that a string is be
Not true for the empty string Sent from my iPhone > On Jul 26, 2016, at 5:01 AM, Wolfgang Laun wolfgang.laun@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Just for fun: > > string-length() idiv 2 le 5 > > Optimization by obfuscation. Phooey. > -W > >> On 26 July 2016 at 13:55, Martin Honnen martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: >> On 26.07.2016 13:51, Costello, Roger L. costello@xxxxxxxxx wrote: >> >>> I need an XPath expression which returns true if the string in <A> is between 1 and 10 characters in length, and false otherwise. >>> >>> For example, the XPath expression should return true on this XML: >>> >>> <A>hi</A> >>> >>> Here's an inefficient XPath expression: >>> >>> (string-length(.) gt 0) and (string-length(.) le 10) >>> >>> It's inefficient because it computes the string length twice. >>> >>> Is there a more efficient XPath expression to solve this problem? >> >> Well, in XPath 3 you can use >> >> let $l := string-length() >> return ($l gt 0 and $l le 10) > > XSL-List info and archive > EasyUnsubscribe (by email)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|