M
MKline
Hello,
I have XML source to map to XML output. I am having trouble getting
the XSL to loop through the entire XML until it reaches the end. This
is an ASN for a Customer and I am getting the first ASN in my output,
but can't get it to continue to next <CUSTASN> and so on until the end.
Suggestions would be greatly appreciated.
Thanks
Source is like this and repeats starting with <CUSTASN> until the end
of all shipment data:
<?xml version="1.0" encoding="UTF-8"?>
<CUSTASN>
<SUPPID>8840 </SUPPID>
<DUNSNO>141 </DUNSNO>
<PLTNME>ACUNA 141 </PLTNME>
<GRWGT>32</GRWGT>
<CONTDE>CTN90</CONTDE>
<CQTY>1</CQTY>
<SHPDTE>2006-12-07</SHPDTE>
<F3WRBT>3747040 00 </F3WRBT>
<USR20C>I202723 </USR20C>
<TODAY>2006-12-12</TODAY>
<PONO>600777 </PONO>
<POLIN>89 </POLIN>
<CPART>213256 </CPART>
<ENGREV>0 </ENGREV>
<UOFMM>EA </UOFMM>
<RELNO>1205060924</RELNO>
<RLSDTE>2006-11-21</RLSDTE>
<QTYSHP>400</QTYSHP>
<SHPDTE01>2006-12-07</SHPDTE01>
</CUSTASN>
.......repeats with next <CUSTASN> until end of XML.....
Target is this format (based on Customer requirement):
<?xml version="1.0" encoding="UTF-8"?>
<MXSCSHIPMENT>
<SUPPLIER></SUPPLIER>
<SHIPFROM></SHIPFROM>
<FACILITY></FACILITY>
<SHIPTO></SHIPTO>
<CREATEDATE></CREATEDATE>
<NUMASN></NUMASN>
<!-- Must match # of ASN Elements included in transaction -->
<ASN>
<!-- One or More ASN Elements must be present -->
<ASNNUMBER/>
<!-- Include ASN Number or if null, system will generate -->
<ASNDATE></ASNDATE>
<CONTAINERTYPE></CONTAINERTYPE>
<!-- Must contain valid MxSC Code of type CONTAINERTYPE -->
<NUMCONTAINERS></NUMCONTAINERS>
<LENGTH></LENGTH>
<WIDTH></WIDTH>
<HEIGHT></HEIGHT>
<GROSSWEIGHT></GROSSWEIGHT>
<LENGTH_UOM></LENGTH_UOM>
<!-- Must contain valid MxSC Code of type LENGTHUOM -->
<WIDTH_UOM></WIDTH_UOM>
<!-- Must contain valid MxSC Code of type LENGTHUOM -->
<HEIGHT_UOM></HEIGHT_UOM>
<!-- Must contain valid MxSC Code of type LENGTHUOM -->
<GROSSWEIGHT_UOM></GROSSWEIGHT_UOM>
<!-- Must contain valid MxSC Code of type WEIGHTUOM -->
<ROUTING></ROUTING>
<PAYMENTMETHOD></PAYMENTMETHOD>
<!-- Must contain valid MxSC Code of type PAYMENTTYPE-->
<TRACKINGNUMBER></TRACKINGNUMBER>
<PACKINGSLIP></PACKINGSLIP>
<NUMSHIPMENTS></NUMSHIPMENTS>
<SHIPMENT>
<PONUMBER></PONUMBER>
<POLINE></POLINE>
<ITEM></ITEM>
<REVISION></REVISION>
<UOM></UOM>
<RELEASEDATE></RELEASEDATE>
<!-- Either this or ReleaseNum are required -->
<RELEASENUM>4</RELEASENUM>
<!-- Customer won't use ReleaseNum -->
<SHIPDATE></SHIPDATE>
<SHIPQUANTITY></SHIPQUANTITY>
</SHIPMENT>
<SHIPMENT>
<PONUMBER></PONUMBER>
<POLINE></POLINE>
<ITEM></ITEM>
<REVISION></REVISION>
<UOM></UOM>
<RELEASEDATE></RELEASEDATE>
<!-- Either this or ReleaseNum are required -->
<RELEASENUM></RELEASENUM>
<!-- Customer won't use ReleaseNum -->
<SHIPDATE></SHIPDATE>
<SHIPQUANTITY></SHIPQUANTITY>
</SHIPMENT>
</ASN>
</MXSCSHIPMENT>
XSL:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<MXSCSHIPMENT>
<SUPPLIER>
<xsl:value-of select="s:sequence/CUSTASN/SUPPID"/>
</SUPPLIER>
<SHIPFROM>
<xsl:value-of select="s:sequence/CUSTASN/SUPPID"/>
</SHIPFROM>
<FACILITY>
<xsl:value-of select="s:sequence/CUSTASN/PLTNME"/>
</FACILITY>
<SHIPTO>
<xsl:value-of select="s:sequence/CUSTASN/DUNSNO"/>
</SHIPTO>
<CREATEDATE>
<xsl:value-of select="s:sequence/CUSTASN/TODAY"/>
</CREATEDATE>
<NUMASN>
<xsl:value-of select="count(s:sequence/CUSTASN/USR20C)"/>
</NUMASN>
<ASN>
<ASNNUMBER>
<xsl:value-of select="s:sequence/CUSTASN/USR20C"/>
</ASNNUMBER>
<CONTAINERTYPE>
<xsl:value-of select="s:sequence/CUSTASN/CONTDE"/>
</CONTAINERTYPE>
<NUMCONTAINERS>
<xsl:value-of select="s:sequence/CUSTASN/CQTY"/>
</NUMCONTAINERS>
<GROSSWEIGHT>
<xsl:value-of select="s:sequence/CUSTASN/GRWGT"/>
</GROSSWEIGHT>
<GROSSWEIGHT_UOM>
<xsl:value-of select="'LB'"/>
</GROSSWEIGHT_UOM>
<PACKINGSLIP>
<xsl:value-of select="s:sequence/CUSTASN/F3WRBT"/>
</PACKINGSLIP>
<NUMSHIPMENTS>
<xsl:value-of select="count(s:sequence/CUSTASN/F3WRBT)"/>
</NUMSHIPMENTS>
<SHIPMENT>
<PONUMBER>
<xsl:value-of select="s:sequence/CUSTASN/PONO"/>
</PONUMBER>
<POLINE>
<xsl:value-of select="s:sequence/CUSTASN/POLIN"/>
</POLINE>
<ITEM>
<xsl:value-of select="s:sequence/CUSTASN/CPART"/>
</ITEM>
<REVISION>
<xsl:value-of select="s:sequence/CUSTASN/ENGREV"/>
</REVISION>
<UOM>
<xsl:value-of select="s:sequence/CUSTASN/UOFMM"/>
</UOM>
<RELEASEDATE>
<xsl:value-of select="s:sequence/CUSTASN/RLSDTE"/>
</RELEASEDATE>
<SHIPDATE>
<xsl:value-of select="s:sequence/CUSTASN/SHPDTE"/>
</SHIPDATE>
<SHIPQUANTITY>
<xsl:value-of select="s:sequence/CUSTASN/QTYSHP"/>
</SHIPQUANTITY>
</SHIPMENT>
</ASN>
</MXSCSHIPMENT>
</xsl:template>
</xsl:stylesheet>
I have XML source to map to XML output. I am having trouble getting
the XSL to loop through the entire XML until it reaches the end. This
is an ASN for a Customer and I am getting the first ASN in my output,
but can't get it to continue to next <CUSTASN> and so on until the end.
Suggestions would be greatly appreciated.
Thanks
Source is like this and repeats starting with <CUSTASN> until the end
of all shipment data:
<?xml version="1.0" encoding="UTF-8"?>
<CUSTASN>
<SUPPID>8840 </SUPPID>
<DUNSNO>141 </DUNSNO>
<PLTNME>ACUNA 141 </PLTNME>
<GRWGT>32</GRWGT>
<CONTDE>CTN90</CONTDE>
<CQTY>1</CQTY>
<SHPDTE>2006-12-07</SHPDTE>
<F3WRBT>3747040 00 </F3WRBT>
<USR20C>I202723 </USR20C>
<TODAY>2006-12-12</TODAY>
<PONO>600777 </PONO>
<POLIN>89 </POLIN>
<CPART>213256 </CPART>
<ENGREV>0 </ENGREV>
<UOFMM>EA </UOFMM>
<RELNO>1205060924</RELNO>
<RLSDTE>2006-11-21</RLSDTE>
<QTYSHP>400</QTYSHP>
<SHPDTE01>2006-12-07</SHPDTE01>
</CUSTASN>
.......repeats with next <CUSTASN> until end of XML.....
Target is this format (based on Customer requirement):
<?xml version="1.0" encoding="UTF-8"?>
<MXSCSHIPMENT>
<SUPPLIER></SUPPLIER>
<SHIPFROM></SHIPFROM>
<FACILITY></FACILITY>
<SHIPTO></SHIPTO>
<CREATEDATE></CREATEDATE>
<NUMASN></NUMASN>
<!-- Must match # of ASN Elements included in transaction -->
<ASN>
<!-- One or More ASN Elements must be present -->
<ASNNUMBER/>
<!-- Include ASN Number or if null, system will generate -->
<ASNDATE></ASNDATE>
<CONTAINERTYPE></CONTAINERTYPE>
<!-- Must contain valid MxSC Code of type CONTAINERTYPE -->
<NUMCONTAINERS></NUMCONTAINERS>
<LENGTH></LENGTH>
<WIDTH></WIDTH>
<HEIGHT></HEIGHT>
<GROSSWEIGHT></GROSSWEIGHT>
<LENGTH_UOM></LENGTH_UOM>
<!-- Must contain valid MxSC Code of type LENGTHUOM -->
<WIDTH_UOM></WIDTH_UOM>
<!-- Must contain valid MxSC Code of type LENGTHUOM -->
<HEIGHT_UOM></HEIGHT_UOM>
<!-- Must contain valid MxSC Code of type LENGTHUOM -->
<GROSSWEIGHT_UOM></GROSSWEIGHT_UOM>
<!-- Must contain valid MxSC Code of type WEIGHTUOM -->
<ROUTING></ROUTING>
<PAYMENTMETHOD></PAYMENTMETHOD>
<!-- Must contain valid MxSC Code of type PAYMENTTYPE-->
<TRACKINGNUMBER></TRACKINGNUMBER>
<PACKINGSLIP></PACKINGSLIP>
<NUMSHIPMENTS></NUMSHIPMENTS>
<SHIPMENT>
<PONUMBER></PONUMBER>
<POLINE></POLINE>
<ITEM></ITEM>
<REVISION></REVISION>
<UOM></UOM>
<RELEASEDATE></RELEASEDATE>
<!-- Either this or ReleaseNum are required -->
<RELEASENUM>4</RELEASENUM>
<!-- Customer won't use ReleaseNum -->
<SHIPDATE></SHIPDATE>
<SHIPQUANTITY></SHIPQUANTITY>
</SHIPMENT>
<SHIPMENT>
<PONUMBER></PONUMBER>
<POLINE></POLINE>
<ITEM></ITEM>
<REVISION></REVISION>
<UOM></UOM>
<RELEASEDATE></RELEASEDATE>
<!-- Either this or ReleaseNum are required -->
<RELEASENUM></RELEASENUM>
<!-- Customer won't use ReleaseNum -->
<SHIPDATE></SHIPDATE>
<SHIPQUANTITY></SHIPQUANTITY>
</SHIPMENT>
</ASN>
</MXSCSHIPMENT>
XSL:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<MXSCSHIPMENT>
<SUPPLIER>
<xsl:value-of select="s:sequence/CUSTASN/SUPPID"/>
</SUPPLIER>
<SHIPFROM>
<xsl:value-of select="s:sequence/CUSTASN/SUPPID"/>
</SHIPFROM>
<FACILITY>
<xsl:value-of select="s:sequence/CUSTASN/PLTNME"/>
</FACILITY>
<SHIPTO>
<xsl:value-of select="s:sequence/CUSTASN/DUNSNO"/>
</SHIPTO>
<CREATEDATE>
<xsl:value-of select="s:sequence/CUSTASN/TODAY"/>
</CREATEDATE>
<NUMASN>
<xsl:value-of select="count(s:sequence/CUSTASN/USR20C)"/>
</NUMASN>
<ASN>
<ASNNUMBER>
<xsl:value-of select="s:sequence/CUSTASN/USR20C"/>
</ASNNUMBER>
<CONTAINERTYPE>
<xsl:value-of select="s:sequence/CUSTASN/CONTDE"/>
</CONTAINERTYPE>
<NUMCONTAINERS>
<xsl:value-of select="s:sequence/CUSTASN/CQTY"/>
</NUMCONTAINERS>
<GROSSWEIGHT>
<xsl:value-of select="s:sequence/CUSTASN/GRWGT"/>
</GROSSWEIGHT>
<GROSSWEIGHT_UOM>
<xsl:value-of select="'LB'"/>
</GROSSWEIGHT_UOM>
<PACKINGSLIP>
<xsl:value-of select="s:sequence/CUSTASN/F3WRBT"/>
</PACKINGSLIP>
<NUMSHIPMENTS>
<xsl:value-of select="count(s:sequence/CUSTASN/F3WRBT)"/>
</NUMSHIPMENTS>
<SHIPMENT>
<PONUMBER>
<xsl:value-of select="s:sequence/CUSTASN/PONO"/>
</PONUMBER>
<POLINE>
<xsl:value-of select="s:sequence/CUSTASN/POLIN"/>
</POLINE>
<ITEM>
<xsl:value-of select="s:sequence/CUSTASN/CPART"/>
</ITEM>
<REVISION>
<xsl:value-of select="s:sequence/CUSTASN/ENGREV"/>
</REVISION>
<UOM>
<xsl:value-of select="s:sequence/CUSTASN/UOFMM"/>
</UOM>
<RELEASEDATE>
<xsl:value-of select="s:sequence/CUSTASN/RLSDTE"/>
</RELEASEDATE>
<SHIPDATE>
<xsl:value-of select="s:sequence/CUSTASN/SHPDTE"/>
</SHIPDATE>
<SHIPQUANTITY>
<xsl:value-of select="s:sequence/CUSTASN/QTYSHP"/>
</SHIPQUANTITY>
</SHIPMENT>
</ASN>
</MXSCSHIPMENT>
</xsl:template>
</xsl:stylesheet>