今天分享EDI报文转换,主要围绕X12标准 850 采购订单展开介绍。

以下方案的源代码先分享出来。
https://www.kasoftware.com/translation/edi_xml_convert_sample.html

实现EDI转自定义XML,可以分两步完成。

  1. 根据国际标准,先将EDI文件转换为标准的XML文件;
  2. 通过脚本,实现标准XML与自定义XML的关系映射。

以850采购订单为例,源文件如下:

ISA*00*          *00*          *ZZ*WAYNE_TECH     *ZZ*ACME           *160609*1330*U*00401*000000007*0*T*>~
GS*PO*WAYNE_TECH*ACME*20160609*1330*7*T*004010~
ST*850*0001~
BEG*00*DS*0476696888**20150708~
REF*SB*ZZ11~
REF*6P*ZZ~
REF*8M*0056~
REF*CR*1070335099~
REF*CO*7109790082~
PER*CN*ACME, Inc.*TE*(555) 555-5555~
CSH*SC~
SAC*C*ZZZZ**********06~
TD5*Z*2*123456~
N9*PD*ZCOF~
MSG*Thanks!~
N1*BY*Wayne Tech*92*5601~
N2*Wayne Tech*~
N3*125 WayneHigh Road.~
N1*EN*ACME, Inc.~
N1*ST*Wayne Tech Plant 1*92*0000505462~
N2*Wayne Tech Plant 1*~
N3*100 Wayne Ave.~
N4*Chapel Hill*MX*27514*US**~
PO1**500000*EA*495*TP*BP*337S3744*VP*422242224~
PID*F****500,000 red widgets****EN~
SCH*500000*EA***002*20180708~
PO1**100*EA*395*HP*BP*337S3745*VP*422242226~
PID*F****100 blue widgets****EN~
SCH*100*EA***002*20180708~
PO1**500*EA*210*TP*BP*337S3746*VP*422201210~
PID*F****AH-0310 red widgets****EN~
SCH*500*EA***002*20180708~
PO1**150*EA*350*TP*BP*337S3747*VP*422241452~
PID*F****F-100 blue widgets****EN~
SCH*100*EA***002*20180708~
PO1**500000*EA*495*TP*BP*337S3748*VP*422244512~
PID*F****HU-021 black widgets****EN~
SCH*500000*EA***002*20180708~
PO1**1500*EA*3000*HP*BP*337S3749*VP*422241023~
PID*F****100-20J widgets****EN~
SCH*100*EA***002*20180708~
CTT*6*500100~
SE*39*0001~
GE*1*7~
IEA*1*000000007~

先看转换标准XML的结果,内容看似很长,一半以上的内容都是注释,解释每个字段对应的业务含义,即便没有EDI规范,也可以快速了解该EDI文件都包含了哪些业务数据:

