0% found this document useful (0 votes)
195 views

Peoplesoft Integration Broker Cdata

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views

Peoplesoft Integration Broker Cdata

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Using CDATA sections in XML File Layout

-produced XML File


Utilizing BIP 11g !"#$%& 'uilt-in support (or )ic* Te+t data using html2fo (unction
in (or, -eld& re.uires t*e use o( CDATA sections (or )T/ data ele,ents in t*e XML
-le" 0*en using XML File Layout to create t*e XML -le *o1e2er3 t*ere is no 'uilt-
in support to create t*ese CDATA 'loc4s" As a result3 t*e CDATA sections need to 'e
added ,anually prior to 1riting out t*e XML File"
T*is docu,ent suggests t1o di5erent ,et*ods (or acco,plis*ing t*is"
Note: All o'6ects re(erenced in t*is doc 1ill also 'e pro2ided in supple,entary
pro6ect 7/8XML8FIL/"
First3 to illustrate t*e issue3 consider t*e (ollo1ing e+a,ple9
0e:ll use ; records to 1rite out t*e XML data9
1) QE_APPLICANT_AD:
select * from PS_QE_APPLICANT_AD;
IDENTIFIER ADDRESS
------------------ -----------------------------------
12231 244 E!er"ree# Terr$ce
23423 1% &'l(ol$#) Dr*!e
3434 34 Col'm+*$ Dr*!e
2) QE_APPL_RE!ME "RTE Te#t hi$hli$hte%):
select * from PS_QE_APPL_RES,&E;
IDENTIFIER QE_RES,&E_TE-T
------------------ ----------------------------------------------------------------
12231 ./0.stro#"0RTE Te1t.2stro#"0.+r 20co#t$*#*#" .30343 $#)
5.2/0
23423 RTE Te1t
3434 RTE Te1t
0e:ll use XML File Layout QE_APPLICANT t*at utilizes t*ese ; records9

T*e (ollo1ing pcode is run 2ia App /ngine QE_XML_FILE1 " It uses t*e
a(ore,entioned )ecord data to 1rite an XML -le 7/8APPLICA<T1"+,l9
Loc$l Recor) 5Rec;
Loc$l F*le 5f-&L;
Loc$l SQL 5SQL;
5f-&L 6 7etF*le84c9:tem/:QE_APPLICANT1;1ml43 4<43 4,TF-=43 >F*leP$t(_A+sol'te?;
If 5f-&L;Is@/e# T(e#
If 5f-&L;SetF*leL$Ao't8F*leL$Ao't;QE_APPLICANT? T(e#
5Rec 6 Cre$teRecor)8Recor);QE_APPLICANT_AD?;
5SQL 6 Cre$teSQL84>Select$ll891?43 5Rec?;
<(*le 5SQL;Fetc(85Rec?
5f-&L;<r*teRecor)85Rec?;
5f-&L;<r*teL*#e84.2QE_APPLICANT_AD04?;
E#)-<(*le;

5Rec 6 Cre$teRecor)8Recor);QE_APPL_RES,&E?;
5SQL 6 Cre$teSQL84>Select$ll891?43 5Rec?;
<(*le 5SQL;Fetc(85Rec?
5f-&L;<r*teRecor)85Rec?;
5f-&L;<r*teL*#e84.2QE_APPL_RES,&E04?;
E#)-<(*le;
E#)-If;
E#)-If;
5f-&L;Close8?;
Follo1ing is a snippet (ro, t*e generated +,l -le )T/ Te+t *ig*lig*ted&9
"""
=7/8APPL8)/>UM/?
=ID/<TIFI/)?1;;$1=@ID/<TIFI/)?=7/8)/>UM/8T/XT?AltBpAgtBAltBstrongAgtB)T/ Te+tAltB@strongAgtBAltB'r
@AgtBcontaining AltB3AgtB3A.uotB3 and Aa,pBAltB@pAgtB=@7/8)/>UM/8T/XT?
=@7/8APPL8)/>UM/?
"""
T*e pro'le, 1it* t*is is t*at )T/ te+t ,ust <CT 'e escaped 1it* entity re(erence
c*aracters3 and MU>T 'e in CDATA 'loc43 in order (or BIP )eporting /ngine to 'e
a'le to process it"
!&&ETI'N 1 ( !)i*$ +,itet,i*$") i*)tea% of +,iteRe-o,%") a*%
ma*ually .,iti*$ out the CDATA )e-tio* fo, ea-h i*%i/i%ual 0el%
that -o*tai*) RTE %ata
T*e (ollo1ing pcode is run 2ia App /ngine QE_XML_FILE2:
Loc$l Recor) 5Rec;
Loc$l F*le 5f-&L;
Loc$l SQL 5SQL;
5f-&L 6 7etF*le84c9:tem/:QE_APPLICANT2;1ml43 4<43 4,TF-=43 >F*leP$t(_A+sol'te?;
If 5f-&L;Is@/e# T(e#
If 5f-&L;SetF*leL$Ao't8F*leL$Ao't;QE_APPLICANT? T(e#
5Rec 6 Cre$teRecor)8Recor);QE_APPLICANT_AD?;
5SQL 6 Cre$teSQL84>Select$ll891?43 5Rec?;
<(*le 5SQL;Fetc(85Rec?
5f-&L;<r*teRecor)85Rec?;
5f-&L;<r*teL*#e84.2QE_APPLICANT_AD04?;
E#)-<(*le;

5Rec 6 Cre$teRecor)8Recor);QE_APPL_RES,&E?;
5SQL 6 Cre$teSQL84>Select$ll891?43 5Rec?;
<(*le 5SQL;Fetc(85Rec?
rem 5f-&L;<r*teRecor)85Rec?;
5f-&L;<r*teL*#e84.QE_APPL_RES,&E04?;
5f-&L;<r*teStr*#"84.IDENTIFIER04?;
5f-&L;<r*teStr*#"85Rec;IDENTIFIER;B$l'e?;
5f-&L;<r*teStr*#"84.2IDENTIFIER04?;
5f-&L;<r*teStr*#"84.QE_RES,&E_TE-T0.CDCDATAD4?;
5f-&L;<r*teStr*#"85Rec;QE_RES,&E_TE-T;B$l'e?;
5f-&L;<r*teStr*#"84EE0.2QE_RES,&E_TE-T04?;
5f-&L;<r*teL*#e84.2QE_APPL_RES,&E04?;
E#)-<(*le;
E#)-If;
E#)-If;
5f-&L;Close8?;
It is essentially t*e sa,e as t*e original code 'ut uses 0rite>tring& to indi2idually
1rite out all -elds (ro, t*e )ecord t*at contains t*e )T/ -eld" T*is is necessary to
'e a'le to 1rite t*e CDATA section string around t*e )T/ -eld contents" It 1rites to
-le 7/8APPLICA<T;"+,l
Follo1ing is a snippet (ro, t*e generated +,l -le )T/ Te+t *ig*lig*ted&9
"""
=7/8APPL8)/>UM/?
=ID/<TIFI/)?1;;$1=@ID/<TIFI/)?=7/8)/>UM/8T/XT?=DECDATAE=p?=strong?)T/ Te+t=@strong?='r
@?containing =3?3F3 and A=@p?GG?=@7/8)/>UM/8T/XT?=@7/8APPL8)/>UM/?
=7/8APPL8)/>UM/?
"""
!&&ETI'N 2 ( !)i*$ -u)tom fu*-tio* that 1a,)e) XML )t,i*$2
)ea,-hi*$ out a*% e*-lo)i*$ )1e-i0e% ta$ *ame)2 .ith CDATA
)e-tio*)
T*e (ollo1ing pcode is run 2ia App /ngine QE_XML_FILE3:
2* e#closeCDATA $cce/ts $# -&L str*#" F*t( esc$/e) RTE te1t3 $#) ret'r#s t(e s$me -&L str*#" F*t( RTE te1t
e#close) *# CDATA sect*o#
-&L eleme#ts co#t$*#*#" RTE te1t #ee) to +e *)e#t*Ge) 's*#" 5$CDATAF*el)s $rr$A of str*#"s*2
F'#ct*o# e#closeCDATA85sNoCDATA As str*#"3 5$CDATAF*el)s As $rr$A of str*#"? Ret'r#s str*#"
Loc$l str*#" 5sCDATA3 5sEscT1t3 5s,#EscT1t;
Loc$l str*#" 5t$"3 5t$"E#);
Loc$l str*#" 5t$"CDATA 6 4.CDCDATAD4;
Loc$l str*#" 5t$"E#)CDATA 6 4EE04;
Loc$l #'m+er 5#Pos13 5#Pos2;

If 5$CDATAF*el)s .0 N'll T(e#
For 5* 6 1 To 5$CDATAF*el)s;Le#
5t$" 6 4.4 H 5$CDATAF*el)s D5*E H 404;
5t$"E#) 6 4.24 H 5$CDATAF*el)s D5*E H 404;
5sCDATA 6 44;

