***** UPDATED *****
How to iterate and collect into array of lines?
XML source and target:
Source:
<?xml version="1.0" encoding="UTF-8" ?>
<OutputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/sp/FBDI">
<P_IN>
<P_IN_ITEM>
<INVOICEHEADERIDENTIFIER>1</INVOICEHEADERIDENTIFIER>
<INVOICELINEIDENTIFIER>1</INVOICELINEIDENTIFIER>
<INVOICELINECOUNT>3</INVOICELINECOUNT>
<ACCOUNTINGDATE>string4</ACCOUNTINGDATE>
<BUSINESSUNIT>string6</BUSINESSUNIT>
<ACCOUNTCODINGSTATUS>string8</ACCOUNTCODINGSTATUS>
<ACCOUNTINGSTATUS>string10</ACCOUNTINGSTATUS>
<APPROVALSTATUS>string12</APPROVALSTATUS>
<CONVERSIONDATE>string14</CONVERSIONDATE>
<CONVERSIONRATE>16</CONVERSIONRATE>
<CONVERSIONRATETYPE>string17</CONVERSIONRATETYPE>
<DESCRIPTIONHEADER>string19</DESCRIPTIONHEADER>
<INVOICEAMOUNT>200</INVOICEAMOUNT>
<INVOICECURRENCY>string22</INVOICECURRENCY>
<INVOICEDATE>string24</INVOICEDATE>
<INVOICEDFFHEADER>string26</INVOICEDFFHEADER>
<INVOICENUMBER>1</INVOICENUMBER>
<INVOICESOURCE>string30</INVOICESOURCE>
<INVOICETYPE>string32</INVOICETYPE>
<PAYMENTCURRENCY>string34</PAYMENTCURRENCY>
<PAYMENTTERMS>string36</PAYMENTTERMS>
<TERMSDATE>string38</TERMSDATE>
<REQUESTER>string40</REQUESTER>
<SUPPLIERNUMBER>string42</SUPPLIERNUMBER>
<SUPPLIERSITE>string44</SUPPLIERSITE>
<TAXATIONCOUNTRY>string46</TAXATIONCOUNTRY>
<CREATEDBY>string48</CREATEDBY>
<CREATIONDATE>string50</CREATIONDATE>
<DOCUMENTCATEGORY>string52</DOCUMENTCATEGORY>
<VALIDATIONSTATUS>string54</VALIDATIONSTATUS>
<BASEAMOUNT>56</BASEAMOUNT>
<BUDGETDATE>2021-05-16T15:31:30.999</BUDGETDATE>
<DESCRIPTIONLINE>string57</DESCRIPTIONLINE>
<DISTRIBUTIONCOMBINATION>string59</DISTRIBUTIONCOMBINATION>
<INVOICELINEDFF>string61</INVOICELINEDFF>
<ITEM>string63</ITEM>
<ITEMDESCRIPTION>string65</ITEMDESCRIPTION>
<LINEAMOUNT>67</LINEAMOUNT>
<LINENUMBER>69</LINENUMBER>
<LINETYPE>string69</LINETYPE>
<QUANTITY>71</QUANTITY>
<UNITPRICE>72</UNITPRICE>
<UOM>string73</UOM>
<MATCHBASIS>string75</MATCHBASIS>
<MATCHOPTION>string77</MATCHOPTION>
<MATCHTYPE>string79</MATCHTYPE>
<PURCHASEORDERLINENUMBER>81</PURCHASEORDERLINENUMBER>
<PURCHASEORDERNUMBER>string82</PURCHASEORDERNUMBER>
<PURCHASEORDERSCHEDLINENUMBER>84</PURCHASEORDERSCHEDLINENUMBER>
<TAXCLASSIFICATION>string85</TAXCLASSIFICATION>
</P_IN_ITEM>
<P_IN_ITEM>
<INVOICEHEADERIDENTIFIER>1</INVOICEHEADERIDENTIFIER>
<INVOICELINEIDENTIFIER>1</INVOICELINEIDENTIFIER>
<INVOICELINECOUNT>89</INVOICELINECOUNT>
<ACCOUNTINGDATE>string90</ACCOUNTINGDATE>
<BUSINESSUNIT>string6</BUSINESSUNIT>
<ACCOUNTCODINGSTATUS>string94</ACCOUNTCODINGSTATUS>
<ACCOUNTINGSTATUS>string96</ACCOUNTINGSTATUS>
<APPROVALSTATUS>string98</APPROVALSTATUS>
<CONVERSIONDATE>string100</CONVERSIONDATE>
<CONVERSIONRATE>102</CONVERSIONRATE>
<CONVERSIONRATETYPE>string103</CONVERSIONRATETYPE>
<DESCRIPTIONHEADER>string105</DESCRIPTIONHEADER>
<INVOICEAMOUNT>200</INVOICEAMOUNT>
<INVOICECURRENCY>string108</INVOICECURRENCY>
<INVOICEDATE>string110</INVOICEDATE>
<INVOICEDFFHEADER>string112</INVOICEDFFHEADER>
<INVOICENUMBER>1</INVOICENUMBER>
<INVOICESOURCE>string116</INVOICESOURCE>
<INVOICETYPE>string118</INVOICETYPE>
<PAYMENTCURRENCY>string120</PAYMENTCURRENCY>
<PAYMENTTERMS>string122</PAYMENTTERMS>
<TERMSDATE>string124</TERMSDATE>
<REQUESTER>string126</REQUESTER>
<SUPPLIERNUMBER>string128</SUPPLIERNUMBER>
<SUPPLIERSITE>string130</SUPPLIERSITE>
<TAXATIONCOUNTRY>string132</TAXATIONCOUNTRY>
<CREATEDBY>string134</CREATEDBY>
<CREATIONDATE>string136</CREATIONDATE>
<DOCUMENTCATEGORY>string138</DOCUMENTCATEGORY>
<VALIDATIONSTATUS>string140</VALIDATIONSTATUS>
<BASEAMOUNT>142</BASEAMOUNT>
<BUDGETDATE>2021-05-16T15:31:31.000</BUDGETDATE>
<DESCRIPTIONLINE>string143</DESCRIPTIONLINE>
<DISTRIBUTIONCOMBINATION>string145</DISTRIBUTIONCOMBINATION>
<INVOICELINEDFF>string147</INVOICELINEDFF>
<ITEM>string149</ITEM>
<ITEMDESCRIPTION>string151</ITEMDESCRIPTION>
<LINEAMOUNT>153</LINEAMOUNT>
<LINENUMBER>68</LINENUMBER>
<LINETYPE>string155</LINETYPE>
<QUANTITY>157</QUANTITY>
<UNITPRICE>158</UNITPRICE>
<UOM>string159</UOM>
<MATCHBASIS>string161</MATCHBASIS>
<MATCHOPTION>string163</MATCHOPTION>
<MATCHTYPE>string165</MATCHTYPE>
<PURCHASEORDERLINENUMBER>167</PURCHASEORDERLINENUMBER>
<PURCHASEORDERNUMBER>string168</PURCHASEORDERNUMBER>
<PURCHASEORDERSCHEDLINENUMBER>170</PURCHASEORDERSCHEDLINENUMBER>
<TAXCLASSIFICATION>string171</TAXCLASSIFICATION>
</P_IN_ITEM>
<P_IN_ITEM>
<INVOICEHEADERIDENTIFIER>2</INVOICEHEADERIDENTIFIER>
<INVOICELINEIDENTIFIER>2</INVOICELINEIDENTIFIER>
<INVOICELINECOUNT>175</INVOICELINECOUNT>
<ACCOUNTINGDATE>string176</ACCOUNTINGDATE>
<BUSINESSUNIT>string178</BUSINESSUNIT>
<ACCOUNTCODINGSTATUS>string180</ACCOUNTCODINGSTATUS>
<ACCOUNTINGSTATUS>string182</ACCOUNTINGSTATUS>
<APPROVALSTATUS>string184</APPROVALSTATUS>
<CONVERSIONDATE>string186</CONVERSIONDATE>
<CONVERSIONRATE>188</CONVERSIONRATE>
<CONVERSIONRATETYPE>string189</CONVERSIONRATETYPE>
<DESCRIPTIONHEADER>string191</DESCRIPTIONHEADER>
<INVOICEAMOUNT>3</INVOICEAMOUNT>
<INVOICECURRENCY>string194</INVOICECURRENCY>
<INVOICEDATE>string196</INVOICEDATE>
<INVOICEDFFHEADER>string198</INVOICEDFFHEADER>
<INVOICENUMBER>222222222</INVOICENUMBER>
<INVOICESOURCE>string202</INVOICESOURCE>
<INVOICETYPE>string204</INVOICETYPE>
<PAYMENTCURRENCY>string206</PAYMENTCURRENCY>
<PAYMENTTERMS>string208</PAYMENTTERMS>
<TERMSDATE>string210</TERMSDATE>
<REQUESTER>string212</REQUESTER>
<SUPPLIERNUMBER>string214</SUPPLIERNUMBER>
<SUPPLIERSITE>string216</SUPPLIERSITE>
<TAXATIONCOUNTRY>string218</TAXATIONCOUNTRY>
<CREATEDBY>string220</CREATEDBY>
<CREATIONDATE>string222</CREATIONDATE>
<DOCUMENTCATEGORY>string224</DOCUMENTCATEGORY>
<VALIDATIONSTATUS>string226</VALIDATIONSTATUS>
<BASEAMOUNT>228</BASEAMOUNT>
<BUDGETDATE>2021-05-16T15:31:31.001</BUDGETDATE>
<DESCRIPTIONLINE>string229</DESCRIPTIONLINE>
<DISTRIBUTIONCOMBINATION>string231</DISTRIBUTIONCOMBINATION>
<INVOICELINEDFF>string233</INVOICELINEDFF>
<ITEM>string235</ITEM>
<ITEMDESCRIPTION>string237</ITEMDESCRIPTION>
<LINEAMOUNT>239</LINEAMOUNT>
<LINENUMBER>99999999</LINENUMBER>
<LINETYPE>string241</LINETYPE>
<QUANTITY>243</QUANTITY>
<UNITPRICE>244</UNITPRICE>
<UOM>string245</UOM>
<MATCHBASIS>string247</MATCHBASIS>
<MATCHOPTION>string249</MATCHOPTION>
<MATCHTYPE>string251</MATCHTYPE>
<PURCHASEORDERLINENUMBER>253</PURCHASEORDERLINENUMBER>
<PURCHASEORDERNUMBER>string254</PURCHASEORDERNUMBER>
<PURCHASEORDERSCHEDLINENUMBER>256</PURCHASEORDERSCHEDLINENUMBER>
<TAXCLASSIFICATION>string257</TAXCLASSIFICATION>
</P_IN_ITEM>
</P_IN>
<X_RETURN_STATUS>X_RETURN_STATUS259</X_RETURN_STATUS>
<X_MSG_COUNT>260</X_MSG_COUNT>
<X_MSG_DATA>X_MSG_DATA261</X_MSG_DATA>
</OutputParameters>
There is 2 headers:
Header number 1 with 2 lines(68,69)
Header number 2 with 1 line(99999999)
This is the flatten data returned from DB, I cannot change it.

