Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Specify an element in a nodeset directly >Thread Next - Re: Specify an element in a nodeset directly Re: Specify an element in a nodeset directlyTo: NULL Date: 10/4/2006 1:15:00 PM eric.goforth@g... wrote: > roy axenov wrote: > > eric.goforth@g... wrote: > > > Martin Honnen wrote: > > > > eric.goforth@g... wrote: > > > > > <xsl:value-of select=" > > > > > $myblahs/blah > > > > > [/xpath1/xpath2/someintegervalue]/yada > > > > > "/> > > > > > > > > $myblahs/blah > > > > [/xpath1/xpath2/someintegervalue=position()]/yada > > > > > > Hmmm, that's not working for me. If I put in a "1" or > > > a "2" it works, but not with the "variable". > > > > Your example is awfully vague. For better results, > > provide a sample XML and a minimum XSLT demonstrating > > your problem. > > Here's an example of what I'm referring to. The "does > not work" comment shows what I'm trying to do. The "this > does work" shows where I'm able to hit the nodeset by > hardcoding the parameter. You should've read the rest of my post. Your example confirms that my initial guess was right on money. I ran a quick test, and the solution I proposed works, too. > <page> > <contents> > <ratessummary rec_count="3"> > <rate> > <ratecode>1</ratecode> > <myrate>1.1</myrate> > </rate> > <rate> > <ratecode>2</ratecode> > <myrate>1.2</myrate> > </rate> > <rate> > <ratecode>3</ratecode> > <myrate>1.3</myrate> > </rate> > </ratessummary> > <thingsummary rec_count="3"> > <thing> > <short_description>Jim</short_description> > <description>James</description> > <thingcode>1</thingcode> > </thing> > <thing> > <short_description>Rick</short_description> > <description>Richard</description> > <thingcode>2</thingcode> > </thing> > <thing> > <short_description>Fred</short_description> > <description>Frederick</description> > <thingcode>3</thingcode> > </thing> > </thingsummary> > </contents> > </page> [XSLT] > <xsl:apply-templates select="thingsummary"> > <xsl:with-param name="rates" > select="/page/contents/ratessummary"></xsl:with-param> > </xsl:apply-templates> . . . > <!-- This does not work--> > test1<xsl:value-of > select="$rates/rate[position()=thingcode]/myrate"/> So what does it do? $rates/rate selects a nodeset of <rate> nodes. The predicate [position()=thingcode] filters this nodeset, dropping all the nodes that don't have a <thingcode> child with content that is equal to the position of the <rate> node in the $rates/rate nodeset. Since there are no <rate> nodes with <thingcode> children in your document, the resulting nodeset is, naturally, empty. I already explained the solution in my previous reply. -- roy axenov | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
