Jonathan
Jonathan

Reputation: 2358

XSLT formatting of string

I am a novice when it comes to XSLT.

I run the below select

<xsl:value-of select="./@name"/>

I get the following result

TestSomething.Cancel(GIVEN WHEN THEN)

I want the output to say

GIVEN WHEN THEN

instead of TestSomething.Cancel(GIVEN WHEN THEN)

Would be thankful if someone could point me in the right direction.

Upvotes: 0

Views: 85

Answers (2)

Sean B. Durkin
Sean B. Durkin

Reputation: 12729

Use ...

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

Upvotes: 2

Adam
Adam

Reputation: 4580

It would help if you could post the source XML and some information on the xslt processor you are using, but at a guess I'd say this.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:value-of select="substring-before(substring-after(./@name, '('), ')')"/>
    </xsl:template>
</xsl:stylesheet>

Upvotes: 2

Related Questions