从 xslt 1.0 中的单个字符串拆分大括号
Split braces from single string in xslt 1.0
客户提供的 XML 包含在 XML 字符串中带有左括号和右括号的描述,我想拆分此字符串并使用 XSLT 1.0 显示为单个字符串。
XML 字符串:
<tempDescs> Loans and deposits schedules_Loans and deposits schedule details_List of Today\'s Entries(Authorised)_List of entries (unauthorised)_Forward entries (unauthorised)_Forward Entries by transaction_ </tempDescs>
代码:
<xsl:variable name="descs">
<xsl:call-template name="remove-parentheses">
<xsl:with-param name="string" select="$tempDescs"/>
</xsl:call-template>
</xsl:variable>
<xsl:template name="remove-parentheses">
<xsl:param name="string" />
<xsl:variable name="opb" select='"~Opb#"' />
<xsl:variable name="clb" select='"~Clb#"' />
<xsl:choose>
<!-- when open parenthesis is present remove it -->
<xsl:when test="contains($string, $opb)">
<xsl:value-of select="substring-before($string, $opb)" />
<xsl:call-template name="remove-parentheses">
<xsl:with-param name="string" select="substring-after($string, $opb)" />
</xsl:call-template>
</xsl:when>
<!-- when close parenthesis is present remove it -->
<xsl:when test="contains($string, $clb)">
<xsl:value-of select="substring-before($string, $clb)" />
<xsl:call-template name="remove-parentheses">
<xsl:with-param name="string" select="substring-after($string, $clb)" />
</xsl:call-template>
</xsl:when>
<!-- otherwise... -->
<xsl:otherwise>
<!-- ... just give the value of the string -->
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我在没有正确拆分右括号的情况下得到了输出。
贷款和存款 schedules_Loans 和存款时间表 details_List 今日条目授权)_未授权条目列表)远期条目 unauthorised_Forward 按交易分类的条目
我期待没有任何大括号的输出
贷款和存款 schedules_Loans 和存款时间表 details_List 今天的 EntriesAuthorised_List 个条目 unauthorised_Forward 个条目 unauthorised_Forward 按交易分类的条目_
请帮忙
为什么不能简单的做:
translate(tempDescs, '()', '')
客户提供的 XML 包含在 XML 字符串中带有左括号和右括号的描述,我想拆分此字符串并使用 XSLT 1.0 显示为单个字符串。 XML 字符串:
<tempDescs> Loans and deposits schedules_Loans and deposits schedule details_List of Today\'s Entries(Authorised)_List of entries (unauthorised)_Forward entries (unauthorised)_Forward Entries by transaction_ </tempDescs>
代码:
<xsl:variable name="descs">
<xsl:call-template name="remove-parentheses">
<xsl:with-param name="string" select="$tempDescs"/>
</xsl:call-template>
</xsl:variable>
<xsl:template name="remove-parentheses">
<xsl:param name="string" />
<xsl:variable name="opb" select='"~Opb#"' />
<xsl:variable name="clb" select='"~Clb#"' />
<xsl:choose>
<!-- when open parenthesis is present remove it -->
<xsl:when test="contains($string, $opb)">
<xsl:value-of select="substring-before($string, $opb)" />
<xsl:call-template name="remove-parentheses">
<xsl:with-param name="string" select="substring-after($string, $opb)" />
</xsl:call-template>
</xsl:when>
<!-- when close parenthesis is present remove it -->
<xsl:when test="contains($string, $clb)">
<xsl:value-of select="substring-before($string, $clb)" />
<xsl:call-template name="remove-parentheses">
<xsl:with-param name="string" select="substring-after($string, $clb)" />
</xsl:call-template>
</xsl:when>
<!-- otherwise... -->
<xsl:otherwise>
<!-- ... just give the value of the string -->
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我在没有正确拆分右括号的情况下得到了输出。
贷款和存款 schedules_Loans 和存款时间表 details_List 今日条目授权)_未授权条目列表)远期条目 unauthorised_Forward 按交易分类的条目
我期待没有任何大括号的输出
贷款和存款 schedules_Loans 和存款时间表 details_List 今天的 EntriesAuthorised_List 个条目 unauthorised_Forward 个条目 unauthorised_Forward 按交易分类的条目_
请帮忙
为什么不能简单的做:
translate(tempDescs, '()', '')