XQuery with string-join, one parameter is string and other is number -


I want to list the year related to the total number of orders.

  & lt; Samples & gt; & Lt; Sample & gt; & Lt; Year & gt; 2010 & lt; / Year & gt; & Lt; Order & gt; 20000 & lt; / Order & gt; & Lt; / Sample & gt; & Lt; Sample & gt; & Lt; Year & gt; 2011 & lt; / Year & gt; & Lt; Order & gt; 20000 & lt; / Order & gt; & Lt; Order & gt; 35,000 & lt; / Order & gt; & Lt; / Sample & gt; & Lt; Sample & gt; & Lt; Year & gt; 2012 and lt; / Year & gt; & Lt; Order & gt; 20000 & lt; / Order & gt; & Lt; Order & gt; 23,000 & lt; / Order & gt; & Lt; Order & gt; 40000 & lt; / Order & gt; & Lt; / Sample & gt; & Lt; / Samples & gt;   

I expect output -

  year order 2010 1 2011 2 2012 3   

forms of number In & lt; Order & gt; element will tell me the number of total orders, I tried it in Bassx with the following -

  Document ("sample") in $ x / samples / sample return & lt; Li & gt; {String-included (($ x / year, count ($ x / command), "#")} & lt; / Li & gt;   

But I am getting an error and it is obvious because I am using an integer instead of a string in the string-join function. Or is there any other way to get the same output?

string-join string is expected, this number is not < Code> Count Add an artist and it will run.

  • In the X $ / sample / sample return
  • {String-join (($ x / year, xs: string (count ($ x) / command))), "#")} & lt; / Li & gt;

    I have fixed two more errors:

    • Why are you questioning the attribute y on year? There is no.
    • You can & lt; Order & gt; tag, .

      Maybe the code can be made more readable by using concat (unless you're using only two parameters)?

  • Comments