One Star

Replace backslash from filepath

Hi,
I want to validate all .xml file against relative .xsd file. I have to fetch each .Xml file from "xmldataload/data" and .Xsd from "xmldataload/conf" directory. So I have created my job as mentioned below

tFileList-------------------------------> tXSDValidator
Properties assigned
tFileList
Directory: xmldataload/data

tXSDValidator
Xsd file:
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).toLowerCase().replace("/data","/conf").replace(".xml",".xsd")
Xml file:
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))

I am facing issue with replace function. for .Xsd file path replace function is not working for "/" backslash.
replace("/data","/conf") is not replacing the string.
If I write
replace("data","conf") then Its works but in my file path xmldataload/data also got chaged to xmlconfload/conf rather then I want xmldataload/conf
Please help to get proper file path.
2 REPLIES
Community Manager

Re: Replace backslash from filepath

Hi
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).toLowerCase().replace("/data","/conf").replace(".xml",".xsd")

Change it to this expression should work.
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")).toLowerCase().replace("\\data","\\conf").replace(".xml",".xsd")

Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Replace backslash from filepath

Thank you Shong... Its work.