BizTalk Map: xslt 1.0 sum “Cannot implicitly convert type 'string' to 'int'” Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!XSLT 1.0 accumulation, summing, multiplicationxslt 1.0 string replace functionConvert Xslt 1.0 String to a NumberConvert string type number to int number and sum up in XSLT 1.0XSLT for BizTalk mapping and changing node nameXslt 1.0 aggregate and sumBizTalk map functoid vs BizTalk map xsltXSLT 1.0 Group By and Sum to compareXSLT call template in BizTalk MappingBizTalk Mapping - xslt muenchian grouping and sum with case

Do wooden building fires get hotter than 600°C?

What is "gratricide"?

Why weren't discrete x86 CPUs ever used in game hardware?

Crossing US/Canada Border for less than 24 hours

How to compare two different files line by line in unix?

Maximum summed subsequences with non-adjacent items

How could we fake a moon landing now?

Amount of permutations on an NxNxN Rubik's Cube

How fail-safe is nr as stop bytes?

Is it fair for a professor to grade us on the possession of past papers?

Did Krishna say in Bhagavad Gita "I am in every living being"

How often does castling occur in grandmaster games?

What does it mean that physics no longer uses mechanical models to describe phenomena?

How to tell that you are a giant?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Illegal assignment from sObject to Id

Why do we bend a book to keep it straight?

What is the difference between globalisation and imperialism?

Generate an RGB colour grid

Would the Life Transference spell be unbalanced if it ignored resistance and immunity?

Morning, Afternoon, Night Kanji

Question about debouncing - delay of state change

Find 108 by using 3,4,6

When a candle burns, why does the top of wick glow if bottom of flame is hottest?



BizTalk Map: xslt 1.0 sum “Cannot implicitly convert type 'string' to 'int'”



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!XSLT 1.0 accumulation, summing, multiplicationxslt 1.0 string replace functionConvert Xslt 1.0 String to a NumberConvert string type number to int number and sum up in XSLT 1.0XSLT for BizTalk mapping and changing node nameXslt 1.0 aggregate and sumBizTalk map functoid vs BizTalk map xsltXSLT 1.0 Group By and Sum to compareXSLT call template in BizTalk MappingBizTalk Mapping - xslt muenchian grouping and sum with case



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Get error:




Cannot implicitly convert type 'string' to 'int'




on this code:



<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>


Then tried this:



 <TotalInvoiceCost>
<xsl:value-of select="sum(number(//*[local-name()='InvoiceTotal']))" />
</TotalInvoiceCost>


but get this error:




Argument 1 of function 'sum()' cannot be converted to a node-set.




Cut Down Sample Data with Structure (all values are numeric):



<TAR210 xmlns="demo">
<DummyHeaderGroup xmlns=""/>
<Invoice xmlns="">
<Level1>
<InvoiceTotal>1075</InvoiceTotal>
</Level1>
<Level1>
<InvoiceTotal>595</InvoiceTotal>
</Level1>
</Invoice>
</TAR210>


In http://www.xpathtester.com/xpath, this works fine:




