|
|
|||
XML /XSL unique list question
Hi,
I am working with and xml-file and want to find unique elemensts in that file using xsl: The xml-file is like the one pasted her: <Tariff> <TariffTemplate templateid="1"> <TariffInputParameter parameterid="95"> <TariffParameterValueSet val="1"/> <TariffParameterValueSet val="2"/> </TariffInputParameter> </TariffTemplate> <TariffTemplate templateid="1"> <TariffInputParameter parameterid="95"> <TariffParameterValueSet val="1"/> <TariffParameterValueSet val="11"/> </TariffInputParameter> </TariffTemplate> <TariffTemplate templateid="3"> <TariffInputParameter parameterid="95"> <TariffParameterValueSet val="20"/> </TariffInputParameter> </TariffTemplate> <TariffTemplate templateid="3"> <TariffInputParameter parameterid="95"> <TariffParameterValueSet val="1"/> </TariffInputParameter> </TariffTemplate> </Tariff> What I want to do is to display unique values for the //TariffInputParameter[@parameterid=95]/TariffParameterValueSet/@val for each distinct //TariffTemplate/@templateid. For templateid="1" there are three differrent values I want to display:1,2,11 For templateid="3" there are two differrent values I want to display :1,20 The xsl-file I have written is pasted below: .... <xsl:template match="/"> <xsl:for-each select="//TariffTemplate"> <xsl:variable name="templateid" select="@templateid"/> <xsl:for-each select="//TariffTemplate[@templateid=$templateid]/TariffInputParameter[@parameterid=95]/TariffParameterValueSet[not(@val=preceding-sibling::TariffParameterValueSet/@val)]"> <xsl:value-of select="@val"/> <br/> </xsl:for-each> <br/> <br/> </xsl:for-each> </xsl:template> Unfortunately this xsl-file just alomost gives me the disired result. It gives the 4 rows: 1,2,1,11 1,2,1,11 20,1 20,1 Can anyone help me with this problem. - Trond 0 Replies |
|||
|