× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Try try encode it in hex or Unicode?

On Mon, Jun 1, 2020 at 9:43 AM Maria Lucia Stoppa <mlstoppa@xxxxxxxxx>
wrote:

Hi all,

There is an issue a can't find a solution to. I have searched the archive
and other sources without success, meaning the issue is probably an issue
only to me.

Is there a way to add a CDATA content using SQL XML functions?

The program I am working on creates an XML body content for an HTTP request
to call a provider's API via HTTPCLOBVERBOSE function from
systoools library.

To create the XML body I add lines like this:

xmlelement(name "RagioneSociale", trim(bor.ORAGDE))

to an SQL xmlserialize select. If the database field contains the ampersand
symbol (' F.LLI COMENSOLI & OLIVARI SAS') the result is this:

<RagioneSociale>F.LLI COMENSOLI &amp; OLIVARI SAS</RagioneSociale>

meaning the SQL functions for XML already translate the invalid XML
characters.

Now, when the call is made, the API rejects the XML as invalid.

If the very same request with the very same body is done through Postman,
it works, because I discovered it translates the &amp; entity into %26.

Instead of focusing on & symbol only, I thought the easiest solution is to
embed these few database fields into a CDATA section so that the final line
should look like this:

<RagioneSociale><![CDATA[F.LLI COMENSOLI & OLIVARI SAS]]></RagioneSociale>

but I don't know how.

I can't manually concatenate the database field with the CDATA section,
because < and > signs will be automatically translated in their entity
counterparts as well, and an XMLCDATA function or similar is not available
on the system (or on my system).

I would like to avoid the use of %scanrpl function because when it comes to
applying to a long varchar field it takes a lot to execute.

Would you have any suggestion to cope with this?

Thank you very much

--

Maria Lucia Stoppa
[image: image]
mlstoppa@xxxxxxxxx
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.