Geeks With Blogs
ErwinAI - Enterprise Application Integration (EAI) blog on BizTalk 2004, Visual Studio, and application integration

As pointed out on the weblogs of many fellow geeks, using xpath expressions in BizTalk orchestrations can be a good alternative to:

  • Maps
  • Promoted and distinhuished properties in XLANG/s expressions

I was recently re-applying a succesful xpath expression in an assignment shape.

When you need the xpath to a specific node in an XML, open the corresponding schema (XSD), navigate to the node, highlight it, and grab the xpath-expression from the node properties.

In this particular case, I required the value of a node that is part of a repeating group in the XML. Because it is part of a repeating group, the node can not be promoted. Using a map was out of the question, so the xpath looked like the best candidate.

When I had deployed the orchestration and tried it, the orchestration remained "Started". In the message flow (HAT), I saw an error message "<targetObject xmlns=''> was not expected", where "targetObject" is the element I am trying to get the value of.

What is the the case?

Weblogs suggested that I should check the xpath expression first. Common errors are missing or incorrect namespace definitions, incorrect element and attribute references. All looked correct.

Due to the problems with promoting the element as a property (part of a repeating group), I realized that this is also the problem in the xpath-expression. When I grabbed the xpath-expression from the XSD, no group instance information was in the xpath. In other words: you have to define in the xpath which instance (occurrence) of the repeating group you want to access.

When the "grabbed" xpath looks like "/*[local-name='rootelt']/*[local-name='groupelt']/@[local-name='myattr']" and when "groupelt" is the repeating group, we have to tell which occurrence of "groupelt" we want to access. When we need to have the very first occurrence of "groupelt" under "rootelt", we should use as xpath "/*[local-name='rootelt']/*[local-name='groupelt'][1]/@[local-name='myattr']"

 

Posted on Thursday, April 20, 2006 9:09 PM BizTalk 2004 Hints, Tips & Tricks | Back to top


Comments on this post: BizTalk 2004 - Xpath evaluation error

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Erwin Homan | Powered by: GeeksWithBlogs.net