gpt4 book ai didi

java - 无效的 XQuery 语法,语法未通过静态验证

转载 作者:行者123 更新时间:2023-12-01 13:09:31 25 4
gpt4 key购买 nike

当我尝试使用 xqj 进行查询时,出现此错误。

Exception in thread "main" javax.xml.xquery.XQException:
XQJQS001 - Invalid XQuery syntax, syntax does not pass static validation.
Root Cause:
XQueryParseException: Encountered "$" at line 1, column 36.
Was expecting one of:
"=" ...
"order" ...

public static void Consultar(XQConnection connexio) 抛出 XQException { 扫描仪 sc = new Scanner(System.in);

    System.out.println(">>>>Please select a mminim stock :)");

int selec = sc.nextInt();

String squery = "for $prod in /productos/produc"
+ "for $zone in $prod/cod_zona"
+ "let $stock :=$prod/stock_minimo"
+ "let $deno :=$prod/denominacion"
+ "let $codi_prod :=$prod/cod_prod"
+ "let $cod:=/zonas/zona[cod_zona = $zone]/cod_zona"
+ "let $nomzona:=/zonas/zona[cod_zona = $zone]/nombre"
+ "let $direc:=/zonas/zona[cod_zona = $zone]/director"
+ "where $prod/$stock < " + selec + ""
+ "return concat('Denominacio:',$deno,'&#xa;' ,"
+ "'Codi producte:',$codi_prod,'&#xa;' ,"
+ "'Stock mínim:',$stock,'&#xa;' ,"
+ "'Codi zona:',$cod,'&#xa;' ,"
+ " 'Nom zona:',$nomzona),'&#xa;'";

XQPreparedExpression consulta = connexio.prepareExpression(squery);

XQResultSequence resultat = consulta.executeQuery();

while (resultat.next()) {
System.out.println(resultat.getItemAsString(null));
System.out
.println("...................................................................");
}

connexio.close();

}

同样的帮助。谢谢。

最佳答案

字符串连接表达式

  "for $prod  in /productos/produc"
+ "for $zone in $prod/cod_zona"

将产生字符串

for $prod  in /productos/producfor $zone in $prod/cod_zona

您需要在 + 两侧的字符串文字之一内的 productfor 之间添加某种空格,例如:

String squery = "for $prod  in /productos/produc "
+ "for $zone in $prod/cod_zona "
+ "let $stock :=$prod/stock_minimo "
+ "let $deno :=$prod/denominacion "
// etc etc.

关于java - 无效的 XQuery 语法,语法未通过静态验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22994355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com