XSLT调用fn:substring-after()报多序列错误如何解决
问题原因
你当前的XSLT报错是因为substring-after()函数的第一个参数返回了两个
报错的根源是匹配../../cc1:Seg/cc1:Amt/cc1:Value/cc1:Value1的路径,是从
修正方案
你只需要把路径改为当前../cc1:Amt/cc1:Value/cc1:Value1(
修正后的完整XSLT代码如下:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:cc1="urn:test1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="cc1" version="2.0"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <!-- 全局复制所有节点和属性 --> <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*"/> </xsl:copy> </xsl:template> <xsl:template match="/cc1:Document/cc1:File/cc1:Detail/cc1:Seg/cc1:Agt"> <xsl:element namespace="urn:test1" name="{local-name()}"> <xsl:value-of select="substring-after(../cc1:Amt/cc1:Value/cc1:Value1,'File: ')"/> </xsl:element> </xsl:template> </xsl:stylesheet>
运行上述代码即可得到你期望的输出结果。
内容的提问来源于stack exchange,提问作者user9324800
相关产品推荐
相关产品推荐

