XSLT element sort via join

terry44

New Member
Would like to sort the following XML by joining the \[code\]fsxml/formula/ingrrow\[/code\] where \[code\]itemcode = fsxml/item\[/code\] (attribute \[code\]objkey\[/code\]) and having the elements named \[code\]erpplantnr_11\[/code\] through \[code\]erpplantnr_30\[/code\] from item moved after the last \[code\]attribute10\[/code\] element for each \[code\]ingrrow\[/code\].Thanks in advance for any help that can be provided!(Simplifying and providing first XSLT attempt)(Simplified example - want to move erpplantnr_11 element after attribute1 element where the attribute objkey matches the itemcode element)Looking for help on how to create the "join". Thanks again.(XSLT):\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:fsxml="http://www.FormationSystems.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy></xsl:template><xsl:template match="formula"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="ingrrow"/> </xsl:copy></xsl:template><xsl:template match="ingrrow | item"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="itemcode"/> <xsl:apply-templates select="attribute1"/> <xsl:apply-templates select="erpplantnr_11"/> </xsl:copy></xsl:template><xsl:template match="fsxml/fsxml"> <xsl:apply-templates select="item"/></xsl:template></xsl:stylesheet>\[/code\]Resultant XML - Need to match the two item objectkey attributes with their ingrrow itemcodes and have the output xml list the erpplantnr_11 element after the attribute1 element:\[code\]<fsxml> <formula maxcol="51" keycount="2" fmt="A" dtlcodes="HEADER\INGR" objectkey="NOR000133\0002" filteredfields="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ingrrow detail="1" fmt="X"> <itemcode>NOR60506</itemcode> <attribute1>000000000050051116</attribute1> </ingrrow> <ingrrow detail="1" fmt="X"> <itemcode>7K015</itemcode> <attribute1>000000000000800479</attribute1> </ingrrow> </formula> <item maxcol="35" keycount="1" fmt="A" dtlcodes="HEADER" objectkey="NOR60506" filteredfields="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <erpplantnr_11>121212;343434</erpplantnr_11> </item> <item maxcol="35" keycount="1" fmt="A" dtlcodes="HEADER" objectkey="7K015" filteredfields="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <erpplantnr_11>123456</erpplantnr_11> </item></fsxml>\[/code\]Original XML:\[code\]<fsxml> <formula maxcol="51" keycount="2" fmt="A" dtlcodes="HEADER\INGR" objectkey="NOR000133\0002" filteredfields="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <keycode>NOR000133</keycode> <keycode2>0002</keycode2> <description>48782 ALABASTER WHITE MB9960 NA</description> <formulaalias /> <alternateformula /> <timedate xsi:nil="true" /> <productcode /> <productdescr /> <reportcode /> <reportregion /> <alias_code1 /> <alias_code2 /> <alias_code3 /> <alias_code4 /> <alias_code5 /> <alias_code6 /> <alias_code7 /> <alias_code8 /> <hseapacdoc /> <hseemeadoc /> <hsenasadoc /> <wau_local_designee /> <apac1_local_designee /> <apac2_local_designee /> <apc_local_designee /> <emea_local_designee /> <na_local_designee>PREST</na_local_designee> <sa_local_designee /> <ras_sent>Yes</ras_sent> <erp_waunr /> <erp_apac1nr /> <erp_apac2nr /> <erp_apcnr /> <erp_emeanr /> <erp_nornr /> <erp_sanr /> <crfc_code>NOR000133</crfc_code> <orig_desc /> <erpglobal_1 /> <erpglobal_2 /> <erpglobal_3 /> <uomcode>KG</uomcode> <itemcode>NOR000133</itemcode> <yield>74.8956541853986</yield> <yieldpct>100</yieldpct> <phantomind>0</phantomind> <primaryformulaind>1</primaryformulaind> <processyield>100</processyield> <projectcode /> <labbookcode /> <labbookpage /> <ownercode>ARFTL</ownercode> <groupcode>GROUP_1</groupcode> <statusind>291</statusind> <approvalcode /> <holdcode /> <workcode /> <workcode2 /> <formulatorcode>ARFTL</formulatorcode> <yieldcalcind>1</yieldcalcind> <customer>RO_NOR</customer> <comment /> <datemodified>2012-05-11T14:55:37</datemodified> <class>PRODUCT</class> <typeind>0</typeind> <parentfid>42871</parentfid> <mfgitemmaster>NOR000133\0002</mfgitemmaster> <calcmode>0</calcmode> <formulaid>728067</formulaid> <adjustparam /> <materialchange>1</materialchange> <judgement /> - <ingrrow detail="1" fmt="X"> <lineid>1</lineid> <itemcode>NOR60506</itemcode> <quantity>66.6877872652848</quantity> <uomcode>KG</uomcode> <description>KV1348 KV1348 White Dispersion</description> <materialpct>89.0409303324918</materialpct> <linebreakcode /> <scaleind>0</scaleind> <subformulaind>0</subformulaind> <formulaid>0</formulaid> <componentind>1</componentind> <instruction /> <substituteind>0</substituteind> <formulacode>NOR60506\0006</formulacode> <status>401</status> <class /> <decdigit>0</decdigit> <cas /> <commcode /> <aliascode1 /> <aliascode2 /> <aliascode3 /> <aliascode4 /> <activequantity>0</activequantity> <relqtypct>0</relqtypct> <attribute1>000000000050051116</attribute1> <attribute2 /> <attribute3 /> <attribute4 /> <attribute5 /> <instrucflag>1</instrucflag> <paramcode /> <pvalue xsi:nil="true" /> <lotcode /> <aliascode5 /> <aliascode6 /> <aliascode7>APC 56% 5T070/3Z145 (KV1348) / P:393367</aliascode7> <aliascode8 /> <sectionname /> <sectiontype>0</sectiontype> <adjustind>0</adjustind> <attribute6 /> <attribute7 /> <attribute8 /> <attribute9 /> <attribute10 /> </ingrrow> - <ingrrow detail="1" fmt="X"> <lineid>2</lineid> <itemcode>7K015</itemcode> <quantity>8.20786692011385</quantity> <uomcode>KG</uomcode> <description>METHYLAMYLKETONE</description> <materialpct>10.9590696675082</materialpct> <linebreakcode /> <scaleind>0</scaleind> <subformulaind>0</subformulaind> <formulaid>0</formulaid> <componentind>8</componentind> <instruction /> <substituteind>0</substituteind> <status>401</status> <class /> <decdigit>0</decdigit> <cas>110-43-0</cas> <commcode /> <aliascode1>S194</aliascode1> <aliascode2>METHYL AMYL KETONE</aliascode2> <aliascode3 /> <aliascode4>METHYLAMYLKETONE</aliascode4> <activequantity>0</activequantity> <relqtypct>0</relqtypct> <attribute1>000000000000800479</attribute1> <attribute2 /> <attribute3 /> <attribute4 /> <attribute5 /> <instrucflag>1</instrucflag> <paramcode /> <pvalue xsi:nil="true" /> <lotcode /> <aliascode5>METHYLAMYLKETONE</aliascode5> <aliascode6>Methylamylketon 165,5 KG</aliascode6> <aliascode7>METHYL N-AMYL KETONE (Bulk)</aliascode7> <aliascode8 /> <sectionname /> <sectiontype>0</sectiontype> <adjustind>0</adjustind> <attribute6 /> <attribute7 /> <attribute8 /> <attribute9 /> <attribute10 /> </ingrrow> </formula> - <fsxml> - <item maxcol="35" keycount="1" fmt="A" dtlcodes="HEADER" objectkey="NOR60506" filteredfields="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <keycode>NOR60506</keycode> <description>KV1348 White Dispersion</description> <rmremark /> <ras_sent /> <erp_waunr /> <erp_apac1nr /> <erp_apac2nr /> <erp_apcnr /> <erp_emeanr /> <erp_nornr>000000000050051116</erp_nornr> <erp_sanr /> <erpglobal_1 /> <erpglobal_2 /> <erpglobal_3 /> <erpplantnr_11>121212;343434</erpplantnr_11> <erpplantnr_12 /> <erpplantnr_13 /> <erpplantnr_14 /> <erpplantnr_15 /> <erpplantnr_16 /> <erpplantnr_17 /> <erpplantnr_18 /> <erpplantnr_19 /> <erpplantnr_20 /> <erpplantnr_21 /> <erpplantnr_22 /> <erpplantnr_23 /> <erpplantnr_24 /> <erpplantnr_25 /> <erpplantnr_26 /> <erpplantnr_27 /> <erpplantnr_28 /> <erpplantnr_29 /> <erpplantnr_30 /> <uomcode>KG</uomcode> <calcind>0</calcind> <scaleind>0</scaleind> <statusind>401</statusind> <approvalcode /> <class /> <componentind>1</componentind> <linebreakcode /> <holdcode /> <formulacode>NOR60506</formulacode> <version>0006</version> <cas /> <commcode /> <aliascode1 /> <aliascode2 /> <aliascode3 /> <aliascode4 /> <aliascode5 /> <aliascode6 /> <aliascode7>APC 56% 5T070/3Z145 (KV1348) / P:393367</aliascode7> <aliascode8 /> <threshold>0</threshold> <datemodified>2012-04-28T19:50:12</datemodified> <ftypeind>0</ftypeind> <judgement /> </item> - <item maxcol="35" keycount="1" fmt="A" dtlcodes="HEADER" objectkey="7K015" filteredfields="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <keycode>7K015</keycode> <description>METHYLAMYLKETONE</description> <rmremark /> <ras_sent /> <erp_waunr>S194</erp_waunr> <erp_apac1nr>00000000000007K015</erp_apac1nr> <erp_apac2nr /> <erp_apcnr>7K015</erp_apcnr> <erp_emeanr>000000000000800479</erp_emeanr> <erp_nornr>000000000000800479</erp_nornr> <erp_sanr /> <erpglobal_1 /> <erpglobal_2 /> <erpglobal_3 /> <erpplantnr_11>123456</erpplantnr_11> <erpplantnr_12>234567</erpplantnr_12> <erpplantnr_13>345678</erpplantnr_13> <erpplantnr_14>456789</erpplantnr_14> <erpplantnr_15>567890</erpplantnr_15> <erpplantnr_16>678901</erpplantnr_16> <erpplantnr_17>789012</erpplantnr_17> <erpplantnr_18>890123</erpplantnr_18> <erpplantnr_19>901234</erpplantnr_19> <erpplantnr_20>012345</erpplantnr_20> <erpplantnr_21>654321</erpplantnr_21> <erpplantnr_22>765432</erpplantnr_22> <erpplantnr_23>876543</erpplantnr_23> <erpplantnr_24>987654</erpplantnr_24> <erpplantnr_25>098765</erpplantnr_25> <erpplantnr_26>109876</erpplantnr_26> <erpplantnr_27>210987</erpplantnr_27> <erpplantnr_28>321098</erpplantnr_28> <erpplantnr_29>432109</erpplantnr_29> <erpplantnr_30>543210</erpplantnr_30> <uomcode>KG</uomcode> <calcind>0</calcind> <scaleind>0</scaleind> <statusind>401</statusind> <approvalcode /> <class /> <componentind>8</componentind> <linebreakcode /> <holdcode /> <formulacode /> <version /> <cas>110-43-0</cas> <commcode /> <aliascode1>S194</aliascode1> <aliascode2>METHYL AMYL KETONE</aliascode2> <aliascode3 /> <aliascode4>METHYLAMYLKETONE</aliascode4> <aliascode5>METHYLAMYLKETONE</aliascode5> <aliascode6>Methylamylketon 165,5 KG</aliascode6> <aliascode7>METHYL N-AMYL KETONE (Bulk)</aliascode7> <aliascode8 /> <threshold>0</threshold> <datemodified>2012-04-24T22:52:56</datemodified> <ftypeind>0</ftypeind> <judgement /> </item> </fsxml> </fsxml>\[/code\]
 
Back
Top