[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:if with "and' in test expression triggers erro
Hi Taras, > Running the stylesheet quoted below in Saxon 7.5.1 triggers the > error: "A sequence of more than one item is not allowed here" at the > line containing the xsl:if element. > > When I set the version attribute to "1.0" the sheet seems to work fine. > > What makes ik fail when running in xslt 2.0 mode? The relevant code is the XPath 2.0 expression: count($rows) = 3 and normalize-space($rows) The normalize-space() function expects an optional string as an argument -- in other words, if you pass it a sequence, then the sequence must either be empty or contain a single item. In your case, $rows contains (usually) 3 items, which means that it isn't a valid argument for the normalize-space() function. In XSLT 1.0, when you pass a node-set that contains more than one node to a function that expects a string as an argument, it's the same as passing the first node of that node-set as the argument. So you can get the same effect in XSLT 2.0 using: count($rows) = 3 and normalize-space($rows[1]) Given this, the fact that you're getting an error highlights for you the fact that in XSLT 1.0 you're only testing the first of the rows for content whereas you actually want to test if "all the cells are empty" or, in other words, if any of the cells has content. For the test to succeed when any of the $rows has content, you should use: count($rows) = 3 and $rows[normalize-space(.)] Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|