× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Good afternoon all, I have just gotten my feet wet with the XML-INTO & XML-SAX functions. I don't consider myself on autopilot by any means, but my powers that be now want me to adapt the working XML-SAX sample I created and make a generic version out of it that would take parameters. I created the working sample in free format.

For example, we will most usually have a store number, trans date, transaction type, sale amount, etc. and an XML file that will be coming to us to parse out.

How would I have a file (I think) that will have mappings that if the element is called 'transdate' that my generic function could take that and know what to do with it. I would prefer to stay in free format for this.

I am not sold that this is possible, being some of our files have different naming convensions for things like date, trantype, etc.


Here is a chunk of my working XML-SAX sample:

when event = *XML_START_ELEMENT;

if %subst(chars : 1 : stringLen) = 'storeNumber';
eval wrkfield = 'storeNumber';
endif;

if %subst(chars : 1 : stringLen) = 'transDate';
eval wrkfield = 'transDate';
endif;

if %subst(chars : 1 : stringLen) = 'localTransactionNumber';
eval wrkfield = 'localTransactionNumber';
endif;

if %subst(chars : 1 : stringLen) = 'centralTransactionNumber';
eval wrkfield = 'centralTransactionNumber';

endif;

if %subst(chars : 1 : stringLen) = 'Status';
eval wrkfield = 'Status';
endif;

if %subst(chars : 1 : stringLen) = 'AssociateID';
eval wrkfield = 'AssociateID';
endif;

if %subst(chars : 1 : stringLen) = 'refundPolicy';
eval wrkfield = 'refundPolicy';
endif;

if %subst(chars : 1 : stringLen) = 'TotalCredit';
eval wrkfield = 'TotalCredit';
endif;

when event = *XML_CHARS;

if wrkfield = 'storeNumber';
eval wrkstore = %subst(chars : 1 : stringLen);
clear wrkfield;
endif;
if wrkfield = 'transDate';
eval wrktdate = %subst(chars : 1 : stringLen);
clear wrkfield;
endif;
if wrkfield = 'localTransactionNumber';
eval wrkltrans = %subst(chars : 1 : stringLen);
clear wrkfield;
endif;


. . . . .

// see if at end of a document record
// if so write collected data to files

when event = *XML_END_ELEMENT;
if %subst(chars : 1 : stringLen) = 'DataArea';

// chain (wrkstore) locdim1;
// eval wrklkey = lockey;
// eval hstrno = wrklkey;
eval hstrno = wrkstore;

// chain ('Day' : wrktdate) datedim5;
// eval wrklkey = datekey;
eval htrandate = wrktdate;

eval hLOCTRNNO = wrkltrans;
eval hCNTTRNNO = wrkctrans;

eval hCREDITAMT =wrkcredamt;

eval iCNTTRNNO = wrkctrans;
eval iSTATUS = wrkistat;
eval iSKU = wrksku;
eval iRETQTY = wrkqty;
eval iCREDAMT = wrkcredamt;
eval iTAXAMT = wrktaxamt;
eval iADJCRED = wrkadjcred;
eval iTOTCRED = wrktotcred;
eval iCNTITEMID = wrkcid;
eval iORGITEMID = wrkoid;

eval pCNTTRNNO = wrkctrans;
eval pTRANDATE = wrktdate;
eval pSTATUS = wrkstatus;
eval pASSOCID = wrkassoc;
eval pREFPOLICY = wrkrpolicy;
eval pTOTCRED = wrkcredamt;
eval pCONVCRED = wrkccred;
eval pCUSTID = wrkcustid;
eval pCUSTFNAM = wrkfname;
eval pCUSTLNAM = wrklname;


write headfmt;
write itemfmt;
write paymfmt;

clear wrkfields;

endif;

. . . . . . .


Any suggestions on how I would attack this would be greatly appreciated.

Thanks in advance,

Sharon



_________________________________________________________________
Color coding for safety: Windows Live Hotmail alerts you to suspicious email.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.