sum(//*[local-name()="InvoiceTotal"])




Example of XSLT in context:



<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl var userCSharp" version="1.0"
xmlns:ns0="demo"
xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">

<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

<xsl:template match="/">
<ns0:TAR210>
<DummyHeaderGroup>
<Level0>
<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>
</Level0>
</DummyHeaderGroup>
</ns0:TAR210>
</xsl:template>

</xsl:stylesheet>









share|improve this question
























  • I tested your sample with xsltproc (Linux XSLT-1.0 processor) and it works as expected.

    – zx485
    Mar 8 at 20:35












  • Thanks, must be a BizTalk thing. I can make the field numeric in the schema, and redeploy.

    – NealWalters
    Mar 8 at 20:41

















0















Get error:




Cannot implicitly convert type 'string' to 'int'




on this code:



<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>


Then tried this:



 <TotalInvoiceCost>
<xsl:value-of select="sum(number(//*[local-name()='InvoiceTotal']))" />
</TotalInvoiceCost>


but get this error:




Argument 1 of function 'sum()' cannot be converted to a node-set.




Cut Down Sample Data with Structure (all values are numeric):



<TAR210 xmlns="demo">
<DummyHeaderGroup xmlns=""/>
<Invoice xmlns="">
<Level1>
<InvoiceTotal>1075</InvoiceTotal>
</Level1>
<Level1>
<InvoiceTotal>595</InvoiceTotal>
</Level1>
</Invoice>
</TAR210>


In http://www.xpathtester.com/xpath, this works fine:




sum(//*[local-name()="InvoiceTotal"])




Example of XSLT in context:



<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl var userCSharp" version="1.0"
xmlns:ns0="demo"
xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">

<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

<xsl:template match="/">
<ns0:TAR210>
<DummyHeaderGroup>
<Level0>
<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>
</Level0>
</DummyHeaderGroup>
</ns0:TAR210>
</xsl:template>

</xsl:stylesheet>









share|improve this question
























  • I tested your sample with xsltproc (Linux XSLT-1.0 processor) and it works as expected.

    – zx485
    Mar 8 at 20:35












  • Thanks, must be a BizTalk thing. I can make the field numeric in the schema, and redeploy.

    – NealWalters
    Mar 8 at 20:41













0












0








0








Get error:




Cannot implicitly convert type 'string' to 'int'




on this code:



<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>


Then tried this:



 <TotalInvoiceCost>
<xsl:value-of select="sum(number(//*[local-name()='InvoiceTotal']))" />
</TotalInvoiceCost>


but get this error:




Argument 1 of function 'sum()' cannot be converted to a node-set.




Cut Down Sample Data with Structure (all values are numeric):



<TAR210 xmlns="demo">
<DummyHeaderGroup xmlns=""/>
<Invoice xmlns="">
<Level1>
<InvoiceTotal>1075</InvoiceTotal>
</Level1>
<Level1>
<InvoiceTotal>595</InvoiceTotal>
</Level1>
</Invoice>
</TAR210>


In http://www.xpathtester.com/xpath, this works fine:




sum(//*[local-name()="InvoiceTotal"])




Example of XSLT in context:



<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl var userCSharp" version="1.0"
xmlns:ns0="demo"
xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">

<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

<xsl:template match="/">
<ns0:TAR210>
<DummyHeaderGroup>
<Level0>
<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>
</Level0>
</DummyHeaderGroup>
</ns0:TAR210>
</xsl:template>

</xsl:stylesheet>









share|improve this question
















Get error:




Cannot implicitly convert type 'string' to 'int'




on this code:



<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>


Then tried this:



 <TotalInvoiceCost>
<xsl:value-of select="sum(number(//*[local-name()='InvoiceTotal']))" />
</TotalInvoiceCost>


but get this error:




Argument 1 of function 'sum()' cannot be converted to a node-set.




Cut Down Sample Data with Structure (all values are numeric):



<TAR210 xmlns="demo">
<DummyHeaderGroup xmlns=""/>
<Invoice xmlns="">
<Level1>
<InvoiceTotal>1075</InvoiceTotal>
</Level1>
<Level1>
<InvoiceTotal>595</InvoiceTotal>
</Level1>
</Invoice>
</TAR210>


In http://www.xpathtester.com/xpath, this works fine:




sum(//*[local-name()="InvoiceTotal"])




Example of XSLT in context:



<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl var userCSharp" version="1.0"
xmlns:ns0="demo"
xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">

<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />

<xsl:template match="/">
<ns0:TAR210>
<DummyHeaderGroup>
<Level0>
<TotalInvoiceCost>
<xsl:value-of select="sum(//*[local-name()='InvoiceTotal'])" />
</TotalInvoiceCost>
</Level0>
</DummyHeaderGroup>
</ns0:TAR210>
</xsl:template>

</xsl:stylesheet>






xslt-1.0 biztalk-2013






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 20:30







NealWalters

















asked Mar 8 at 20:18









NealWaltersNealWalters

5,7392888163




5,7392888163












  • I tested your sample with xsltproc (Linux XSLT-1.0 processor) and it works as expected.

    – zx485
    Mar 8 at 20:35












  • Thanks, must be a BizTalk thing. I can make the field numeric in the schema, and redeploy.

    – NealWalters
    Mar 8 at 20:41

















  • I tested your sample with xsltproc (Linux XSLT-1.0 processor) and it works as expected.

    – zx485
    Mar 8 at 20:35












  • Thanks, must be a BizTalk thing. I can make the field numeric in the schema, and redeploy.

    – NealWalters
    Mar 8 at 20:41
















I tested your sample with xsltproc (Linux XSLT-1.0 processor) and it works as expected.

– zx485
Mar 8 at 20:35






I tested your sample with xsltproc (Linux XSLT-1.0 processor) and it works as expected.

– zx485
Mar 8 at 20:35














Thanks, must be a BizTalk thing. I can make the field numeric in the schema, and redeploy.

– NealWalters
Mar 8 at 20:41





Thanks, must be a BizTalk thing. I can make the field numeric in the schema, and redeploy.

– NealWalters
Mar 8 at 20:41












1 Answer
1






active

oldest

votes


















0














Well, the real world program is typically more complex than what we post on the web when we have a problem; I tried to simplify. The error had nothing to do with the code I posted.



To me, it seems like the biggest issue is that the error from the "Test Map" in Visual Studio doesn't give any hint to the line number with the error.



<Level0>
<BatchNumberLeaveBlank></BatchNumberLeaveBlank>
<InvoiceSendDateCCYYMM>
<!-- Get current CCYYMM -->
<!-- Current-DateTime doesn't exist in XSLT 1.0, had to use C#
<xsl:value-of select="concat(substring(current-dateTime(),1,4),substring(current-dateTime(),6,2))"/>
-->
<xsl:value-of select="userCSharp:GetDateCCYYMM()"/>
</InvoiceSendDateCCYYMM>
<DefaultValueN>N</DefaultValueN>
<TotalInvoiceCost>...


Then I had the C# code below:



 <msxsl:script language="C#" implements-prefix="userCSharp">
<![CDATA[ int lineCount = 0;

public int GetDateCCYYMM()

return DateTime.Now.ToString("yyyyMMdd");


]]>
</msxsl:script>


Obviously, the "public int" should have been "public string" above.



The only way I know how to tackle these problems is the "divide and conquer" method.
I made a copy of the XSLT, named it same with _Debug.xslt, changed the BizTalk map to use it instead, and started ripping out lines of code left and right until the error goes away. Even removing the call to the c# didn't remove the error, so it must have been running a .NET compile or syntax check on the code.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070442%2fbiztalk-map-xslt-1-0-sum-cannot-implicitly-convert-type-string-to-int%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Well, the real world program is typically more complex than what we post on the web when we have a problem; I tried to simplify. The error had nothing to do with the code I posted.



    To me, it seems like the biggest issue is that the error from the "Test Map" in Visual Studio doesn't give any hint to the line number with the error.



    <Level0>
    <BatchNumberLeaveBlank></BatchNumberLeaveBlank>
    <InvoiceSendDateCCYYMM>
    <!-- Get current CCYYMM -->
    <!-- Current-DateTime doesn't exist in XSLT 1.0, had to use C#
    <xsl:value-of select="concat(substring(current-dateTime(),1,4),substring(current-dateTime(),6,2))"/>
    -->
    <xsl:value-of select="userCSharp:GetDateCCYYMM()"/>
    </InvoiceSendDateCCYYMM>
    <DefaultValueN>N</DefaultValueN>
    <TotalInvoiceCost>...


    Then I had the C# code below:



     <msxsl:script language="C#" implements-prefix="userCSharp">
    <![CDATA[ int lineCount = 0;

    public int GetDateCCYYMM()

    return DateTime.Now.ToString("yyyyMMdd");


    ]]>
    </msxsl:script>


    Obviously, the "public int" should have been "public string" above.



    The only way I know how to tackle these problems is the "divide and conquer" method.
    I made a copy of the XSLT, named it same with _Debug.xslt, changed the BizTalk map to use it instead, and started ripping out lines of code left and right until the error goes away. Even removing the call to the c# didn't remove the error, so it must have been running a .NET compile or syntax check on the code.






    share|improve this answer



























      0














      Well, the real world program is typically more complex than what we post on the web when we have a problem; I tried to simplify. The error had nothing to do with the code I posted.



      To me, it seems like the biggest issue is that the error from the "Test Map" in Visual Studio doesn't give any hint to the line number with the error.



      <Level0>
      <BatchNumberLeaveBlank></BatchNumberLeaveBlank>
      <InvoiceSendDateCCYYMM>
      <!-- Get current CCYYMM -->
      <!-- Current-DateTime doesn't exist in XSLT 1.0, had to use C#
      <xsl:value-of select="concat(substring(current-dateTime(),1,4),substring(current-dateTime(),6,2))"/>
      -->
      <xsl:value-of select="userCSharp:GetDateCCYYMM()"/>
      </InvoiceSendDateCCYYMM>
      <DefaultValueN>N</DefaultValueN>
      <TotalInvoiceCost>...


      Then I had the C# code below:



       <msxsl:script language="C#" implements-prefix="userCSharp">
      <![CDATA[ int lineCount = 0;

      public int GetDateCCYYMM()

      return DateTime.Now.ToString("yyyyMMdd");


      ]]>
      </msxsl:script>


      Obviously, the "public int" should have been "public string" above.



      The only way I know how to tackle these problems is the "divide and conquer" method.
      I made a copy of the XSLT, named it same with _Debug.xslt, changed the BizTalk map to use it instead, and started ripping out lines of code left and right until the error goes away. Even removing the call to the c# didn't remove the error, so it must have been running a .NET compile or syntax check on the code.






      share|improve this answer

























        0












        0








        0







        Well, the real world program is typically more complex than what we post on the web when we have a problem; I tried to simplify. The error had nothing to do with the code I posted.



        To me, it seems like the biggest issue is that the error from the "Test Map" in Visual Studio doesn't give any hint to the line number with the error.



        <Level0>
        <BatchNumberLeaveBlank></BatchNumberLeaveBlank>
        <InvoiceSendDateCCYYMM>
        <!-- Get current CCYYMM -->
        <!-- Current-DateTime doesn't exist in XSLT 1.0, had to use C#
        <xsl:value-of select="concat(substring(current-dateTime(),1,4),substring(current-dateTime(),6,2))"/>
        -->
        <xsl:value-of select="userCSharp:GetDateCCYYMM()"/>
        </InvoiceSendDateCCYYMM>
        <DefaultValueN>N</DefaultValueN>
        <TotalInvoiceCost>...


        Then I had the C# code below:



         <msxsl:script language="C#" implements-prefix="userCSharp">
        <![CDATA[ int lineCount = 0;

        public int GetDateCCYYMM()

        return DateTime.Now.ToString("yyyyMMdd");


        ]]>
        </msxsl:script>


        Obviously, the "public int" should have been "public string" above.



        The only way I know how to tackle these problems is the "divide and conquer" method.
        I made a copy of the XSLT, named it same with _Debug.xslt, changed the BizTalk map to use it instead, and started ripping out lines of code left and right until the error goes away. Even removing the call to the c# didn't remove the error, so it must have been running a .NET compile or syntax check on the code.






        share|improve this answer













        Well, the real world program is typically more complex than what we post on the web when we have a problem; I tried to simplify. The error had nothing to do with the code I posted.



        To me, it seems like the biggest issue is that the error from the "Test Map" in Visual Studio doesn't give any hint to the line number with the error.



        <Level0>
        <BatchNumberLeaveBlank></BatchNumberLeaveBlank>
        <InvoiceSendDateCCYYMM>
        <!-- Get current CCYYMM -->
        <!-- Current-DateTime doesn't exist in XSLT 1.0, had to use C#
        <xsl:value-of select="concat(substring(current-dateTime(),1,4),substring(current-dateTime(),6,2))"/>
        -->
        <xsl:value-of select="userCSharp:GetDateCCYYMM()"/>
        </InvoiceSendDateCCYYMM>
        <DefaultValueN>N</DefaultValueN>
        <TotalInvoiceCost>...


        Then I had the C# code below:



         <msxsl:script language="C#" implements-prefix="userCSharp">
        <![CDATA[ int lineCount = 0;

        public int GetDateCCYYMM()

        return DateTime.Now.ToString("yyyyMMdd");


        ]]>
        </msxsl:script>


        Obviously, the "public int" should have been "public string" above.



        The only way I know how to tackle these problems is the "divide and conquer" method.
        I made a copy of the XSLT, named it same with _Debug.xslt, changed the BizTalk map to use it instead, and started ripping out lines of code left and right until the error goes away. Even removing the call to the c# didn't remove the error, so it must have been running a .NET compile or syntax check on the code.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 12 at 20:27









        NealWaltersNealWalters

        5,7392888163




        5,7392888163





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070442%2fbiztalk-map-xslt-1-0-sum-cannot-implicitly-convert-type-string-to-int%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко