[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: testing for existence of an element - multiple var
> I realise I am missing the point somewhere here but I cannot get my head > round it. the point is that $thisone contains a string not a fragment of an XPath expression. in C or java, if the variable x contained the string "1 + 2" people do not expect to be able to use this in the middle of an expression like y = x + 3 and have this evaluate to y being 6. But for some reason XPath users (many of them, not just you:-) expect to put a string in $thisone and use this in the middle of an expression exactly analogous to the above. $doc1//CommonSoFar/$thisone note here $doc1 is OK but it is not standing for the "expression" that was used to set the variable, it is standing for its value, which will be a node set, and the infix // operator is taking that value as its first argument. so if $thisone is "elemname" the above is $doc1//CommonSoFar/"elemname" and a syntax error. anyway that's why it doesn't work, but in your case, where you just have an element name not a more complicated expression, there's an easy fix (which is probably in the faq for this list) $doc1//CommonSoFar/*[name()=$thisone] David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service. 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
|