XSLT copy parent element tree inside child template

xXx15

New Member
Well, for example I have an XML:\[code\]<ProcessPurchaseOrder > <PurchaseOrderLine> <DocumentReference type="sendersReference2"> <DocumentID> <ID>100</ID> </DocumentID> </DocumentReference> <DocumentReference type="sendersReference3"> <DocumentID> <ID>ru</ID> </DocumentID> </DocumentReference> <Item> <CustomerItemID> <ID>00126</ID> </CustomerItemID> </Item> </PurchaseOrderLine> <PurchaseOrderLine> <DocumentReference type="sendersReference2"> <DocumentID> <ID>200</ID> </DocumentID> </DocumentReference> <DocumentReference type="sendersReference3"> <DocumentID> <ID>ru</ID> </DocumentID> </DocumentReference> <Item> <CustomerItemID> <ID>123122</ID> </CustomerItemID> </Item> </PurchaseOrderLine></ProcessPurchaseOrder>\[/code\]and part of XSLT:\[code\] <xsl:for-each select="*:PurchaseOrderLine"> <xsl:variable name="ArtNr" select="*:Item/*:CustomerItemID/*:ID"/> <xsl:variable name="WepNr" select="/*/DbResponse/ResultSet/Row[Cell[@name='ARTNR']=$ArtNr][Cell[@name='WEANR']=$WeaNr]/Cell[@name='WEPNR']"/> <xsl:copy> <xsl:if test="$WepNr!=''"> <xsl:for-each select="$WepNr"> <LineNumber><xsl:value-of select="$WepNr/current()"/></LineNumber> </xsl:for-each> </xsl:if> <xsl:apply-templates select="@*|node()"/> </xsl:copy></xsl:for-each>\[/code\]For every \[code\]$WepNr\[/code\] value I want to copy whole \[code\]<PurchaseOrderLine>\[/code\] and insert \[code\]<LineNumber>\[/code\] with current \[code\]WepNr\[/code\] value.So, for example: if \[code\]$WepNr\[/code\] for 1st PurchaseOrderLine returns: 16; 26 result will be:\[code\]<ProcessPurchaseOrder > <PurchaseOrderLine> <!-- wepnr[1] = 16 --> <LineNumber>16</LineNumber> <DocumentReference type="sendersReference2"> <DocumentID> <ID>100</ID> </DocumentID> </DocumentReference> <DocumentReference type="sendersReference3"> <DocumentID> <ID>ru</ID> </DocumentID> </DocumentReference> <Item> <CustomerItemID> <ID>00126</ID> </CustomerItemID> </Item> </PurchaseOrderLine> <PurchaseOrderLine> <!-- copied PurchaseOrderLine with wepnr[2]=26 --> <LineNumber>26</LineNumber> <DocumentReference type="sendersReference2"> <DocumentID> <ID>100</ID> </DocumentID> </DocumentReference> <DocumentReference type="sendersReference3"> <DocumentID> <ID>ru</ID> </DocumentID> </DocumentReference> <Item> <CustomerItemID> <ID>00126</ID> </CustomerItemID> </Item> </PurchaseOrderLine> <!-- here is 2nd PurchaseOrderLine> <!-- ... --></ProcessPurchaseOrder>\[/code\]Is it possible?UPD:DBresponse XML part\[code\]<DbResponse> <ResultSet> <Row> <Cell name="WEANR" type="VARCHAR2">1909123</Cell> <Cell name="ARTNR" type="VARCHAR2">00126</Cell> <Cell name="WEPNR" type="VARCHAR2">1</Cell> </Row> <Row> <Cell name="WEANR" type="VARCHAR2">1909123</Cell> <Cell name="ARTNR" type="VARCHAR2">00126</Cell> <Cell name="WEPNR" type="VARCHAR2">16</Cell> </Row> </ResultSet></DbResponse>\[/code\]It just means that \[code\]WepNr\[/code\] could return multiple values: like "\[code\]1 16\[/code\]" in this case
 
Back
Top