This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Choosing content depending on content of other element


Hi Jochen,

> No I have the nodes /root/output/data/product_id and order/product
>
> Depending on the product_id output, I wan't to choose the equivalent
> node
>
> /root/order/product/@id='xxx'/content/@group

You're almost there with:

  /root/order/product[@id='/root/output/data/product_id']

The only problem is that you're comparing the id attribute of the
product with *the string* '/root/output/data/product_id' rather than
*the value of* the product_id element that you're selecting. Just
remove the quotes, and it should work:

  /root/order/product[@id=/root/output/data/product_id]

although it would be more efficient to hold the value of
/root/output/data/product_id in a variable and then reference that.

By the way, if the only products to which you're apply templates are
those that have the correct id, then there's no point testing whether
they have the correct id when you try to match them with a template
*as well*. Also, from what I can see, the only product elements are
those within the order, so you may as well have the template just
match any product element; the only ones it will process are the ones
you apply templates to:

<xsl:template match="product">
  <br/><xsl:value-of select="content/@group"/>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]