<Interchange Delimiters=":*. ^~" xmlns="http://www.rssbus.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Meta><!--Authorization Information Qualifier--><ISA01><!--No Authorization Information Present (No Meaningful Information in I02)-->00</ISA01><!--Authorization Information--><ISA02>          </ISA02><!--Security Information Qualifer--><ISA03>00</ISA03><!--Security Information--><ISA04>          </ISA04><!--Interchange ID Qualifier--><ISA05><!--Mutually Defined-->ZZ</ISA05><!--Interchange Sender ID--><ISA06>WAYNE_TECH     </ISA06><!--Interchange ID Qualifier--><ISA07><!--Mutually Defined-->ZZ</ISA07><!--Interchange Receiver ID--><ISA08>ACME           </ISA08><!--Interchange Date--><ISA09>160609</ISA09><!--Interchange Time--><ISA10>1330</ISA10><!--Interchange Control Standards Identifier--><ISA11>U</ISA11><!--Interchange Control Version Number Code--><ISA12><!--Standards Approved for Publication by ASC X12 Procedures Review Board through October 1997-->00401</ISA12><!--Inter Control Number--><ISA13>000000007</ISA13><!--Acknowlegment Requested Code--><ISA14>0</ISA14><!--Interchange Usage Indicator Code--><ISA15><!--Test Data-->T</ISA15><!--Component Element Separator--><ISA16>&gt;</ISA16></Meta><FunctionalGroup><Meta><!--Functional Identifier Code--><GS01><!--Purchase Order (850)-->PO</GS01><!--Application Sender&apos;s Code--><GS02>WAYNE_TECH</GS02><!--Application Receiver&apos;s Code--><GS03>ACME</GS03><!--Date--><GS04>20160609</GS04><!--Time--><GS05>1330</GS05><!--Group Control Number--><GS06>7</GS06><!--Responsible Agency Code--><GS07><!--Transportation Data Coordinating Committee (TDCC)-->T</GS07><!--Version / Release / Industry Identifier Code--><GS08><!--Standards Approved for Publication by ASC X12 Procedures Review Board through October 1997-->004010</GS08></Meta><TransactionSet><TX-00401-850 type="TransactionSet"><Meta><!--Transaction Set Identifier Code--><ST01><!--Purchase Order-->850</ST01><!--Transaction Set Control Number--><ST02>0001</ST02></Meta><BEG type="Segment"><!--Transaction Set Purpose Code--><BEG01><!--Original-->00</BEG01><!--Purchase Order Type Code--><BEG02><!--Dropship-->DS</BEG02><!--Purchase Order Number--><BEG03>0476696888</BEG03><!--Release Number--><BEG04 xsi:nil="true"/><!--Date--><BEG05>20150708</BEG05></BEG><REF type="Segment"><!--Reference Identification Qualifier--><REF01><!--Sales Region Number-->SB</REF01><!--Reference Identification--><REF02>ZZ11</REF02></REF><REF type="Segment"><!--Reference Identification Qualifier--><REF01><!--Group Number-->6P</REF01><!--Reference Identification--><REF02>ZZ</REF02></REF><REF type="Segment"><!--Reference Identification Qualifier--><REF01><!--Originating Company Identifier-->8M</REF01><!--Reference Identification--><REF02>0056</REF02></REF><REF type="Segment"><!--Reference Identification Qualifier--><REF01><!--Customer Reference Number-->CR</REF01><!--Reference Identification--><REF02>1070335099</REF02></REF><REF type="Segment"><!--Reference Identification Qualifier--><REF01><!--Customer Order Number-->CO</REF01><!--Reference Identification--><REF02>7109790082</REF02></REF><PER type="Segment"><!--Contact Function Code--><PER01><!--General Contact-->CN</PER01><!--Name--><PER02>ACME, Inc.</PER02><!--Communication Number Qualifier--><PER03><!--Telephone-->TE</PER03><!--Communication Number--><PER04>(555) 555-5555</PER04></PER><CSH type="Segment"><!--Sales Requirement Code--><CSH01><!--Ship Complete-->SC</CSH01></CSH><SACLoop1 type="Loop"><SAC type="Segment"><!--Allowance or Charge Indicator--><SAC01>C</SAC01><!--Service, Promotion, Allowance, or Charge Code--><SAC02><!--Mutually Defined-->ZZZZ</SAC02><!--Agency Qualifier Code--><SAC03/><!--Agency Service, Promotion, Allowance, or Charge Code--><SAC04 xsi:nil="true"/><!--Amount--><SAC05 xsi:nil="true"/><!--Allowance/Charge Percent Qualifier--><SAC06/><!--Percent--><SAC07 xsi:nil="true"/><!--Rate--><SAC08 xsi:nil="true"/><!--Unit or Basis for Measurement Code--><SAC09/><!--Quantity--><SAC10 xsi:nil="true"/><!--Quantity--><SAC11 xsi:nil="true"/><!--Allowance or Charge Method of Handling Code--><SAC12><!--Charge to be Paid by Customer-->06</SAC12></SAC></SACLoop1><TD5 type="Segment"><!--Routing Sequence Code--><TD501><!--Mutually Defined-->Z</TD501><!--Identification Code Qualifier--><TD502><!--Standard Carrier Alpha Code (SCAC)-->2</TD502><!--Identification Code--><TD503>123456</TD503></TD5><N9Loop1 type="Loop"><N9 type="Segment"><!--Reference Identification Qualifier--><N901><!--Promotion/Deal Number-->PD</N901><!--Reference Identification--><N902>ZCOF</N902></N9><MSG type="Segment"><!--Free-Form Message Text--><MSG01>Thanks!</MSG01></MSG></N9Loop1><N1Loop1 type="Loop"><N1 type="Segment"><!--Entity Identifier Code--><N101><!--Buying Party (Purchaser)-->BY</N101><!--Name--><N102>Wayne Tech</N102><!--Identification Code Qualifier--><N103><!--Assigned by Buyer or Buyer&apos;s Agent-->92</N103><!--Identification Code--><N104>5601</N104></N1><N2 type="Segment"><!--Name--><N201>Wayne Tech</N201></N2><N3 type="Segment"><!--Address Information--><N301>125 WayneHigh Road.</N301></N3></N1Loop1><N1Loop1 type="Loop"><N1 type="Segment"><!--Entity Identifier Code--><N101><!--End User-->EN</N101><!--Name--><N102>ACME, Inc.</N102></N1></N1Loop1><N1Loop1 type="Loop"><N1 type="Segment"><!--Entity Identifier Code--><N101><!--Ship To-->ST</N101><!--Name--><N102>Wayne Tech Plant 1</N102><!--Identification Code Qualifier--><N103><!--Assigned by Buyer or Buyer&apos;s Agent-->92</N103><!--Identification Code--><N104>0000505462</N104></N1><N2 type="Segment"><!--Name--><N201>Wayne Tech Plant 1</N201></N2><N3 type="Segment"><!--Address Information--><N301>100 Wayne Ave.</N301></N3><N4 type="Segment"><!--City Name--><N401>Chapel Hill</N401><!--State or Province Code--><N402>MX</N402><!--Postal Code--><N403>27514</N403><!--Country Code--><N404>US</N404></N4></N1Loop1><PO1Loop1 type="Loop"><PO1 type="Segment"><!--Assigned Identification--><PO101 xsi:nil="true"/><!--Quantity Ordered--><PO102>500000</PO102><!--Unit or Basis for Measurement Code--><PO103><!--Each-->EA</PO103><!--Unit Price--><PO104>495</PO104><!--Basis of Unit Price Code--><PO105><!--Price per Thousand-->TP</PO105><!--Product/Service ID Qualifier--><PO106><!--Buyer&apos;s Part Number-->BP</PO106><!--Product/Service ID--><PO107>337S3744</PO107><!--Product/Service ID Qualifier--><PO108><!--Vendor&apos;s (Seller&apos;s) Part Number-->VP</PO108><!--Product/Service ID--><PO109>422242224</PO109></PO1><PIDLoop1 type="Loop"><PID type="Segment"><!--Item Description Type--><PID01>F</PID01><!--Product/Process Characteristic Code--><PID02/><!--Agency Qualifier Code--><PID03/><!--Product Description Code--><PID04 xsi:nil="true"/><!--Description--><PID05>500,000 red widgets</PID05><!--Surface/Layer/Position Code--><PID06/><!--Source Subqualifier--><PID07 xsi:nil="true"/><!--Yes/No Condition or Response Code--><PID08/><!--Language Code--><PID09>EN</PID09></PID></PIDLoop1><SCHLoop1 type="Loop"><SCH type="Segment"><!--Quantity--><SCH01>500000</SCH01><!--Unit or Basis for Measurement Code--><SCH02><!--Each-->EA</SCH02><!--Entity Identifier Code--><SCH03/><!--Name--><SCH04 xsi:nil="true"/><!--Date/Time Qualifier--><SCH05><!--Delivery Requested-->002</SCH05><!--Date--><SCH06>20180708</SCH06></SCH></SCHLoop1></PO1Loop1><PO1Loop1 type="Loop"><PO1 type="Segment"><!--Assigned Identification--><PO101 xsi:nil="true"/><!--Quantity Ordered--><PO102>100</PO102><!--Unit or Basis for Measurement Code--><PO103><!--Each-->EA</PO103><!--Unit Price--><PO104>395</PO104><!--Basis of Unit Price Code--><PO105><!--Price per Hundred-->HP</PO105><!--Product/Service ID Qualifier--><PO106><!--Buyer&apos;s Part Number-->BP</PO106><!--Product/Service ID--><PO107>337S3745</PO107><!--Product/Service ID Qualifier--><PO108><!--Vendor&apos;s (Seller&apos;s) Part Number-->VP</PO108><!--Product/Service ID--><PO109>422242226</PO109></PO1><PIDLoop1 type="Loop"><PID type="Segment"><!--Item Description Type--><PID01>F</PID01><!--Product/Process Characteristic Code--><PID02/><!--Agency Qualifier Code--><PID03/><!--Product Description Code--><PID04 xsi:nil="true"/><!--Description--><PID05>100 blue widgets</PID05><!--Surface/Layer/Position Code--><PID06/><!--Source Subqualifier--><PID07 xsi:nil="true"/><!--Yes/No Condition or Response Code--><PID08/><!--Language Code--><PID09>EN</PID09></PID></PIDLoop1><SCHLoop1 type="Loop"><SCH type="Segment"><!--Quantity--><SCH01>100</SCH01><!--Unit or Basis for Measurement Code--><SCH02><!--Each-->EA</SCH02><!--Entity Identifier Code--><SCH03/><!--Name--><SCH04 xsi:nil="true"/><!--Date/Time Qualifier--><SCH05><!--Delivery Requested-->002</SCH05><!--Date--><SCH06>20180708</SCH06></SCH></SCHLoop1></PO1Loop1><PO1Loop1 type="Loop"><PO1 type="Segment"><!--Assigned Identification--><PO101 xsi:nil="true"/><!--Quantity Ordered--><PO102>500</PO102><!--Unit or Basis for Measurement Code--><PO103><!--Each-->EA</PO103><!--Unit Price--><PO104>210</PO104><!--Basis of Unit Price Code--><PO105><!--Price per Thousand-->TP</PO105><!--Product/Service ID Qualifier--><PO106><!--Buyer&apos;s Part Number-->BP</PO106><!--Product/Service ID--><PO107>337S3746</PO107><!--Product/Service ID Qualifier--><PO108><!--Vendor&apos;s (Seller&apos;s) Part Number-->VP</PO108><!--Product/Service ID--><PO109>422201210</PO109></PO1><PIDLoop1 type="Loop"><PID type="Segment"><!--Item Description Type--><PID01>F</PID01><!--Product/Process Characteristic Code--><PID02/><!--Agency Qualifier Code--><PID03/><!--Product Description Code--><PID04 xsi:nil="true"/><!--Description--><PID05>AH-0310 red widgets</PID05><!--Surface/Layer/Position Code--><PID06/><!--Source Subqualifier--><PID07 xsi:nil="true"/><!--Yes/No Condition or Response Code--><PID08/><!--Language Code--><PID09>EN</PID09></PID></PIDLoop1><SCHLoop1 type="Loop"><SCH type="Segment"><!--Quantity--><SCH01>500</SCH01><!--Unit or Basis for Measurement Code--><SCH02><!--Each-->EA</SCH02><!--Entity Identifier Code--><SCH03/><!--Name--><SCH04 xsi:nil="true"/><!--Date/Time Qualifier--><SCH05><!--Delivery Requested-->002</SCH05><!--Date--><SCH06>20180708</SCH06></SCH></SCHLoop1></PO1Loop1><PO1Loop1 type="Loop"><PO1 type="Segment"><!--Assigned Identification--><PO101 xsi:nil="true"/><!--Quantity Ordered--><PO102>150</PO102><!--Unit or Basis for Measurement Code--><PO103><!--Each-->EA</PO103><!--Unit Price--><PO104>350</PO104><!--Basis of Unit Price Code--><PO105><!--Price per Thousand-->TP</PO105><!--Product/Service ID Qualifier--><PO106><!--Buyer&apos;s Part Number-->BP</PO106><!--Product/Service ID--><PO107>337S3747</PO107><!--Product/Service ID Qualifier--><PO108><!--Vendor&apos;s (Seller&apos;s) Part Number-->VP</PO108><!--Product/Service ID--><PO109>422241452</PO109></PO1><PIDLoop1 type="Loop"><PID type="Segment"><!--Item Description Type--><PID01>F</PID01><!--Product/Process Characteristic Code--><PID02/><!--Agency Qualifier Code--><PID03/><!--Product Description Code--><PID04 xsi:nil="true"/><!--Description--><PID05>F-100 blue widgets</PID05><!--Surface/Layer/Position Code--><PID06/><!--Source Subqualifier--><PID07 xsi:nil="true"/><!--Yes/No Condition or Response Code--><PID08/><!--Language Code--><PID09>EN</PID09></PID></PIDLoop1><SCHLoop1 type="Loop"><SCH type="Segment"><!--Quantity--><SCH01>100</SCH01><!--Unit or Basis for Measurement Code--><SCH02><!--Each-->EA</SCH02><!--Entity Identifier Code--><SCH03/><!--Name--><SCH04 xsi:nil="true"/><!--Date/Time Qualifier--><SCH05><!--Delivery Requested-->002</SCH05><!--Date--><SCH06>20180708</SCH06></SCH></SCHLoop1></PO1Loop1><PO1Loop1 type="Loop"><PO1 type="Segment"><!--Assigned Identification--><PO101 xsi:nil="true"/><!--Quantity Ordered--><PO102>500000</PO102><!--Unit or Basis for Measurement Code--><PO103><!--Each-->EA</PO103><!--Unit Price--><PO104>495</PO104><!--Basis of Unit Price Code--><PO105><!--Price per Thousand-->TP</PO105><!--Product/Service ID Qualifier--><PO106><!--Buyer&apos;s Part Number-->BP</PO106><!--Product/Service ID--><PO107>337S3748</PO107><!--Product/Service ID Qualifier--><PO108><!--Vendor&apos;s (Seller&apos;s) Part Number-->VP</PO108><!--Product/Service ID--><PO109>422244512</PO109></PO1><PIDLoop1 type="Loop"><PID type="Segment"><!--Item Description Type--><PID01>F</PID01><!--Product/Process Characteristic Code--><PID02/><!--Agency Qualifier Code--><PID03/><!--Product Description Code--><PID04 xsi:nil="true"/><!--Description--><PID05>HU-021 black widgets</PID05><!--Surface/Layer/Position Code--><PID06/><!--Source Subqualifier--><PID07 xsi:nil="true"/><!--Yes/No Condition or Response Code--><PID08/><!--Language Code--><PID09>EN</PID09></PID></PIDLoop1><SCHLoop1 type="Loop"><SCH type="Segment"><!--Quantity--><SCH01>500000</SCH01><!--Unit or Basis for Measurement Code--><SCH02><!--Each-->EA</SCH02><!--Entity Identifier Code--><SCH03/><!--Name--><SCH04 xsi:nil="true"/><!--Date/Time Qualifier--><SCH05><!--Delivery Requested-->002</SCH05><!--Date--><SCH06>20180708</SCH06></SCH></SCHLoop1></PO1Loop1><PO1Loop1 type="Loop"><PO1 type="Segment"><!--Assigned Identification--><PO101 xsi:nil="true"/><!--Quantity Ordered--><PO102>1500</PO102><!--Unit or Basis for Measurement Code--><PO103><!--Each-->EA</PO103><!--Unit Price--><PO104>3000</PO104><!--Basis of Unit Price Code--><PO105><!--Price per Hundred-->HP</PO105><!--Product/Service ID Qualifier--><PO106><!--Buyer&apos;s Part Number-->BP</PO106><!--Product/Service ID--><PO107>337S3749</PO107><!--Product/Service ID Qualifier--><PO108><!--Vendor&apos;s (Seller&apos;s) Part Number-->VP</PO108><!--Product/Service ID--><PO109>422241023</PO109></PO1><PIDLoop1 type="Loop"><PID type="Segment"><!--Item Description Type--><PID01>F</PID01><!--Product/Process Characteristic Code--><PID02/><!--Agency Qualifier Code--><PID03/><!--Product Description Code--><PID04 xsi:nil="true"/><!--Description--><PID05>100-20J widgets</PID05><!--Surface/Layer/Position Code--><PID06/><!--Source Subqualifier--><PID07 xsi:nil="true"/><!--Yes/No Condition or Response Code--><PID08/><!--Language Code--><PID09>EN</PID09></PID></PIDLoop1><SCHLoop1 type="Loop"><SCH type="Segment"><!--Quantity--><SCH01>100</SCH01><!--Unit or Basis for Measurement Code--><SCH02><!--Each-->EA</SCH02><!--Entity Identifier Code--><SCH03/><!--Name--><SCH04 xsi:nil="true"/><!--Date/Time Qualifier--><SCH05><!--Delivery Requested-->002</SCH05><!--Date--><SCH06>20180708</SCH06></SCH></SCHLoop1></PO1Loop1><CTTLoop1 type="Loop"><CTT type="Segment"><!--Number of Line Items--><CTT01>6</CTT01><!--Hash Total--><CTT02>500100</CTT02></CTT></CTTLoop1></TX-00401-850></TransactionSet></FunctionalGroup>
</Interchange>

