xsl-list
[Top] [All Lists]

AW: [xsl] XPath question concerning distinct-values()

2012-08-03 06:21:58
Hi, 

You could still use distinct-values and then "iterate" those values and output 
the desire values from the first item you find with the corresponding 
order-number.

Something like 

<xsl:for-each select="distinct-values(/pricelist/item) ">
        <xsl:value-of 
select="concat(/pricelist/item/order-number[parent::item[order-number=.][1]], ' 
', /pricelist/item/price[parent::item[order-number=.][1]])">
</xsl:for-each>

There's probably a more elegant way to do it tough. 

Best regards 


. . . . . . . . . . . . . . . . . . . . . . . . . .
Developer Patrick Szabo
 Developer 
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at
Tel.: +43 1 53452 1573 
Fax: +43 1 534 52 146 


-----Ursprüngliche Nachricht-----

Von: Thorsten [mailto:xsl-list(_at_)vw-freaks(_dot_)net] 
Gesendet: Freitag, 03. August 2012 13:14
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: [xsl] XPath question concerning distinct-values()

Hello,

I have a terrible SAP export that looks (simplified) like this:

<pricelist>
   <item>
      <title>Lorem Ipsum Dolor Sit Amet</title>
      <order-number>XY7020280901</order-number>
      <price>12.00</price>
      <unit>50</unit>
   </item>
   <item>
      <title>Some Title</title>
      <order-number>XY9010200901</order-number>
      <price>19.00</price>
      <unit>50</unit>
   </item>
   <item>
      <title>The Same Item With A Different Title</title>
      <order-number>XY9010200901</order-number>
      <price>19.00</price>
      <unit>50</unit>
   </item>
   <item>
      <title>Lorem Ipsum Dolor</title>
      <order-number>XY7010220201</order-number>
      <price>18.00</price>
      <unit>50</unit>
   </item>
</pricelist>

I want to select each <item> with different <order-number>. Simply
distinct-values(/pricelist/item) doesn't work because the <title> of item[2] and
item[3] are different.

My output should look like this:
XY7020280901  12.00
XY9010200901  19.00
XY7010220201  18.00

I'm using XSLT2.0 with Saxon 9.2 PE.

Any ideas?

Many thanks in advance.

Kind regards
Thorsten

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--