Each node contains a list of colour in the field LIGHT_COLOUR, identied by a letter R(red), W(white), etc etc. In the field LIGHT_COLOUR can be only one colour/letter or more than one separated by '-'.
This is my XML for testing:
<LIGHT_INFORMATION_LIST>
<LIGHT_INFORMATION>
<LIGHT_CHARACTERISTICS>Al</LIGHT_CHARACTERISTICS>
<LIGHT_COLOUR>W-G</LIGHT_COLOUR>
</LIGHT_INFORMATION>
<LIGHT_INFORMATION>
<LIGHT_CHARACTERISTICS>Al</LIGHT_CHARACTERISTICS>
<LIGHT_COLOUR>W-R</LIGHT_COLOUR>
</LIGHT_INFORMATION>
<LIGHT_INFORMATION>
<LIGHT_CHARACTERISTICS>F</LIGHT_CHARACTERISTICS>
<LIGHT_COLOUR>R</LIGHT_COLOUR>
</LIGHT_INFORMATION>
<LIGHT_INFORMATION>
<LIGHT_CHARACTERISTICS>F</LIGHT_CHARACTERISTICS>
<LIGHT_COLOUR>G</LIGHT_COLOUR>
</LIGHT_INFORMATION>
<LIGHT_INFORMATION>
<LIGHT_CHARACTERISTICS>F</LIGHT_CHARACTERISTICS>
<LIGHT_COLOUR>W</LIGHT_COLOUR>
</LIGHT_INFORMATION>
</LIGHT_INFORMATION_LIST>
This is my XSLT:
<xsl:for-each select="LIGHT_INFORMATION_LIST">
<xsl:for-each select="LIGHT_INFORMATION">
<xsl:for-each select="LIGHT_COLOUR">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
Now my output is : W-G W-R R G W
This is all element in LIGHT_COLOUR field.
I would in Output all element taken one time (LIGHT_COLOUR distinct).
In Output I would : W G R
If - as I suspect - there is a known list of possible colors, and in this list each color is represented by a single letter, then this could be dead simple. For example, the following stylesheet:
XSLT 1.0
when applied to your example input, would return:
One way to do this would be first to create a variable containing all the separate
LIGHT_COLOUR
elements concatenated into one stringSo, in your example, it would be set to "W-G-T-W-R-E-E-R-E-E-".
You could then have a recursive template that splits the string into characters, but at the same time keeps a running list of the distinct values. So, on each iteration, it gets the next character before the hyphen and checks whether it is not already in the list of distinct values. If not, it adds it to this list, and the recursive template carries on processing until nothing left.
Try this XSLT
When applied to your XML, the following is output