People who are familiar with XPath know that using the Translate function in XSL can replace a string. E.g:
Translate ("Bar", "ABC", "ABC") will get bar
Translate ("- AAA -", "ABC -", "ABC") will get AAA.
However, if you want to replace a sub-string as another sub-string, in terms of xpath1.0, it is a bit force that use translate.
In general, there are two methods for string in XSL:
(1) Use MS: Script to embed XSL implementation, but as required by the XML parser must be MS.
(2) Use the pure XSL template to achieve.
Of course, there is a benefit using subsection (1) to make full use of the JavaScript powerful string processing function, for example, a regular expression can also be used. A pure XSL template is used here to implement a string replacement. The source code is as follows, where the following part is an example for testing:
xsl: call-template> td> tr> xsl: for-each> table> body> html> xsl: Template> xsl: Stylesheet> XML used to test:
XML Version = "1.0" encoding = "GB2312"?>
Conversion results:
Character string replacement function
Replace the source string FromStringToString result asdflaksdjfalsdkfjaslkdjfabbbbbbsdflbbbksdjfbbblsdkfjbbbslkdjfasdflaksdjfalsdkfjaslkdjfflaksdjfalsbbbasdbbbdkfjaslkdjfasdflaksdjfalsdkfjaslkdjfdjfabbbasdflaksbbblsdkfjaslkdjfasdflaksdjfalsdkfjaslkdjfsdfVVVaVVVlaksdjfalsdkfjaslkdjf I am not a native of Sichuan, Chongqing, Sichuan, Chongqing I am not a man SELECT * FROM TAble where a = b = * = SELECT * FROM TAble where a * = b