I tried this logic in the XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:tns="http://Invoice.com/ServiceName"
xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/db/sp/FBDI"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
xmlns:oracle-xsl-mapper="http://www.oracle.com/xsl/mapper/schemas"
xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
xmlns:oraxsl="http://www.oracle.com/XSL/Transform/java"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes=" xsd oracle-xsl-mapper xsi xsl ns0 tns mhdr oraext xp20 xref socket dvm oraxsl"
xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns:ns2="http://xmlJSON.com/ServiceName">
<oracle-xsl-mapper:schema>
<!--SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY.-->
<oracle-xsl-mapper:mapSources>
<oracle-xsl-mapper:source type="WSDL">
<oracle-xsl-mapper:schema location="../WSDLs/FBDI.wsdl"/>
<oracle-xsl-mapper:rootElement name="OutputParameters"
namespace="http://xmlns.oracle.com/pcbpel/adapter/db/sp/FBDI%22/%3E
</oracle-xsl-mapper:source>
</oracle-xsl-mapper:mapSources>
<oracle-xsl-mapper:mapTargets>
<oracle-xsl-mapper:target type="WSDL">
<oracle-xsl-mapper:schema location="../WSDLs/.wsdl"/>
<oracle-xsl-mapper:rootElement name="Root-Element" namespace="http://Invoice.com/ServiceName"/>
</oracle-xsl-mapper:target>
</oracle-xsl-mapper:mapTargets>
<!--GENERATED BY ORACLE XSL MAPPER 12.2.1.3.0(XSLT Build 170820.1700.2557) AT [SUN MAY 16 17:24:58 IDT 2021].-->
</oracle-xsl-mapper:schema>
<!--User Editing allowed BELOW this line - DO NOT DELETE THIS LINE-->
<xsl:template match="/">
<tns:Root-Element>
<xsl:for-each select="/ns0:OutputParameters/ns0:P_IN/ns0:P_IN_ITEM[not(ns0:INVOICEHEADERIDENTIFIER =
preceding-sibling::ns0:P_IN_ITEM/ns0:INVOICEHEADERIDENTIFIER)]">
<xsl:sort select="ns0:INVOICEHEADERIDENTIFIER" case-order="lower-first"/>
<xsl:variable name="v_identifier"
select="/ns0:OutputParameters/ns0:P_IN/ns0:P_IN_ITEM/ns0:INVOICEHEADERIDENTIFIER"/>
<tns:P_ITEM>
<tns:AccountingDate/>
<tns:BusinessUnit>
<xsl:value-of select="ns0:BUSINESSUNIT"/>
</tns:BusinessUnit>
<tns:ProcurementBU/>
<tns:InvoiceNumber>
<xsl:value-of select="ns0:INVOICEHEADERIDENTIFIER"/>
</tns:InvoiceNumber>
<tns:InvoiceCurrency/>
<tns:InvoiceAmount>
<xsl:value-of select="ns0:INVOICEAMOUNT"/>
</tns:InvoiceAmount>
<tns:InvoiceDate>
<xsl:value-of select="ns0:INVOICEDATE"/>
</tns:InvoiceDate>
<tns:Supplier>
<xsl:value-of select="ns0:SUPPLIERNUMBER"/>
</tns:Supplier>
<tns:SupplierSite>
<xsl:value-of select="ns0:SUPPLIERSITE"/>
</tns:SupplierSite>
<tns:PaymentCurrency>
<xsl:value-of select="ns0:PAYMENTCURRENCY"/>
</tns:PaymentCurrency>
<tns:InvoiceType>
<xsl:value-of select="ns0:INVOICETYPE"/>
</tns:InvoiceType>
<tns:Description>
<xsl:value-of select="ns0:DESCRIPTIONHEADER"/>
</tns:Description>
<tns:TermsDate>
<xsl:value-of select="ns0:TERMSDATE"/>
</tns:TermsDate>
<tns:Requester>
<xsl:value-of select="ns0:REQUESTER"/>
</tns:Requester>
<xsl:variable name="v_lineNumber"
select="/ns0:OutputParameters/ns0:P_IN/ns0:P_IN_ITEM/ns0:LINENUMBER"/>
<xsl:for-each select="/ns0:OutputParameters/ns0:P_IN/ns0:P_IN_ITEM[ns0:INVOICELINEIDENTIFIER = $v_identifier][ns0:LINENUMBER = $v_lineNumber]">
<tns:invoiceLines>
<tns:LineNumber>
<xsl:value-of select="ns0:LINENUMBER"/>
</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>
<xsl:value-of select="ns0:LINEAMOUNT"/>
</tns:LineAmount>
<tns:Description>
<xsl:value-of select="ns0:DESCRIPTIONLINE"/>
</tns:Description>
<tns:DistributionCombination>
<xsl:value-of select="ns0:DISTRIBUTIONCOMBINATION"/>
</tns:DistributionCombination>
</tns:invoiceLines>
</xsl:for-each>
</tns:P_ITEM>
</xsl:for-each>
</tns:Root-Element>
</xsl:template>
</xsl:stylesheet>
Ther returned output:
Target
<?xml version = '1.0' encoding = 'UTF-8'?>
<tns:Root-Element xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:ns2="http://xmlJSON.com/ServiceName" xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/ad/FBDI" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:client="http://xmlns.oracle.com/adPELProcess" xmlns:tns="http://Invoice.com/ServiceName">
<tns:P_ITEM>
<tns:AccountingDate/>
<tns:BusinessUnit>string6</tns:BusinessUnit>
<tns:ProcurementBU/>
<tns:InvoiceNumber>1</tns:InvoiceNumber>
<tns:InvoiceCurrency/>
<tns:InvoiceAmount>200</tns:InvoiceAmount>
<tns:InvoiceDate>string24</tns:InvoiceDate>
<tns:Supplier>string42</tns:Supplier>
<tns:SupplierSite>string44</tns:SupplierSite>
<tns:PaymentCurrency>string34</tns:PaymentCurrency>
<tns:InvoiceType>string32</tns:InvoiceType>
<tns:Description>string19</tns:Description>
<tns:TermsDate>string38</tns:TermsDate>
<tns:Requester>string40</tns:Requester>
<tns:invoiceLines>
<tns:LineNumber>1</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>67</tns:LineAmount>
<tns:Description>string57</tns:Description>
<tns:DistributionCombination>string59</tns:DistributionCombination>
</tns:invoiceLines>
<tns:invoiceLines>
<tns:LineNumber>2</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>153</tns:LineAmount>
<tns:Description>string143</tns:Description>
<tns:DistributionCombination>string145</tns:DistributionCombination>
</tns:invoiceLines>
<tns:invoiceLines>
<tns:LineNumber>99999999</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>239</tns:LineAmount>
<tns:Description>string229</tns:Description>
<tns:DistributionCombination>string231</tns:DistributionCombination>
</tns:invoiceLines>
</tns:P_ITEM>
<tns:P_ITEM>
<tns:AccountingDate/>
<tns:BusinessUnit>string178</tns:BusinessUnit>
<tns:ProcurementBU/>
<tns:InvoiceNumber>2</tns:InvoiceNumber>
<tns:InvoiceCurrency/>
<tns:InvoiceAmount>3</tns:InvoiceAmount>
<tns:InvoiceDate>string196</tns:InvoiceDate>
<tns:Supplier>string214</tns:Supplier>
<tns:SupplierSite>string216</tns:SupplierSite>
<tns:PaymentCurrency>string206</tns:PaymentCurrency>
<tns:InvoiceType>string204</tns:InvoiceType>
<tns:Description>string191</tns:Description>
<tns:TermsDate>string210</tns:TermsDate>
<tns:Requester>string212</tns:Requester>
<tns:invoiceLines>
<tns:LineNumber>1</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>67</tns:LineAmount>
<tns:Description>string57</tns:Description>
<tns:DistributionCombination>string59</tns:DistributionCombination>
</tns:invoiceLines>
<tns:invoiceLines>
<tns:LineNumber>2</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>153</tns:LineAmount>
<tns:Description>string143</tns:Description>
<tns:DistributionCombination>string145</tns:DistributionCombination>
</tns:invoiceLines>
<tns:invoiceLines>
<tns:LineNumber>99999999</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>239</tns:LineAmount>
<tns:Description>string229</tns:Description>
<tns:DistributionCombination>string231</tns:DistributionCombination>
</tns:invoiceLines>
</tns:P_ITEM>
</tns:Root-Element>
I want that the desired output:
<?xml version = '1.0' encoding = 'UTF-8'?>
<tns:Root-Element xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:ns2="http://xmlJSON.com/ServiceName" xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/ad/FBDI" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:client="http://xmlns.oracle.com/adPELProcess" xmlns:tns="http://Invoice.com/ServiceName">
<tns:P_ITEM>
<tns:AccountingDate/>
<tns:BusinessUnit>string6</tns:BusinessUnit>
<tns:ProcurementBU/>
<tns:InvoiceNumber>1</tns:InvoiceNumber>
<tns:InvoiceCurrency/>
<tns:InvoiceAmount>200</tns:InvoiceAmount>
<tns:InvoiceDate>string24</tns:InvoiceDate>
<tns:Supplier>string42</tns:Supplier>
<tns:SupplierSite>string44</tns:SupplierSite>
<tns:PaymentCurrency>string34</tns:PaymentCurrency>
<tns:InvoiceType>string32</tns:InvoiceType>
<tns:Description>string19</tns:Description>
<tns:TermsDate>string38</tns:TermsDate>
<tns:Requester>string40</tns:Requester>
<tns:invoiceLines>
<tns:LineNumber>1</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>67</tns:LineAmount>
<tns:Description>string57</tns:Description>
<tns:DistributionCombination>string59</tns:DistributionCombination>
</tns:invoiceLines>
<tns:invoiceLines>
<tns:LineNumber>2</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>153</tns:LineAmount>
<tns:Description>string143</tns:Description>
<tns:DistributionCombination>string145</tns:DistributionCombination>
</tns:invoiceLines>
</tns:P_ITEM>
<tns:P_ITEM>
<tns:AccountingDate/>
<tns:BusinessUnit>string178</tns:BusinessUnit>
<tns:ProcurementBU/>
<tns:InvoiceNumber>2</tns:InvoiceNumber>
<tns:InvoiceCurrency/>
<tns:InvoiceAmount>3</tns:InvoiceAmount>
<tns:InvoiceDate>string196</tns:InvoiceDate>
<tns:Supplier>string214</tns:Supplier>
<tns:SupplierSite>string216</tns:SupplierSite>
<tns:PaymentCurrency>string206</tns:PaymentCurrency>
<tns:InvoiceType>string204</tns:InvoiceType>
<tns:Description>string191</tns:Description>
<tns:TermsDate>string210</tns:TermsDate>
<tns:Requester>string212</tns:Requester>
<tns:invoiceLines>
<tns:LineNumber>99999999</tns:LineNumber>
<tns:LineType/>
<tns:LineAmount>239</tns:LineAmount>
<tns:Description>string229</tns:Description>
<tns:DistributionCombination>string231</tns:DistributionCombination>
</tns:invoiceLines>
</tns:P_ITEM>
</tns:Root-Element>
I am using JDeveloper BPEL Designer where to put the XSLT file? Is the XSLT saved as .xsl file which is then just imported into project folder? And how does the Assign have to look like? I want to assign the new list to a variable of type datacontainerreferencelist (defined with XSD, which has exactly the structure of the given How to do it in for each in XSLT, its possible?
Thanks.

Please try the following XSLT.
You would need to specify your real namespace URI for the tns prefix.
XSLT
Output
XSLT #2
Output XML #2