Xquery转换将int转换为字符串

Xquery转换将int转换为字符串,xquery,Xquery,我想使用XQuery转换函数将int转换为string 我有如下的XQuery转换: <ns8:postCode>{ fn:string(data($customer/ns9:postCode)) }</ns8:postCode> {fn:string(数据($customer/ns9:postCode))} 我试图将int转换为string,但上面的一行仍然给出了错误 它与目标架构不匹配。源为int,目标为string 我还尝试: <ns8:postCode&

我想使用XQuery转换函数将int转换为string

我有如下的XQuery转换:

<ns8:postCode>{ fn:string(data($customer/ns9:postCode)) }</ns8:postCode>
{fn:string(数据($customer/ns9:postCode))}
我试图将int转换为string,但上面的一行仍然给出了错误 它与目标架构不匹配。源为int,目标为string

我还尝试:

<ns8:postCode>{ xs:string(xs:integer(data($customer/ns9:postCode))) }</ns8:postCode>
{xs:string(xs:integer(数据($customer/ns9:postCode)))}
但是我得到了相同的错误

fn:data()
将返回为
ns9:postCode
定义的任何原子类型(或
untypedAtomic
)。如果需要字符串,则没有理由首先获取原子类型或进行任何其他类型转换:

<ns8:postCode>{ fn:string($customer/ns9:postCode) }</ns8:postCode>
{fn:string($customer/ns9:postCode)}

您的问题没有提供问题中的错误,但有可能将
定义为
xs:string
以外的类型。如果该元素包含一个
xs:string
,并且模式将该元素定义为
xs:integer
,它将抛出一个类型不匹配错误。

您需要提供错误消息(最好是模式的相关部分)才能回答此问题。