Subject: [xsl] multiple replace From: Jim_Albright@xxxxxxxxxxxx Date: Sun, 10 Aug 2008 16:15:55 -0400 |
I need to make multiple replacements. <!-- simple replacements to meaningful entities or Unicode --> <replacements> <replace><<</replace><with>“</with> <replace>>></replace><with>”</with> <replace><;</replace><with>‘</with> <replace>></replace><with>’</with> <!-- need to be able to mark text for omission in a way that we can roundtrip it replacing the text with <omit>|fn</omit> is option that would work --> <omit>|fn</omit> </replacements> I was considering this external XML that the user can easily edit as the source of the changes. I am using Saxon 9 ... XSLT 2.0 (Thanks for the elegant tools.) I found the acronym example and started changing it to replacements/replace but am lost now as to how to proceed. <xsl:variable name="replacements" as="element(replace)+" select="document('../xml/replacements.xml')/replacements/replace" /> <xsl:variable name="replace-regex" as="xs:string" select="string-join($replacements/@replace, '|')" /> <xsl:analyze-string select="$text" regex="{$replace-regex}"> <xsl:matching-substring> <xsl:variable name="replace" as="xs:string" select="." /> <replace title="{$replacements[@replace = $replace]}"> <xsl:value-of select="$replace" /> </replace> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="." /> </xsl:non-matching-substring> </xsl:analyze-string> Thanks for your help. Jim Albright 704 843-0582 JAARS, Speeding Bible Translation Wycliffe, Partners in Bible Translation
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: user functions with varia, Tony Nassar | Thread | Re: [xsl] multiple replace, Sam Byland |
RE: [xsl] Create xml file with recu, Bordeman, Chris | Date | [xsl] counting element characters, tom s |
Month |