What I am trying to do is, in a loop shape, extract child node data
from an incoming message so that I can use them as parameters to call a
webservice.
The incoming message schema is called
"msgGMASRequestStationCloseNotifications", and it looks like this:
<?xml version="1.0"?>
<StationCloseNotifications xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://Union.CARE.GMAS.BizTalk.schGMASRequestStationCloseNotifications">
<StationCloseNotification xmlns="">
<stationName>Bob</stationName>
<organizationName>Bob</organizationName>
<closedPeriodStart>2006-08-17T14:47:01.3387810-04:00</closedPeriodStart>
<closedPeriodEnd>2006-08-17T14:47:01.3387810-04:00</closedPeriodEnd>
<closeUser>Bob</closeUser>
</StationCloseNotifications>
In my expression shape I am using the xpath expression:
varStrStationName =
xpath(msgGMASRequestStationCloseNotifications,"/*[local-name()='StationCloseNotifications'
and
namespace-uri()='http://Union.CARE.GMAS.BizTalk.schGMASRequestStationCloseNotifications']/*[local-name()='StationCloseNotification'
and namespace-uri()='']/*[local-name()='stationName' and
namespace-uri()='']");
which gives me the event log error:
<stationName xmlns=''> was not expected.
Do you have any idea what I am missing? It is so maddening that
anywhere other than BT I can use a statement like
//StationCloseNotification[1]/stationName to get at data in any node I
want.
Thanks in advance for your help.
>varStrStationName =
>xpath(msgGMASRequestStationCloseNotifications,"/*[local-name()='StationCloseNotifications'
>and
>namespace-uri()='http://Union.CARE.GMAS.BizTalk.schGMASRequestStationCloseNotifications']/*[local-name()='StationCloseNotification'
>and namespace-uri()='']/*[local-name()='stationName' and
>namespace-uri()='']");
How did you get this xpath expression? What I usually do is open the
schema in the schemaeditor, select the node you need, and go to the
properties. There is a property called "XPath" - copy the expression
from this and use that in your orchestration.
What about the input instance that is failing? Does that have an
xmlns="" on the stationName element?
--
eliasen, representing himself and not the company he works for.
private email: j...@eliasen.dk
A simple fix is to add "/text()" to the end of you XPath. This will return
the text content of the <stationName> element, and this will de-serialise to
a string without throwing an exception.
>A simple fix is to add "/text()" to the end of you XPath. This will return
>the text content of the <stationName> element, and this will de-serialise to
>a string without throwing an exception.
Or, as I have just written about at
http://blog.eliasen.dk/PermaLink,guid,83d9f5af-60b4-45ad-bdc1-1e345b83772f.aspx
- use the xpath(message, "string(xpathexpression)") way of doing it.
Not sure which is the prettier? Or faster, even?
--
eliasen, representing himself and not the company he works for.
Private blog: http://blog.eliasen.dk
Private email: j...@eliasen.dk