如何在XSLT 1.0中实现SPLIT功能
我有以下场景。我有一个 TEAM-MEMBERS 节点,其名称格式为“姓氏,名字”,
<TEAM-MEMBER><LONG-NAME>Last Name, First Name</LONG-NAME></TEAM-MEMBER>
我想将其转换为
<CONTACT><FIRSTNAME>First Name</FIRSTNAME><LASTNAME>Last Name</LASTNAME></CONTACT>
基本上我想按 拆分
节点的值,
我如何使用 XSLT 1.0 实现此目的
此 XSLT 将由 BizTalk Server 使用,因此我只寻找一些 XSLT 1.0 解决方案
谢谢
Karthik
I have a following scenario. I have a TEAM-MEMBERS node which has name in the format last name, first name
<TEAM-MEMBER><LONG-NAME>Last Name, First Name</LONG-NAME></TEAM-MEMBER>
I want to transform this to
<CONTACT><FIRSTNAME>First Name</FIRSTNAME><LASTNAME>Last Name</LASTNAME></CONTACT>
Basically i want to split the <LONG-NAME>
node's value by ,
How can I achieve this using XSLT 1.0
This XSLT will be consumed by BizTalk Server hence i am looking for some XSLT 1.0 solutions only
Thanks
Karthik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个完整的 XSLT 1.0 解决方案,它使用通用的“拆分”模板,将字符串拆分为多个子字符串,并提供分隔符来指定子字符串之间的边界:
当此转换应用于提供的 XML 文档:
生成所需的正确结果:
II.使用 FXSL 的解决方案
此转换使用 FXSL 中的
str-split-to-words
模板:应用于此 XML 文档时(变得更加复杂):
< strong>生成了想要的正确结果:
请注意:
str-split-to-words
模板接受多个分隔符。因此,在此转换中使用的分隔符为:','
、'('
和')'
Here is a complete XSLT 1.0 solution that uses a general "split" template that splits a string into multiple substrings, provided a delimiter to designate the boundary between substrings:
When this transformation is applied on the provided XML document:
the wanted, correct result is produced:
II. Solution using FXSL
This transformation uses the
str-split-to-words
template from FXSL:when applied to this XML document (made quite more complex):
the wanted, correct result is produced:
Do Note:
The
str-split-to-words
template accepts multiple delimiters. Thus in this transformation the delimiters used are:','
,'('
and')'
您需要一个递归命名模板。幸运的是,它已经被编写:在 http://www.exslt.org< 查找
str:tokenize
/a>.You need a recursive named template. Fortunately it's already been written: look for
str:tokenize
at http://www.exslt.org.使用
substring-after()
和substring-before()
来绕过分割used
substring-after()
andsubstring-before()
to get around the split