[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Applying contains() to multiple nodes problem

Subject: Re: Applying contains() to multiple nodes problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 4 Oct 2007 14:49:54 +0100
Re:  Applying contains() to multiple nodes problem
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform "

That should generate an error about missing xsl namespace (because of
the space)

$ saxon reac.xml reac.xsl
Error 
  Namespace for stylesheet element should be http://www.w3.org/1999/XSL/Transform
Transformation failed: Namespace for stylesheet element should be http://www.w3.org/1999/XSL/Transform


fixing that gives the result you posted

  "contains(//entry/@reaction, $rea)"

in xslt 2 that would be an error (multiple nodes supplied as 1st
argument.) in XSLT1 line most string functions contains will silently
dicard all but the first node, so it is the same as

  "contains((//entry/@reaction)[1], $rea)"

what you want is to check each node individually, so

  "//entry[contains(@reaction, $rea)]"

you then get the reult that you wanted 


however note that // is an expendive operation and you do it lots of
times (unless syour xslt engine optimises this away for you)
You could use a key to optimise this but that's rather easier in xslt2
than xslt1 as you want to key off the reaction element after spliiting
on white space.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.