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

Re: processing nodes by value precedence

Subject: Re: processing nodes by value precedence
From: "Matthew Stoeffler matthew.stoeffler@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 3 Feb 2016 14:50:31 -0000
Re:  processing nodes by value precedence
On Feb 2, 2016, at 4:09 PM, David Carlisle
d.p.carlisle@xxxxxxxxx<mailto:d.p.carlisle@xxxxxxxxx>
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx
rytech.com>> wrote:



On 2 February 2016 at 20:57, Matthew Stoeffler
matthew.stoeffler@xxxxxxxxxx<mailto:matthew.stoeffler@xxxxxxxxxx>
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx
rytech.com>>wrote:
Lets say Ibm processing products that can have multiple types of a certain
node distinguished by value, of which I want only one in my result, and I have
a precedence order by type of those nodes that shoudl determine which one I
get.  So, if the child of product Ibm interested in is price currency and my
product had



<product>

b&.



<price>

<amount>25.00</amount>

<currency>FR</currency>

</price>



<price>

<amount>20.00</amount>

<currency>US</currency>

</price>



<price>

<amount>30.00</amount>

<currency>CA</currency>

</price>



</product>



And my preference is to take the only one price in the order 1., US, 2. CA,
3.FR<http://3.fr/>.



In context product, if I say



<xsl:apply-templates
select=b(price[currency=bUSb],price[currency=bCAb],price[currency=b
FRb])[1]b/>



I get the FR price because itbs first in doc order, but my expression was
meant to say process nodes in this sequence order, taking the first one, in
the sequence, not in the doc order of the input tree.

No you should get the US one. if you execute

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="product">
  <xsl:copy-of
select="(price[currency='US'],price[currency='CA'],price[currency='FR'])[1]"/>
 </xsl:template>
</xsl:stylesheet>


on the xml you posted then you get

<price>

<amount>20.00</amount>

<currency>US</currency>

</price>

If I use xsl:copy-of I DO  get the US price, but Ibm using
xsl:apply-templates, and when I do that I get doc order.  How do I get past
that?

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.