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

Re: variable in xpath

Subject: Re: variable in xpath
From: "James Carlyle" <james.carlyle@xxxxxxxxxxxx>
Date: Fri, 15 Nov 2002 11:56:45 -0000
xpath position count
I'll take a shot at answering this.


> How do I obtain and copy the node <adesc> of File2 using the above
> $path variable? Something like the below one:
>
> <xsl:template match="node()">
>     <xsl:copy-of select="document(File2.xml)/$path.."/>
> </xsl:template>

I assume that you want to process file 1, but cross check in file 2 for
additional elements to copy into file 1.  You want to use an XPath
expression like element[1]/child[1]/a[1] (note I have added positions) to
reference the appropriate point in file 2.  Is my understanding correct?

You can't evaluate dynamic XPath expressions in the body of a select clause.
So what you have written won't work.  If the structure element/child/a is
fixed, you could use a nasty expression like

<xsl:template match="a">
<xsl:copy-of
select="document(File2.xml)/element[position()=count(current()/../../precedi
ng-sibling::element)+1]/child[position()=count(current()/../preceding-siblin
g::child)+1]/a[position()=count(current()/preceding-sibling::a)+1]/adesc"/>
</xsl:template>

There are probably 2 other ways that I can think of for solving this
problem, but I can't address and test them right now.  I might try and post
a follow up message later.

Hope this helps,

James Carlyle
www.takepart.com


 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.