none
Xpath problems RRS feed

  • Question

  • Hi,

    I am creating a solution based on this guide:

    http://blogical.se/blogs/johan/archive/2011/05/02/biztalk-mapper-keyed-cumulative-sum.aspx

    The trouble for me starts in the third scripting functoid where i have to create a sum with 2 xpaths in 2 different parameters:

    <xsl:template name="OutputSum">
      <xsl:param name="param1" />
      <xsl:param name="param2" />
      <xsl:element name="Compensation_Amount">
      <xsl:value-of select="sum(//row[Compensation_SubCode=$param1 
                  and Compensation_Level=$param2]/Compensation_Amount)" />
      </xsl:element>
    </xsl:template>
    

    We all know that the Biztalk xpaths arent this simple, so the smallest working Xpath in my case i  can create is:

    (/*[local-name()='InterfaceControlObject']/*[local-name()='InterfaceDataXML']/*[local-name()='StockRoot']/*[local-name()='StockOption']/*[local-name()='StockProductList']/*[local-name()='StockProduct']/*[local-name()='DirectBeschikbareVoorraad'])

    Param 1 should be:

    /*[local-name()='InterfaceControlObject']/*[local-name()='InterfaceDataXML']/*[local-name()='StockRoot']/*[local-name()='StockOption']/*[local-name()='StockProductList']/*[local-name()='StockProduct']/*[local-name()='Productnummer']


    But i dont get the syntax working to create a param2 of this Xpath.

    /*[local-name()='InterfaceControlObject']/*[local-name()='InterfaceDataXML']/*[local-name()='StockRoot']/*[local-name()='StockOption']/*[local-name()='StockProductList']/*[local-name()='StockProduct']/*[local-name()='DirectBeschikbareVoorraad'='$param2']


    I keep getting errors. 

    What should be he correct syntax for the example and my 2 Xpaths?

    Tuesday, January 26, 2016 10:57 AM

Answers

  • This looks pretty simple, have you tried this with Functoids?

    In an element query, each [...] basically represents a predicate so closer to what you really need is something like this:

    *[local-name()='DirectBeschikbareVoorraad'][.= $param2]

    • Marked as answer by Ronald Veenman Thursday, January 28, 2016 2:12 PM
    Tuesday, January 26, 2016 1:55 PM
    Moderator
  • For XPATH 2 it should be

    /*[local-name()='InterfaceControlObject']/*[local-name()='InterfaceDataXML']/*[local-name()='StockRoot']/*[local-name()='StockOption']/*[local-name()='StockProductList']/*[local-name()='StockProduct'][*[local-name()='DirectBeschikbareVoorraad']='$param2']

    Regards.

    • Marked as answer by Ronald Veenman Thursday, January 28, 2016 2:12 PM
    Wednesday, January 27, 2016 10:16 AM

All replies

  • This looks pretty simple, have you tried this with Functoids?

    In an element query, each [...] basically represents a predicate so closer to what you really need is something like this:

    *[local-name()='DirectBeschikbareVoorraad'][.= $param2]

    • Marked as answer by Ronald Veenman Thursday, January 28, 2016 2:12 PM
    Tuesday, January 26, 2016 1:55 PM
    Moderator
  • For XPATH 2 it should be

    /*[local-name()='InterfaceControlObject']/*[local-name()='InterfaceDataXML']/*[local-name()='StockRoot']/*[local-name()='StockOption']/*[local-name()='StockProductList']/*[local-name()='StockProduct'][*[local-name()='DirectBeschikbareVoorraad']='$param2']

    Regards.

    • Marked as answer by Ronald Veenman Thursday, January 28, 2016 2:12 PM
    Wednesday, January 27, 2016 10:16 AM
  • Hi Ronald,

    Could you provide a test file?

    Best regards

    Rasmus Jaeger

    Wednesday, January 27, 2016 11:27 AM