xsl-list
[Top] [All Lists]

Re: [xsl] XPath expression which checks that a string is between 1 and 10 characters in length?

2016-07-26 06:58:48
On 26.07.2016 13:51, Costello, Roger L. costello(_at_)mitre(_dot_)org 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?


I don't know if

  string-length() = 1 to 10

is more efficient but it only calls string-length once.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>