如何通过xsl解析xml中的值
<block4>
<tag>
<name>50K</name>
<value>/001/002/300060000120135670
CREDIT AGRICOLE ASSET MANAGEMENT</value>
</tag>
</block4>
我需要获得如下所示的输出:
/001/002,/300060000120135670,CREDIT AGRICOLE ASSET MANAGEMENT
我已经在 XSL 中这样做了,但我没有得到我想要的输出。谁能告诉我如何获得该输出?
<xsl:for-each select ="block4/tag[name = '50K']">
<xsl:value-of select="
concat(
substring(value,1,8),
(concat(substring(value,9,' '),',')),
substring-after(value,' ')
)
" />,<xsl:text/>
</xsl:for-each>
<block4>
<tag>
<name>50K</name>
<value>/001/002/300060000120135670
CREDIT AGRICOLE ASSET MANAGEMENT</value>
</tag>
</block4>
I need to get output that looks like:
/001/002,/300060000120135670,CREDIT AGRICOLE ASSET MANAGEMENT
I have done like this in XSL, but I didn't get the output I wanted. Can anyone please give me some idea how I could get that output?
<xsl:for-each select ="block4/tag[name = '50K']">
<xsl:value-of select="
concat(
substring(value,1,8),
(concat(substring(value,9,'
'),',')),
substring-after(value,'
')
)
" />,<xsl:text/>
</xsl:for-each>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
concat
接受任意数量的参数,无需嵌套这些调用。此外,substring
采用开头和可选长度,而不是终止字符。尝试这样的事情:我保留了最后的逗号,这是您没有真正指定的许多事情之一。
concat
takes any number of arguments, no need to nest those calls. Besides,substring
takes a beginning and an optional length, not a terminating character. Try something like this instead:I've kept the final comma in, which is one of the many things you did not really specify.
为什么不使用 XSLT 2.0
tokenize()
函数?请参阅此处
Why not use XSLT 2.0
tokenize()
function?See Here