xml . xquery数学表达式错误

本文关键字:表达式 错误 xquery xml | 更新日期: 2023-09-27 18:12:01

我是Microsoft.Xml的新手。XQuery,当我试图运行一个XQuery与数学表达式,如sum我有错误:不能应用添加到非整数数据。

XML:

<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>
XQuery:

for $item in document("xqt")/bookstore/book[price < '30']
return $item/year/text()  +  $item/year/text() 
c#:

  XmlDocument doc1 = new XmlDocument();
        doc1.LoadXml(rteXml.Text);
        XQueryNavigatorCollection navCol = new XQueryNavigatorCollection();
        navCol.AddNavigator(doc1.CreateNavigator(), "xqt");
        XQueryExpression expr = new XQueryExpression(rteXQuery.Text.Trim().Replace("''n", " "));
        XQueryNavigator nav = expr.Execute(navCol);
        rteOutput.Text = nav.ToXml();

任何想法?

xml . xquery数学表达式错误

for $item in document("xqt")/bookstore/book[price < '30']
return sum($item/year/text(), $item/price/text())