|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath for variable search anywhere
At 2004-01-22 12:48 +0000, Andrew Maclean wrote:
I have a variable in my XSL (call it myVar) and I wish to search the entire node hierarchy for nodes which share it's name. Do you mean nodes whose name is the value of myVar? Or nodes that share the same name "m","y","V","a","r"? I'll assume the former. <xsl:copy-of select="//$myVar"> You can use: <xsl:copy-of select="//node()[name(.)=$myVar]"/> ... but this is *not* namespace safe. If you only wanted to check elements: <xsl:copy-of select="//*[name(.)=$myVar]"/> ... but same caveat about namespaces. Perhaps if you give the context of why the node name is important in your search, another solution might be presented. The name() function is suitable for exposition but *not* suitable for node checking because it isn't namespace-safe. causes my processor (4suite) to generate an XsltException. Does anybody know the syntax I need to look at all levels of the hierarchy for nodes that have the name (or attribute) "myVar"? "have" the attribute myVar? or *is* the attribute myVar? For "an element that has an attribute named by myVar" it would be: <xsl:copy-of select="//*[@*[name(.)=$myVar]]"/> For "an element or attribute named by myVar" it would be the top one above. I hope one of these is what you need ... I'm sorry I couldn't understand precisely what you were looking for from your wording. ...................... Ken
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc 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
|

Cart








