Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2013, 07:06 AM
Registered User
 
Join Date: Sep 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get distinct values​​?

Hello All!

I am have some XML.

Code:
<row>
  <Systems>
    <System>AAA, BBB, AAA, CCC, AAA</System>
  </Systems>
</row>

<row>
  <Systems>
    <System>AAA, CCC</System>
  </Systems>
</row>

<row>
  <Systems>
    <System>EEE, DDD, AAA</System>
  </Systems>
</row>
My xml output should look like that.
Code:
<row>
  <Systems>
    <System>AAA</System>
    <System>BBB</System>
    <System>CCC</System>
    <System>EEE</System>
    <System>DDD</System>
  </Systems>
</row>
How I can perform this conversion using XSLT 1.0?

Please help me!!!
 
Old September 30th, 2013, 07:12 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you really need to use XSLT 1.0 then tell us which XSLT 1.0 processor you use and whether it supports EXSLT like http://www.exslt.org/str/functions/split/index.html.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old September 30th, 2013, 07:31 AM
Registered User
 
Join Date: Sep 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Martin Honnen View Post
If you really need to use XSLT 1.0 then tell us which XSLT 1.0 processor you use and whether it supports EXSLT like http://www.exslt.org/str/functions/split/index.html.
I use XSLT 1.0 processor Saxon 6.5.5. it supports EXSLT.
 
Old October 1st, 2013, 05:27 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you use Saxon 6 which is an XSLT 1.0 processor implemented in Java why can't you simply switch to Saxon 9, an XSLT 2.0 processor also implemented in Java?
That way you could use XSLT 2.0 and all you need is
Code:
<xsl:template match="/">
  <row>
     <Systems>
        <for-each select="distinct-values(row/Systems/System/tokenize(., ','))">
           <System><xsl:value-of select="."/></System>
        <for-each>
     </Systems>
  </row>
</xsl:template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Distinct Values 1.0 musman0047 XSLT 2 February 25th, 2009 04:48 PM
getting distinct values from attribute markus2000 XSLT 1 June 13th, 2006 03:06 AM
distinct-values in Javascript Jan1 XML 2 October 10th, 2005 04:56 AM
Distinct values of data arnabghosh Access 18 September 13th, 2005 05:41 PM
DISTINCT ntext Values fleming SQL Server 2000 2 July 23rd, 2005 06:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.