xPath error

Viewing 1 reply thread
  • Author
    Posts
    • #13202

      If you open the schema inside BizTalk and click on the Body node, it will give you the full xpath expression inside the Node Xpath property (something named like that). That’s what I usually use.

      Also, I sometimes build a simple .net app to test my xpath queries. That saves a lot of time as well.

    • #13203

      Also the context-position is 1- based
      So you should have something like this:

      [code:1:51ddb39d9a]/*[local-name()=’Sample’ and namespace-uri()=’http://BizTalkOrch.InPutSchema’]/*[local-name()=’Body’ and position()=1 and namespace-uri()=”][/code:1:51ddb39d9a]

      • #13204

        The error is from StringBuilder not from the xpath function.
        I would suggest removing the System.String.Format and just assigning the string to XPathStatement.

        Also the position() function is case sensitive.

        • #13205

          I have the following xml:

          [color=blue:67475ee949]<ns0:Sample xmlns:ns0=\”http://BizTalkOrch.InPutSchema\”>
          <Body>
          <AnyThing>AnyThing_0</AnyThing>
          </Body>
          </ns0:Sample>[/color:67475ee949]

          This message is assigned to message variable InMsg.
          I have a variable called xmlDoc of type System.xml.xmldocument
          I have another message of type System.xml.xmldocument called OutMsg

          I am using xPath to extract some of InMsg message details:
          my xpath expression is:

          [color=darkred:67475ee949]xDoc = new System.Xml.XmlDocument();
          xDoc= xpath(InMsg, \”//*[local-name()=’Body’][0]\”);
          OutMsg=xDoc;[/color:67475ee949]

          When I execute this and check it the Debug mode tracked events:

          I get the following error:

          [color=red:67475ee949]Microsoft.XLANGs.Core.NullPartException: The part ‘part’ of message ‘OutMsg’ contained a null value at the end of the construct block[/color:67475ee949].
          at Microsoft.XLANGs.Core.Part.ConstructionCompleteEvent()
          at Microsoft.XLANGs.Core.XMessage.ConstructionCompleteEvent()
          at BizTalkOrch1.XPath.segment1(StopConditions stopOn)
          at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
          Microsoft.XLANGs.Core.NullPartException
          Scoped@
          XPath.XPath
          9363d962-4b5b-4fda-b012-74d2e73cf154

          I feel something is wrong in my xPath statment. Please help If you can suggest some thing better.

          • #13206

            Thanks for your advice:
            Now I have changed it to

            [color=blue:f19eb68538]XPathStatement = System.String.Format(\”/*[local-name()=’Sample’ and namespace-uri()=’http://BizTalkOrch.InPutSchema’%5D/*%5Blocal-name()=’Body&#8217; and Position()=1 and namespace-uri()=”]\”);
            xDoc = xpath(InMsg, XPathStatement);[/color:f19eb68538]

            But Now I am getting the following error:

            [color=red:f19eb68538]System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
            at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
            at System.String.Format(IFormatProvider provider, String format, Object[] args)
            at BizTalkOrch1.XPath.segment1(StopConditions stopOn)
            at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
            System.FormatException
            Scoped@
            XPath.XPath
            ea9527c1-8a78-47d6-ad83-3f8e058936a7[/color:f19eb68538]

            Please note that I have tried with both position 0 as well as 1 but the error remain the same.

            regards,

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.