Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a XML file on the input and i want to generate a flat file.
I want to extract from the ROLESPART loop a specific value with a XPATH expression /CLIENT/DONNCOMM[LB_ROLE_PART='PA']/CD_CLIENT and transform it to a string with XPathFunction but there is no example in TDM documentation for XPathFunction
Thanks for your help
(below a example of the XML input)
<CLIENT>
<TECHNI>
<LB_CRE_NAME/>
<DT_CRE_DATE>20170414</DT_CRE_DATE>
<CD_LEGACY>FWI_01</CD_LEGACY>
</TECHNI>
<GENERA>
<CD_CLIENT>0002000016</CD_CLIENT>
<CD_TITRE>10003</CD_TITRE>
<LB_TELF1>199303030</LB_TELF1>
<LB_TELF2>607080910</LB_TELF2>
<LB_TELFX>607080910</LB_TELFX>
<LB_SOC_PART>S0104</LB_SOC_PART>
<LB_TVA>FR93383542974</LB_TVA>
<LB_DNS>11</LB_DNS>
<LB_RNA>11</LB_RNA>
<BT_BLOC_ECR/>
<LB_BLOC_CLI_COM/>
<LB_BLOC_CLI_LIV/>
<LB_BLOC_CLI_FAC/>
<LB_NUM_APE/>
<LB_TITRE>Société</LB_TITRE>
<LB_NUMRUE/>
<LB_RUE2>RUE2</LB_RUE2>
<LB_RUE3>RUE3</LB_RUE3>
<LB_RUE4>RUE4</LB_RUE4>
<LB_RUE5>RUE5</LB_RUE5>
<LB_PAYS>FR</LB_PAYS>
<LB_LANG_COMM>FR</LB_LANG_COMM>
<LB_CRIT_RI/>
</GENERA>
<DONNCOMM>
<CD_ORGA_COMM>0104</CD_ORGA_COMM>
<LB_CAN_DIST>01</LB_CAN_DIST>
<LB_SEC_ACT>01</LB_SEC_ACT>
<LB_AGEN_COMM/>
<BT_SCHE_CLI>1</BT_SCHE_CLI>
<LB_GROU_PRIX_CLI/>
<BT_LIV_COMP/>
<BT_LIV_PART>9</BT_LIV_PART>
<BT_CODE_REGR_CLI>true</BT_CODE_REGR_CLI>
<BT_PRI_LIV>1</BT_PRI_LIV>
<LB_COND_EXP>01</LB_COND_EXP>
<LB_DEVISE>EUR</LB_DEVISE>
<LB_GROU_IMP/>
<LB_COND_PAI/>
<BT_CLI_RIST/>
<LB_BLOC_CLI_COMM/>
<LB_BLOC_CLI_LIV/>
<LB_BLOC_CLI_FAC/>
<LB_INCOTERM1/>
<LB_INCOTERM2/>
<LB_REGR_COM_FAC/>
<DT_DATE_REF/>
<BT_TRAI_LIV_PAR/>
<LB_CPTE_CH_CLI/>
<BT_SIG_ARL/>
<LB_ZONE_DIST/>
<ROLESPART>
<LB_ROLE_PART>PA</LB_ROLE_PART>
<CD_CLIENT>0002000016</CD_CLIENT>
<LB_COMPT_PART>0</LB_COMPT_PART>
</ROLESPART>
<ROLESPART>
<LB_ROLE_PART>RE</LB_ROLE_PART>
<CD_CLIENT>0002000016</CD_CLIENT>
<LB_COMPT_PART>0</LB_COMPT_PART>
</ROLESPART>
</DONNCOMM>
</CLIENT>
Hi,
To use XPath functions in Talend Data Mapper, for example fn:lower-case
But to extract from the ROLESPART loop the specific value of /CLIENT/DONNCOMM[LB_ROLE_PART='PA']/CD_CLIENT, you don't need XPath function but XQuery and Talend Data Mapper is good at it.
Hi,
Suppose you have a global variable which contains the string "PA".
Add a tFileInputXML to your job and set the schema with 3 fields (LB_ROLE_PART, CD_CLIENT and LB_COMPT_PART) and for the rest, configure the component lie this:
The loop XPath query ("/CLIENT/DONNCOMM/ROLESPART[LB_ROLE_PART='"+(String)globalMap.get("LB_ROLE_PART")+"']") includes the value of the global variable (here "LB_ROLE_PART") and the result is the required ROLESPART:
Hope this helps,
In xpath query you should give the correct path,only then you can extract data.
Hi,
To use XPath functions in Talend Data Mapper, for example fn:lower-case
But to extract from the ROLESPART loop the specific value of /CLIENT/DONNCOMM[LB_ROLE_PART='PA']/CD_CLIENT, you don't need XPath function but XQuery and Talend Data Mapper is good at it.
Thanks all for your replies