用于删除尾随字符的 XSLT/XPath 函数

XSLT / XPath function to remove trailing characters

我有这样的情况,我在 XForm 中显示一个地址,这个地址是预先格式化的,但偶尔包含几个尾随逗号,我需要将其删除。

这是我的代码:

    <xf:output id="Address-control" ref="$Address" >
        <xf:label>GP Address</xf:label>
    </xf:output>

其中,有时会产生这样的输出:

 My House, My Road, My Town, , , , ,

我需要一些东西来去掉尾随的逗号,这样输出就变成了:

 My House, My Road, My Town

提前致谢

使用 replace($Address, '[\s,]+$', '') 应该删除任何结尾的白色 space 和逗号的混合。