大家可以看下这个XML结构,其标签名称与原始EDI文件的Segment名称都是对应的,从BEG开始,到CTT Segment,不同的segment涵盖不同的业务数据,根据该XML的Xpath取相关的业务数据,难易程度比直接处理EDI文件低很多。

接下来说说,如何从该XML文件获取数据,生成一个自定义XML。先看Mapping 源代码,这段代码可在Script Port直接运行。

<!-- NOTE: Do not edit -->
<rsb:info title="Custom Script" desc="This script will be executed when a file is processed."><input name="PortId"        desc="The id of this port." /><input name="MessageId"     desc="The message id." /><input name="FilePath"      desc="The path of the file being processed." /><input name="FileName"      desc="The name of the file being processed." /><output name="Data"         desc="The data that will be write to Receive folder." /><output name="FileName"     desc="The name of the output file in Receive folder." />
</rsb:info><rsb:set attr="input.uri" value="[FilePath]"/>
<rsb:set attr="input.xpath" value="/Interchange/FunctionalGroup/TransactionSet/TX-00401-850" /><rsb:call op="xmlDOMSearch" in="input"><rsb:set attr="po.po_no" value="[xpath('BEG/BEG03') | def]" /><rsb:set attr="output.data"><PURORDER><CustomerId>[xpath("REF\[REF01='8M'\]/REF02") | def]</CustomerId><ReferenceNumber>[xpath("REF\[REF01='CR'\]/REF02") | def]</ReferenceNumber><PONumber>[xpath("BEG/BEG03") | def]</PONumber><BillAddress>[xpath("N1Loop1\[N1/N101='BY'\]/N2/N201") | def]</BillAddress><BillLine1>[xpath("N1Loop1\[N1/N101='BY'\]/N3/N301") | def]</BillLine1><BillLine2>[xpath("N1Loop1\[N1/N101='BY'\]/N3/N302") | def]</BillLine2><BillCity>[xpath("N1Loop1\[N1/N101='BY'\]/N4/N401") | def]</BillCity><BillState>[xpath("N1Loop1\[N1/N101='BY'\]/N4/N402") | def]</BillState><BillZip >[xpath("N1Loop1\[N1/N101='BY'\]/N4/N403")  | def]</BillZip ><BillCountry>[xpath("N1Loop1\[N1/N101='BY'\]/N4/N404") | def]</BillCountry><ShipAddress>[xpath("N1Loop1\[N1/N101='ST'\]/N2/N201") | def]</ShipAddress><ShipLine1>[xpath("N1Loop1\[N1/N101='ST'\]/N3/N301") | def]</ShipLine1><ShipLine2>[xpath("N1Loop1\[N1/N101='ST'\]/N3/N302") | def]</ShipLine2><ShipCity>[xpath("N1Loop1\[N1/N101='ST'\]/N4/N401") | def]</ShipCity><ShipState>[xpath("N1Loop1\[N1/N101='ST'\]/N4/N402") | def]</ShipState><ShipZip>[xpath("N1Loop1\[N1/N101='ST'\]/N4/N403") | def]</ShipZip><ShipCountry>[xpath("N1Loop1\[N1/N101='ST'\]/N4/N404") | def]</ShipCountry><rsb:call op="xmlDOMSearch?xpath=PO1Loop1"><PURORDERLINEITEMS><ItemQty>[xpath("PO1/PO102") | def]</ItemQty>     <ItemQtyUnit>[xpath("PO1/PO103") | def]</ItemQtyUnit><ItemPrice>[xpath("PO1/PO104") | def]</ItemPrice><ItemPriceUnit>[xpath("PO1/PO105") | def]</ItemPriceUnit><ItemVendorNo>[xpath("PO1/PO109") | def]</ItemVendorNo><ItemDesc>[xpath("PIDLoop1/PID/PID05") | def]</ItemDesc><DueDate>[xpath("DTM\[DTM01='002'\]/DTM02") | def]</DueDate></PURORDERLINEITEMS></rsb:call></PURORDER></rsb:set>
</rsb:call><rsb:set attr="output.filename" value="PO850#[po.po_no].xml"/>
<rsb:push item="output"/>

