XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (112 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
8.95Mb size Format: txt, pdf, ePub

One thing that can trip you up if you aren't using schemas, and are therefore used to most of your data being untyped, is that the result of an operation is never untyped. This means, for example, that you can write
string-length(@chap-num)
, and the value of
@chap-num
will be treated as an
xs:string
, which is what the
string-length()
function requires. You can also write
@chap-num + 1
, and
@chap-num
will be treated as a number, which is what the
+
operator requires. But you can't write
string-length(@chap-num + 1)
, because the result of
@chap-num + 1
is not untyped, it is an
xs:double
, and the
string-length()
function requires an
xs:string
. You have to do the conversion explicitly, like this:
string-length(string(@chap-num + 1))

Other books

High Stakes by Waltz, Vanessa
Omega Pathogen: Despair by J. G. Hicks Jr, Scarlett Algee
Ark-13: An Odyssey by B.B. Gallagher
Jenna's Story by Lizzy Stevens
Finger Prints by Barbara Delinsky
Adventures in the Orgasmatron by Christopher Turner
Luke's #1 Rule by Cynthia Harrison