BizTalk Server Orchestration - Using XPath in an Expression Shape

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > December 2005 > Using XPath in an Expression Shape





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Using XPath in an Expression Shape
Jim Adams

2005-12-19, 5:54 pm

I have an orchestration which reads in a XML file that has multiple
Order nodes which has several children. I cannot promote any of the
fields because there are multiple nodes. I am therefore attempting to
use XPath to pull out data from the first record that I will use later
in my processing. The data I am pulling out is common to all Order
nodes so I just need to get it once. However, when I use the xpath
statement in my Expression Shape I am not getting the value I am
looking for. In fact, I am not getting anything. Here is a shortened
version of what the XML file looks like and the statement I am using to
pull the first value of RecordType.

XML Message:
<ns0:LoadRoot xmlns:ns0="http://Load_Messaging.UpLoadRecv">
<OrderRec RecordType="shp" Company="ABC ">
<Date>12/16/2005</Date>
<Name>Some Name</Name>
</OrderRec>
<OrderRec RecordType="shp" Company="ABC ">
<Date>12/16/2005</Date>
<Name>Some Other Name</Name>
</OrderRec>
</ns0:UpLoadRoot>

Statement in Expression Shape:0
strRecordType = xpath(XMLMessage, "//*/OrderRec[1]/@RecordType");

I tried to use the XPath for RecordType from the Schema editor but I
cannot figure out how to tell the XPath statement I just want the first
instance.

Any help would be greatly appreciated!

Thanks,
Jim

Samuel L

2005-12-20, 5:54 pm

Hi Jim!

I think this XPATH should work for you:
"/child::*/OrderRec[position()=1]/@RecordType"

Hope this helps you! Please let me know whether it does or not.
Good luck!

"Jim Adams" wrote:

> I have an orchestration which reads in a XML file that has multiple
> Order nodes which has several children. I cannot promote any of the
> fields because there are multiple nodes. I am therefore attempting to
> use XPath to pull out data from the first record that I will use later
> in my processing. The data I am pulling out is common to all Order
> nodes so I just need to get it once. However, when I use the xpath
> statement in my Expression Shape I am not getting the value I am
> looking for. In fact, I am not getting anything. Here is a shortened
> version of what the XML file looks like and the statement I am using to
> pull the first value of RecordType.
>
> XML Message:
> <ns0:LoadRoot xmlns:ns0="http://Load_Messaging.UpLoadRecv">
> <OrderRec RecordType="shp" Company="ABC ">
> <Date>12/16/2005</Date>
> <Name>Some Name</Name>
> </OrderRec>
> <OrderRec RecordType="shp" Company="ABC ">
> <Date>12/16/2005</Date>
> <Name>Some Other Name</Name>
> </OrderRec>
> </ns0:UpLoadRoot>
>
> Statement in Expression Shape:0
> strRecordType = xpath(XMLMessage, "//*/OrderRec[1]/@RecordType");
>
> I tried to use the XPath for RecordType from the Schema editor but I
> cannot figure out how to tell the XPath statement I just want the first
> instance.
>
> Any help would be greatly appreciated!
>
> Thanks,
> Jim
>
>

Jim Adams

2005-12-22, 7:48 am

Thanks Samuel you got me on the right track. The final xpath was
"/*/child::*[position()=1]/@RecordType" For some reason your
suggestion did not work in BT either but at least it gave me a
different approach that did work. I think the problem is that the
incoming message wasn't exactly what I thought it was.

Anyway, thanks for your help.

Jim Adams

2005-12-22, 7:48 am

Thanks Samuel you got me on the right track. The final xpath was
"/*/child::*[position()=1]/@RecordType" For some reason your
suggestion did not work in BT either but at least it gave me a
different approach that did work. I think the problem is that the
incoming message wasn't exactly what I thought it was.

Anyway, thanks for your help.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com