Creating an XML File Add-in

You can create XML add-ins to group multiple commands for calling executable programs or VB scripts and add them to PowerDesigner menus.

The following illustration helps you understand the XML file structure:



Note: The DTD is available at PD_installdir\Add-ins\XMLAddins.dtd.

The Profile is the root element of the XML file add-in descriptor and can contain:

Both these elements can contain sub-elements as follows:
The following example defines two menu items for the Perforce repository and the methods that are called by them:
<?xml version="1.0" encoding="UTF-8"?>
<Profile>
  <Metaclass Name="PdOOM.Model">
	<Menus>
	  <Menu Location="Tools">
		<Popup Caption="Perforce">
		  <Command Name="CheckIn" Caption="Check In"/>
		  <Separator/>
		  <Command Name="CheckOut" Caption="Check Out"/>
		</Popup>
	  </Menu>
	</Menus>
	<Methods>
	  <Method Name="CheckIn">
        Sub %Method%(obj)
        execute_command( p4, submit %Filename%, cmd_PipeOutput)
        End Sub
	  </Method>
      <Method Name="CheckOut">
        Sub %Method%(obj)
        execute_command( p4, edit %Filename%, cmd_PipeOutput)
        End Sub
	  </Method>
	</Methods>
  </Metaclass>
</Profile>
The following example defines a global script which is referenced by a method defined under a metaclass:
<?xml version="1.0" encoding="UTF-8"?>
<Profile>
  <Shared>
	<GlobalScript>
      Option Explicit
      Function Print (obj)
      Output obj.classname &amp; &quot; &quot; &amp; obj.name
      End Function
	</GlobalScript>
  </Shared>
  <Metaclass Name="PdOOM.Class">
	<Menus>
	  <Menu>
		<Popup Caption="Transformation">
		  <Command Name="ToInt" Caption="Convert to interface"/>
		  <Separator/>
		</Popup>
	  </Menu>
	</Menus>
	<Methods>
	  <Method Name="ToInt">
        Sub %Method%(obj)
        Print obj
        ExecuteCommand(&quot;%MORPHEUS%\ToInt.vbs&quot;, &quot;&quot;, cmd_InternalScript)
        End Sub
	  </Method>
	</Methods>
  </Metaclass>
</Profile>
Note: To use your add-in, save it to the Add-ins directory beneath your PowerDesigner installation directory and enable it through the PowerDesigner General Options window (see Core Features Guide > Modeling with PowerDesigner > Customizing Your Modeling Environment > General Options > Add-Ins).