Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
651 views
in Technique[技术] by (71.8m points)

java - 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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...