distinct-values() function won't work in XSL

1.3k Views Asked by At

I'm trying to create a new XML document trasforming an already existing one using XSLT. My problem is that the distinct-values() function won't work as I would expect to. My XML is the following:

<parlamento>
 <parlamentare cognome="Adornato" 
 partito="UDC"/>
 <parlamentare cognome="Barbato" 
 partito="IdV"/>
 <parlamentare cognome="Bondi" 
 partito="PDL"/>
 <parlamentare cognome="Casini" 
 partito="UDC"/>
 <parlamentare cognome="Bossi" 
 partito="Lega Nord"/>
 <parlamentare cognome="Cesa" 
 partito="UDC"/>
 <parlamentare cognome="Chiamparino" 
 partito="PD"/>
 <parlamentare cognome="Cicchitto" 
 partito="PDL"/>
 <parlamentare cognome="Cota" 
 partito="Lega Nord"/>
 <parlamentare cognome="Di Giuseppe" 
 partito="IdV"/>
 <parlamentare cognome="Di Pietro" 
 partito="IdV"/>
 <parlamentare cognome="Fassino" 
 partito="PD"/>
 <parlamentare cognome="Finocchiaro" 
 partito="PD"/>
 <parlamentare cognome="Lupi" 
 partito="PDL"/>
 <parlamentare cognome="Maroni" 
 partito="Lega Nord"/>
</parlamento>

and I'm trying to do something like this:

distinct-values(//parlamentare/@partito)

Does anyone know why I can't get this line to be recognized by my evaluator? Thank you very much in advance!

1

There are 1 best solutions below

0
On

Well distinct-values was introduced in 2007 in XPath version 2.0 and that way is only supported by XSLT 2.0 processors like Saxon 9 or AltovaXML or XmlPrime. XSLT 1.0 processors like Xalan or libxslt/xsltproc or the various XSLT implementation in the major browsers don't support that function. So you need to either change to an XSLT 2.0 processor or you need to use a different approach like Muenchian grouping with your XSLT 1.0 processor.