代码实现部分,唯一的亮点就是调用了XMLDomSearch这个ops,掌握了它的调用,又如掌握了全世界:-)
如何正确调用XMLDOMSearch,请看下图。

输出结果如下:

<PURORDER><CustomerId>0056</CustomerId><ReferenceNumber>1070335099</ReferenceNumber><PONumber>0476696888</PONumber><BillAddress>Wayne Tech</BillAddress><BillLine1>125 WayneHigh Road.</BillLine1><BillLine2></BillLine2><BillCity></BillCity><BillState></BillState><BillZip ></BillZip><BillCountry></BillCountry><ShipAddress>Wayne Tech Plant 1</ShipAddress><ShipLine1>100 Wayne Ave.</ShipLine1><ShipLine2></ShipLine2><ShipCity>Chapel Hill</ShipCity><ShipState>MX</ShipState><ShipZip>27514</ShipZip><ShipCountry>US</ShipCountry><PURORDERLINEITEMS><ItemQty>500000</ItemQty>     <ItemQtyUnit>EA</ItemQtyUnit><ItemPrice>495</ItemPrice><ItemPriceUnit>TP</ItemPriceUnit><ItemVendorNo>422242224</ItemVendorNo><ItemDesc>500,000 red widgets</ItemDesc><DueDate></DueDate></PURORDERLINEITEMS><PURORDERLINEITEMS><ItemQty>100</ItemQty>     <ItemQtyUnit>EA</ItemQtyUnit><ItemPrice>395</ItemPrice><ItemPriceUnit>HP</ItemPriceUnit><ItemVendorNo>422242226</ItemVendorNo><ItemDesc>100 blue widgets</ItemDesc><DueDate></DueDate></PURORDERLINEITEMS><PURORDERLINEITEMS><ItemQty>500</ItemQty>     <ItemQtyUnit>EA</ItemQtyUnit><ItemPrice>210</ItemPrice><ItemPriceUnit>TP</ItemPriceUnit><ItemVendorNo>422201210</ItemVendorNo><ItemDesc>AH-0310 red widgets</ItemDesc><DueDate></DueDate></PURORDERLINEITEMS><PURORDERLINEITEMS><ItemQty>150</ItemQty>     <ItemQtyUnit>EA</ItemQtyUnit><ItemPrice>350</ItemPrice><ItemPriceUnit>TP</ItemPriceUnit><ItemVendorNo>422241452</ItemVendorNo><ItemDesc>F-100 blue widgets</ItemDesc><DueDate></DueDate></PURORDERLINEITEMS><PURORDERLINEITEMS><ItemQty>500000</ItemQty>     <ItemQtyUnit>EA</ItemQtyUnit><ItemPrice>495</ItemPrice><ItemPriceUnit>TP</ItemPriceUnit><ItemVendorNo>422244512</ItemVendorNo><ItemDesc>HU-021 black widgets</ItemDesc><DueDate></DueDate></PURORDERLINEITEMS><PURORDERLINEITEMS><ItemQty>1500</ItemQty>     <ItemQtyUnit>EA</ItemQtyUnit><ItemPrice>3000</ItemPrice><ItemPriceUnit>HP</ItemPriceUnit><ItemVendorNo>422241023</ItemVendorNo><ItemDesc>100-20J widgets</ItemDesc><DueDate></DueDate></PURORDERLINEITEMS>
</PURORDER>

