Kerry, Richard wrote:
I had wondered about the "(@size, 1)[1]" term, which I'd not seen before
but I think I have now worked out. If there is no "size" attribute, the
term "@size" returns null and thus does not appear as a first node in
the node-set, ie what's within the (), and thus [1] returns what appears
to be the second element, the '1'.
More precisely, in XSLT 2.0 (the above construct will error in XSLT 1.0)
is a _sequence_ of items, of which the first item is a selection of an
attribute-node and the second item is an integer. When the
attribute-node selection returns nothing, the selection will actually
return the empty sequence, and indeed, you guessed correctly, empty
sequences are folded when they are part of a sequence:
if @size is not there (@size, 1) becomes ((), 1) which then becomes (1).
if @size is there, (@size, 1) will beomce (@size, 1), i.e., it does not
change, @size holds the selected attribute-node.
This shortcut is often used, but when you start out with XSLT 2.0, you
may prefer the more verbose form:
if (@size) then @size else 1
which is semantically equivalent with (@size, 1)[1].
Cheers,
-- Abel --
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--