[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

Subject: Re: testing for existence of an element - multiple variables
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 4 Oct 2001 13:02:57 +0100
xpath node existence
> 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


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-2013 All Rights Reserved.