Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is completely doable out of the box with a simple map. </p> <p>Here is the soure XML file:</p> <pre><code>&lt;root&gt; &lt;shop&gt; &lt;product&gt; &lt;type&gt;1&lt;/type&gt; &lt;code&gt;ab&lt;/code&gt; &lt;desc&gt;&lt;/desc&gt; &lt;/product&gt; &lt;product&gt; &lt;type&gt;2&lt;/type&gt; &lt;code&gt;cd&lt;/code&gt; &lt;desc&gt;&lt;/desc&gt; &lt;/product&gt; &lt;/shop&gt; &lt;address /&gt; &lt;names /&gt; &lt;/root&gt; </code></pre> <p>Here is the source schema:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="root"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="shop"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="1" maxOccurs="unbounded" name="product"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="type" type="xs:string" /&gt; &lt;xs:element name="code" type="xs:string" /&gt; &lt;xs:element name="desc" type="xs:string" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="address"&gt; &lt;xs:complexType /&gt; &lt;/xs:element&gt; &lt;xs:element name="names"&gt; &lt;xs:complexType /&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p>Here is the target schema:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="products"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="1" maxOccurs="unbounded" name="product"&gt; &lt;xs:complexType mixed="true"&gt; &lt;xs:attribute name="type" type="xs:string" /&gt; &lt;xs:attribute name="code" type="xs:string" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p>And here is the map:</p> <p><img src="https://i.stack.imgur.com/AAO9T.gif" alt="BizTalk Map for Source and destination schemas"></p> <p>And here is the output:</p> <pre><code>&lt;products&gt; &lt;product type="1" code="ab" /&gt; &lt;product type="2" code="cd" /&gt; &lt;/products&gt; </code></pre> <p>Armed witht his result, you can follow one of two suggestions outlined by Mark Brimble in his blog. </p> <p><a href="http://connectedpawns.wordpress.com/2009/08/01/how-to-copy-the-entire-node-to-element-of-string-type-in-a-map/" rel="nofollow noreferrer">How to copy the entire node to element of string type in a map</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload