简体   繁体   English

如何拆分和连接 xslt 中的字符串

[英]How to split and concatenate the string in xslt

I am trying to split the string when character is in uppercase n later concatenate with space.我试图在字符为大写 n 时拆分字符串,然后与空格连接。 For example:--例如: -

Given:--给定:--

<test>UnitOfMeasure</test>

Desired o/p:--所需的o / p:--

<final>Unit Of Measure</final>

what function/algorithm I should write to achieve the above requirement(no idea should I use string-split or tokenize() here).我应该编写什么函数/算法来实现上述要求(不知道我应该在这里使用 string-split 还是 tokenize() )。 Thanks in advance提前致谢

<final>
<Xsl:value-of select= "concat(?)"/>
</final>

In XSLT 2 and later you can xsl:analyze-string :在 XSLT 2 及更高版本中,您可以xsl:analyze-string

  <xsl:param name="pattern" as="xs:string">(\p{Lu}\p{Ll}*)</xsl:param>

  <xsl:template match="test">
      <final>
          <xsl:value-of separator=" ">
              <xsl:analyze-string select="." regex="{$pattern}">
                  <xsl:matching-substring>
                      <xsl:sequence select="."/>
                  </xsl:matching-substring>
              </xsl:analyze-string>
          </xsl:value-of>
      </final>
  </xsl:template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM