From: Michael Smith Date: Mon, 27 Jun 2005 00:50:16 +0000 (+0000) Subject: Added an "apply-string-subst-map" function (template). Only X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=182b0a558b6c95b8ee819c0620d6bf26521721cd;p=docbook-dsssl Added an "apply-string-subst-map" function (template). Only difference is that in the map that it expects, "oldstring" and "newstring" attributes are used instead of "character" and "string" attributes. --- diff --git a/xsl/lib/lib.xweb b/xsl/lib/lib.xweb index 98f76d720..7990df806 100644 --- a/xsl/lib/lib.xweb +++ b/xsl/lib/lib.xweb @@ -725,6 +725,88 @@ and preserving the delimiters as text nodes between the tokens. + + + apply-string-subst-map + Apply a string-substitution map + + + Description + + This function applies a "string substitution" map. Use it when + you want to do multiple string substitutions on the same target + content. It reads in two things: content, the + content on which to perform the substitution, and + map.contents, a node set of + elements (the names of the elements don't matter), with each element + having the following attributes: + + + oldstring, a string to + be replaced + + + newstring, a string with + which to replace oldstring + + + The function uses map.contents to + do substitution on content, and then + returns the modified contents. + + + This function is a very slightly modified version of Jeni + Tennison's replace_strings function in the + multiple string replacements section of Dave Pawson's + XSLT + FAQ. + + The apply-string-subst-map function is + essentially the same function as the + apply-character-map function; the only + difference is that in the map that + apply-string-subst-map expects, oldstring and newstring attributes are used instead of + character and string attributes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + apply-character-map @@ -735,14 +817,14 @@ and preserving the delimiters as text nodes between the tokens. This function applies an XSLT character - maps; that is, it cause certain individual characters to be + map; that is, it cause certain individual characters to be substituted with strings of one or more characters. It is useful - mainly for replacing "special" chararacters or symbols. It reads in - two things: content, the content on which to - perform the character replacement, and - character.map.contents, a node set of - elements (the names of the elements don't matter), with each element - having the following attributes: + mainly for replacing multiple "special" chararacters or symbols in + the same target content. It reads in two things: + content, the content on which to perform the + substitution, and map.contents, a + node set of elements (the names of the elements don't matter), with + each element having the following attributes: character, a character to @@ -750,13 +832,12 @@ and preserving the delimiters as text nodes between the tokens. string, a string with - which to replace the character specified by the character attribute + which to replace character - This function uses character.map.contents to - do character replacement on content, and then - returns the modified contents. + This function uses map.contents to + do substitution on content, and then returns + the modified contents. This function is a very slightly modified version of Jeni @@ -766,27 +847,37 @@ and preserving the delimiters as text nodes between the tokens. >multiple string replacements section of Dave Pawson's XSLT FAQ. + + The apply-string-subst-map function is + essentially the same function as the + apply-character-map function; the only + difference is that in the map that + apply-string-subst-map expects, oldstring and newstring attributes are used instead of + character and string attributes. - + + select="$map.contents[1]/@character" /> + select="$map.contents[1]/@string" /> - + - + @@ -1017,6 +1108,7 @@ around these functions. +