locked
Retrive Records using XPath in Orchestration. RRS feed

  • Question

  • Hi All,
    I am working on one applicaiton in which i am having one schema as follows :
    Sess
       Data
          Pol
    line
       risk
         @deleted

    I want count of number of risk excluding risk\@deleted = '1' or attribute deleted is not exist.
    currently i am using simple count function as follows :
    VehCnt = xpath(msgPol, "count(/*[local-name()='sess' and namespace-uri()='http://Pol/1.0']/*[local-name()='data' and namespace-uri()='']/*[local-name()='pol' and namespace-uri()='']/*[local-name()='line' and namespace-uri()='']/*[local-name()='risk' and namespace-uri()=''])");


    Thanks and Regards, Nitin.

    Wednesday, August 2, 2017 7:33 AM

Answers

  • Nitin,

    Try the following Xpath which gets the count of "risk" nodes EXCLUDING @deleted=1

    VehCnt = xpath(msgPol, "count(/*[local-name()='sess' and namespace-uri()='http://Pol/1.0']/*[local-name()='data' and namespace-uri()='']/*[local-name()='line' and namespace-uri()='']/*[local-name()='risk' and namespace-uri()=''][not(@*[local-name()='deleted' and namespace-uri()='']=1)])");

    where I use the Xpath as:

    count(/*[local-name()='sess' and namespace-uri()='http://Pol/1.0']/*[local-name()='data' and namespace-uri()='']/*[local-name()='line' and namespace-uri()='']/*[local-name()='risk' and namespace-uri()=''][not(@*[local-name()='deleted' and namespace-uri()='']=1)])

    You may need change the name of the elemetns exactly to match yours. But the curx here is to use the Xpath with NOT as mentioned above.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.


    Wednesday, August 2, 2017 8:44 AM
  • So get a total count of the risk records and subtract from that the number where the attribute exists. Something like

    xpath(msgPol, count(//*[local-name()='risk'])) - xpath(msgPol, count(//*[local-name()='risk]/@*[local-name()='deleted']))

    The first XPATH will get you a count of all the "risk" records while the second will give you a count of all those risk/@deleted records..

    Regards.


    Wednesday, August 2, 2017 8:42 AM

All replies

  • So get a total count of the risk records and subtract from that the number where the attribute exists. Something like

    xpath(msgPol, count(//*[local-name()='risk'])) - xpath(msgPol, count(//*[local-name()='risk]/@*[local-name()='deleted']))

    The first XPATH will get you a count of all the "risk" records while the second will give you a count of all those risk/@deleted records..

    Regards.


    Wednesday, August 2, 2017 8:42 AM
  • Nitin,

    Try the following Xpath which gets the count of "risk" nodes EXCLUDING @deleted=1

    VehCnt = xpath(msgPol, "count(/*[local-name()='sess' and namespace-uri()='http://Pol/1.0']/*[local-name()='data' and namespace-uri()='']/*[local-name()='line' and namespace-uri()='']/*[local-name()='risk' and namespace-uri()=''][not(@*[local-name()='deleted' and namespace-uri()='']=1)])");

    where I use the Xpath as:

    count(/*[local-name()='sess' and namespace-uri()='http://Pol/1.0']/*[local-name()='data' and namespace-uri()='']/*[local-name()='line' and namespace-uri()='']/*[local-name()='risk' and namespace-uri()=''][not(@*[local-name()='deleted' and namespace-uri()='']=1)])

    You may need change the name of the elemetns exactly to match yours. But the curx here is to use the Xpath with NOT as mentioned above.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.


    Wednesday, August 2, 2017 8:44 AM
  • You can make this a lot easier by stripping out all the namespaces first.

    Details: BizTalk: Simplify BizTalk Dev by Using the Empty Namespace

    Really, there's no reason to use Xml Namespaces in any new development.

    Wednesday, August 2, 2017 1:41 PM
    Moderator
  • Hi Shankycheil,

    Thanks for your help ...your solution worked for me thanks....


    Thanks and Regards, Nitin.

    Wednesday, August 2, 2017 5:06 PM
  • Hi Ashwin,

    Thanks for your help ...your solution worked for me thanks....


    Thanks and Regards, Nitin.

    Wednesday, August 2, 2017 5:07 PM
  • Hi Nitin, Kindly mark the right reply as answer.

    Regards PK: Please mark the reply as answer or vote it up, as deemed fit.

    Wednesday, August 2, 2017 5:29 PM