From the XML & XSL below, I just want to be able to create a list of all the items (as described below). However, I am having difficulty easily and efficiently producing the output I want without duplication.
Basically, for each <Index> I want to report all it's child elements & attributes in a given format, including concatenating some of them together.
Any help would be very much appreciated.
XML:
XSL:Code:<Config> <!--Indexes--> <Indexes RangeName="LookupIndexTradeIDs"> <!--CDX--> <Index Name="cdx"> <Series> <SeriesNumber>9</SeriesNumber> </Series> <Issuances> <Maturity OldID="d10" NewID="3Y"/> <Maturity OldID="d12" NewID="5Y"/> <Maturity OldID="d14" NewID="7Y"/> <Maturity OldID="d17" NewID="10Y"/> </Issuances> <Tranches> <Tranche Attach="0" Detach="3" NonSS="True" ThirtyTop="False" SixtyTop="False"/> <Tranche Attach="3" Detach="7" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="7" Detach="10" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="10" Detach="15" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="15" Detach="30" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="30" Detach="60" NonSS="False" ThirtyTop="False" SixtyTop="True"/> <Tranche Attach="30" Detach="100" NonSS="False" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="60" Detach="100" NonSS="False" ThirtyTop="False" SixtyTop="True"/> </Tranches> </Index> <!--HY--> <Index Name="HY"> <Series> <SeriesNumber>10</SeriesNumber> </Series> <Issuances> <Maturity OldID="j10" NewID="3Y"/> <Maturity OldID="j12" NewID="5Y"/> <Maturity OldID="j14" NewID="7Y"/> </Issuances> <Tranches> <Tranche Attach="0" Detach="10" NonSS="True" ThirtyTop="False" SixtyTop="False"/> <Tranche Attach="10" Detach="15" NonSS="True" ThirtyTop="False" SixtyTop="False"/> <Tranche Attach="15" Detach="25" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="25" Detach="35" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="35" Detach="100" NonSS="False" ThirtyTop="True" SixtyTop="True"/> </Tranches> </Index> <!--iTraxx--> <Index Name="itraxx"> <Series> <SeriesNumber>9</SeriesNumber> </Series> <Issuances> <Maturity OldID="j11" NewID="3Y"/> <Maturity OldID="j13" NewID="5Y"/> <Maturity OldID="j15" NewID="7Y"/> <Maturity OldID="j18" NewID="10Y"/> </Issuances> <Tranches> <Tranche Attach="0" Detach="3" NonSS="True" ThirtyTop="False" SixtyTop="False"/> <Tranche Attach="3" Detach="6" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="6" Detach="9" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="9" Detach="12" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="12" Detach="22" NonSS="True" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="22" Detach="60" NonSS="False" ThirtyTop="False" SixtyTop="True"/> <Tranche Attach="22" Detach="100" NonSS="False" ThirtyTop="True" SixtyTop="True"/> <Tranche Attach="60" Detach="100" NonSS="False" ThirtyTop="False" SixtyTop="True"/> </Tranches> </Index> </Indexes> </Config>
Output Required:Code:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:for-each select="//Config/Indexes/Index"> <xsl:variable name="indexName" select="@Name"/> <xsl:for-each select="//Config/Indexes/Index/Series/SeriesNumber"> <xsl:variable name="seriesNo" select="SeriesNumber"/> <xsl:for-each select="//Config/Indexes/Index/Issuances/Maturity"> <xsl:variable name="issueOld" select="@OldID"/> <xsl:variable name="issueNew" select="@NewID"/> <xsl:for-each select="//Config/Indexes/Index/Tranches/Tranche"> <xsl:variable name="attachment" select="@Attach"/> <xsl:variable name="detachment" select="@Detach"/> <xsl:variable name="oldTradeID" select="concat($indexName, $seriesNo, '_', $issueOld, '_T', $attachment, '-', $detachment)"/> <xsl:variable name="newTradeID" select="concat($indexName, $seriesNo, '_', $attachment, '_', $detachment, '_', $issueNew)"/> Indexes|<xsl:value-of select="//Config/Indexes/@RangeName"/>|<xsl:value-of select="$oldTradeID"/>|<xsl:value-of select="$newTradeID"/>|<xsl:value-of select="@NonSS"/>|<xsl:value-of select="@ThirtyTop"/>|<xsl:value-of select="@SixtyTop"/> </xsl:for-each> </xsl:for-each> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Code:cdx9|cdx9_d10_T0-3|cdx9_0_3_3Y|TRUE|FALSE|FALSE cdx9|cdx9_d10_T3-7|cdx9_3_7_3Y|TRUE|TRUE|TRUE cdx9|cdx9_d10_T7-10|cdx9_7_10_3Y|TRUE|TRUE|TRUE cdx9|cdx9_d10_T10-15|cdx9_10_15_3Y|TRUE|TRUE|TRUE cdx9|cdx9_d10_T15-30|cdx9_15_30_3Y|TRUE|TRUE|TRUE cdx9|cdx9_d10_T30-60|cdx9_30_60_3Y|FALSE|FALSE|TRUE cdx9|cdx9_d10_T30-100|cdx9_30_100_3Y|FALSE|TRUE|TRUE cdx9|cdx9_d10_T60-100|cdx9_60_100_3Y|FALSE|FALSE|TRUE cdx9|cdx9_d12_T0-3|cdx9_0_3_5Y|TRUE|FALSE|FALSE cdx9|cdx9_d12_T3-7|cdx9_3_7_5Y|TRUE|TRUE|TRUE cdx9|cdx9_d12_T7-10|cdx9_7_10_5Y|TRUE|TRUE|TRUE cdx9|cdx9_d12_T10-15|cdx9_10_15_5Y|TRUE|TRUE|TRUE cdx9|cdx9_d12_T15-30|cdx9_15_30_5Y|TRUE|TRUE|TRUE cdx9|cdx9_d12_T30-60|cdx9_30_60_5Y|FALSE|FALSE|TRUE cdx9|cdx9_d12_T30-100|cdx9_30_100_5Y|FALSE|TRUE|TRUE cdx9|cdx9_d12_T60-100|cdx9_60_100_5Y|FALSE|FALSE|TRUE cdx9|cdx9_d14_T0-3|cdx9_0_3_7Y|TRUE|FALSE|FALSE cdx9|cdx9_d14_T3-7|cdx9_3_7_7Y|TRUE|TRUE|TRUE cdx9|cdx9_d14_T7-10|cdx9_7_10_7Y|TRUE|TRUE|TRUE cdx9|cdx9_d14_T10-15|cdx9_10_15_7Y|TRUE|TRUE|TRUE cdx9|cdx9_d14_T15-30|cdx9_15_30_7Y|TRUE|TRUE|TRUE cdx9|cdx9_d14_T30-60|cdx9_30_60_7Y|FALSE|FALSE|TRUE cdx9|cdx9_d14_T30-100|cdx9_30_100_7Y|FALSE|TRUE|TRUE cdx9|cdx9_d14_T60-100|cdx9_60_100_7Y|FALSE|FALSE|TRUE cdx9|cdx9_d17_T0-3|cdx9_0_3_10Y|TRUE|FALSE|FALSE cdx9|cdx9_d17_T3-7|cdx9_3_7_10Y|TRUE|TRUE|TRUE cdx9|cdx9_d17_T7-10|cdx9_7_10_10Y|TRUE|TRUE|TRUE cdx9|cdx9_d17_T10-15|cdx9_10_15_10Y|TRUE|TRUE|TRUE cdx9|cdx9_d17_T15-30|cdx9_15_30_10Y|TRUE|TRUE|TRUE cdx9|cdx9_d17_T30-60|cdx9_30_60_10Y|FALSE|FALSE|TRUE cdx9|cdx9_d17_T30-100|cdx9_30_100_10Y|FALSE|TRUE|TRUE cdx9|cdx9_d17_T60-100|cdx9_60_100_10Y|FALSE|FALSE|TRUE HY10|hy10_j10_T0-10|hy10_0_10_3Y|TRUE|FALSE|FALSE HY10|hy10_j10_T10-15|hy10_10_15_3Y|TRUE|FALSE|FALSE HY10|hy10_j10_T15-25|hy10_15_25_3Y|TRUE|TRUE|TRUE HY10|hy10_j10_T25-35|hy10_25_35_3Y|TRUE|TRUE|TRUE HY10|hy10_j10_T35-100|hy10_35_100_3Y|FALSE|TRUE|TRUE HY10|hy10_j12_T0-10|hy10_0_10_5Y|TRUE|FALSE|FALSE HY10|hy10_j12_T10-15|hy10_10_15_5Y|TRUE|FALSE|FALSE HY10|hy10_j12_T15-25|hy10_15_25_5Y|TRUE|TRUE|TRUE HY10|hy10_j12_T25-35|hy10_25_35_5Y|TRUE|TRUE|TRUE HY10|hy10_j12_T35-100|hy10_35_100_5Y|FALSE|TRUE|TRUE HY10|hy10_j14_T0-10|hy10_0_10_7Y|TRUE|FALSE|FALSE HY10|hy10_j14_T10-15|hy10_10_15_7Y|TRUE|FALSE|FALSE HY10|hy10_j14_T15-25|hy10_15_25_7Y|TRUE|TRUE|TRUE HY10|hy10_j14_T25-35|hy10_25_35_7Y|TRUE|TRUE|TRUE HY10|hy10_j14_T35-100|hy10_35_100_7Y|FALSE|TRUE|TRUE itraxx9|itraxx9_j11_T0-3|itrx9_0_3_3Y|TRUE|FALSE|FALSE itraxx9|itraxx9_j11_T3-6|itrx9_3_6_3Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j11_T6-9|itrx9_6_9_3Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j11_T9-12|itrx9_9_12_3Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j11_T12-22|itrx9_12_22_3Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j11_T22-60|itrx9_22_60_3Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j11_T22-100|itrx9_22_100_3Y|FALSE|TRUE|TRUE itraxx9|itraxx9_j11_T60-100|itrx9_60_100_3Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j13_T0-3|itrx9_0_3_5Y|TRUE|FALSE|FALSE itraxx9|itraxx9_j13_T3-6|itrx9_3_6_5Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j13_T6-9|itrx9_6_9_5Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j13_T9-12|itrx9_9_12_5Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j13_T12-22|itrx9_12_22_5Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j13_T22-60|itrx9_22_60_5Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j13_T22-100|itrx9_22_100_5Y|FALSE|TRUE|TRUE itraxx9|itraxx9_j13_T60-100|itrx9_60_100_5Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j15_T0-3|itrx9_0_3_7Y|TRUE|FALSE|FALSE itraxx9|itraxx9_j15_T3-6|itrx9_3_6_7Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j15_T6-9|itrx9_6_9_7Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j15_T9-12|itrx9_9_12_7Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j15_T12-22|itrx9_12_22_7Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j15_T22-60|itrx9_22_60_7Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j15_T22-100|itrx9_22_100_7Y|FALSE|TRUE|TRUE itraxx9|itraxx9_j15_T60-100|itrx9_60_100_7Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j18_T0-3|itrx9_0_3_10Y|TRUE|FALSE|FALSE itraxx9|itraxx9_j18_T3-6|itrx9_3_6_10Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j18_T6-9|itrx9_6_9_10Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j18_T9-12|itrx9_9_12_10Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j18_T22-60|itrx9_22_60_10Y|FALSE|FALSE|TRUE itraxx9|itraxx9_j18_T12-22|itrx9_12_22_10Y|TRUE|TRUE|TRUE itraxx9|itraxx9_j18_T22-100|itrx9_22_100_10Y|FALSE|TRUE|TRUE itraxx9|itraxx9_j18_T60-100|itrx9_60_100_10Y|FALSE|FALSE|TRUE


Reply With Quote



Bookmarks