Subject: Re: [xsl] Text based stage play scripts to XML From: Jacobus Reyneke <jacobusreyneke@xxxxxxxxx> Date: Mon, 24 Jan 2011 16:25:26 +0200 |
Solved, thank you all! For the benefit of someone searching the forum: Useful as part of solution for up-marking (because more than one pattern adds another contextual dimension, thereby avoiding false true's). For similar problem and suggestions see http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201101/msg00113.html Given: The sound a dog makes is woof and the sound a cat makes is bark. regex="(the sound)(.*)(makes)" gives you "a dog" and "a cat" as regex-group(2) -- Thanks David Using this: <xsl:variable name="regex" as="xs:string">(sound)(.*?)(makes)</xsl:variable> <xsl:analyze-string select="." regex="{$regex}"> <xsl:matching-substring> <xsl:value-of select="regex-group(1)"/> <wrapped><xsl:value-of select="regex-group(2)"/></wrapped> <xsl:value-of select="regex-group(3)"/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> Gives you: The sound<wrapped> a dog </wrapped>makes is woof and the sound<wrapped> a cat </wrapped>makes is bark. -- Thanks Andrew and David Why is this useful? Because now you can change: CAPTAIN: Was that the sound of cannon fire? Into: <actor name="CAPTAIN"> <dialogue-line> Was that the sound of cannon fire? <dialogue-line> </actor> ... with minimum guessing
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Text based stage play scr, Andrew Welch | Thread | Re: [xsl] Text based stage play scr, Liam R E Quin |
Re: [xsl] Text based stage play scr, Andrew Welch | Date | [xsl] round-half-to-even problem., Szabo, Patrick \(LNG |
Month |