BizTalk Server Orchestration - xPath question

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > August 2005 > xPath question





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 xPath question
Yossi Dahan

2005-08-01, 8:09 am

Hi all,

I've got an orchestration that receives an xml that is structured
something like:

<A>
<b>
<c>text 1</c>
</b>
<b>
<c>text 2</c>
</b>
</A>

I need to loop and get values of all c element

I have a loop shape based on count of c using xpath - count(/A/b/c)
which works just fine.

then I'm trying to extract the c element using the xpath "/A/b[i]/c"
where i is the counter of the loop+1 but I'm getting an empty string as
if the node was not found.

checking the same xpath in an external xml tool works fine, I would
expect it to work in the orchestration just as well..


Anyone sees what I'm missing?

Thanks

Yossi Dahan
Scott Colestock

2005-08-01, 5:51 pm

Try: /A/b[position()=i]/c

or string(/A/b[position()=2]/c) if you want the element content rather than
the node.

Scott Colestock
www.traceofthought.net


"Yossi Dahan" <yossi.dahan@sabratech.co.uk> wrote in message
news:um9CjjplFHA.3960@TK2MSFTNGP12.phx.gbl...
> Hi all,
>
> I've got an orchestration that receives an xml that is structured
> something like:
>
> <A>
> <b>
> <c>text 1</c>
> </b>
> <b>
> <c>text 2</c>
> </b>
> </A>
>
> I need to loop and get values of all c element
>
> I have a loop shape based on count of c using xpath - count(/A/b/c) which
> works just fine.
>
> then I'm trying to extract the c element using the xpath "/A/b[i]/c" where
> i is the counter of the loop+1 but I'm getting an empty string as if the
> node was not found.
>
> checking the same xpath in an external xml tool works fine, I would expect
> it to work in the orchestration just as well..
>
>
> Anyone sees what I'm missing?
>
> Thanks
>
> Yossi Dahan



Marvin Smit

2005-08-01, 5:51 pm

Hi,

ehh... I see you basing the counter on the C nodes, but try to use the
counter in the B position. I think you still need to 'count the C's'.

/A/b/c[count(preceding::c)=i]

Hope this helps,

Marvin Smit.

Ps: this is assuming i = 0 based, if i = 1 based.. use (i-1) ;)


On Mon, 1 Aug 2005 09:43:06 -0500, "Scott Colestock"
<scolestock@community.nospam> wrote:

>Try: /A/b[position()=i]/c
>
>or string(/A/b[position()=2]/c) if you want the element content rather than
>the node.
>
>Scott Colestock
>www.traceofthought.net
>
>
>"Yossi Dahan" <yossi.dahan@sabratech.co.uk> wrote in message
>news:um9CjjplFHA.3960@TK2MSFTNGP12.phx.gbl...
>


Yossi Dahan

2005-08-02, 7:50 am

Marvin Smit wrote:
> Hi,
>
> ehh... I see you basing the counter on the C nodes, but try to use the
> counter in the B position. I think you still need to 'count the C's'.
>
> /A/b/c[count(preceding::c)=i]
>
> Hope this helps,
>
> Marvin Smit.
>
> Ps: this is assuming i = 0 based, if i = 1 based.. use (i-1) ;)
>
>
> On Mon, 1 Aug 2005 09:43:06 -0500, "Scott Colestock"
> <scolestock@community.nospam> wrote:
>
>
>

Thanks for the answer guys, but I'm still not getting anything, I
changed my simple [i] to [position=1], but it did not make any
difference. I've tried the string method before I've posted (as you'd
expect) and it did not make a difference)

The count itself works great, it's just extracting the nodes text that
doesn't happen.

Yossi Dahan
Scott Colestock

2005-08-02, 5:57 pm

I notice you are missing the parens in your position function - is that just
a mistake in your post?

/A/b[position()=2]/c

Scott Colestock
www.traceofthought.net


"Yossi Dahan" <yossi.dahan@sabratech.co.uk> wrote in message
news:%23cH2yB0lFHA.1412@TK2MSFTNGP09.phx.gbl...
> Marvin Smit wrote:
> Thanks for the answer guys, but I'm still not getting anything, I changed
> my simple [i] to [position=1], but it did not make any difference. I've
> tried the string method before I've posted (as you'd expect) and it did
> not make a difference)
>
> The count itself works great, it's just extracting the nodes text that
> doesn't happen.
>
> Yossi Dahan



Yossi Dahan

2005-08-03, 2:54 am

Scott Colestock wrote:
> I notice you are missing the parens in your position function - is that just
> a mistake in your post?
>
> /A/b[position()=2]/c
>
> Scott Colestock
> www.traceofthought.net
>
>
> "Yossi Dahan" <yossi.dahan@sabratech.co.uk> wrote in message
> news:%23cH2yB0lFHA.1412@TK2MSFTNGP09.phx.gbl...
>
>
>
>

I found it. and I'm embarrassed to admit how silly it was.

the xpath was fine I've actually had to re-check, but I did use
position() properly.

What I didn't do is actually pass the message as a parameter to the
xpath method. my call was simply - xpath(myXPathString) and not xpath
(myMessage,myXPathString) which is, of course, wrong and totally silly.
I am surprised though that it does compile and execute with no errors.

Thanks for the help guys, but unfortunately there's still no cure for
plain stupidity ;-)


Yossi Dahan
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com