Forum Stats

  • 3,760,128 Users
  • 2,251,647 Discussions
  • 7,870,992 Comments

Discussions

From xml variable to string and viceversa

Piero Mestici
Piero Mestici Member Posts: 76 Blue Ribbon

Hi All,

I am using BPEL 12c.

I have converted bpel variable defined with complex type into a string using the following command ora:toCDATA($variableComplexBpel) ad I am able to assign it to a string variable $variableString.

The result of the transformation and assignment is (from EM console), looks like:

<tns:Message>&lt;![CDATA[<variableDelete xmlns="http://www.xxx.xxx.int/sales">

            <field1>MM0002</field1>

            <field2>DELETE</field2>

            <field3>MM</field3>

            <field4>123123123</field4>

         </variableDelete>]]&gt;

</tns:Message>

Now I need to do the viceversa, from the string, previously created convert it into the xml variable. That should look like:

[<variableDelete xmlns="http://www.xxx.xxx.int/sales">

            <field1>MM0002</field1>

            <field2>DELETE</field2>

            <field3>MM</field3>

            <field4>123123123</field4>

        </variableDelete>

In order to be used in the BPEL process.

I have tried doTranslateFrom/toNative but I get the following error:

Execution  XPath non execute The cause : impossible to build the schema 'http://xxxxxxxx/common' found in in 'common.xsd'.

What is strange is that the common.xsd is an import in the sales.xsd schema that I passed to the commands:

ora:doTranslateToNative($Variable1, 'Schemas/sales.xsd', 'variableDelete', 'STRING')

ora:doTranslateFromNative(string($Variable2stringa), 'Schemas/sales.xsd', 'variabileDelete', 'DOM').

Both schemas are valid as they are used in the bpel and are working.

Can someone lead me to achieve the needs?

regards

Martien van den Akker

Best Answer

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Sep 15, 2018 4:39AM Accepted Answer

    Hi,

    Try the combination ora:getContentAsString() and ora:parseEscapedXML(). That works for me.

    I get the idea that you don't use  doTranslateFrom/toNative as intended. These functions are meant to translate to and from a native format, for instance comma-separate-values, fixed or variable lenght records, etc., as described by an nxsd document. Those nxsd's are used for file, jms, aq adapters, etc., to translate the content as delivered by or to those adapters from and to XML. When you design those adapters services, you have the choice to supply a regular xsd if the content is already delivered in XML. But you can also choose for Opaque (not interpreted but delivered as Base64) or Native Schema. In the last option you get an editor to design the nxsd based on native content.

    So the functions you used are not so much for interpreting an encoded string into a xml DOM structure. I think that toCDATA is more or less similar to getContentAsString(). But the encoding is different (CDATA vs. encoded characters). But in essense the result is functionally the same.

    For more info, lookup each function in https://docs.oracle.com/cd/E15586_01/integration.1111/e10224/bp_appx_functs.htm .

    Regards,

    Martien

Answers

  • Hemanth Lakkaraju-Oracle
    Hemanth Lakkaraju-Oracle Member Posts: 412 Employee
    edited Sep 14, 2018 1:47PM

    Out of curiosity, can't you use $variableComplexBpel directly - as it is already and xml?

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Sep 15, 2018 4:39AM Accepted Answer

    Hi,

    Try the combination ora:getContentAsString() and ora:parseEscapedXML(). That works for me.

    I get the idea that you don't use  doTranslateFrom/toNative as intended. These functions are meant to translate to and from a native format, for instance comma-separate-values, fixed or variable lenght records, etc., as described by an nxsd document. Those nxsd's are used for file, jms, aq adapters, etc., to translate the content as delivered by or to those adapters from and to XML. When you design those adapters services, you have the choice to supply a regular xsd if the content is already delivered in XML. But you can also choose for Opaque (not interpreted but delivered as Base64) or Native Schema. In the last option you get an editor to design the nxsd based on native content.

    So the functions you used are not so much for interpreting an encoded string into a xml DOM structure. I think that toCDATA is more or less similar to getContentAsString(). But the encoding is different (CDATA vs. encoded characters). But in essense the result is functionally the same.

    For more info, lookup each function in https://docs.oracle.com/cd/E15586_01/integration.1111/e10224/bp_appx_functs.htm .

    Regards,

    Martien

  • Piero Mestici
    Piero Mestici Member Posts: 76 Blue Ribbon
    edited Sep 17, 2018 5:24AM

    The variable $variableComplexBpel is not resolved.

  • Piero Mestici
    Piero Mestici Member Posts: 76 Blue Ribbon
    edited Sep 17, 2018 5:25AM

    Thanks a lot for clarification.

    It is working fine your suggestion.

    Martien van den Akker
This discussion has been closed.