2* G#) RTE eleme#ts *2
5#Pos1 6 1;
5#Pos2 6 F*#)85t$"3 5sNoCDATA3 5#Pos1?;

2* $s lo#" $s RTE eleme#ts $re fo'#)3 -&L Gle str*#" *s re+'*lt3 s'rro'#)*#" RTE eleme#ts F*t( CDATA *2
<(*le 5#Pos2 0 I
5sCDATA 6 5sCDATA H S'+str*#"85sNoCDATA3 5#Pos13 85#Pos2 - 5#Pos1 J Le#85t$"??? H 5t$"CDATA;

5#Pos1 6 5#Pos2 J Le#85t$"?;
5#Pos2 6 F*#)85t$"E#)3 5sNoCDATA3 5#Pos1?;
If 5#Pos2 .0 5#Pos1 T(e#
5sEscT1t 6 S'+str*#"85sNoCDATA3 5#Pos13 5#Pos2 - 5#Pos1?;
5s,#EscT1t 6 Str*/@KLtmlT$"s85sEscT1t?;
5sCDATA 6 5sCDATA H 5s,#EscT1t;
E#)-If;
5sCDATA 6 5sCDATA H 5t$"E#)CDATA H 5t$"E#);

2* se$rc( for #e1t *#st$#ce of RTE eleme#t *2
5#Pos1 6 5#Pos2 J Le#85t$"E#)?;
5#Pos2 6 F*#)85t$"3 5sNoCDATA3 5#Pos1?;
E#)-<(*le;

2* com/lete Fr*t*#" o't mo)*Ge) -&L str*#" $#) re/l$ce or*"*#$l 5sNoCDATA str*#" F*t( t(*s str*#" 8for
#e1t *ter$t*o# of loo/?*2
5sCDATA 6 5sCDATA H S'+str*#"85sNoCDATA3 5#Pos13 8Le#85sNoCDATA? - 5#Pos1 J 1??;
5sNoCDATA 6 5sCDATA;
E#)-For;
Else
2* *f #o#e of t(e s/ec*Ge) Gel)s $re fo'#)3 ret'r# or*"*#$l '#mo)*Ge) str*#"*2
5sCDATA 6 5sNoCDATA;
E#)-If;

Ret'r# 5sCDATA;
E#)-F'#ct*o#;
Loc$l Recor) 5Rec;
Loc$l F*le 5f-&L;
Loc$l SQL 5SQL;
5f-&L 6 7etF*le84c9:tem/:QE_APPLICANT3;1ml43 4<43 4,TF-=43 >F*leP$t(_A+sol'te?;
If 5f-&L;Is@/e# T(e#
If 5f-&L;SetF*leL$Ao't8F*leL$Ao't;QE_APPLICANT? T(e#
5Rec 6 Cre$teRecor)8Recor);QE_APPLICANT_AD?;
5SQL 6 Cre$teSQL84>Select$ll891?43 5Rec?;
<(*le 5SQL;Fetc(85Rec?
5f-&L;<r*teRecor)85Rec?;
5f-&L;<r*teL*#e84.2QE_APPLICANT_AD04?;
E#)-<(*le;

5Rec 6 Cre$teRecor)8Recor);QE_APPL_RES,&E?;
5SQL 6 Cre$teSQL84>Select$ll891?43 5Rec?;
<(*le 5SQL;Fetc(85Rec?
5f-&L;<r*teRecor)85Rec?;
5f-&L;<r*teL*#e84.2QE_APPL_RES,&E04?;
E#)-<(*le;
E#)-If;
E#)-If;
Loc$l str*#" 5sD$t$ 6 5f-&L;7etStr*#"8?;
Loc$l $rr$A of str*#" 5$RTEF*el)s;
5$RTEF*el)s 6 Cre$teArr$A84QE_RES,&E_TE-T4?;
2* '#comme#t folloF*#" st$teme#t for e$c( $))*t*o#$l Gel)2t$" t($t co#t$*#s RTE te1t*2
rem 5$RTEF*el)s;P's(84QE_ADDITI@NAL_RTE_TE-T4?;
5sD$t$ 6 e#closeCDATA85sD$t$3 5$RTEF*el)s?;
2* 7etStr*#" closes t(e Gle so m'st reo/e#; *2
5f-&L 6 7etF*le84c9:tem/:QE_APPLICANT3;1ml43 4<43 4,TF-=43 >F*leP$t(_A+sol'te?;
If 5f-&L;Is@/e# T(e#
5f-&L;<r*teStr*#"85sD$t$?;
5f-&L;<r*teL*#e84.2APPLICATI@N04?;
5f-&L;Close8?;
E#)-If;
Follo1ing is a snippet (ro, t*e generated +,l -le )T/ Te+t *ig*lig*ted&9
"""
=7/8APPL8)/>UM/?
=ID/<TIFI/)?1;;$1=@ID/<TIFI/)?=7/8)/>UM/8T/XT?=DECDATAE=p?=strong?)T/ Te+t=@strong?='r
@?containing =3?3F3 and A=@p?GG?=@7/8)/>UM/8T/XT?
=@7/8APPL8)/>UM/?
"""
T*is code is t*e sa,e as t*e original e+cept (or t*e additional lines9
Loc$l str*#" 5sD$t$ 6 5f-&L;7etStr*#"8?;
;;;
E#)-If;
/ssentially3 t*e XML -le string is read and parsed3 'y calling ne1ly created (unction
e#closeCDATA8?; T*e ,odi-ed string is t*en 1ritten to -le"
T*e (unction parses t*roug* t*e entire XML string3 searc*ing (or )T/ tags speci-ed
as a para,eter to t*e (unction" T*is para,eter is an Array o( strings3 so t*at
,ultiple )T/ -elds can 'e speci-ed" T*e (unction 'ot* 1raps t*e content (or
speci-ed -elds3 in CDATA section3 as 1ell as unescapes it to re,o2e t*e entity
re(erence su'stitutions"
In conclusion3 t*ere are 'ene-ts and dra1'ac4s to eit*er ,et*od t*at need to 'e
considered9
u$$e)tio* 1 ( !)i*$ +,itet,i*$") i*)tea% of +,iteRe-o,%") fo, )1e-i0-
RTE Fiel% Re-o,%
Ad2antages9
- <o additional parsing and re-1riting o( t*e XML -le is re.uired since eac*
o( t*e )T/ -elds are *andled 1*ile generating XML -le" T*is translates to
4ette, ,u*time 1e,fo,ma*-e"
Disad2antages9
- >ince eac* )T/ )ecords@Field is *andled indi2idually3 i( t*ere are ,ore
t*an one )T/ -eld in t*e data source3 t*en eac* *as to 'e *andled
indi2idually3 resulting in t*e addition o( *ardcoded H-+I applied to ,ultiple
areas o( t*e code3 ma5i*$ mai*te*a*-e a*% futu,e u1%ate) ha,%e,
a*% mo,e time -o*)umi*$ to im1leme*t"
- T*is ,et*od in*erently re.uires t*at all -elds in t*e record containing
)T/ -eld&3 'e 1ritten out indi2idually 2ia t*e 0rite>tring& ,et*od3 as
opposed to 1riting t*e entire record contents 2ia a single call to
0rite)ecord&" T*is can also im1a-t mai*te*a*-e a*% futu,e u1%ate)"
u$$e)tio* 2 ( !)i*$ -u)tom fu*-tio* to 1a,)e XML 0le -o*te*t) a*%
,e.,ite it
Ad2antages9
- Multiple )T/ -elds can 'e *andled 2ia t*e sa,e generic (unction call"
Futu,e -o%e mai*te*a*-e i) mo,e ma*a$ea4le6
- +,iteRe-o,%") -a* -o*ti*ue to 4e u)e%" >o i( a record contains +
nu,'er o( -elds3 including t*e )T/ -eld3 eac* o( t*ose -elds does <CT
need to 'e 1ritten out indi2idually using 0rite>tring&"
- Cu)tom fu*-tio* -a* 4e ma%e a utility fu*-tio*3 and called in any
A/@Pcode t*at needs to *andle )T/ in generated XML -le" T*is si,ilar to
point 13 i,pro2es code ,anagea'ility and ,aintenance"
Disad2antages9
- >ince XML File does *a2e to 'e parsed@re1ritten X nu,'er o( ti,es +
'eing t*e nu,'er o( )T/ -elds speci-ed as a para,eter&3 t*is .ill im1a-t
,u*time 1e,fo,ma*-e e)1e-ially if XML 0le i) la,$e to 4e$i* .ith6
FINAL N'TE AND !&&ETI'N:
Due to t*e co,ple+ities in 1rapping )T/ data in CDATA section 1*en using an XML
File Layout to 1rite an XML File3 it is suggested t*at XMLDo- o'6ect 'e used instead
to generate t*e XML File" XMLDoc *as 'uilt-in API (or 1riting data to a CDATA section
XML<ode:s AddCData>ection&&" T*is a2oids t*e pit(alls ,entioned in 'ot*
suggestions pre2iously descri'ed3 'y a2oiding eit*er *ardcoded special *andling per
)T/ -eld in t*e data source3 as 1ell as a2oiding t*e per(or,ance i,pact o( parsing
and re1riting t*e XML -le 2ia a custo, (unction"
P,o7e-t QE_XML_FILE A11li-atio* i*)t,u-tio*):
1& Copy JP)CK/CT>J7/8XML8FIL/ to LP>MCM/LJPro6ects (older and i,port into
en2 using App Designer
;& )un rel script JscriptsJi,port"s.l 2ia a >7L Client tool suc* as >7L De2eloper
to 'uild t*e ne1 records
$& Copy JdataJP>87/8APPLICA<T8AD"dat and P>87/8APPL8)/>UM/"dat to
LP>MCM/LJdata (older" )un script JscriptsJi,port87/8XML8FIL/"d,s 2ia Data
Mo2er psd,t"e+e& to populate ne1 records 1it* test data"

You might also like