Functions

src/CustomActions/XmlTools/XmlToolsImpl.h File Reference

Go to the source code of this file.

Functions

CA_API UINT __stdcall Xml_SelectNodeValue (MSIHANDLE hInstall)
 Select the text value of an xml node in a document.
CA_API UINT __stdcall Xml_SelectNodeXml (MSIHANDLE hInstall)
 Select the XML value of a node in a document.
CA_API UINT __stdcall Xml_SelectNodeAttributeValue (MSIHANDLE hInstall)
 Select the text value of an xml node attribute.
CA_API UINT __stdcall Xml_XslTransform (MSIHANDLE hInstall)
 Transform an XML document with XSLT into a new XML document.
CA_API UINT __stdcall Xml_DeleteNodes (MSIHANDLE hInstall)
 Delete an xml node in a document.

Function Documentation

CA_API UINT __stdcall Xml_DeleteNodes ( MSIHANDLE  hInstall)

Delete an xml node in a document.

Parameters:
XML_FILENAMEXML file
XML_XPATHXPATH to select, if more than one node matches, all are deleted
Returns:
XML_DELETED set to the number of nodes deleted (0 if none)
CA_API UINT __stdcall Xml_SelectNodeAttributeValue ( MSIHANDLE  hInstall)

Select the text value of an xml node attribute.

Parameters:
XML_FILENAMEXML file
XML_XPATHXPATH to select, if more than one node matches the first one only is used
XML_ATTRIBUTENAMEattribute name
XML_ATTRIBUTEVALUEMSI property that contains the result after execution
CA_API UINT __stdcall Xml_SelectNodeValue ( MSIHANDLE  hInstall)

Select the text value of an xml node in a document.

Parameters:
XML_FILENAMEXML file
XML_XPATHXPATH to select, if more than one node matches the first one only is used
XML_NODEVALUEMSI property that contains the result after execution
Example:

Suppose that we're upgrading an existing product (OLDERVERSIONBEINGUPGRADED is defined somewhere in the MSI sequence), which has a configuration file called config\Config.xml. This file contains a Configuration node with Host and Port.

The following code declares the custom actions that will prepare the configuration parameters for the Xml_SelectNodeValue custom action. Each action must be named individually.

 <!-- set the filename to config\Config.xml -->
 <CustomAction Id="Xml_SetFileName" Property="XML_FILENAME" Value="[INSTALLDIR]\config\Config.xml" Execute="immediate" />
 <!-- select /Configuration/Host into the HOST property -->
 <CustomAction Id="Xml_SelectNodeValue_Host_XPath" Property="XML_XPATH" Value="/Configuration/Host" Execute="immediate" />
 <CustomAction Id="Xml_SelectNodeValue_Host" BinaryKey="XmlTools" DllEntry="Xml_SelectNodeValue" Execute="immediate" Return="check" />
 <CustomAction Id="Xml_GetNodeValue_Host" Property="HOST" Value="[XML_NODEVALUE]" Execute="immediate" />
 <!-- select /Configuration/Port into the PORT property -->
 <CustomAction Id="Xml_SelectNodeValue_Port_XPath" Property="XML_XPATH" Value="/Configuration/Port" Execute="immediate" />
 <CustomAction Id="Xml_SelectNodeValue_Port" BinaryKey="XmlTools" DllEntry="Xml_SelectNodeValue" Execute="immediate" Return="check" />
 <CustomAction Id="Xml_GetNodeValue_Port" Property="PORT" Value="[XML_NODEVALUE]" Execute="immediate" />
 <!-- custom action binary -->
 <Binary Id="XmlTools" SourceFile="$(var.BinDir)\XmlTools.dll" />

These custom actions are then inserted into InstallExecuteSequence. Once they are executed, two properties HOST and PORT are defined.

<InstallExecuteSequence>
 <Custom Action="Xml_SetFileName" After="FindRelatedProducts">OLDERVERSIONBEINGUPGRADED</Custom>      
 <!-- get /Configuration/Host -->
 <Custom Action="Xml_SelectNodeValue_Host_XPath" After="Xml_SetFileName">OLDERVERSIONBEINGUPGRADED</Custom>
 <Custom Action="Xml_SelectNodeValue_Host" After="Xml_SelectNodeValue_Host_XPath">OLDERVERSIONBEINGUPGRADED</Custom>
 <Custom Action="Xml_GetNodeValue_Port" After="Xml_SelectNodeValue_Host">OLDERVERSIONBEINGUPGRADED</Custom>
 <!-- get /Configuration/Port -->
 <Custom Action="Xml_SelectNodeValue_Port_XPath" After="Xml_GetNodeValue_Port">OLDERVERSIONBEINGUPGRADED</Custom>
 <Custom Action="Xml_SelectNodeValue_Port" After="Xml_SelectNodeValue_Port_XPath">OLDERVERSIONBEINGUPGRADED</Custom>
 <Custom Action="Xml_GetNodeValue_Port" After="Xml_SelectNodeValue_Port">OLDERVERSIONBEINGUPGRADED</Custom>
 ...
</InstallExecuteSequence>
CA_API UINT __stdcall Xml_SelectNodeXml ( MSIHANDLE  hInstall)

Select the XML value of a node in a document.

Parameters:
XML_FILENAMEXML file
XML_XPATHXPATH to select, if more than one node matches the first one only is used
XML_NODEXMLMSI property that contains the result after execution
CA_API UINT __stdcall Xml_XslTransform ( MSIHANDLE  hInstall)

Transform an XML document with XSLT into a new XML document.

Parameters:
XML_FILENAMEXML file to transform
XSLT_FILENAMEXSLT file to use for the transform
XSLT_RESULT_FILENAMEfile that will contain the transformed output


© Application Security Inc. - All Rights Reserved http://msiext.codeplex.com