|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using the Input Document to Control Generation of
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].
|
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
|