如何EDI标准文件转换为自定义XML?相关推荐

  1. docx 转 html api,将docX转换为自定义XML

    docx4j可用于通过XSLT将OpenXML转换为任意XML. 假设模板xslt和javax.xml.transform.stream.StreamResult结果,你会做这样的事情: Wordpr ...

  2. 【Groovy】自定义 Xml 生成器 BuilderSupport ( 创建 XmlNode 节点 | 管理 XmlNode 节点并将根节点转为 Xml 信息 | 完整代码示例 )

    文章目录 一.创建 XmlNode 节点 二.管理 XmlNode 节点并将根节点转为 Xml 信息 三.完整代码示例 1.自定义 Xml 生成器 MyBuilderSupport 2.Xml 节点封 ...

  3. 【Groovy】自定义 Xml 生成器 BuilderSupport ( nodeCompleted 方法获取节点闭合信息 )

    文章目录 一.nodeCompleted 方法获取节点闭合信息 二.完整代码示例 1.MyBuilderSupport 生成器代码 2.使用 MyBuilderSupport 生成器创建 Xml 代码 ...

  4. 【Groovy】自定义 Xml 生成器 BuilderSupport ( setParent 方法中设置父节点与子节点关系 )

    文章目录 一.setParent 方法中设置父节点与子节点关系 二.完整代码示例 1.MyBuilderSupport 生成器代码 2.使用 MyBuilderSupport 生成器创建 Xml 代码 ...

  5. 【Groovy】自定义 Xml 生成器 BuilderSupport ( 继承 BuilderSupport 抽象类 | 在 createNode 方法中获取节点名称、节点属性、节点值信息 )

    文章目录 一.继承 BuilderSupport 抽象类 二.在 createNode 方法中获取节点名称.节点属性.节点值信息 三.完整代码示例 1.MyBuilderSupport 生成器代码 2 ...

  6. Android自定义XML属性以及遇到的命名空间的问题

    转载请注明出处:http://www.cnblogs.com/kross/p/3458068.html 最近在做一些UI,很蠢很蠢的重复写了很多代码,比如一个自定义的UI Tab,由一个ImageVi ...

  7. Groovy中转换成java,Groovy将字符串类型转换为自定义类型的方法

    将一个字符串转换为自定义类型: 例如Quantity是自定义的一个class,现在想这么调用 Quantity quantity = "100个" as Quantity 或 de ...

  8. Winform中对自定义xml配置文件进行Xml节点的添加与删除

    场景 Winform中自定义xml配置文件后对节点进行读取与写入: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10053213 ...

  9. Winform中自定义xml配置文件后对节点进行读取与写入

    场景 Winform中自定义xml配置文件,并配置获取文件路径: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100522648 ...

  10. Winform中自定义xml配置文件,并配置获取文件路径

    场景 在Winform程序中,需要将一些配置项存到配置文件中,这时就需要自定义xml的配置文件格式.并在一些工具类中去获取配置文件的路径并加载其内容. 关注公众号 霸道的程序猿 获取编程相关电子书.教 ...

