Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Specify an element in a nodeset directly

From: "roy axenov" <r_axenov@----.-->
To: 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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent