EDIFACT - EANCOM - V007 PURCHASE ORDER message - reverseXSL Sample (prepared by Bernard H. August 2009) ********************************************************************* ** FOREWORD: This is a tutorial sample. ** ** ** ** IMPORTANT: understanding Regular Expressions is a MUST before ** ** looking any further; your guessing attempts will be defeated! ** ** A one hour tutorial is available at the web site. ** ********************************************************************* (every line not starting in column 1 is a comment or annotation ignored by the Parser) (best displayed with fixed-spacing font) Next lines support integrated testing facilities (within StylusStudio(TM)) #ONE=ORDER001.edi; #TWO=--N/A--; REVISIONS: - This version and associated samples have been developed to illustrate the parsing of EDIFACT interchanges and are bound to the terms of use published at www.reversexsl.com DESIGN NOTES: * EAN, the international Article Numbering association, has historically published several versions of EDIFACT message subsets for use by the retail industry. The version 7 of the purchase order subset (EDIFACT ORDERS message) is still in wide use by the industry. * *** the message is assumed as an EANCOM order of the proper version *** this verification is performed *** by a match on the UNH segment like: UNH+27691754+ORDERS:D:93A:UN:EAN007' ---------- SETTINGS ----------------------- SET RELEASECHARACTER '?' ---------- CONDITIONS --------------------- *** The matching ref verification reg-exp reads as: ()capture from ^start on input .any char *repeated ?reluctantly *** up to a ~tilda char, followed by \1=the copy of what the 1st capturing group has captured, up to $end of input. COND MatchingMsgRefs "(^.*?)~\1$" DEPTH 1 R F "Message references in UNH/UNT must be identical to ensure message integrity" COND MatchingInterchgRefs "(^.*?)~\1$" DEPTH 0 R F "Interchange references in UNB/UNZ must be identical to ensure Interchange integrity" COND FirstLast "[CF]" DEPTH 2 R W "One letter, C or F for Creation or Final" COND DateTimeFormat "101|102|201|203" DEPTH 3 R W "one of (coded) YYMMDD(101), CCYYMMDD(102), YYMMDDHHMM(201), CCYYMMDDHHMM(203)" COND G07DateTimeFormat "101|102|201|203" DEPTH 4 R W "one of (coded) YYMMDD(101), CCYYMMDD(102), YYMMDDHHMM(201), CCYYMMDDHHMM(203)" COND G25DateTimeFormat "101|102|201|203" DEPTH 4 R W "one of (coded) YYMMDD(101), CCYYMMDD(102), YYMMDDHHMM(201), CCYYMMDDHHMM(203)" ---------- MESSAGE DEFINITION ------------- *** by construction, the pattern in MSG has an identification role limited to the first segmented piece! *** here, a UNA or UNB segment. MSG "^UN[AB]" EAN-Orders-v7 M 1 1 ACC 1 T F "EDIFACT Interchange containing EANCOM ORDERS V007" CUT-ON-(') |D "^UNA(.*)" SKIP O 0 1 ACC 1 R W "UNA service segment - skipped" ASMATCHED *** UNB *** |SEG "^UNB" InterchangeHeader M 1 1 ACC 1 T F "UNB Interchange Header" CUT-ON-(+) ||D "(UNB)" SKIP M 1 1 ACC 1 T F "UNB segment tag" ASMATCHED ||SEG "" Syntax M 1 1 ACC 1 R W "UNB-S001 composite data" CUT-ON-(:) |||D "(.*)" @Identifier M 1 1 ACC 1 R W "UNB-0001 - Syntax identifier" ALPHA [4..4] |||D "(.*)" @Version M 1 1 ACC 1 R W "UNB-0002 - Syntax version number" NUMERIC [1..1] ||SEG "" Sender M 1 1 ACC 1 R W "UNB-S002 composite data" CUT-ON-(:) |||GRP "" Identifier M 1 1 ACC 1 R W "UNB-0004 - Sender identifier & Qualifier" ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0004 - Sender identifier" ASMATCHED [1..35] ||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "UNB-0007 - Sender id code qualifier" ASMATCHED [1..4] |||D "(.*)" ReverseRouting O 0 1 ACC 1 R W "UNB-0008 - Address for Reverse Routing" ASMATCHED [1..14] ||SEG "" Recipient M 1 1 ACC 1 R W "UNB-S003 composite data" CUT-ON-(:) |||GRP "" Identifier M 1 1 ACC 1 R W "UNB-0010 - Recipient identifier & Qualifier" ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0010 - Recipient identifier" ASMATCHED [1..35] ||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "UNB-0007 - Recipient id code qualifier" ASMATCHED [1..4] |||D "(.*)" Routing O 0 1 ACC 1 R W "UNB-0014 - Address for Routing" ASMATCHED [1..14] ||SEG "" Date M 1 1 ACC 1 R W "UNB-S004 composite data" CUT-ON-(:) |||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0010 - Date YYMMDD" NUMERIC [6..6] |||D "(.*)" NOTAG O 0 1 ACC 1 R W "UNB-0007 - Time HHMM" NUMERIC [4..4] ||D "(.*)" Reference C 1 1 ACC 1 COND MatchingInterchgRefs "(.*)" "UNB-0020 - INTERCHANGE CONTROL REFERENCE" ASMATCHED [1..14] ||SEG "" Password O 0 1 ACC 1 R W "UNB-S005 composite data" CUT-ON-(:) |||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0022 - Recipient's reference/password" ASMATCHED [1..14] |||D "(.*)" @Qualifier O 0 1 ACC 1 R W "UNB-0025 - Recipient's reference/password qualifier" ASMATCHED [2..2] ||D "(.*)" ApplicationReference O 0 1 ACC 1 R W "UNB-0026 - APPLICATION REFERENCE" ASMATCHED [1..14] ||D "(.*)" PriorityCode O 0 1 ACC 1 R W "UNB-0029 - PROCESSING PRIORITY CODE" ALPHA [1..1] ||D "(.*)" AckRequest O 0 1 ACC 1 R W "UNB-0031 - ACKNOWLEDGEMENT REQUEST" NUMERIC [1..1] ||D "(.*)" AgreementId O 0 1 ACC 1 R W "UNB-0032 - COMMUNICATIONS AGREEMENT ID" ASMATCHED [1..35] ||D "(.*)" @Test O 0 1 ACC 1 R W "UNB-0035 - TEST INDICATOR" NUMERIC [1..1] === MAIN EDIFACT MESSAGE === |GRP "^UNH" Message M 1 999 ACC 999 T F "UNH-UNT Message" *** UNH *** ||SEG "^UNH" NOTAG M 1 1 ACC 1 T F "UNH Message Header" CUT-ON-(+) |||D "(UNH)" SKIP M 1 1 ACC 1 T F "UNH segment tag" ASMATCHED |||D "(.*)" Reference C 1 1 ACC 1 COND MatchingMsgRefs "(.*)" "UNH-0062 MESSAGE REFERENCE NUMBER" ASMATCHED [1..14] |||SEG "" NOTAG M 1 1 ACC 1 R W "UNH-S009 composite data" CUT-ON-(:) ||||D "(.*)" @Type M 1 1 ACC 1 R W "UNH-0065 - Message type" ASMATCHED [1..6] ||||D "(.*)" @Ver M 1 1 ACC 1 R W "UNH-0052 - Message version number" ASMATCHED [1..3] ||||D "(.*)" @Rel M 1 1 ACC 1 R W "UNH-0054 - Message release number" ASMATCHED [1..3] ||||D "(.*)" @Agency M 1 1 ACC 1 R W "UNH-0051 - Controling agency" ASMATCHED [1..2] ||||D "(.*)" @AssocCode O 0 1 ACC 1 R W "UNH-0057 - Association assigned code" ASMATCHED [1..6] |||D "(.*)" CommonReference O 0 1 ACC 1 R W "UNH-0068 COMMON ACCESS REFERENCE" ASMATCHED [1..35] |||SEG "" TransferSequence O 0 1 ACC 1 R W "UNH-S010 composite data" CUT-ON-(:) ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNH-0070 - Sequence of the transfers" NUMERIC [1..2] ||||D "(.*)" SKIP C 0 1 ACC 1 COND FirstLast "(.*)" "UNH-0073 - First and last transfer" ALPHA [1..1] ||||MARK @Status COND FirstLast "C" "Creation" "NULL" ||||MARK @Status COND FirstLast "F" "Final" "NULL" *** BGM *** ||SEG "^BGM" Document M 1 1 ACC 1 R W "BGM Begin Message" CUT-ON-(+) |||D "(BGM)" SKIP M 1 1 ACC 1 T F "BGM segment tag" ASMATCHED |||SEG "" NOTAG O 0 1 ACC 1 R W "BGM-C002 composite data" CUT-ON-(:) ||||GRP "" CodedName O 0 1 ACC 1 R W "BGM-1001 - Document/message name, coded" |||||D "(.*)" NOTAG O 0 1 ACC 1 R W "BGM-1001 - Document/message name, coded" ASMATCHED [1..3] |||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "BGM-1131 - Code list qualifier" ASMATCHED [1..3] |||||D "(.*)" @Agency O 0 1 ACC 1 R W "BGM-3055 - Code list responsible agency, coded" ASMATCHED [1..3] ||||D "(.*)" Literal O 0 1 ACC 1 R W "BGM-1000 - Document/message name" ASMATCHED [1..35] |||D "(.*)" Number O 0 1 ACC 1 R W "BGM-1004 DOCUMENT/MESSAGE NUMBER" ASMATCHED [1..35] |||D "(.*)" Function O 0 1 ACC 1 R W "BGM-1225 MESSAGE FUNCTION, CODED" ASMATCHED [1..3] |||D "(.*)" ResponseType O 0 1 ACC 1 R W "BGM-4343 RESPONSE TYPE, CODED" ASMATCHED [1..3] *** DTM *** ||SEG "^DTM" DateTime M 1 35 ACC 2 R W "DTM Date and Time" CUT-ON-(+) |||D "(DTM)" SKIP M 1 1 ACC 1 T F "DTM segment tag" ASMATCHED |||SEG "" NOTAG M 1 1 ACC 1 R W "DTM-C507 composite data" CUT-ON-(:) ||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "DTM-2005 - Date/time/period qualifier" ASMATCHED [1..3] ||||D "(.*)" NOTAG O 0 1 ACC 1 R W "DTM-2380 - Date/time/period" ASMATCHED [1..35] ||||D "(.*)" SKIP C 0 1 ACC 1 COND DateTimeFormat "(.*)" "DTM-2379 - Date/time/period format qualifier" ASMATCHED [1..3] ||||MARK @Fmt COND DateTimeFormat "101" "YYMMDD" "NULL" ||||MARK @Fmt COND DateTimeFormat "102" "CCYYMMDD" "NULL" ||||MARK @Fmt COND DateTimeFormat "201" "YYMMDDHHMM" "NULL" ||||MARK @Fmt COND DateTimeFormat "203" "CCYYMMDDHHMM" "NULL" *** FTX *** ||SEG "^FTX" Info O 0 5 ACC 5 R W "FTX Free Text" CUT-ON-(+) |||D "(FTX)" SKIP M 1 1 ACC 1 T F "FTX segment tag" ASMATCHED |||D "(.*)" @Subject M 1 1 ACC 1 R W "FTX-4451 TEXT SUBJECT QUALIFIER" ASMATCHED [1..3] |||D "(.*)" @Function O 0 1 ACC 1 R W "FTX-4453 TEXT FUNCTION, CODED" ASMATCHED [1..3] |||SEG "" Coded O 0 1 ACC 1 R W "FTX-C107 composite data" CUT-ON-(:) ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "FTX-4441 - Free text, coded" ASMATCHED [1..3] ||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "FTX-1131 - Code list qualifier" ASMATCHED [1..3] ||||D "(.*)" @Agency O 0 1 ACC 1 R W "FTX-3055 - Code list responsible agency, coded" ASMATCHED [1..3] |||SEG "" NOTAG O 0 1 ACC 1 R W "FTX-C108 composite data" CUT-ON-(:) ||||D "(.*)" Literal M 1 5 ACC 5 R W "FTX-4440 - Free text" ASMATCHED [1..70] ... GROUP G01 ----- references ----- not implemented === GROUP G02 ----- Parties' Names and Addresses ----- BEGIN ||GRP "^NAD" Party O 0 20 ACC 5 R W "G02 Parties' Names and Addresses" *** NAD *** |||SEG "^NAD" NOTAG M 1 1 ACC 1 R W "NAD Names and Address" CUT-ON-(+) ||||D "(NAD)" SKIP M 1 1 ACC 1 T F "NAD segment tag" ASMATCHED ||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "NAD-3035 PARTY QUALIFIER" ASMATCHED [1..3] ||||SEG "" Identifier O 0 1 ACC 1 R W "NAD-C082 composite data" CUT-ON-(:) |||||D "(.*)" NOTAG M 1 1 ACC 1 R W "NAD-3039 - Party id identification" ASMATCHED [1..17] |||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "NAD-1131 - Code list qualifier" ASMATCHED [1..3] |||||D "(.*)" @Agency O 0 1 ACC 1 R W "NAD-3055 - Code list responsible agency, coded" ASMATCHED [1..3] ||||SEG "" Address O 0 1 ACC 1 R W "NAD-C058 composite data" CUT-ON-(:) |||||D "(.*)" Info M 1 5 ACC 5 R W "NAD-3124 - Name and address line" ASMATCHED [1..35] ||||SEG "" Name O 0 1 ACC 1 R W "NAD-C080 composite data" CUT-ON-(:) |||||D "(.*)" Literal M 1 5 ACC 5 R W "NAD-3036 - Party name" ASMATCHED [1..35] |||||D "(.*)" @Format O 0 1 ACC 1 R W "NAD-3045 - Party name format, coded" ASMATCHED [1..3] ||||SEG "" Street O 0 1 ACC 1 R W "NAD-C059 composite data" CUT-ON-(:) |||||D "(.*)" Info M 1 3 ACC 3 R W "NAD-3042 - Street and number/P.O. Box" ASMATCHED [1..35] ||||D "(.*)" City O 0 1 ACC 1 R W "NAD-3164 CITY NAME" ASMATCHED [1..35] ||||D "(.*)" SubCountry O 0 1 ACC 1 R W "NAD-3229 COUNTRY SUB-ENTITY IDENTIFICATION" ASMATCHED [1..9] ||||D "(.*)" PostCode O 0 1 ACC 1 R W "NAD-3251 POSTCODE IDENTIFICATION" ASMATCHED [1..9] ||||D "(.*)" Country O 0 1 ACC 1 R W "NAD-3207 COUNTRY, CODED" ASMATCHED [1..3] ... SUB GROUP G03 ----- references ----- not implemented ... SUB GROUP G05 ----- contact details ----- not implemented ^^^ GROUP G02 ----- END === GROUP G06 ----- tax details ----- not implemented === GROUP G07 ----- currencies ----- BEGIN ||GRP "^CUX" Currencies O 0 5 ACC 5 R W "G07 Currencies" *** CUX *** |||SEG "^CUX" NOTAG M 1 1 ACC 1 R W "CUX Currency details" CUT-ON-(+) ||||D "(CUX)" SKIP M 1 1 ACC 1 T F "CUX segment tag" ASMATCHED *** TIP: if we make the next composite data in EDIFACT (SEG here) repeatable twice in order to *** prevent duplication, we won't benefit from the facility to 'remove non repeatable nil optional elements' ! (cfr documentation) *** Moreover, EDIFACT being positional, we can't exclude a convention between trading parties that *** would associate distinguished implicit meanings to the first and second instance of this same composite element. ||||SEG "" Currency1 O 0 1 ACC 1 R W "CUX-C504 composite data" CUT-ON-(:) |||||D "(.*)" @Use M 1 1 ACC 1 R W "CUX-6347 - Currency details qualifier" ASMATCHED [1..3] |||||D "(.*)" Code O 0 1 ACC 1 R W "CUX-6345 - Currency, coded" ASMATCHED [1..3] |||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "CUX-6343 - Currency qualifier" ASMATCHED [1..3] |||||D "(.*)" Rate O 0 1 ACC 1 R W "CUX-6348 - Currency rate base" NUMERIC [1..4] ||||SEG "" Currency2 O 0 1 ACC 1 R W "CUX-C504 composite data" CUT-ON-(:) |||||D "(.*)" @Use M 1 1 ACC 1 R W "CUX-6347 - Currency details qualifier" ASMATCHED [1..3] |||||D "(.*)" Code O 0 1 ACC 1 R W "CUX-6345 - Currency, coded" ASMATCHED [1..3] |||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "CUX-6343 - Currency qualifier" ASMATCHED [1..3] |||||D "(.*)" Rate O 0 1 ACC 1 R W "CUX-6348 - Currency rate base" NUMERIC [1..4] ||||GRP "" ExchangeRate O 0 1 ACC 1 R W "CUX-5402 RATE OF EXCHANGE" |||||D "(.*)" NOTAG O 0 1 ACC 1 R W "CUX-5402 RATE OF EXCHANGE" NUMERIC [1..12] |||||D "(.*)" @Market O 0 1 ACC 1 R W "CUX-6341 RATE OF EXCHANGE" ASMATCHED [1..3] *** DTM *** |||SEG "^DTM" DateTime O 0 5 ACC 1 R W "DTM Date and Time" CUT-ON-(+) ||||D "(DTM)" SKIP M 1 1 ACC 1 T F "DTM segment tag" ASMATCHED ||||SEG "" NOTAG M 1 1 ACC 1 R W "DTM-C507 composite data" CUT-ON-(:) |||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "DTM-2005 - Date/time/period qualifier" ASMATCHED [1..3] |||||D "(.*)" NOTAG O 0 1 ACC 1 R W "DTM-2380 - Date/time/period" ASMATCHED [1..35] |||||D "(.*)" SKIP C 0 1 ACC 1 COND G07DateTimeFormat "(.*)" "DTM-2379 - Date/time/period format qualifier" ASMATCHED [1..3] |||||MARK @Fmt COND G07DateTimeFormat "101" "YYMMDD" "NULL" |||||MARK @Fmt COND G07DateTimeFormat "102" "CCYYMMDD" "NULL" |||||MARK @Fmt COND G07DateTimeFormat "201" "YYMMDDHHMM" "NULL" |||||MARK @Fmt COND G07DateTimeFormat "203" "CCYYMMDDHHMM" "NULL" ^^^ GROUP G07 ----- END ... GROUP G08 ----- payment terms ----- not implemented === GROUP G09 ----- transport details ----- BEGIN ||GRP "^TDT" Transport O 0 10 ACC 5 R W "G09 Transport Details" *** TDT *** |||SEG "^TDT" Stage M 1 1 ACC 1 R W "TDT Transport Stage Details" CUT-ON-(+) ||||D "(TDT)" SKIP M 1 1 ACC 1 T F "TDT segment tag" ASMATCHED ||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "TDT-8051 TRANSPORT STAGE QUALIFIER" ASMATCHED [1..3] ||||D "(.*)" ReferenceNbr O 0 1 ACC 1 R W "TDT-8028 CONVEYANCE REFERENCE NUMBER" ASMATCHED [1..17] ||||SEG "" Mode O 0 1 ACC 1 R W "TDT-C220 composite data" CUT-ON-(:) |||||D "(.*)" Coded O 0 1 ACC 1 R W "TDT-8067 - Mode of transport, coded" ASMATCHED [1..3] |||||D "(.*)" Literal O 0 1 ACC 1 R W "TDT-8066 - Mode of transport" ASMATCHED [1..17] ||||SEG "" Means O 0 1 ACC 1 R W "TDT-C228 composite data" CUT-ON-(:) |||||D "(.*)" Id O 0 1 ACC 1 R W "TDT-8179 - Type of means of transport identification" ASMATCHED [1..8] |||||D "(.*)" Type O 0 1 ACC 1 R W "TDT-8178 - Type of means of transport" ASMATCHED [1..17] ||||SEG "" Carrier O 0 1 ACC 1 R W "TDT-C040 composite data" CUT-ON-(:) |||||GRP "" Id O 0 1 ACC 1 R W "TDT-3127 - Carrier identification" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "TDT-3127 - Carrier identification" ASMATCHED [1..17] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "TDT-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "TDT-3055 - Code list responsible agency, coded" ASMATCHED [1..3] |||||D "(.*)" Name O 0 1 ACC 1 R W "TDT-3128 - Carrier name" ASMATCHED [1..35] ||||D "(.*)" Direction O 0 1 ACC 1 R W "TDT-8101 TRANSIT DIRECTION, CODED" ASMATCHED [1..3] ||||SEG "" ExcessTransportation O 0 1 ACC 1 R W "TDT-C401 composite data" CUT-ON-(:) |||||D "(.*)" Reason M 1 1 ACC 1 R W "TDT-8457 - Excess transportation reason, coded" ASMATCHED [1..3] |||||D "(.*)" Responsibility M 1 1 ACC 1 R W "TDT-8459 - Excess transportation responsibility, coded" ASMATCHED [1..3] |||||D "(.*)" Authorization O 0 1 ACC 1 R W "TDT-7130 - Customer authorization number" ASMATCHED [1..17] ||||SEG "" Identification O 0 1 ACC 1 R W "TDT-C222 composite data" CUT-ON-(:) |||||GRP "" Qualified O 0 1 ACC 1 R W "TDT-8213 - Id of means of transport identification" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "TDT-8213 - Id of means of transport identification" ASMATCHED [1..9] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "TDT-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "TDT-3055 - Code list responsible agency, coded" ASMATCHED [1..3] |||||D "(.*)" Unqualified O 0 1 ACC 1 R W "TDT-8212 - Id of the means of transport" ASMATCHED [1..17] |||||D "(.*)" Nationality O 0 1 ACC 1 R W "TDT-8453 - Nationality of means of transport, coded" ASMATCHED [1..3] ^^^ GROUP G09 ----- END === GROUP G11 ----- terms of delivery ----- BEGIN ||GRP "^TOD" TransportTerms O 0 10 ACC 5 R W "G11 Transport Terms" *** TOD *** |||SEG "^TOD" Delivery M 1 1 ACC 1 R W "TOD Terms of Delivery" CUT-ON-(+) ||||D "(TOD)" SKIP M 1 1 ACC 1 T F "TOD segment tag" ASMATCHED ||||D "(.*)" Function O 0 1 ACC 1 R W "TOD-4055 TERMS OF DELIVERY FUNCTION, CODED" ASMATCHED [1..3] ||||D "(.*)" PaymentMethod O 0 1 ACC 1 R W "TOD-4215 TRANSPORT CHARGES METHOD OF PAYMENT, CODED" ASMATCHED [1..3] ||||SEG "" Terms O 0 1 ACC 1 R W "TOD-C100 composite data" CUT-ON-(:) |||||GRP "" Coded O 0 1 ACC 1 R W "TOD-4053 - Terms of delivery, coded" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "TOD-4053 - Terms of delivery, coded" ASMATCHED [1..3] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "TOD-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "TOD-3055 - Code list responsible agency, coded" ASMATCHED [1..3] |||||D "(.*)" Literal O 0 2 ACC 2 R W "TOD-4052 - Terms of delivery" ASMATCHED [1..70] *** LOC *** |||SEG "^LOC" Location O 0 2 ACC 2 R W "LOC Place/Location" CUT-ON-(+) ||||D "(LOC)" SKIP M 1 1 ACC 1 T F "LOC segment tag" ASMATCHED ||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "LOC-3227 PLACE/LOCATION QUALIFIER" ASMATCHED [1..3] *** TIP: we have again a false composite data repetition in EDIFACT (SEG here)! *** EDIFACT being positional, there is a risk for a convention between trading parties that *** would associate distinguished implicit meanings to the first, second and third instance of this same composite element. *** However, compared with the similar case about currencies here above, we decide for the sake of demo *** to go for a repetition that can accept empty fields as defined below. Consequently, if the Relation element that *** follows is ever used, the intermediate empty 'Place' elements will appear in the output XML. ||||SEG "" Place O 0 3 ACC 3 R W "LOC-C517 composite data" CUT-ON-(:) |||||GRP "" Identification O 0 1 ACC 1 R W "LOC-3225 - Place/location identification" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "LOC-3225 - Place/location identification" ASMATCHED [0..25] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "LOC-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "LOC-3055 - Code list responsible agency, coded" ASMATCHED [1..3] |||||D "(.*)" Name O 0 1 ACC 1 R W "LOC-3224 - Place/location" ASMATCHED [1..17] ||||D "(.*)" Relation O 0 1 ACC 1 R W "LOC-5479 RELATION, CODED" ASMATCHED [1..3] ^^^ GROUP G11 ----- END === GROUP G25 ----- line items ----- BEGIN ||GRP "^LIN" LineItem O 0 9999 ACC 9999 R W "G25 Line Item" *** LIN *** |||SEG "^LIN" NOTAG M 1 1 ACC 1 R W "LIN Line Item" CUT-ON-(+) ||||D "(LIN)" SKIP M 1 1 ACC 1 T F "LIN segment tag" ASMATCHED ||||D "(.*)" @Nb O 0 1 ACC 1 R W "LIN-1082 LINE ITEM NUMBER" NUMERIC [1..6] ||||D "(.*)" @Action O 0 1 ACC 1 R W "LIN-1229 ACTION REQUEST/NOTIFICATION, CODED" ASMATCHED [1..3] ||||SEG "" Article O 0 1 ACC 1 R W "LIN-C212 composite data" CUT-ON-(:) |||||D "(.*)" Number O 0 1 ACC 1 R W "LIN-7140 - Item number" ASMATCHED [1..35] |||||GRP "" NumberType O 0 1 ACC 1 R W "LIN-7143 - Item number type, coded" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "LIN-7143 - Item number type, coded" ASMATCHED [1..3] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "LIN-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "LIN-3055 - Code list responsible agency, coded" ASMATCHED [1..3] ||||D "(.*)" SubLineId O 0 1 ACC 1 R W "LIN-5495 SUB-LINE INDICATOR, CODED" ASMATCHED [1..3] ||||D "(.*)" ConfigLevel O 0 1 ACC 1 R W "LIN-1222 CONFIGURATION LEVEL" NUMERIC [1..2] ||||D "(.*)" Configuration O 0 1 ACC 1 R W "LIN-7083 CONFIGURATION, CODED" ASMATCHED [1..3] *** PIA *** |||SEG "^PIA" ProductId O 0 25 ACC 1 R W "PIA Additional Product Information" CUT-ON-(+) ||||D "(PIA)" SKIP M 1 1 ACC 1 T F "PIA segment tag" ASMATCHED ||||D "(.*)" @Function M 1 1 ACC 1 R W "PIA-4347 PRODUCT ID FUNCTION QUALIFIER" ASMATCHED [1..3] *** TIP: compared with the above cases of a falsely repeated composite element in EDIFACT *** we can here safely repeat the Article element because no other element follows in this same segment ||||SEG "" Article M 1 5 ACC 5 R W "PIA-C212 composite data" CUT-ON-(:) |||||D "(.*)" Number O 0 1 ACC 1 R W "PIA-7140 - Item number" ASMATCHED [1..35] |||||GRP "" NumberType O 0 1 ACC 1 R W "PIA-7143 - Item number type, coded" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "PIA-7143 - Item number type, coded" ASMATCHED [1..3] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "PIA-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "PIA-3055 - Code list responsible agency, coded" ASMATCHED [1..3] *** IMD *** |||SEG "^IMD" Description O 0 99 ACC 3 R W "IMD Item Description" CUT-ON-(+) ||||D "(IMD)" SKIP M 1 1 ACC 1 T F "IMD segment tag" ASMATCHED ||||D "(.*)" @Type O 0 1 ACC 1 R W "IMD-7077 ITEM DESCRIPTION TYPE, CODED" ASMATCHED [1..3] ||||D "(.*)" Characteristic O 0 1 ACC 1 R W "IMD-7081 ITEM CHARACTERISTIC, CODED" ASMATCHED [1..3] ||||SEG "" Id O 0 1 ACC 1 R W "IMD-C273 composite data" CUT-ON-(:) |||||GRP "" Coded O 0 1 ACC 1 R W "IMD-7009 - Item description identification" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "IMD-7009 - Item description identification" ASMATCHED [1..7] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "IMD-1131 - Code list qualifier" ASMATCHED [1..3] ||||||D "(.*)" @Agency O 0 1 ACC 1 R W "IMD-3055 - Code list responsible agency, coded" ASMATCHED [1..3] |||||D "(.*)" Literal O 0 2 ACC 2 R W "IMD-7008 - Item description" ASMATCHED [1..35] ||||D "(.*)" Layer O 0 1 ACC 1 R W "IMD-7383 SURFACE/LAYER INDICATOR, CODED" ASMATCHED [1..3] *** MEA *** |||SEG "^MEA" Measurement O 0 5 ACC 5 R W "MEA Measurements" CUT-ON-(+) ||||D "(MEA)" SKIP M 1 1 ACC 1 T F "MEA segment tag" ASMATCHED ||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "MEA-6311 MEASUREMENT APPLICATION QUALIFIER" ASMATCHED [1..3] ||||SEG "" NOTAG O 0 1 ACC 1 R W "MEA-C502 composite data" CUT-ON-(:) |||||D "(.*)" Dimension O 0 1 ACC 1 R W "MEA-6313 - Measurement dimension, coded" ASMATCHED [1..3] |||||D "(.*)" Significance O 0 1 ACC 1 R W "MEA-6321 - Measurement significance, coded" ASMATCHED [1..3] |||||D "(.*)" Attribute O 0 1 ACC 1 R W "MEA-6315 - Measurement attribute, coded" ASMATCHED [1..3] ||||SEG "" NOTAG O 0 1 ACC 1 R W "MEA-C502 composite data" CUT-ON-(:) |||||D "(.*)" Unit M 1 1 ACC 1 R W "MEA-6411 - Measure unit qualifier" ASMATCHED [1..3] |||||D "(.*)" Value O 0 1 ACC 1 R W "MEA-6314 - Measurement value" NUMERIC [1..18] |||||D "(.*)" RangeMin O 0 1 ACC 1 R W "MEA-6162 - Range minimum" NUMERIC [1..18] |||||D "(.*)" RangeMax O 0 1 ACC 1 R W "MEA-6152 - Range maximum" NUMERIC [1..18] ||||D "(.*)" Layer O 0 1 ACC 1 R W "MEA-7383 SURFACE/LAYER INDICATOR, CODED" ASMATCHED [1..3] *** QTY *** |||SEG "^QTY" Quantity O 0 10 ACC 10 R W "QTY Quantity" CUT-ON-(+) ||||D "(QTY)" SKIP M 1 1 ACC 1 T F "QTY segment tag" ASMATCHED ||||SEG "" NOTAG M 1 1 ACC 1 R W "QTY-C186 composite data" CUT-ON-(:) |||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "QTY-6063 - Quantity qualifier" ASMATCHED [1..3] |||||D "(.*)" NOTAG M 1 1 ACC 1 R W "QTY-6060 - Quantity" NUMERIC [1..15] |||||D "(.*)" @Unit O 0 1 ACC 1 R W "QTY-6411 - Measure unit qualifier" ASMATCHED [1..3] *** DTM *** |||SEG "^DTM" DateTime O 0 35 ACC 2 R W "DTM Date and Time" CUT-ON-(+) ||||D "(DTM)" SKIP M 1 1 ACC 1 T F "DTM segment tag" ASMATCHED ||||SEG "" NOTAG M 1 1 ACC 1 R W "DTM-C507 composite data" CUT-ON-(:) |||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "DTM-2005 - Date/time/period qualifier" ASMATCHED [1..3] |||||D "(.*)" NOTAG O 0 1 ACC 1 R W "DTM-2380 - Date/time/period" ASMATCHED [1..35] |||||D "(.*)" SKIP C 0 1 ACC 1 COND G25DateTimeFormat "(.*)" "DTM-2379 - Date/time/period format qualifier" ASMATCHED [1..3] |||||MARK @Fmt COND G25DateTimeFormat "101" "YYMMDD" "NULL" |||||MARK @Fmt COND G25DateTimeFormat "102" "CCYYMMDD" "NULL" |||||MARK @Fmt COND G25DateTimeFormat "201" "YYMMDDHHMM" "NULL" |||||MARK @Fmt COND G25DateTimeFormat "203" "CCYYMMDDHHMM" "NULL" *** MOA *** |||SEG "^MOA" Monetary O 0 5 ACC 5 R W "MOA Monetary Amount" CUT-ON-(+) ||||D "(MOA)" SKIP M 1 1 ACC 1 T F "MOA segment tag" ASMATCHED ||||SEG "" NOTAG M 1 1 ACC 1 R W "MOA-C516 composite data" CUT-ON-(:) |||||D "(.*)" @Type M 1 1 ACC 1 R W "MOA-5025 Monetary amount type qualifier" ASMATCHED [1..3] |||||GRP "" Amount O 0 1 ACC 1 R W "MOA-5004 - Monetary amount" ||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "MOA-5004 - Monetary amount" NUMERIC [1..18] ||||||D "(.*)" @Currency O 0 1 ACC 1 R W "MOA-6345 - Currency, coded" ASMATCHED [1..3] ||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "MOA-6343 - Currency qualifier" ASMATCHED [1..3] ||||||D "(.*)" Status O 0 1 ACC 1 R W "MOA-4405 - Status, coded" ASMATCHED [1..3] ... SEGMENT qva ----- quantity difference ----- not implemented ... SEGMENT ftx ----- free text ----- not implemented ... SUB GROUP G27 ----- per item pricing details ----- not implemented ... SUB GROUP G28 ----- per item references ----- not implemented === SUB GROUP G29 ----- packaging ----- BEGIN |||GRP "^PAC" Packaging O 0 10 ACC 10 R W "G29 Packaging" *** PAC *** ||||SEG "^PAC" NOTAG M 1 1 ACC 1 R W "PAC Packaging" CUT-ON-(+) |||||D "(PAC)" SKIP M 1 1 ACC 1 T F "PAC segment tag" ASMATCHED |||||D "(.*)" Count O 0 1 ACC 1 R W "PAC-7224 NUMBER OF PACKAGES" NUMERIC [1..8] |||||SEG "" NOTAG O 0 1 ACC 1 R W "PAC-C531 composite data" CUT-ON-(:) ||||||D "(.*)" Level O 0 1 ACC 1 R W "PAC-7075 - Packaging level, coded" ASMATCHED [1..3] ||||||D "(.*)" Code O 0 1 ACC 1 R W "PAC-7233 - Packaging related information, coded" ASMATCHED [1..3] ||||||D "(.*)" Terms O 0 1 ACC 1 R W "PAC-7073 - Packaging terms and conditions, coded" ASMATCHED [1..3] |||||SEG "" Type O 0 1 ACC 1 R W "PAC-C202 composite data" CUT-ON-(:) ||||||GRP "" Coded O 0 1 ACC 1 R W "PAC-7065 - Type of packages identification" |||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "PAC-7065 - Type of packages identification" ASMATCHED [1..7] |||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "PAC-1131 - Code list qualifier" ASMATCHED [1..3] |||||||D "(.*)" @Agency O 0 1 ACC 1 R W "PAC-3055 - Code list responsible agency, coded" ASMATCHED [1..3] ||||||D "(.*)" Literal O 0 1 ACC 1 R W "PAC-7064 - Type of packages" ASMATCHED [1..35] |||||SEG "" Form O 0 1 ACC 1 R W "PAC-C402 composite data" CUT-ON-(:) ||||||D "(.*)" @Type M 1 1 ACC 1 R W "PAC-7077 - Item description type, coded" ASMATCHED [1..3] ||||||GRP "" Description M 1 2 ACC 2 R W "PAC-7064 - Type of packages" |||||||D "(.*)" NOTAG O 0 1 ACC 1 R W "PAC-7064 - Type of packages" ASMATCHED [1..35] |||||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "PAC-7143 - Item number type, coded" ASMATCHED [1..3] |||||SEG "" Returnable O 0 1 ACC 1 R W "PAC-C532 composite data" CUT-ON-(:) ||||||D "(.*)" FreightPayment M 1 1 ACC 1 R W "PAC-8395 - Returnable package freight payment responsibility, coded" ASMATCHED [1..3] ||||||D "(.*)" LoadContents M 1 1 ACC 1 R W "PAC-8393 - Returnable package load contents, coded" ASMATCHED [1..3] ... SUB SUB GROUP G31 ----- packaging instructions ----- not implemented ^^^ SUB GROUP G29 ----- END ... SUB GROUP G32 ----- location, quantities ----- not implemented ... SUB GROUP G33 ----- Tax details ----- not implemented ... SUB GROUP G34 ----- name and address ----- not implemented ... SUB GROUP G38 ----- allowance and charges with taxes ----- not implemented ... SUB GROUP G44 ----- transport details ----- not implemented ^^^ GROUP G25 ----- END *** UNS *** ||SEG "^UNS" SKIP M 1 1 ACC 1 R W "UNS Service Segment - Separator" CUT-ON-(+) |||D "(UNS)" SKIP M 1 1 ACC 1 T F "UNS segment tag" ASMATCHED |||D "(S)" Separator M 1 1 ACC 1 T F "UNS Summary section separator" ASMATCHED *** MOA *** ||SEG "^MOA" Monetary O 0 12 ACC 3 R W "MOA Monetary Amount" CUT-ON-(+) |||D "(MOA)" SKIP M 1 1 ACC 1 T F "MOA segment tag" ASMATCHED |||SEG "" NOTAG M 1 1 ACC 1 R W "MOA-C516 composite data" CUT-ON-(:) ||||D "(.*)" @Type M 1 1 ACC 1 R W "MOA-5025 Monetary amount type qualifier" ASMATCHED [1..3] ||||GRP "" Amount O 0 1 ACC 1 R W "MOA-5004 - Monetary amount" |||||D "(.*)" NOTAG O 0 1 ACC 1 R W "MOA-5004 - Monetary amount" NUMERIC [1..18] |||||D "(.*)" @Currency O 0 1 ACC 1 R W "MOA-6345 - Currency, coded" ASMATCHED [1..3] |||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "MOA-6343 - Currency qualifier" ASMATCHED [1..3] |||||D "(.*)" Status O 0 1 ACC 1 R W "MOA-4405 - Status, coded" ASMATCHED [1..3] *** CNT *** ||SEG "^CNT" Control O 0 10 ACC 3 R W "CNT Control totals" CUT-ON-(+) |||D "(CNT)" SKIP M 1 1 ACC 1 T F "CNT segment tag" ASMATCHED |||SEG "" NOTAG M 1 1 ACC 1 R W "CNT-C270 composite data" CUT-ON-(:) ||||D "(.*)" @Qualifier M 1 1 ACC 1 R W "CNT-6069 - Control qualifier" ASMATCHED [1..3] ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "CNT-6066 - Control value" NUMERIC [1..18] ||||D "(.*)" @Unit O 0 1 ACC 1 R W "CNT-6411 - Measure unit qualifier" ASMATCHED [1..3] *** UNT *** ||SEG "^UNT" Trailer M 1 1 ACC 1 R W "UNT Service Segment - Message Trailer" CUT-ON-(+) |||D "(UNT)" SKIP C 1 1 ACC 1 COND MatchingMsgRefs "~" "UNT segment tag" ASMATCHED |||D "(.*)" SegmentCount M 1 1 ACC 1 R W "UNT-0074 NUMBER OF SEGMENTS IN THE MESSAGE" NUMERIC [1..6] |||D "(.*)" Reference C 1 1 ACC 1 COND MatchingMsgRefs "(.*)" "UNT-0062 MESSAGE REFERENCE NUMBER" ASMATCHED [1..14] *** UNZ *** |SEG "^UNZ" InterchangeTrailer M 1 1 ACC 1 R W "UNZ Service Segment - Interchange Trailer" CUT-ON-(+) ||D "(UNZ)" SKIP C 1 1 ACC 1 COND MatchingInterchgRefs "~" "UNZ segment tag" ASMATCHED ||D "(.*)" MessageCount M 1 1 ACC 1 R W "UNZ-0036 INTERCHANGE CONTROL COUNT" NUMERIC [1..6] ||D "(.*)" Reference C 1 1 ACC 1 COND MatchingInterchgRefs "(.*)" "UNZ-0020 INTERCHANGE CONTROL REFERENCE" ASMATCHED [1..14] END #### ANYTHING next to the 'END' of the DEFinition is automatically a Comment #### *** The following is a generic XML'izer for any EDIFACT interchange! *** only the UNB envelope is decomposed, rest is XML'ized generically MSG "^UN[AB]" EAN-Orders-v7 M 1 1 ACC 1 T F "EDIFACT Interchange containing EANCOM ORDERS V007" CUT-ON-(') |D "^UNA(.*)" SKIP O 0 1 ACC 1 R W "UNA service segment - skipped" ASMATCHED *** UNB *** |SEG "^UNB" InterchangeHeader M 1 1 ACC 1 T F "UNB Interchange Header" CUT-ON-(+) ||D "(UNB)" SKIP M 1 1 ACC 1 T F "UNB segment tag" ASMATCHED ||SEG "" Syntax M 1 1 ACC 1 R W "UNB-S001 composite data" CUT-ON-(:) |||D "(.*)" Identifier M 1 1 ACC 1 R W "UNB-0001 - Syntax identifier" ALPHA [4..4] |||D "(.*)" Version M 1 1 ACC 1 R W "UNB-0002 - Syntax version number" NUMERIC [1..1] ||SEG "" Sender M 1 1 ACC 1 R W "UNB-S002 composite data" CUT-ON-(:) |||GRP "" Identifier M 1 1 ACC 1 R W "UNB-0004 - Sender identifier & Qualifier" ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0004 - Sender identifier" ASMATCHED [1..35] ||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "UNB-0007 - Sender id code qualifier" ASMATCHED [1..4] |||D "(.*)" ReverseRouting O 0 1 ACC 1 R W "UNB-0008 - Address for Reverse Routing" ASMATCHED [1..14] ||SEG "" Recipient M 1 1 ACC 1 R W "UNB-S003 composite data" CUT-ON-(:) |||GRP "" Identifier M 1 1 ACC 1 R W "UNB-0010 - Recipient identifier & Qualifier" ||||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0010 - Recipient identifier" ASMATCHED [1..35] ||||D "(.*)" @Qualifier O 0 1 ACC 1 R W "UNB-0007 - Recipient id code qualifier" ASMATCHED [1..4] |||D "(.*)" Routing O 0 1 ACC 1 R W "UNB-0014 - Address for Routing" ASMATCHED [1..14] ||SEG "" Date M 1 1 ACC 1 R W "UNB-S004 composite data" CUT-ON-(:) |||D "(.*)" YYMMDD M 1 1 ACC 1 R W "UNB-0010 - Date" NUMERIC [6..6] |||D "(.*)" HHMM O 0 1 ACC 1 R W "UNB-0007 - Time" NUMERIC [4..4] ||D "(.*)" Reference M 1 1 ACC 1 R W "UNB-0020 - INTERCHANGE CONTROL REFERENCE" ASMATCHED [1..14] ||SEG "" Password O 0 1 ACC 1 R W "UNB-S005 composite data" CUT-ON-(:) |||D "(.*)" NOTAG M 1 1 ACC 1 R W "UNB-0022 - Recipient's reference/password" ASMATCHED [1..14] |||D "(.*)" @Qualifier O 0 1 ACC 1 R W "UNB-0025 - Recipient's reference/password qualifier" ASMATCHED [2..2] ||D "(.*)" ApplicationReference O 0 1 ACC 1 R W "UNB-0026 - APPLICATION REFERENCE" ASMATCHED [1..14] ||D "(.*)" PriorityCode O 0 1 ACC 1 R W "UNB-0029 - PROCESSING PRIORITY CODE" ALPHA [1..1] ||D "(.*)" AckRequest O 0 1 ACC 1 R W "UNB-0031 - ACKNOWLEDGEMENT REQUEST" NUMERIC [1..1] ||D "(.*)" AgreementId O 0 1 ACC 1 R W "UNB-0032 - COMMUNICATIONS AGREEMENT ID" ASMATCHED [1..35] ||D "(.*)" @Test O 0 1 ACC 1 R W "UNB-0035 - TEST INDICATOR" NUMERIC [1..1] |SEG "" S O 0 999 ACC 999 R W "Un-parsed EDIFACT Segment" CUT-ON-(+) ||D "(.*)" @Tag M 1 1 ACC 1 R W "Segment Tag" ASMATCHED ||SEG "" D O 0 999 ACC 999 R W "Un-parsed Data or Composite element" CUT-ON-(:) |||D "(.*)" V O 0 999 ACC 999 R W "Un-parsed (Sub) Data Element Value" ASMATCHED END