Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xsl substring-after usage

Tags:

xslt

I have this XSL code and I would like to configure the string. However I couldn't get the configured string yet. What could be the matter?

<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 comes from my Java file. in sum I am trying to convert this string "1010-Text" to "1010" and "Text" separately in XSL

like image 340
gencay Avatar asked Feb 14 '26 02:02

gencay


1 Answers

If the context is correct and $topicId='WordA-WordB'

substring-after($topicId,'-')

should get WordB and

substring-before(' ',$topicId)

should get nothing.

While

substring-before($topicId,'-')

shoud get WordA.

like image 147
Emiliano Poggi Avatar answered Feb 17 '26 11:02

Emiliano Poggi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!