0

I have this piece of XML and want to get the number immediately after Chapter

<para>Insolvency Rules, r 12.12, which gives the court a broad discretion, unfettered by the English equivalent of the heads of Order 11, r 1(1) (which are now to be found, in England, in CPR, Chapter 6, disapplied in the insolvency context by Insolvency Rules, r 12.12(1)). </para> 

When I used this XSLT transform

<xsl:value-of select="translate(substring-after(current(),'Chapter'), translate(substring-after(current(),'Chapter'),'0123456789',''), '')"/> 

I get this output

612121 

Butut I want just 6.

Please let me know how I should do it.

I don't want to use a statement like

<xsl:value-of select="substring-before(substring-after(current(),'Chapter'), ,',')"/> 

as the chapter number will be different in each instance, between 1 and 15.

1 Answer 1

1

Try this:

 <xsl:variable name="vS" select="concat(substring-after(current(),'Chapter '),'Z')"/> <xsl:value-of select= "substring-before(translate($vS,translate($vS,'0123456789',''),'Z'),'Z')"/> 

This is based on: https://stackoverflow.com/a/4188249/2115381 Thanks to @Dimitre Novatchev

Update: If the quantity of space after the "Chapter" is not known you can use something like this:

<xsl:variable name="vS" select="concat(substring-after(current(),'Chapter'),'Z')"/> <xsl:value-of select= " translate( substring-before(translate($vS,translate($vS,' 0123456789',''),'Z'),'Z') , ' ','')"/> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.