As described in Integrating Two SystemWeaver Installations Using SystemWeaver XML, data can be exchanged between different SystemWeaver Installations using XML Export and then XML Import. However, if the two systems have different meta models the conversion can be very complex and, in some cases, impossible. The manual work of matching items based on a context, converting item types, re-structuring the data, etc. can be extensive. If the decision is made to proceed, there are two options for converting the data: a stand-alone application or an XML converter. 


Stand-alone Application Solution

For more complex conversions, a stand-alone solution developed in-house or by Systemite, is the better option. It requires building a customized stand-alone application, using SystemWeaver’s API, which reads from the source database (Database A in the figure below), then does the conversion based on the targeted database's meta model, and finally writes to the destination database (Database B in the figure below). 



XML Conversion Solution

This alternative is for fairly straight forward scenarios and uses the XMLs view in the source database (Database A in the figure below) where you add a customized XML definition to complete the conversion and create the new XML applicable to the meta model in the destination database (Database B in the figure below). The new XML is then imported into the destination database using Import from XML.


Prerequisite

  • You must have the Architect role in the source database.




Example

The example shown below converts "Block" to "Function Block".


Meta Models


XML

This is an example XML that would be entered into the XMLs view for the conversion from "Block" to "Function Block".


<XDocument name="SystemWeaver4">
  <Options>
    <Indent/>
  </Options>
  <XElement name="Info">
    <XElement name="Description">
      <Text>TOP ITEM DESCRIPTION</Text>
        </XElement>                                           
        <XElement name="ExportedBy">
            <Text>EXPORTER</Text>
        </XElement>                                           
        <XElement name="ExportDate">
            <Text>#{?Now.Format('iso')}</Text>
        </XElement>                                           
        <XElement name="ExportedItem">
            <Text>ITEM XID</Text>
        </XElement>                                           
    </XElement>    

    <Context name="HARAContext">
        <AddParts owner="main" sid="IDI" part="ProjectItems" defobj="ItemBlock"/>
        <AddParts owner="ItemBlock" sid="IBDP" part="SubBlocks" defobj="+ItemBlock"/>
        <AddParts owner="ItemBlock" sid="IBIS" part="Inport" defobj="+Signal"/>
        <AddParts owner="ItemBlock" sid="IBOS" part="Outport" defobj="+Signal"/>  
        <AddParts owner="Signal" sid="ICDP" part="Subsignal" defobj="+Signal"/>  
    </Context>

    <XElement name="Items">
        <!-- Project -->
        <ApplyItemTemplates/>

        <ForEachInContext name="HARAContext" group="ItemBlock">
            <XElement name="Item">
                <ApplyTemplate name="ItemDetails">
                    <WithParam name="sid" select="'FUBL'"/>
                </ApplyTemplate>
                <XElement name="PartGroups"> 
                    <ApplyTemplate name="PartDetails">
                        <WithParam name="sid" select="'FUSB'"/>
                        <WithParam name="parts" select="Context:/part::SubBlocks"/>
                    </ApplyTemplate>
                    <ApplyTemplate name="PartDetails">
                        <WithParam name="sid" select="'REIN'"/>
                        <WithParam name="parts" select="Context:/part::Inport"/>
                    </ApplyTemplate>
                    <ApplyTemplate name="PartDetails">
                        <WithParam name="sid" select="'SEIN'"/>
                        <WithParam name="parts" select="Context:/part::Outport"/>
                    </ApplyTemplate>
                </XElement>                                           
                </XElement>                                           
            </XElement>
        </ForEachInContext>

        <ForEachInContext name="HARAContext" group="Signal">
            <XElement name="Item">
                <ApplyTemplate name="ItemDetails">
                    <WithParam name="sid" select="'ININFO'"/>
                </ApplyTemplate>
            </XElement>      
            <XElement name="PartGroups"> 
                <ApplyTemplate name="PartDetails">
                    <WithParam name="sid" select="'IRE'"/>
                    <WithParam name="parts" select="Context:/part::Subsignal"/>
                </ApplyTemplate>
            </XElement> 
        </ForEachInContext>        
    </XElement>       

    <ItemTemplate type="SPR">
        <XElement name="Item">    
            <ApplyTemplate name="ItemDetails">
                <WithParam name="sid" select="'SPR'"/>  
            </ApplyTemplate> 
            <XElement name="PartGroups"> 
                <ApplyTemplate name="PartDetails">
                    <WithParam name="sid" select="'IDI'"/>
                    <WithParam name="parts" select="/part::IDI"/>
                </ApplyTemplate>
            </XElement>  
        </XElement> 
    </ItemTemplate> 

    <Template name="ItemDetails"> 
        <Parameter name="sid" as="String"/>
        <XAttribute name="sid" value="#{?$sid}"/>
        <XAttribute name="id" value="#{Handle}"/>
        <XElement name="Name">
            <Text>#{Name}</Text>
        </XElement>                                           
        <XElement name="VersionText">
            <Text>#{VersionText}</Text>
        </XElement>                                           
        <XElement name="VersionNumber">
            <Text>#{?(AllVersions.Select(VersionNumber).Max.ToInteger + 1).ToString}</Text>
        </XElement>                                           
        <XElement name="Status">
            <!--Text>#{?if Status.ToString='Work' then 'I' else (if Status.ToString='CS Released' then 'X' else Status)}</Text-->
            <Text>I</Text>
        </XElement>                                           
        <XElement name="Description">
            <XElement name="Binary">    
                <Description format="rvf"/>
            </XElement>                                           
            <XElement name="Plain">
                <Description format="plain"/>
            </XElement>                                           
        </XElement>                                           
    </Template>

    <Template name="PartDetails"> 
        <Parameter name="sid" as="String"/>
        <Parameter name="parts" as="[Part]"/>
        <XElement name="PartGroup">
            <XAttribute name="sid" value="#{?$sid}"/>
            <XElement name="Name">
                <Text>#{Type.Name}</Text> 
            </XElement>                                           
            <XElement name="Parts">
                <ForEach select="$parts">
                    <XElement name="Part">
                        <XAttribute name="id" value="#{Handle}"/>
                        <XElement name="DefObj">
                            <XAttribute name="id" value="#{DefObj.Handle}"/>
                        </XElement>                                           
                    </XElement>                                           
                </ForEach>
            </XElement>                                           
        </XElement>   
    </Template>
</XDocument>