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

Dynamic XPath Expression

Subject: Dynamic XPath Expression
From: "Fraser Goffin" <goffinf@xxxxxxxxxxx>
Date: Wed, 09 Nov 2005 12:07:17 +0000
dynamic xpath expression
Is is possible to build up an XPath expression (as a string) and then use it with a select or match. For example :-

If the variable $xPath contained the string value '/root/first'

could I do :-

<xsl:copy-of select='$xPath'/>

I have to say from my initial testing this doesn't appear work and copy-of would just return the string itself not evaluate as an XPath expression, but I wondered whether there is a way of getting something like this to work ?

What I'm trying to do is compare aspects of one XML instance with another. There are a lot of comparisons I need to make and I don't really want to hard code in each individual test's XPath in an 'if' statement. So I was considering creating templates which match the portions of the document I want to compare and from that context recursing through matching each node found with the corresponding structure in the other doc :-

Doc 1                                                               Doc 2
====                                                              ====

... ...
<Employees> <Employees>
<Employee> <Employee>
<FName>Fraser</FName> <-- OK --> <FName>Fraser</FName>
<LName>Goffin</LName> <-- OK --> <LName>Goffin</LName>
</Employee> </Employee>
<Employee> <Employee>
<FName>Luke</FName> <-- MISMATCH --> <FName>Marie</FName>
<LName>Goffin</LName> <-- MISMATCH --> <LName>Smith</LName>
</Employee> </Employee>
... ...
</Employees> </Employees>


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.