Subject: [xsl] Transforming and sorting nodes into the same format from differen t parts of the XML document From: Thomas Keegan <thomas.keegan@xxxxxxxxxxxxx> Date: Wed, 2 Feb 2005 19:14:06 -0000 |
(DOC 1) I have a XML Document like so... <FUND> <FUND_CODES> <FUND_CODE fundCodeType="MEXID" fundCode=""/> <FUND_CODE fundCodeType="ISIN" fundCode="SE0001039561"/> <FUND_CODE fundCodeType="COB" fundCode=""/> <FUND_CODE fundCodeType="WKN" fundCode=""/> <FUND_CODE fundCodeType="CNMV" fundCode=""/> <FUND_CODE fundCodeType="SIX" fundCode="910536"/> <FUND_CODE fundCodeType="CITYGATE" fundCode="636481"/> </FUND_CODES> <DETAILS> <DETAIL detailFieldId="1" detailFieldName="Adress">SEB Fonder AB</DETAIL> <DETAIL detailFieldId="2" detailFieldName="Telefon">771 36 63 37</DETAIL> <DETAIL detailFieldId="3" detailFieldName="telefonnummer">36 63 37</DETAIL> <DETAIL detailFieldId="4" detailFieldName="Fax"/> <DETAIL detailFieldId="5" detailFieldName="E-post">der@xxxxxx</DETAIL> <DETAIL detailFieldId="6" detailFieldName="Kontakt"/> <DETAIL detailFieldId="7" detailFieldName="Fvr">dinaviska</DETAIL> <DETAIL detailFieldId="8" detailFieldName="Sparplan"/> <DETAIL detailFieldId ="374" detailFieldName ="No 4 %">8%</DETAIL> <DETAIL detailFieldId ="375" detailFieldName ="No 5 %">6%</DETAIL> <DETAIL detailFieldId ="376" detailFieldName ="No 6 %">5%</DETAIL> <DETAIL detailFieldId ="377" detailFieldName ="No 7 %">5%</DETAIL> <DETAIL detailFieldId ="378" detailFieldName ="No 8 %">5%</DETAIL> <DETAIL detailFieldId ="379" detailFieldName ="No 9 %"/> <DETAIL detailFieldId ="380" detailFieldName ="No 10 %"/> <DETAIL detailFieldId ="384" detailFieldName ="Datum">2004-09-30</DETAIL> </DETAILS> </FUND> (DOC 2) I want it outputted like this...as u can see the attribute id is sorted <FUND> <DETAIL id="1" Name="Adress">SEB Fonder AB</DETAIL> <DETAIL id="2" Name="Telefon">771 36 63 37</DETAIL> <DETAIL id="3" Name="telefonnummer">36 63 37</DETAIL> <DETAIL id="4" Name="Fax"/> <DETAIL id="5" Name="E-post">der@xxxxxx</DETAIL> <DETAIL id="6" Name="Kontakt"/> <DETAIL id="7" Name="Fvr">dinaviska</DETAIL> <DETAIL id="8" Name="Sparplan"/> <DETAIL id="70" Name="MEXID"/> <DETAIL id="87" Name="SEDOL"/> <DETAIL id="88" Name="ISIN">SE0001039561</DETAIL> <DETAIL id="89" Name="COB"/> <DETAIL id="90" Name="WKN"/> <DETAIL id="91" Name="CMNV"/> <DETAIL id="93" Name="SIX">910536</DETAIL> <DETAIL id="94" Name="CITYGATE">636481</DETAIL> <DETAIL id ="374" Name ="No 4 %">8%</DETAIL> <DETAIL id ="375" Name ="No 5 %">6%</DETAIL> <DETAIL id ="376" Name ="No 6 %">5%</DETAIL> <DETAIL id ="377" Name ="No 7 %">5%</DETAIL> <DETAIL id ="378" Name ="No 8 %">5%</DETAIL> <DETAIL id ="379" Name ="No 9 %"/> <DETAIL id ="380" Name ="No 10 %"/> <DETAIL id ="384" Name ="Datum ">2004-09-30</DETAIL> </FUND> id 70, 87, 88, 89, 90, 91, 93, 94 are hard coded So this... <FUND_CODE fundCodeType="MEXID" fundCode=""/> <FUND_CODE fundCodeType="ISIN" fundCode="SE0001039561"/> <FUND_CODE fundCodeType="COB" fundCode=""/> <FUND_CODE fundCodeType="WKN" fundCode=""/> <FUND_CODE fundCodeType="CNMV" fundCode=""/> <FUND_CODE fundCodeType="SIX" fundCode="910536"/> <FUND_CODE fundCodeType="CITYGATE" fundCode="636481"/> goes to this.... <DETAIL id="70" Name="MEXID"/> <DETAIL id="87" Name="SEDOL"/> <DETAIL id="88" Name="ISIN">SE0001039561</DETAIL> <DETAIL id="89" Name="COB"/> <DETAIL id="90" Name="WKN"/> <DETAIL id="91" Name="CMNV"/> <DETAIL id="93" Name="SIX">910536</DETAIL> <DETAIL id="94" Name="CITYGATE">636481</DETAIL> MY STYLE SHEET... <xsl:element name="DETAILS"> <xsl:for-each select="DETAILS/DETAIL"> <xsl:element name="DETAIL"> <xsl:attribute name="id"> <xsl:value-of select="@detailFieldId"/> </xsl:attribute> <xsl:attribute name="Name"> <xsl:value-of select="@detailFieldName"/> </xsl:attribute> <xsl:if test=". != ''"> <xsl:value-of select="."/> </xsl:if> </xsl:element> </xsl:for-each> </xsl:element> Now this part of my style sheet (above) converts <DETAIL detailFieldId="1" detailFieldName="Adress">SEB Fonder AB</DETAIL> in to this... <DETAIL id="1" Name="Adress">SEB Fonder AB</DETAIL> Converting this... <FUND_CODE fundCodeType="MEXID" fundCode=""/> in to this <DETAIL detailFieldId="1" detailFieldName="Adress">SEB Fonder AB</DETAIL> or this <DETAIL id="1" Name="Adress">SEB Fonder AB</DETAIL> is simple and I know how to get my output document to output like so... <FUND> <DETAIL id="1" Name="Adress">SEB Fonder AB</DETAIL> <DETAIL id="2" Name="Telefon">771 36 63 37</DETAIL> <DETAIL id="3" Name="telefonnummer">36 63 37</DETAIL> <DETAIL id="4" Name="Fax"/> <DETAIL id="5" Name="E-post">der@xxxxxx</DETAIL> <DETAIL id="6" Name="Kontakt"/> <DETAIL id="7" Name="Fvr">dinaviska</DETAIL> <DETAIL id="8" Name="Sparplan"/> <DETAIL id ="374" Name ="No 4 %">8%</DETAIL> <DETAIL id ="375" Name ="No 5 %">6%</DETAIL> <DETAIL id ="376" Name ="No 6 %">5%</DETAIL> <DETAIL id ="377" Name ="No 7 %">5%</DETAIL> <DETAIL id ="378" Name ="No 8 %">5%</DETAIL> <DETAIL id ="379" Name ="No 9 %"/> <DETAIL id ="380" Name ="No 10 %"/> <DETAIL id ="384" Name ="Datum ">2004-09-30</DETAIL> <DETAIL id="70" Name="MEXID"/> <DETAIL id="87" Name="SEDOL"/> <DETAIL id="88" Name="ISIN">SE0001039561</DETAIL> <DETAIL id="89" Name="COB"/> <DETAIL id="90" Name="WKN"/> <DETAIL id="91" Name="CMNV"/> <DETAIL id="93" Name="SIX">910536</DETAIL> <DETAIL id="94" Name="CITYGATE">636481</DETAIL> </FUND> but how do I get it to be sorted at the same time???? Any help or even pointing me in the right direction would be great! If you need any clarification on any part just ask. Cheer, Thomas Keegan ********************************************************************** For more information on MoneyMate please visit our web site at http://www.moneymate.com This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT for Extensibility, Colin Paul Adams | Thread | RE: [xsl] Transforming and sorting , Michael Kay |
RE: [xsl] Grouping and Summing info, Anton Damhuis | Date | RE: [xsl] Transforming and sorting , Michael Kay |
Month |