【问题标题】:Removing prefix before '.' (dot)删除 '.' 之前的前缀(点)
【发布时间】:2020-08-25 08:19:19
【问题描述】:

假设一个变量

varCode = kvnownananna.ThisistheStringRequired.iobabvoabnv

我需要删除.(点)之前的前缀并删除第二个.(点)之后的后缀

只需要获取“ThisistheStringRequired”。

我们如何在 xsl-fo 模板中做到这一点?

【问题讨论】:

    标签: xslt xslt-1.0 xslt-2.0 xsl-fo


    【解决方案1】:
    <xsl:variable name="newVar" select="replace($varCode, '.*\.(.*)\..*', '$1')"/>
    

    或

    <xsl:variable name="newVar" select="tokenize($varCode, '.')[2]"/>
    

    【讨论】:

      【解决方案2】:

      试试:

      <xsl:value-of select="substring-before(substring-after($varCode, '.'), '.')"/>
      

      【讨论】:

      • 在此之后,修剪后的字符串将仅存储在 varCode 中,或者我们需要进行某种分配?
      • 这将返回修剪后的字符串。如果您想在变量中使用它,请使用&lt;xsl:variable name="anotherVar" select="substring-before(substring-after($varCode, '.'), '.')"/&gt;。 XSLT 中的变量是不可变的。
      猜你喜欢
      • 2015-04-09
      • 2021-07-08
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 2018-03-18
      相关资源
      最近更新 更多