blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Dave Morris' Blog

Strange Behaviour of BizTalk 2004 XPath Expressions

I've just been working on a problem with an XPath expression in an orchestration and thought its strangeness warranted a Blog - just to see if anyone else had come across it and to make other people aware of it really.

What I am trying to do is check the count of a certain child element in a message for zero and not to perform a send operation if it is zero.  Sounds simple and here is the Boolean expression from my decide shape:

xpath(msg, "count(/*[local-name()='root']/*[local-name()='child'])")) != "0"

(Note I've abbreviated the XPath here before anyone says it's wrong - it is definitely right.)

That expression always evaluated to true.  I even dumped out the result of the XPath as debug information to check and it was 0.

Confused, I changed the expression as follows:

System.Convert.ToInt32(xpath(msg, "count(/*[local-name()='root']/*[local-name()='child'])"))) != 0

Basically convert the XPath result to an integer and check its value against numeric zero rather than a string of zero.  This works perfectly.

If anyone can explain this strange behaviour I'd appreciate it.  If not at least its one for everyone else to be aware of.

Oh and I do have SP1 installed before anyone asks.

 

Published 08 March 2005 09:55 by dave.morris

Comments

No Comments
Anonymous comments are disabled
Powered by Community Server (Personal Edition), by Telligent Systems