DataPower

 View Only
  • 1.  Preserving Incoming UTF-16 encoding

    Posted Mon February 14, 2022 08:49 AM
    Hi All,

     The MPG is converting the UTF-16 encoding to UTF-8. Wondering how can we preserve the UTF-16 encoding in XSLT?

    Please advise.

    Regards,

    Vijay..

    ------------------------------
    Vijayasaradhi Peddysetty
    ------------------------------


  • 2.  RE: Preserving Incoming UTF-16 encoding

    Posted Tue February 15, 2022 03:50 PM
    In the xml header of the payload you need to set the proper encoding, eg.

    <?xml version="1.0" encoding="UTF-16" standalone="no" ?>

    Also if you do any transformation actions such as XSLT you need the xsl:output to have the encoding eg. UTF-16

    If you do not pass a xml header with encoding DataPower defaults UTF-8, same with XSLT.

    ------------------------------
    DOMINIC MICALE
    ------------------------------



  • 3.  RE: Preserving Incoming UTF-16 encoding

    Posted Tue February 15, 2022 04:02 PM
    Encoding is an aspect of the bits on the wire, not of the XML Infoset Model, which stores codepoints.  See the XML Infoset spec here:  https://www.w3.org/TR/xml-infoset/  --- as such, it is relevant for inputs and outputs from the gateway, but not to internal data in the middle of a flow.

    Therefore, internal versions of the XML data have no control over encoding, but what form of XML you send on the wire to a backend, or a response to a frontend, can be controlled, as Dominic showed in the prior comment here mentioning xsl:output.

    Putting these two pieces of information together, it should become clear that it matters where that XSLT is in your dataflow.  If it is generating internal data, then the data won't have any encoding and the xsl:output  will have had no effect.  If it is generating the result of your flow, or an internal byte buffer (rather than an internal XML document) then it will control the output bytes.

    ------------------------------
    Morris Matsa
    ------------------------------



  • 4.  RE: Preserving Incoming UTF-16 encoding

    Posted Wed February 16, 2022 10:15 AM
    Thank you Morris and Dominic for detailed explanation. We have determined that the incoming XML is UTF-8 which has UTF-16 encoding characters. We are converting the request type to non xml and will use the stylesheet to convert from non-xml to xml with utf-16 encoding. Will keep you posted how it does.

    ------------------------------
    Vijayasaradhi Peddysetty
    ------------------------------