The patch sequencing and applicability information that is returned by the MsiExtractPatchXMLData function or the ExtractPatchXMLData method is in the format of an XML blob that contains the elements and attributes that are identified in this topic. The XML blob can be provided to MsiDeterminePatchSequence and MsiDetermineApplicablePatches instead of the full patch file.
- The MsiPatch element is the top element of the XML blob, and contains information about the patch.
The SchemaVersion attribute specifies the version of the schema definition. The schema is specified by MSIPatchApplicability.xsd and the current schema version is 1.0.0.0. The value of the PatchGUID attribute is the GUID patch code for the patch package obtained from the Revision Number Summary Property in the Summary Information Stream of the patch. The MinMsiVersion is the minimum version of the Windows Installer required to install the patch obtained from the Word Count Summary Property.
- The TargetProduct element is a container element for information about an application that a patch targets.
There can be multiple TargetProduct elements if the patch can be applied to multiple applications. The information in the TargetProduct element is extracted from transforms that are embedded within the patch.
- The TargetProductCode element contains the value of the ProductCode property of the target application before the patch has been applied.
There can be multiple TargetProductCode elements if the patch can be applied to multiple applications.
- The UpdatedProductCode element contains the product code GUID of the target application after the patch is applied.
This element is only present if the patch changes the value of the ProductCode property. A patch that changes the ProductCode is referred to as a Major Upgrade.
- The TargetVersion element contains the ProductVersion property of the target application before the patch has been applied.
- The UpdateVersion element contains the value of the ProductVersion property of the target application after the patch is applied.
This element is only present if the patch changes the value of the ProductVersion property. The XML blob for a patch that implements a Small Update, also referred to as a QFE, will not include this element. The XML blob for a patch that implements a minor upgrade, also referred to as a service pack, will include this element.
- The TargetLanguage element contains the value of the ProductLanguage property of the target application before the patch has been applied.
- The UpdatedLanguages element contains the value of the ProductLanguage property after the patch has been applied.
- The UpgradeCode element contains the value of the UpgradeCode property of the target application.
- The ObsoletedPatch element contains the patch codes (GUIDs) of the patches that are specified as obsolete by this patch.
The list of obsolete patches is obtained from Revision Number Summary in the Summary Information Stream of the patch.
- The SequenceData element contains patch sequencing information for the patch.
There can be multiple SequenceData elements in the XML blob. Each SequenceData element contains the information in one row of the MsiPatchSequence table of the patch. The SequenceData element contains a ProductCode, Sequence, and Attributes subelement for the information in the corresponding fields in the MsiPatchSequence table. See the MsiPatchSequence table section for a description of each field.
Extracting Applicability Information
The following example shows you how to extract the applicability information for a Windows Installer Patch (.msp file) using MsiExtractPatchXMLData. The extracted XML blob is based on the schema definition in MSIPatchApplicability.xsd and returned to szXMLData.
#include <windows.h>
#include <msi.h>
#pragma comment( lib, "msi.lib" )
void main()
{
TCHAR szPatchPath[] = TEXT("c:\\scratch\\RTM-RTMQFE.msp");
TCHAR* szXMLData = NULL;
DWORD cchXMLData = 0;
UINT uiStatus = ERROR_SUCCESS;
// Determine size of XML blob buffer.
if (ERROR_SUCCESS == (uiStatus = MsiExtractPatchXMLData(szPatchPath,
/*dwReserved: must be 0*/ 0, szXMLData, &cchXMLData)))
{
// cchXMLData now includes size of szXMLData in characters not including terminating NULL
++cchXMLData;
szXMLData = new TCHAR[cchXMLData];
if (ERROR_SUCCESS == (uiStatus = MsiExtractPatchXMLData(szPatchPath,
/*dwReserved: must be 0*/ 0, szXMLData, &cchXMLData)))
{
//
// szXMLData now contains the XML patch applicability blob. This could be
// provided to MsiDetermineApplicablePatches or MsiDeterminePatchSequence in the
// proper format to evaluate patch applicability.
//
}
delete [] szXMLData;
szXMLData = NULL;
}
}
The following example shows you how to extract the applicability information for a Windows Installer Patch (.msp file) in XML form. The extracted XML blob is based on the schema definition in MSIPatchApplicability.xsd and returned in strPatchXML.
Dim installer
Set installer = CreateObject("WindowsInstaller.Installer")
strPatchXML = installer.ExtractPatchXMLData("c:\example\patch.msp")
Patch Applicability Schema Definition
Copy the following text into Notepad or another text editor to create the schema definition file for the patch applicability information in the XML blob. Name this file MSIPatchApplicability.XSD.
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Applicability"
targetNamespace="http://www.microsoft.com/msi/patch_applicability.xsd"
elementFormDefault="qualified"
xmlns="http://www.microsoft.com/msi/patch_applicability.xsd"
xmlns:mstns="http://www.microsoft.com/msi/patch_applicability.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MsiPatch">
<xs:complexType>
<xs:sequence>
<xs:element name="TargetProduct" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="TargetProductCode" type="ValidateGUID" />
<xs:element name="UpdatedProductCode" type="GUID" minOccurs="0" maxOccurs="1" />
<xs:element name="TargetVersion" type="ValidateVersion" />
<xs:element name="UpdatedVersion" type="Version" minOccurs="0" maxOccurs="1" />
<xs:element name="TargetLanguage" type="ValidateLanguage" />
<xs:element name="UpdatedLanguages" type="intList" minOccurs="0" maxOccurs="1" />
<xs:element name="UpgradeCode" type="ValidateGUID" />
<xs:element name="UpdatedUpgradeCode" type="GUID" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="MinMsiVersion" type="xs:int" />
</xs:complexType>
</xs:element>
<xs:element name="TargetProductCode" type="GUID" minOccurs="1" maxOccurs="unbounded" />
<xs:element name="ObsoletedPatch" minOccurs="0" maxOccurs="unbounded" type="GUID" />
<xs:element name="SequenceData" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="PatchFamily" type="Identifier" />
<xs:element name="ProductCode" type="GUID" minOccurs="0" maxOccurs="1" />
<xs:element name="Sequence" type="Version" />
<xs:element name="Attributes" type="xs:int" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="SchemaVersion" type="Version" />
<xs:attribute name="PatchGUID" type="GUID" />
<xs:attribute name="MinMsiVersion" type="xs:int" />
<xs:attribute name="TargetsRTM" type="xs:boolean" use="optional" />
</xs:complexType>
</xs:element>
<xs:simpleType name="GUID">
<xs:restriction base="xs:string">
<xs:pattern value="\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\}" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Version">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{1,5}(\.[0-9]{1,5}){0,3}" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ValidateGUID">
<xs:simpleContent>
<xs:extension base="GUID">
<xs:attribute name="Validate" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ValidateVersion">
<xs:simpleContent>
<xs:extension base="Version">
<xs:attribute name="ComparisonType">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="LessThan" />
<xs:enumeration value="LessThanOrEqual" />
<xs:enumeration value="Equal" />
<xs:enumeration value="GreaterThanOrEqual" />
<xs:enumeration value="GreaterThan" />
<xs:enumeration value="None" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ComparisonFilter">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Major" />
<xs:enumeration value="MajorMinor" />
<xs:enumeration value="MajorMinorUpdate" />
<xs:enumeration value="None" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Validate" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ValidateLanguage">
<xs:simpleContent>
<xs:extension base="xs:int">
<xs:attribute name="Validate" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="intList">
<xs:list itemType="xs:int" />
</xs:simpleType>
<xs:simpleType name="Identifier">
<xs:restriction base="xs:string">
<xs:pattern value="[_a-zA-Z][_a-zA-Z0-9\.]*" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
See Also
Send comments about this topic to Microsoft
Build date: 8/13/2009
© 2009 Microsoft Corporation. All rights reserved.