简体   繁体   中英

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. For example:--

Given:--

<test>UnitOfMeasure</test>

Desired 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). Thanks in advance

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

In XSLT 2 and later you can 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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