Answered Write-xml no escape character <

progdev1

Member
Is it possible to configure write-xml so that it doesn't replace <B> with &lt;B&gt;

I have several letters that are broadly the same, so instead of using 1 xsl for each letter I output the data using a temp table.
I have the following code snippet which creates an xml file, to be read by fop and converted to pdf using xsl.
Code:
DEFINE TEMP-TABLE ttSalutation NO-UNDO
    FIELD iLine         AS INTEGER 
    FIELD cSalutation   AS CHARACTER
    INDEX iLine IS PRIMARY iLine.

DEFINE DATASET ds-FeeLetter XML-NODE-NAME "Letter"
    FOR ttSalutation,
        ttInstruction,
        ttFeeSummary.
....

    CREATE ttSalutation.
    ASSIGN ttSalutation.iLine = viCnt
           ttSalutation.cSalutation = "As per our Agreement a Fee of <B>" + TRIM(string(Fee.feeamt,">>>,>>>,>>9.99")) 
                                       + " " + Fee.currency  + "</B> is due for the period "


DATASET ds-FeeLetter:WRITE-XML ("FILE", "fee.xml", TRUE).

I would like to get the below XML output as I have a xsl template that converts B /B tag to output the containing text as bold.
Code:
<Letter>
...
    <ttSalutation> 
        <iLine>4</iLine> 
        <cSalutation>The calculated amount due for the period April 1, 2013 to June 30, 2013 is <B> EUR 0.00</B>.</cSalutation> 
    </ttSalutation>
...
<Letter>

However the XML output I get is :
Code:
<Letter>
...
    <ttSalutation> 
        <iLine>4</iLine> 
        <cSalutation>The calculated amount due for the period April 1, 2013 to June 30, 2013 is &lt;B&gt; EUR 0.00&lt;/B&gt;.</cSalutation> 
    </ttSalutation>
....
<Letter>

The problem I have when I convert this to pdf using fop and instead of having the fee amont and currency in bold. I end up with the text outputted literall.
Code:
The calculated amount due for the period April 1, 2013 to June 30, 2013 is <B>EUR 0.00<B>.
I notice in xsl there is a disable-output-escaping. Is there something similar I can do with write-xml. Or is anyone aware of a better approach to doing this such as maybe using
Code:
/<B/>
~<B~>
 

progdev1

Member
I figured out how to do this so I'll put the solution up. It is a bit of a hack but it will have to do. What I did was to output the initial xml to a longchar. Then use the progress replace function to replace &lt; with <. Then save the xml document using a handle and the SAVE() method

Code is below. If anyone has a better solution please put it up.
Code:
DEFINE VARIABLE hDoc AS HANDLE NO-UNDO.

DEFINE VAR vlnstr AS LONGCHAR NO-UNDO.
ASSIGN vlnstr = "<?xml version='1.0' encoding='ISO-8859-1'?><ARLetter xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>&lt;B&gt;&lt;/B&gt;</ARLetter>".

ASSIGN vlnstr = REPLACE(vlnstr,"&lt;", "<")
       vlnstr = REPLACE(vlnstr,"&gt;", ">").


CREATE X-DOCUMENT hDoc.
hDoc:LOAD("Longchar",vlnstr,FALSE).
hDoc:SAVE("FILE","vlnstr.xml").
DELETE OBJECT hDoc.
 
Top