characters between two characters

Post here questions and problems related to editing and publishing DITA content.
Raga Mounika
Posts: 49
Joined: Mon Mar 28, 2016 3:54 pm

characters between two characters

Post by Raga Mounika »

Hi Team,

I want to write a schematron rule for document number in XSLT 1.0.For that I want to get the characters between two hyphen's (-) and also I want the characters after second hyphen.

Example:1313-231-546
I need to write the code for 231( placed in between two hyphens).
I need to write code for 546(after second hyphen)

Please help me out in solving this issue.

Thanks!

Regards,
Mounika
tavy
Posts: 388
Joined: Thu Jul 01, 2004 12:29 pm

Re: characters between two characters

Post by tavy »

Hello,

You can use the "substring-before()" and "substring-after()" functions to get the characters that you want, as in the following example:

Code: Select all


<xsl:variable name="var" select="'1313-231-546'"/>
<xsl:variable name="value" select="substring-after($var, '-')"/>
<xsl:variable name="no1" select="substring-before($value, '-')"/>
<xsl:variable name="no2" select="substring-after($value, '-')"/>
The value of the "$no1" variable will be "231", and the value of the "$no2" variable will be "546".

I recommend you to address this type of questions on the Schematron mailing list or on the XSL mailing list, because are related to Schematron and XSL.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply