加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 使用XSLT将一个字符串模式转换为另一个字符串模式

发布时间:2020-12-15 23:54:12 所属栏目:百科 来源:网络整理
导读:我有我的源 XML,如下所示 contents contentAuthorInformation/content contentPersonInformation/content contentPersonPersonalInformation/content contentGurdianDetails/content/contents 我想将上面的XML转换成 contents contentAuthor Information/con
我有我的源 XML,如下所示
<contents>
  <content>AuthorInformation</content>
  <content>PersonInformation</content>
  <content>PersonPersonalInformation</content>
  <content>GurdianDetails</content>
</contents>

我想将上面的XML转换成

<contents>
  <content>Author Information</content>
  <content>Person Information</content>
  <content>Person Personal Information</content>
  <content>Gurdian Details</content>
</contents>

在源xml文件中的任何地方,内容元素数据都有大写字母,我想在其间添加空格.我可以使用XSLT 2.0示例如何实现这一目标.

使用这样的模板:
<xsl:template match="text()">
    <xsl:value-of select="replace(.,'([a-z])([A-Z])','$1 $2')"/>
</xsl:template>

这通常对输入中的所有文本内容执行规则.您可以轻松地使其更具体(如果您不想翻译其他元素).替换功能是关键点.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读