Hi,
I need to read from xml during transformation . based on some parameter i need to identify sending location. Following is my xml and XML is generatin from database (SQL Server 2005)
- <ns0:BOAArlineItem xmlns:ns0="http://BOAArlineItem"> <ns0:dbo.BELB_History recordbatchnumber="recordbatchnumber_0" RecordLockboxnumber="RecordLockboxnumber_1" contechdepositdate="contechdepositdate_2" EXPORTRECORDLINE="EXPORTRECORDLINE_3" /> <ns0:dbo.BELB_History recordbatchnumber="recordbatchnumber_0" RecordLockboxnumber="RecordLockboxnumber_1" contechdepositdate="contechdepositdate_2" EXPORTRECORDLINE="EXPORTRECORDLINE_3" /> <ns0:dbo.BELB_History recordbatchnumber="recordbatchnumber_0" RecordLockboxnumber="RecordLockboxnumber_1" contechdepositdate="contechdepositdate_2" EXPORTRECORDLINE="EXPORTRECORDLINE_3" /> </ns0:BOAArlineItem>
Attributes recordbatchnumber, RecordLockboxnumber and contechdepositdate value would be same in all the record in file
Now I need to read those attribute value and generate sending file name.
I have used xPath to read attribute values from xml. following is the code for reading attribute using xpath
//Get the path of the the first HeaderInfo ElementHeaderInfoPath = System.String.Format("//dbo.BankExternalLockBox_History[{0}]",1);XmlDoc = xpath(BOAArlineItemMSG,HeaderInfoPath);
//Construct MessageXmlDocMSG = XmlDoc;
LockBoxNo = xpath(XmlDocMSG,"string(/dbo.BankExternalLockBox_History/RecordLockboxnumber)");BatchNo = xpath(XmlDocMSG,"string(/dbo.BankExternalLockBox_History/recordbatchnumber)");
SendFileName = LockBoxNo + BatchNo + System.DateTime.Now.Date.ToString() + ".txt";
OUTBOAArlineMSG(FILE.ReceivedFileName) = SendFileName;
Can anyone suggest how to use xPath within orchestration or suggest other alternative?
Thanks for early response.
Regards,
- Dhaval M.
I would tend to extract the LockBoxNo and BatchNo from the
StringXpathBase = "string(/*[local-name()='BOAArlineItem ']/*[local-name()='dbo.BankExternalLockBox_History'][{0}]/*[local-name()='{1}'])";
LockBoxNo = xpath(BOAArlineItemMSG, System.String.Format(StringXpathBase,"1", "RecordLockboxnumber"));BatchNo = xpath(BOAArlineItemMSGSystem.String.Format(StringXpathBase,"1", "recordbatchnumber"));
Your original xpath statements will not resolve because the message has a namespace. You need to use a predicate i.e.
*[local-name()='nodename']or*[local-name()='nodename' and namespace-uri='message-namespace']