Access single occurance element in repeated node in orchestration.

Hi All,

Can someone give any idea on how to access the IssuerIdentificationnumber as per the below screenshot in Orchestration. Please note that IssuerIdentificationnumber will only come 1 time mostly in last Line item ( not always) but it will only come once in the full file.

I can access it in the custom pipeline component or in the external lib but is there any way to access it using xpath ? 

February 17th, 2015 5:23am

Hi!

Try the following XPath:
/RetailTransaction//Tender/CreditDebit/IssuerIdentificationNumber

in an expression shape in the following manner:

varIssuerId = xpath(msgMyTransaction, "string(/RetailTransaction//Tender/CreditDebit/IssuerIdentificationNumber)");

where varIssuerId is an orchestration variable of type string.

Your screenshot appears to not have any namespaces, which makes the XPath expression simpler. If there are namespaces in the document, adjust the XPath accordingly (copy the instance xpath for IssuerIdentificationNumber and adjust it).

Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 6:43am

hi Peter,

With the instance xpath only my understanding says that we cannot access because the parent node is repeating.i.e. LineItem

thanks,
vaurn

February 17th, 2015 7:31am

The correct XPATH should be - assumption is that you know the sequence number

//*[local-name()='LineItem'][/*[local-name()='SequenceNumber'] = '9']/*[local-name()='Tender']/*[local-name()='CreditDebit']/*[local-name()='IssuerIdentificationNumber']

whereas if you know the index of LineItem then the XPATH would be

//*[local-name()='LineItem'][<index>]/*[local-name()='Tender']/*[local-name()='CreditDebit']/*[local-name()='IssuerIdentificationNumber']

if IssuerIdentificationNumber is unique in the LineItem structure then you can further shorten it to

//*[local-name()='LineItem'][/*[local-name()='SequenceNumber'] = '9']//*[local-name()='IssuerIdentificationNumber']

OR

//*[local-name()='LineItem'][<index>]//*[local-name()='IssuerIdentificationNumber']

Regards.

Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 7:52am

Hi,

In you're case, i would suggest using XpathMutator class.  I think you need to create a library file and access it inside you're orchestration to get the value under repeating nodes.I have done this earlier ,searching the code,once i get i will share.

Thanks,

Dani

February 17th, 2015 8:25am

Hi,

Open the schema definition of this xml go to that node. You will have the property called instance XPATH. Use that 

xpath(msgYourMsgType, "string(XPATH YOU COPED OVER from VS))"

Note: If it is an unbounded node you will have to consider the index value of the node and modify accordingly.

Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 9:45am

Hi!

Actually my XPath works, I just tested it.

Important: The OP stated that the element IssuerIdentificationNumber only occurs once, and the key here is the double // path in the middle of the XPath. It's an "any" path, so that the XPath finds all Tender/CreditDebit/IssuerIdentificationNumber node(s) in any sub-tree situated below /RetailTransaction.

Given this schema:

Schema with IssuerIdentificationNumber under repeating node

and this input XML:

<ns0:Root xmlns:ns0="http://interchangeid_xmldocument.Schema1">
  <action>action_0</action>
  <RetailTransaction>
    <LineItem>
      <Tender>
        <Amount>Amount_0</Amount>
        <CreditDebit>
        </CreditDebit>
      </Tender>
    </LineItem>
    <LineItem>
      <Tender>
        <Amount>Amount_1</Amount>
        <CreditDebit>
        </CreditDebit>
      </Tender>
    </LineItem>
    <LineItem>
      <Tender>
        <Amount>Amount_2</Amount>
        <CreditDebit>
          <IssuerIdentificationNumber>IssuerIdentificationNumber_2</IssuerIdentificationNumber>
        </CreditDebit>
      </Tender>
    </LineItem>
    <LineItem>
      <Tender>
        <Amount>Amount_3</Amount>
        <CreditDebit>
        </CreditDebit>
      </Tender>
    </LineItem>
  </RetailTransaction>
</ns0:Root>

and the following code in an Expression shape:

varIssuerIdentificationNumber = xpath(msgReceived, "string(/*[local-name()='Root' and namespace-uri()='http://interchangeid_xmldocument.Schema1']/*[local-name()='RetailTransaction' and namespace-uri()='']//*[local-name()='Tender' and namespace-uri()='']/*[local-name()='CreditDebit' and namespace-uri()='']/*[local-name()='IssuerIdentificationNumber' and namespace-uri()=''])");

System.Diagnostics.EventLog.WriteEntry("BizTalk Server", varIssuerIdentificationNumber);

the event log contains the text 

IssuerIdentificationNumber_2

Peter Lindgren

February 17th, 2015 10:55am

Varun,

Can you give the schema for the above image? I'll try to match the xpath exactly for your requirement.

Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 11:07am

Hi Aswin/All,

I have done it in the lib part by fetching the XML and reading the IssuerIDentificaitonnumber in the lib and returned the value. It is working fine.

thanks everyone.

Can you please look into the below link , as 1 more suggestion i require :)

https://social.msdn.microsoft.com/Forums/en-US/93807598-daae-418f-9f9f-3d848556c0b7/sorting-and-disassembling-biztalk-flat-file?forum=biztalkgeneral

Thanks,
Varun

February 17th, 2015 11:29am

Hi!

Try the following XPath:
/RetailTransaction//Tender/CreditDebit/IssuerIdentificationNumber

in an expression shape in the following manner:

varIssuerId = xpath(msgMyTransaction, "string(/RetailTransaction//Tender/CreditDebit/IssuerIdentificationNumber)");

where varIssuerId is an orchestration variable of type string.

Your screenshot appears to not have any namespaces, which makes the XPath expression simpler. If there are namespaces in the document, adjust the XPath accordingly (copy the instance xpath for IssuerIdentificationNumber and adjust it).

  • Proposed as answer by Richard.Spice Tuesday, February 17, 2015 7:39 PM
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2015 2:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics