xml - (XSL 2.0) Transform/Replace HTML and ASCII Characters in String -
I am editing XSL stylesheets to convert an XML document into a style RTF file and I have some HTML code And ASCII characters are a string that I would like to replace with equivalent text characters. I am looking for an answer for this one, but the work that works does not get the solution. This is my first time working with XLS, so I really appreciate any help!
For example, I have XML, translated via CSV via Oxygen Editor
I would like to replace all instances of "& amp; # 39; and replace" all the HTML breaks with a correct single quote and one place.
I have tried
& lt; Xsl: value selection = "translation (. ',' Am amp; amp;; ',' '')" />
and
& lt; Xsl: Select Value = "Translation (., 'Amp ;,' '')" />
"& amp; # 39; To change, and to change line breaks, similar code.
Am I missing something? I really appreciate the help. The full XSL is below.
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Xsl: stylesheet xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" xmlns: xs = "http://www.w3.org/2001/XMLSchema" out-result-prefix = " Xs "version =" 2.0 "& gt; & Lt; Xsl: output method = "text" indent = "no" encoding = "macroman" /> & Lt; Xsl: strip-space element = "*" /> & Lt; Xsl: template name = "line" & gt; & Lt; Xsl: text & gt; {\ Pard \ s2 \ ql \ f22 \ fs24 \ li0 \ ri0 \ sb240 \ sl-360 \ slmult0 & lt; / Xsl: text & gt; & Lt; Xsl: text & gt; {\ Cs11 \ b & lt; / Xsl: text & gt; & Lt; Xsl: variable name = "first_name" = "normal-location (first_name)" /> & Lt; Xsl: select variable name = "last_name" = "normal-location (last_name)" /> & Lt; Xsl: Select the value = "$ first_name" /> & Lt; Xsl: Select value = "concat ('', $ last_name)" /> & Lt; Xsl: value-of select = "If (normal-location (SVP)) contact again ('', normal-location (replace (SVP, '' ',' '' ')),', ') Other' ' & Lt; xsl: call-template name = "degree" /> } & lt; xsl: Value Selection = "Replace (Replace ($ temp, '& amp; quot; ',' '' ',' ',' '', '' '', '' '', '' ') "/"> & Gt; XSL: Text & gt; \ par} & amp; # 10; & lt; / XSL: Text & gt; & lt; xsl: Value Selection = "Translation (., '& Amp; 39;', '' ')" /> & lt; / XSL: T Template> gt;
classnote
The element is referred to as a string with an XML fragment, then the commercial version of Oxygen or any other environment is available 9x, it is easy to use XSLT 3.0 and parse-xml-fragment
As we can write to replace a template, br
element:
& lt; Xsl: stylesheet xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" xmlns: xs = "http://www.w3.org/2001/XMLSchema" out-result-prefix = " Xs "version =" 3.0 "& gt; & Lt; Xsl: output method = "text" /> & Lt; Xsl: template match = "squarenote" & gt; & Lt; Xsl: select applied-template = "parse-xml-fragment (.)" Mode = "convert" /> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "br" mode = "convert" & gt; & Lt; XSL: Text & gt; & Lt; / XSL: text & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "text ()" mode = "convert" & gt; & Lt; Xsl: Select Value = "Change (., 'Amp; amp; amp;; | ‰ Ûªs', '' '')" /> & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;
with input
& lt; Classnote & gt; Joe Smith & amp; Amp; Amp; 62; Sent a text to your friend ‰ Ûªs Phone & amp; Lt; Br / & gt; & Lt; / Classnote & gt;
Suxan 9.5 PE output
Joe Smith '62 has sent a phone to his friend
If you have XSLT 3.0, at least the sample shows how substrings can be replaced with a single quote: replace (., '& Amp; amp; amp; amp; 39; | ‰ Ûªs ',' '')
.
Comments
Post a Comment