-1

I have a BizTalk map that look like this:

map

The string concat look like this:

map string concat

when I test this map I get this output:

output

what I need is this output:

enter image description here

Can anyone tell me how I can get the shown output, where the .. tags and all the sub tags is not a string but is xml element tag..? I Need to do this in the shown BizTalk Map!

I have now made a small VS project where you can test and see how to solve my problem. You can download the project from this link:

Visual Studio Project

For the test project map the input is this:

<ns0:SomeData xmlns:ns0="http://CustomSchemaMapping.SourceSchema">
  <ID>0</ID>
  <NAME>Test Person</NAME>
  <YEAR>2022</YEAR>
</ns0:SomeData>

and the output should be like this:

<ns0:OutputData xmlns:ns0="http://CustomSchemaMapping.OutputSchema">
    <OtherElement>Test</OtherElement>
    <BrevparamXML>
        <DATA>
            <ID>0</ID>
            <NAME>Test Person</NAME>
            <YEAR>2022</YEAR>
        </DATA>
    </BrevparamXML>
</ns0:OutputData>

and NOT like this:

<ns0:OutputData xmlns:ns0="http://CustomSchemaMapping.OutputSchema">
    <OtherElement>Test</OtherElement>
    <BrevparamXML>  &lt;DATA&gt;&lt;ID&gt;0&lt;/ID&gt;&lt;NAME&gt;Test Person&lt;/NAME&gt;&lt;YEAR&gt;2022&lt;/YEAR&gt;&lt;/DATA&gt;
    </BrevparamXML>
</ns0:OutputData>
Bala
  • 21
  • 4
  • 1
    Please post a [mcve] of your Xml to allow people here to test without having to re-type your Xml data. – Filburt Feb 04 '22 at 13:05
  • Usually you have to use the Scripting Functoid with XSLT to achieve that. – Dijkgraaf Feb 05 '22 at 20:29
  • Hello Dijkgraaf, I have tried that, but it’s removing destination tag BrevparamXML. Can you give me an sample of XSLT thar does not remove the BrevparamXML tag, but just add my xml string as xml element under BrevparamXML element. Because I need the Head BrevparamXML element with it correct namespace. Thanks – Bala Feb 06 '22 at 21:04
  • 1
    As Filburt has said, you need to provide a minimal reproducible example. So 2 small schemas, a input XML payload and small map that reproduces the issue, plus a small example XML showing what you want. – Dijkgraaf Feb 07 '22 at 19:25
  • P.S. Your XSLT also needs to create the BrevparamXML node. – Dijkgraaf Feb 08 '22 at 06:11
  • Now I have uploaded a small project, please link on the link in the description. – Bala Feb 09 '22 at 09:54

2 Answers2

0

Is your output schema only used for one integration and you are always going to send the same "Any"-xml? Then I would change the outgoing schema to include those elements. The outgoing xml will be the same anyway and no one else will be affected.

Martin Bring
  • 1,176
  • 1
  • 7
  • 17
  • Hi Martin, thanks for your solution.. and I have implemented it and it's working fine.. But is it possible to get the BrevparamXML namespace automatically from the destination schema, so it can have the correct namespace defined like , ns22 point to the correct namespace fra the dest schema? Because I consume the destionation schema from a third-party, and this namesapce can possible change.. – Bala Feb 21 '22 at 09:12
  • since you have control of the prefix, you can set it in the map, there is no problem hard code it in the xslt. Test 2022 0 Test Person – Martin Bring Feb 25 '22 at 09:36
  • Did the last comment solve it for you? – Martin Bring Mar 07 '22 at 15:01
  • Hi Martin, your sample solved my mapping issue but not the namespace. I still have to manually change the ns nummer, everytime i update the destination schema.. so if you have any idea of how to get the correct namespace from the dest schema will be wonderful.. – Bala Mar 09 '22 at 12:22
  • Sorry for answering every six month or so :) Did you see my comment on namespace? You have control of what prefix to use in the map, so if you update with a new destination schema change the prefix to the one you want you. Note: If the destination part demands certain prefix they do not use xml correctly, one do not need to be depended on prefix if you use a parser and a namespacemanager. – Martin Bring Jan 04 '23 at 15:14
0

I tried with a Scripting Functoid of type "Inline XSLT Call Template" with following template and got the desired output. Label the inputs ID, NAME and YEAR. You need to tweak my code to get it to validate. Probably add a namespace from SourceSchema.xsd.

XSLT Template

   <xsl:template name="MyXsltConcatTemplate">
    <xsl:param name="ID" />
    <xsl:param name="NAME" />
    <xsl:param name="YEAR" />

    <xsl:element name="BrevparamXML">
        <xsl:element name="DATA">
            <xsl:element name="ID">
                <xsl:value-of select="$ID" />
            </xsl:element>
            <xsl:element name="NAME">
                <xsl:value-of select="$NAME" />
            </xsl:element>
            <xsl:element name="YEAR">
                <xsl:value-of select="$YEAR" />
            </xsl:element>
        </xsl:element>
    </xsl:element>
</xsl:template>

Result

<ns0:OutputData xmlns:ns0="http://CustomSchemaMapping.OutputSchema">
    <OtherElement>Test</OtherElement>
    <BrevparamXML>
        <DATA>
            <ID>2022</ID>
            <NAME>0</NAME>
            <YEAR>Test Person</YEAR>
        </DATA>
    </BrevparamXML>
</ns0:OutputData>
Martin Bring
  • 1,176
  • 1
  • 7
  • 17