On 23.02.2017 13:49, Rick Quatro rick(_at_)rickquatro(_dot_)com wrote:
I have an attribute value that I want to convert to a sequence of decimals:
@colwidth="0.439in 1.845in"
I am using tokenize to drop the measurement units before I convert each
member to decimal:
tokenize($widths,'[^\.\d]')
This works, except I get a empty string as the last item in the list. I saw
in Michael's book that I can filter out the empty member with a predicate:
tokenize($widths,'[^\.\d]')[.]
I can't quite understand how the predicate [.] works. Is it like saying
"non-empty strings"? Would it be equivalent to
[not(.="")]
tokenize returns a sequence of strings and then then the predicate [.]
applied to the sequence of strings checks the boolean value of each
string and empty strings, when converted to a boolean, are false while
non-empty strings are true.
If you check https://www.w3.org/TR/xpath-30/#id-filter-expression then
it says
The predicate truth value is derived by applying the following rules, in
order:
If the value of the predicate expression is a singleton atomic
value of a numeric type or derived from a numeric type, the predicate
truth value is true if the value of the predicate expression is equal
(by the eq operator) to the context position, and is false otherwise.
[Definition: A predicate whose predicate expression returns a numeric
type is called a numeric predicate.]
Otherwise, the predicate truth value is the effective boolean value
of the predicate expression.
and https://www.w3.org/TR/xpath-30/#id-ebv says
If its operand is a singleton value of type xs:string, xs:anyURI,
xs:untypedAtomic, or a type derived from one of these, fn:boolean
returns false if the operand value has zero length; otherwise it returns
true.
--~----------------------------------------------------------------
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
--~--