You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

string-join()函数抛出XPath无效表达式错误,寻求解决方法

Fixing the XPathError with string-join() in Your Expression

Let's break down why you're hitting that "Invalid expression" error with string-join(/form/Data/MProcess/Process/Id/string(), ',')—it all comes down to how string-join() expects its arguments to be structured.

The Root Cause

string-join() requires two core parameters:

  1. A sequence of nodes or strings (the items you want to join together)
  2. The delimiter string (in your case, ',')

Your current code tries to call string() directly on each Id node within the path (/Id/string()), which isn't valid XPath syntax here. XPath doesn't allow chaining the string() function onto a node selection like that when passing it as the first argument to string-join().

Working Solutions

Solution 1: Let string-join() Handle Implicit String Conversion

Most modern XPath 2.0+ implementations automatically convert nodes to their string values when passed to string-join(). Just pass the node sequence directly:

string-join(/form/Data/MProcess/Process/Id, ',')

This works because each Id node's string value is its text content (like your example aee865d1-7253-489c-8d53-2a0d580639d0). string-join() will iterate through all matching Id nodes, convert them to strings implicitly, and join them with commas.

Solution 2: Explicitly Convert Nodes with a for Expression

If you're working with an older XPath version or need explicit control over string conversion, use a for loop to generate a sequence of strings:

string-join(for $id in /form/Data/MProcess/Process/Id return string($id), ',')

This loops through each Id node, converts it to a string explicitly, then passes the resulting string sequence to string-join().

Quick Check to Rule Out Other Issues

Before testing the fixes, double-check your XPath path:

  • Make sure node names match exactly (most XPath parsers are case-sensitive)
  • Confirm that Id nodes actually exist under the Process path in your XML structure

A misspelled node name or incorrect hierarchy could still cause errors even after fixing the string-join() syntax.

内容的提问来源于stack exchange,提问作者Poyraz Kürkçoğlu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 17:27:38