xsl substring-after usage

时间:2011-06-09 13:58:19

标签: xslt

我有这个XSL代码,我想配置字符串。但是我还没有得到配置的字符串。可能是什么事?

                                

<xsl:param name="topicId"></xsl:param>
<xsl:param name="topicName"/>

 <xsl:attribute-set name="attrTopic">
  <xsl:attribute name="id">
  <xsl:value-of select="/message/file/@name[substring-after($topicId,'-')]"/>
  </xsl:attribute>
 <xsl:attribute name="name">
<xsl:value-of select="/message/file/@name[substring-before(' ',$topicId)]"/>
 </xsl:attribute>
  </xsl:attribute-set>
<xsl:attribute-set name="attrVars">
</xsl:attribute-set>

$ topicId来自我的Java文件。总之,我试图在XSL中将此字符串“1010-Text”分别转换为“1010”和“Text”

1 个答案:

答案 0 :(得分:11)

如果上下文正确且$topicId='WordA-WordB'

substring-after($topicId,'-')

应该获得WordB

substring-before(' ',$topicId)

什么都不会。

虽然

substring-before($topicId,'-')

得到WordA

相关问题