RE: length of string from a set of nodes.
> > And of course, you could combine the two variables: > > > > <xsl:variable name="slen" as="xs:integer" > > select="string-length(answers)"/> > > > I got an error when I tried that ??? > XPTY0004: A sequence of more than one item is not allowed as > the first argument of string-length() OK, so child::answers selects more than one element. I didn't know that. You were using <xsl:value-of select="answers"> to concatenate the values of the elements (plus some separator spaces), which I hadn't appreciated. > > Should it work? > > But when I used a combined version from Martin's suggestion > with string-join. > <xsl:variable name="slen" as="xs:integer" > select="string-length(string-join(answers, ''))"/> If answers is a sequence of elements, then string-join() is the right solution. > > It works great. > > Interestingly, when I put a copy of your example in, but with > an unused @name. I don't get an error. I guess it only hits > the error when the variable is evaluated. > Yes, Saxon doesn't evaluate variables if they aren't used. Michael Kay http://www.saxonica.com/
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