最新文章

  1. Python之区块链简单记账本实现
  2. ceil和floor
  3. Linux学习系列之Nginx调优实战
  4. OpenCV:OpenCV4.0更新
  5. java比较equlse_java基础知识要点
  6. jq 鼠标指向隐藏显示区域
  7. 新年发财专属红包封面,高端大气上档次!
  8. 直接拿来用的 CTO 创业技术栈指南!
  9. 金属商务本-戴尔Vostro成就3450评测
  10. 对方qq空间权限需要申请访问怎么破解
  11. Java调用第三方http接口的方式
  12. 各种最短路算法能够处理的情况(优劣比较,时间复杂度等)
  13. Python 元组大全
  14. 现在流行的少儿编程是不是再收大家的智商税?来看看最中肯的回答
  15. 数据结构(计算机存储、组织数据方式)
  16. 手工转换中缀式与前、后缀式(转)
  17. ThinkPHP3.2.3 where注入
  18. GPU Profiling 101
  19. 互联网企业的项目管理者:免费的才是最贵的
  20. dom元素转化成字符串;字符串html 转换成 实际代码html; innerHTML, outerHTML,

热门文章

  1. teams快捷键_每个Microsoft Teams键盘快捷键及其使用方法
  2. 智能DNS - 免费智能DNS解析服务-迄今为止最好用的智能DNS
  3. 什么是APS高级计划排程系统?APS计划排产有什么功能和作用?
  4. 详细解说iexplore.exe
  5. 洛谷 P3332 BZOJ 3110 [ZJOI2013]K大数查询
  6. 数据分析之--Mataplotlib入门
  7. 微信公众账号开发模式3
  8. 自动控制原理专业词汇中英文对照(一)
  9. 【机翻】xenomai RTnet – 灵活的硬实时网络框架
  10. python产品管理系统_python实现超市商品销售管理系统