Created
May 2, 2024 16:29
-
-
Save nk-gears/7f0f49079bc0a62ac14a282e851c6e70 to your computer and use it in GitHub Desktop.
test xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<!-- Define the input and output XML namespaces --> | |
<xsl:output method="xml" indent="yes"/> | |
<!-- Root template that matches the source XML's root element --> | |
<xsl:template match="/Receive"> | |
<Root> | |
<!-- Iterate through each E2EDL37005GRP element --> | |
<xsl:for-each select="idocData/E2EDL20003GRP/E2EDL37005GRP"> | |
<!-- Start transforming each group into an Order --> | |
<Order> | |
<!-- OrderNumber: hardcoded based on the position --> | |
<xsl:choose> | |
<xsl:when test="position() = 1"> | |
<OrderNumber>5500034975Dumm</OrderNumber> | |
</xsl:when> | |
<xsl:otherwise> | |
<OrderNumber>5500034974</OrderNumber> | |
</xsl:otherwise> | |
</xsl:choose> | |
<!-- HL03 --> | |
<HL03>I</HL03> | |
<!-- Lin01 --> | |
<xsl:variable name="posnr" select="E2EDL44004GRP/E2EDL44004/POSNR"/> | |
<Lin01> | |
<xsl:value-of select="$posnr"/> | |
</Lin01> | |
<!-- Lin02 --> | |
<Lin02>SK</Lin02> | |
<!-- Lin03 --> | |
<xsl:variable name="kdmat"> | |
<xsl:for-each select="../../E2EDL24007GRP"> | |
<xsl:if test="E2EDL24007/POSNR = $posnr"> | |
<xsl:value-of select="E2EDL24007/KDMAT"/> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:variable> | |
<Lin03> | |
<xsl:value-of select="$kdmat"/> | |
</Lin03> | |
<!-- Lin04 --> | |
<Lin04>VP</Lin04> | |
<!-- Lin05 --> | |
<xsl:choose> | |
<xsl:when test="$kdmat='857152000102'"> | |
<Lin05>138UF87M</Lin05> | |
</xsl:when> | |
<xsl:when test="$kdmat='857152000101'"> | |
<Lin05>7086099U01</Lin05> | |
</xsl:when> | |
<xsl:otherwise> | |
<Lin05 /> | |
</xsl:otherwise> | |
</xsl:choose> | |
<!-- Lin06, Lin07, SN101, SN102, SN103 --> | |
<Lin06> | |
<xsl:value-of select="$posnr"/> | |
</Lin06> | |
<Lin07> | |
<xsl:value-of select="$posnr"/> | |
</Lin07> | |
<SN101> | |
<xsl:value-of select="$posnr"/> | |
</SN101> | |
<SN102>10.000</SN102> | |
<SN103>LBR</SN103> | |
<!-- Lin08 --> | |
<xsl:choose> | |
<xsl:when test="$kdmat='857152000102'"> | |
<Lin08>86 045X550#OMP 4/PLT</Lin08> | |
</xsl:when> | |
<xsl:when test="$kdmat='857152000101'"> | |
<Lin08>86 035X1100# MPU 2/PLT PB</Lin08> | |
</xsl:when> | |
<xsl:otherwise> | |
<Lin08 /> | |
</xsl:otherwise> | |
</xsl:choose> | |
<!-- Lin09 --> | |
<Lin09 /> | |
<!-- Lin10 and Lin11 --> | |
<Lin10>10.000</Lin10> | |
<Lin11> 10.000</Lin11> | |
<!-- Lin12 --> | |
<xsl:choose> | |
<xsl:when test="$kdmat='857152000102'"> | |
<Lin12>662303674793</Lin12> | |
</xsl:when> | |
<xsl:when test="$kdmat='857152000101'"> | |
<Lin12>662303213091</Lin12> | |
</xsl:when> | |
<xsl:otherwise> | |
<Lin12 /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</Order> | |
</xsl:for-each> | |
<!-- Other elements of the root --> | |
<Man02>0083521965</Man02> | |
<VendorNumber>0000007691</VendorNumber> | |
<CarrierCode /> | |
<BillTo /> | |
<GrossWeight>20.000</GrossWeight> | |
<UnitOfMeasure>LBR</UnitOfMeasure> | |
<FreightInformation>00002</FreightInformation> | |
<ZZShipQTY /> | |
</Root> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment