DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.

Community Support Admin

Community Support AdminFri November 27, 2020 08:34 PMBest Answer

Community Support Admin

Community Support AdminMon November 30, 2020 01:42 PMBest Answer

  • 1.  Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.

    Posted Thu November 26, 2020 02:46 PM

    I always get this error whenever running transformation.

    Saved (using Notepad++) with BOM, without BOM as UTF-8, still no luck.

    The transformation completes successfully, but this error is always logged.

    XSLT file starts with:

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:dp="http://www.datapower.com/extensions"

    xmlns:dpconfig="http://www.datapower.com/param/config"

    xmlns:func="http://exslt.org/functions"

    extension-element-prefixes="dp">

    or with BOM it has 0xef,0xbb,0xbf before the "<?xml..."

    How should I save the XSLT so it does not log this error anymore?



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 07:51 AM

    Hi

    Can you set the level log to debug then share the entire transaction log ?



    #DataPower
    #Support
    #SupportMigration


  • 3.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 02:41 PM

    I've set the to debug all logs. When I ran a transaction, the system logs shows the error but not the XMLManager. Here is what I see on the system logs:

    xmlmgr (xmgr-b2b-default): xslt Compilation Request: Beginning compilation of URL 'local:///dp-b2b-core-utils/common/xslt/b2b-archive.xslt'. xmlmgr (xmgr-b2b-default): xslt Compilation Request: Compilation complete of URL 'local:///dp-b2b-core-utils/common/xslt/b2b-archive.xslt'. Memory used 350792 bytes. .... mpgw (mpgw-b2b-common): dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///dp-b2b-core-utils/common/xslt/b2b-archive.xslt)*.

    Yet, the transformation completes successfully.

    I just noticed, this error only occurs on Docker Datapower, but not on the appliance itself - I will dig more see if that's true.

    So it could be related to my Docker on Windows handling of encoding.



    #DataPower
    #Support
    #SupportMigration


  • 4.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 02:46 PM

    Now you have to see into local:///dp-b2b-core-utils/common/xslt/b2b-archive.xslt where there is a parse command and understand why the objet is not a valid xml




    #DataPower
    #Support
    #SupportMigration


  • 5.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 02:58 PM

    Thanks D


    To my understanding, DataPower tries to parse my xslt and abends on the very first character (which is "<" or for BOM : 0xef,0xbb,0xbf + "<"). There is no character "4" on my xslt.

    Still the transformation completes fine (on both physical and virtual).

    But only under Docker seem to get the error.



    #DataPower
    #Support
    #SupportMigration


  • 6.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 04:55 PM

    It actually happens on the physical appliance as well (just could not see it before).


    If anyone has an idea, will be greatly appreciated.



    #DataPower
    #Support
    #SupportMigration


  • 7.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 08:34 PM

    I Don't think

    Can you share b2b-archive.xslt  ?



    #DataPower
    #Support
    #SupportMigration


  • 8.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Fri November 27, 2020 08:45 PM

    There is no way to upload to original file, so here is the content:


    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet version="1.0"

     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

     xmlns:dp="http://www.datapower.com/extensions"

     xmlns:dpconfig="http://www.datapower.com/param/config"

     xmlns:func="http://exslt.org/functions"

     extension-element-prefixes="dp">


     <dp:input-mapping href="store:///pkcs7-convert-input.ffd" type="ffd"/>


     <xsl:template match="/">

      <xsl:variable name="newMQMDStr">

       <MQMD>

        <CorrelId>

         <xsl:value-of select="dp:http-request-header('CorrelationId')"/>

        </CorrelId>

       </MQMD>

      </xsl:variable>


      <!-- Setting MQMD header -->

      <xsl:variable name="mqHeaders">

       <header name="MQMD">

        <!-- serialize the header so that it can be set -->

        <dp:serialize select="$newMQMDStr" omit-xml-decl="yes"/>

       </header>

      </xsl:variable>


      <xsl:variable name="resultMQ">

       <xsl:variable name="target" select="concat('dpmqfte://qmg-ebci-1-2/?DestAgent=AGENT2&amp;DestQM=qmg-ebci-1-2&amp;DestFile=archive.bin&amp;RequestQueue=',dp:variable('var://context/b2bContext/archivingQueue'))"/>

       <dp:url-open target="{$target}" response="binaryNode" http-headers="$mqHeaders">

        <xsl:copy-of select="/object/message/node()"/>

       </dp:url-open>

      </xsl:variable>


      <dp:set-variable name="'var://context/service/MQResult'" value="$resultMQ"/>

      <dp:set-variable name="'var://context/service/MQResponseCode'" value="string($resultMQ/result/responsecode)"/>

      <dp:set-variable name="'var://context/service/MQResponseheader'" value="dp:parse(string($resultMQ/result/headers/header))"/>

      <xsl:variable name="responseMQMD" select="dp:parse(string($resultMQ/result/headers/header))"/>

      <xsl:variable name="MsgId" select="$responseMQMD/MQMD/MsgId"/>

      <dp:set-variable name="'var://context/service/MQMsgId'" value="string($MsgId)"/>

      <dp:set-variable name="'var://context/service/mycontent'" value="concat('var://context/', dp:variable('var://service/multistep/input-context-name'))"/>

      <xsl:variable name="contentname" select="dp:variable('var://context/service/mycontent')"/>

      <dp:set-variable name="'var://context/service/mydpcontent'" value="$contentname"/>

      <xsl:variable name="payload" select="dp:variable($contentname)"/>

      <xsl:variable name="msg" select="dp:binaryNodeToString($payload)"/>

      <dp:set-variable name="'var://context/service/contentmsg'" value="string($msg)"/>

      <dp:set-variable name="'var://context/service/contentmsgSize'" value="string-length($msg)"/>


     </xsl:template>


    </xsl:stylesheet>



    #DataPower
    #Support
    #SupportMigration


  • 9.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Sat November 28, 2020 09:04 AM

    I see in your styleSheet that there is a MQ call.

    If you turn on the probe, can you see this call (you have to clic on the stylesheet on the probe).

    I really think that your XSLT is ok, and it 's this parse command which generate your error : dp:parse(string($resultMQ/result/headers/header)). That the reason i ask you to check if datapower make mq call.

    Can you share all your transaction debug log or it's not possible ?




    #DataPower
    #Support
    #SupportMigration


  • 10.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Mon November 30, 2020 10:28 AM

    I agree with D, you should see if the probe shows any signs why your dp:parse() is failing. Your XSLT is just fine. If it would be somehow faulty, then the transform would not succeed. dp:parse() failure is informational and doesn't automatically fail your transaction. I'd check that your XPATH ($resultMQ/result/headers/header) is really valid and you get the MQMD node-set that you are apparently trying to extract. And did you try dp:parse without string()? There shouldn't be a need for a "type cast" the value of the header element.


    --HP



    #DataPower
    #Support
    #SupportMigration


  • 11.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Mon November 30, 2020 01:23 PM

    Indeed it was the dp:parse from within the XSLT itself (as nodes were incorrect) causing the error message.

    Error message is confusing, I always thought the error is raised by parsing my XSLT rather than parsing the runtime response.

    Thanks D& hpernaa :)



    #DataPower
    #Support
    #SupportMigration


  • 12.  RE: Error on dp:parse() error: illegal character '4' at offset 0 of *dp:parse(local:///my.xslt)*.
    Best Answer

    Posted Mon November 30, 2020 01:42 PM

    great. It was a pleasur​



    #DataPower
    #Support
    #SupportMigration