Page 1 of 1

characters between two characters

Posted: Tue Jul 19, 2016 10:13 am
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

Re: characters between two characters

Posted: Tue Jul 19, 2016 4:51 pm
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