My input file,
<?xml version="1.0" encoding="UTF-8"?> <TstData> <ENT_A_BLY Common_Key="3195 KG" NAME="COMPDATA_AC"/> <SOLUTIONS> <A_BLY Name="LPT nozzle cracked." Common_Key="489BB8CC-5978-4D45-B781-929703D1826A"> <SOLUTION> <ID>2060000000000000000001309</ID> <TITLE Common_Key="FD08B464-B115-433F-82A9-0B2BC5CC0A4E"> LPT(Low Pressure Turbine) Damage</TITLE> </SOLUTION> <SOLUTION> <ID>206000000000000000001310</ID> <TITLE Common_Key="FFDSFE64-8DF9-43RF-8DF9-0DFSD5CC0A4E"> LPT(Low Pressure Turbine) Damage</TITLE> </SOLUTION> <SOLUTION> <ID>2060000000000000000001316</ID> <TITLE Common_Key="ADUIEI42-B115-433F-82A9-0B2BC5CC0A4E">Temperature High due to LPT(Low Pressure Turbine) Damage</TITLE> </SOLUTION> </A_BLY> </SOLUTIONS> </TstData>
In the XSLT, I am trying to fetch only one TITLE text from the 2 solutions.(as both the TITLE names are same.) so that no duplicate data will be displayed in the output.
My XSLT.. (part shown).
<xsl:element name="FMs"> <xsl:variable name="distinctFM" select="distinct-values(//SOLUTION/TITLE/@Common_Key)"/> <xsl:for-each select="$distinctFM"> <xsl:variable name="TITLENAME" select="."/> <xsl:variable name="TITLENAME1" select="//SOLUTIONS/A_BLY/SOLUTION/TITLE[@Common_Key=$TITLENAME]"/> <xsl:element name="FailureMode"> <xsl:attribute name="CommonKey"><xsl:value-of select="$TITLENAME"/></xsl:attribute> <xsl:attribute name="FMName"><xsl:value-of select="substring(normalize-space($TITLENAME1),1,200)"/></xsl:attribute> </xsl:element> </xsl:for-each> </xsl:element>
I am expecting the output in this format,
<FM CommonKey="FD08B464-B115-433F-82A9-0B2BC5CC0A4E" FMName="LPT(Low Pressure Turbine) Damage"/> <FM CommonKey="ADUIEI42-B115-433F-82A9-0B2BC5CC0A4E" FMName="Temperature High due to LPT(Low Pressure Turbine) Damage"/>
But, currently while I debugged, for FMName, it throws error at Variable TITLENAME1. Pls help me in framing this output.
Thanks Ramm