Index: /trunk/src/VBox/Installer/win/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Installer/win/Makefile.kmk	(revision 59389)
+++ /trunk/src/VBox/Installer/win/Makefile.kmk	(revision 59390)
@@ -139,4 +139,6 @@
 	$(VBOX_WIN_INST_OUT_DIR)/VirtualBox.wixobj.dep \
 	$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib.wxi \
+	$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib_x86.wxi \
+	$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_ProxyStub.wxi \
 	$(if $(VBOX_WITH_QTGUI),$(VBOX_WIN_INST_OUT_DIR)/VBoxGuiNLS.wxi) \
 	$(VBOX_WIN_INST_OUT_DIR)/VBoxKey.wxi \
@@ -146,4 +148,6 @@
 		$(VBOX_WIN_INST_OUT_DIR)/NLS/$(lang).mst \
 		$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_$(lang).wixobj \
+		$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_$(lang).wixobj.dep \
+		$(VBOX_WIN_INST_OUT_DIR)/$(PACKAGE_NAME_LANG)_$(lang).wixpdb \
 		$(VBOX_WIN_INST_OUT_DIR)/$(PACKAGE_NAME_LANG)_$(lang).msi) \
 	$(VBOX_WIN_INST_OUT_DIR)/DirComponentsAndFiles_DTrace.wxi \
@@ -520,4 +524,5 @@
 		-E 'VBOX_SIGNING_MODE=$(strip $(if $(VBOX_SIGNING_MODE),$(VBOX_SIGNING_MODE),none))' \
 		-E 'VBOX_GUI_USE_QGL=$(if $(VBOX_GUI_USE_QGL),yes,no)' \
+		-E 'VBOX_MIDL_PROXY_CLSID=$(VBOX_MIDL_PROXY_CLSID)' \
 		$(if $(VBOX_WITH_MSM_INSTALL), \
 			$(foreach module,$(VBOX_INSTALLER_MERGE_MODULES), \
@@ -608,4 +613,5 @@
 		-E 'VBOX_SIGNING_MODE=$(strip $(if $(VBOX_SIGNING_MODE),$(VBOX_SIGNING_MODE),none))' \
 		-E 'VBOX_GUI_USE_QGL=$(if $(VBOX_GUI_USE_QGL),yes,no)' \
+		-E 'VBOX_MIDL_PROXY_CLSID=$(VBOX_MIDL_PROXY_CLSID)' \
 		-E 'VBOX_WINDOWS_ICON_FILE=$(subst /,\,$(VBOX_WINDOWS_ICON_FILE))' \
 		-E 'VBOX_WITH_32_ON_64_MAIN_API=$(if $(VBOX_WITH_32_ON_64_MAIN_API),yes,no)' \
@@ -656,40 +662,19 @@
 #
 $(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib.wxi: \
-		$(PATH_SUB_CURRENT)/VirtualBox_TypeLib.xsl \
+		$(PATH_SUB_CURRENT)/$(if-expr defined(VBOX_WITH_MIDL_PROXY_STUB),VirtualBox_TypeLibWithInterfaces.xsl,VirtualBox_TypeLib.xsl) \
 		$(VBOX_XIDL_FILE) \
 		$(MAKEFILE) \
-               $(if-expr defined(VBOX_WITH_MIDL_PROXY_STUB),$(PATH_STAGE_BIN)/VBoxProxyStub$(if-expr "$(KBUILD_TARGET_ARCH)" == "amd64",-x86,).dll,) \
 		| $$(dir $$@)
-ifndef VBOX_WITH_MIDL_PROXY_STUB
-	$(VBOX_XSLTPROC) -o $@ $< $(VBOX_XIDL_FILE)
-else
-	$(VBOX_XSLTPROC) -o "$@.xidl" $< $(VBOX_XIDL_FILE)
-	$(VBOX_PATH_WIX)/heat.exe \
-		file $(PATH_STAGE_BIN)/VBoxProxyStub$(if-expr "$(KBUILD_TARGET_ARCH)" == "amd64",-x86,).dll \
-		-nologo -o $@.heat
-	$(SED) -e '/\<Interface Id/!d' -e 's/^[[:space:]]*/    /' $@.heat --output $@.interfaces
-	$(SED) -e '/<\/AppId>/{' -e 'r $@.interfaces' -e '}' "$@.xidl" --output $@
-	$(RM) -f -- "$@.xidl" "$@.heat" "$@.interfaces"
-endif
+	$(VBOX_XSLTPROC) \
+		$(if-expr defined(VBOX_WITH_MIDL_PROXY_STUB),--stringparam "a_sProxyStubClsid" '$(VBOX_MIDL_PROXY_CLSID)',) \
+		-o $@ $< $(VBOX_XIDL_FILE)
 
 $(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib_x86.wxi: \
-		$(PATH_SUB_CURRENT)/VirtualBox_TypeLib.xsl \
+		$(PATH_SUB_CURRENT)/$(if-expr defined(VBOX_WITH_MIDL_PROXY_STUB),VirtualBox_TypeLibWithInterfaces.xsl,VirtualBox_TypeLib.xsl) \
 		$(VBOX_XIDL_FILE) \
-               $(if-expr defined(VBOX_WITH_MIDL_PROXY_STUB),$(PATH_STAGE_BIN)/VBoxProxyStub-x86.dll,) \
 		| $$(dir $$@)
-ifndef VBOX_WITH_MIDL_PROXY_STUB
-	$(VBOX_XSLTPROC) --stringparam "a_sTarget" "VBoxClient-x86" -o $@.tmp $< $(VBOX_XIDL_FILE)
-	$(SED) -e 's/VBoxC/VBoxClient_x86/g' --output $@ $@.tmp
-	$(RM) -f $@.tmp
-else
-	$(VBOX_XSLTPROC) --stringparam "a_sTarget" "VBoxClient-x86" -o "$@.xidl-pre" $< $(VBOX_XIDL_FILE)
-	$(SED) -e 's/VBoxC/VBoxClient_x86/g' --output "$@.xidl" "$@.xidl-pre"
-	$(VBOX_PATH_WIX)/heat.exe \
-		file $(PATH_STAGE_BIN)/VBoxProxyStub-x86.dll \
-		-nologo -o $@.heat
-	$(SED) -e '/\<Interface Id/!d' -e 's/^[[:space:]]*/    /' $@.heat --output $@.interfaces
-	$(SED) -e '/<\/AppId>/{' -e 'r $@.interfaces' -e '}' $@.xidl --output $@
-	$(RM) -f -- "$@.xidl-pre" "$@.xidl" "$@.tmp2" "$@.heat" "$@.interfaces"
-endif
+	$(VBOX_XSLTPROC) --stringparam "a_sTarget" "VBoxClient-x86" \
+		$(if-expr defined(VBOX_WITH_MIDL_PROXY_STUB),--stringparam "a_sProxyStubClsid" '$(VBOX_MIDL_PROXY_CLSID)',) \
+		-o $@ $< $(VBOX_XIDL_FILE)
 
 #
Index: /trunk/src/VBox/Installer/win/VBoxMergeApp.wxi
===================================================================
--- /trunk/src/VBox/Installer/win/VBoxMergeApp.wxi	(revision 59389)
+++ /trunk/src/VBox/Installer/win/VBoxMergeApp.wxi	(revision 59390)
@@ -64,32 +64,47 @@
         </File>
 
-        <!-- Note: This file ID *must not* be changed because of our typelib template generation file! -->
-<?if $(env.VBOX_WITH_MIDL_PROXY_STUB) != "yes" ?>
         <!-- We set KeyPath on this file to instruct TypeLib to read the TLB resource from it
              and create appropriate Interface registry entries. Note that the same TLB is present
              in VBoxSVC.exe - it's just a matter of choice which one to use -->
+        <!-- Note: This file ID *must not* be changed because of our typelib template generation file! -->
         <File Id="VBoxC" Name="VBoxC.dll"
               Source="$(env.PATH_OUT)\bin\VBoxC.dll" KeyPath="yes">
         </File>
-<?else?>
-        <File Id="VBoxC" Name="VBoxC.dll"
-              Source="$(env.PATH_OUT)\bin\VBoxC.dll" KeyPath="no">
-        </File>
-
-        <!-- We put the typelib in the proxy stub since it's always required to be loaded and is
-             significantly smaller than VBoxC.dll.  So, KeyPath for this element instead of the above. -->
+
+<?if $(env.VBOX_WITH_MIDL_PROXY_STUB) != "yes" ?>
+        <!-- Include the auto-generated TypeLib block -->
+        <?include $(env.PATH_TARGET)\VirtualBox_TypeLib.wxi ?>
+<?endif?>
+    </Component>
+
+<?if $(env.VBOX_WITH_MIDL_PROXY_STUB) = "yes" ?>
+
+    <Component Id="cp_ProxyStub" Guid="CDD09BA4-8D87-4383-DCA6-1CCCF9D11091" Win64="$(var.Property_Win64)">
+    <?if $(env.BUILD_TARGET_ARCH) != "x86" ?>
+        <!-- AMD64: Only install this proxy stub DLL on Windows 7 and later (OLE32 imports). -->
+        <Condition><![CDATA[(VersionNT >= 610)]]></Condition>
+    <?endif ?>
         <File Id="file_VBoxProxyStub" Name="VBoxProxyStub.dll" KeyPath="yes"
               Source="$(env.PATH_OUT)\bin\VBoxProxyStub.dll">
-            <!-- Note! 0bb3b78c-1807-4249-5ba5-ea42d66af0bf is hardcoded in Main/Makefile.kmk and VBoxMergeCOM32On64.wxi -->
-            <Class Id="{0bb3b78c-1807-4249-5ba5-ea42d66af0bf}" Context="InprocServer32"
-                Description="PSFactoryBuffer" ThreadingModel="both" >
-            </Class>
-        </File>
-<?endif?>
-
-        <!-- Include the auto-generated TypeLib block -->
+            <Class Id="$(env.VBOX_MIDL_PROXY_CLSID)" Context="InprocServer32"
+                Description="PSFactoryBuffer" ThreadingModel="both" />
+        </File>
         <?include $(env.PATH_TARGET)\VirtualBox_TypeLib.wxi ?>
-
-    </Component>
+    </Component>
+
+    <?if $(env.BUILD_TARGET_ARCH) != "x86" ?>
+    <Component Id="cp_ProxyStubLegacy" Guid="97F12055-5B6D-481C-E8CD-F41D8C733280" Win64="$(var.Property_Win64)">
+        <!-- AMD64: Only install this proxy stub DLL pre-Windows 7 (legacy NDR stuff). -->
+        <Condition><![CDATA[(VersionNT < 610)]]></Condition>
+        <File Id="file_VBoxProxyStubLegacy" Name="VBoxProxyStubLegacy.dll" KeyPath="yes"
+              Source="$(env.PATH_OUT)\bin\VBoxProxyStubLegacy.dll">
+            <Class Id="$(env.VBOX_MIDL_PROXY_CLSID)" Context="InprocServer32"
+                Description="PSFactoryBuffer" ThreadingModel="both" />
+        </File>
+        <?include $(env.PATH_TARGET)\VirtualBox_TypeLib.wxi ?>
+    </Component>
+    <?endif ?>
+
+<?endif?>
 
     <?include $(env.PATH_TARGET)\DirComponentsAndFiles_DTrace.wxi ?>
Index: /trunk/src/VBox/Installer/win/VBoxMergeCOM32On64.wxi
===================================================================
--- /trunk/src/VBox/Installer/win/VBoxMergeCOM32On64.wxi	(revision 59389)
+++ /trunk/src/VBox/Installer/win/VBoxMergeCOM32On64.wxi	(revision 59390)
@@ -34,8 +34,7 @@
             <!-- Our key path, see VBoxMergeApp.wxi. -->
             <File Id="file_VBoxProxyStub_x86" Name="VBoxProxyStub-x86.dll" KeyPath="yes"
-                Source="$(env.PATH_OUT)\bin\VBoxProxyStub-x86.dll"
+                Source="$(env.PATH_OUT)\bin\x86\VBoxProxyStub-x86.dll"
                 DiskId="$(var.Property_DiskIdCommon)">
-                <!-- Note! 0bb3b78c-1807-4249-5ba5-ea42d66af0bf is hardcoded in Main/Makefile.kmk and VBoxMergeApp.wix -->
-                <Class Id="{0bb3b78c-1807-4249-5ba5-ea42d66af0bf}" Context="InprocServer32"
+                <Class Id="$(env.VBOX_MIDL_PROXY_CLSID)" Context="InprocServer32"
                     Description="PSFactoryBuffer" ThreadingModel="both" />
             </File>
Index: /trunk/src/VBox/Installer/win/VirtualBox.wxs
===================================================================
--- /trunk/src/VBox/Installer/win/VirtualBox.wxs	(revision 59389)
+++ /trunk/src/VBox/Installer/win/VirtualBox.wxs	(revision 59390)
@@ -399,4 +399,8 @@
     <?endif ?>
         <ComponentRef Id="cp_MainCOM" />
+    <?if $(env.VBOX_WITH_MIDL_PROXY_STUB) = "yes" ?>
+        <ComponentRef Id="cp_ProxyStub" />
+        <ComponentRef Id="cp_ProxyStubLegacy" />
+    <?endif?>
         <ComponentRef Id="cp_MainBinaries" />
     <?if $(env.VBOX_WITH_QTGUI) = "yes" ?>
Index: /trunk/src/VBox/Installer/win/VirtualBox_TypeLibWithInterfaces.xsl
===================================================================
--- /trunk/src/VBox/Installer/win/VirtualBox_TypeLibWithInterfaces.xsl	(revision 59390)
+++ /trunk/src/VBox/Installer/win/VirtualBox_TypeLibWithInterfaces.xsl	(revision 59390)
@@ -0,0 +1,259 @@
+<?xml version="1.0"?>
+
+<!--
+    Generates a wiX include files with Interface elements for
+    the stuff in the proxy stub DLLs.
+
+    Copyright (C) 2007-2016 Oracle Corporation
+
+    This file is part of VirtualBox Open Source Edition (OSE), as
+    available from http://www.virtualbox.org. This file is free software;
+    you can redistribute it and/or modify it under the terms of the GNU
+    General Public License (GPL) as published by the Free Software
+    Foundation, in version 2 as it comes in the "COPYING" file of the
+    VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+    hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+-->
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xml"
+            version="1.0"
+            encoding="utf-8"
+            indent="yes"/>
+
+<xsl:strip-space elements="*"/>
+
+<xsl:param name="a_sTarget">all</xsl:param>
+<xsl:param name="a_sProxyStubClsid">{0BB3B78C-1807-4249-5BA5-EA42D66AF0BF}</xsl:param>
+<xsl:variable name="g_sProxyStubClsid" select="translate($a_sProxyStubClsid,'abcdef','ABCDEF')"/>
+
+
+<!--
+//  templates
+/////////////////////////////////////////////////////////////////////////////
+-->
+
+<!--
+ *  header
+-->
+<xsl:template match="/idl">
+  <xsl:comment>
+
+    DO NOT EDIT! This is a generated file.
+
+    WiX include script for the VirtualBox Type Library
+    generated from XIDL (XML interface definition).
+
+    Source    : src/VBox/Main/idl/VirtualBox.xidl
+    Generator : src/VBox/Installer/win/VirtualBox_Interfaces.xsl
+    Arguments : a_sTarget=<xsl:value-of select="$a_sTarget"/>
+                a_sProxyStubClsid=<xsl:value-of select="$a_sProxyStubClsid"/>
+
+  </xsl:comment>
+  <xsl:apply-templates/>
+</xsl:template>
+
+
+<!-- - - - - - - - - - - - - - - - - - - - - - -
+  Key for more efficiently looking up of parent interfaces.
+ - - - - - - - - - - - - - - - - - - - - - - -->
+
+<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
+
+
+<!--
+  Libraries.
+-->
+<xsl:template match="library">
+  <Include>
+    <TypeLib>
+      <xsl:attribute name="Id"><xsl:value-of select="@uuid"/></xsl:attribute>
+      <xsl:attribute name="Advertise">yes</xsl:attribute>
+      <xsl:attribute name="MajorVersion"><xsl:value-of select="substring(@version,1,1)"/></xsl:attribute>
+      <xsl:attribute name="MinorVersion"><xsl:value-of select="substring(@version,3)"/></xsl:attribute>
+      <xsl:attribute name="Language">0</xsl:attribute>
+      <xsl:attribute name="Description"><xsl:value-of select="@desc"/></xsl:attribute>
+      <xsl:attribute name="HelpDirectory"><xsl:text>INSTALLDIR</xsl:text></xsl:attribute>
+      <AppId>
+        <xsl:attribute name="Id"><xsl:value-of select="@appUuid"/></xsl:attribute>
+        <xsl:attribute name="Description"><xsl:value-of select="@name"/> Application</xsl:attribute>
+        <xsl:choose>
+          <xsl:when test="$a_sTarget = 'VBoxClient-x86'">
+            <xsl:apply-templates select="module[@name='VBoxC']/class"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select="module/class"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </AppId>
+      <xsl:apply-templates select="interface | if/interface">
+        <xsl:sort select="translate(@uuid,'abcdef','ABCDEF')"/>
+      </xsl:apply-templates>
+    </TypeLib>
+  </Include>
+</xsl:template>
+
+
+<!--
+  Classes.
+-->
+<xsl:template match="library//module/class">
+  <Class>
+    <xsl:attribute name="Id"><xsl:value-of select="@uuid"/></xsl:attribute>
+    <xsl:attribute name="Description"><xsl:value-of select="@name"/> Class</xsl:attribute>
+    <xsl:attribute name="Server">
+      <xsl:choose>
+        <xsl:when test="$a_sTarget = 'VBoxClient-x86' and ../@name = 'VBoxC'"><xsl:text>VBoxClient_x86</xsl:text></xsl:when>
+        <xsl:otherwise><xsl:value-of select="../@name"/></xsl:otherwise>
+      </xsl:choose>
+    </xsl:attribute>
+    <xsl:attribute name="Context">
+      <xsl:choose>
+        <xsl:when test="../@context='InprocServer'">InprocServer32</xsl:when>
+        <xsl:when test="../@context='LocalServer'">LocalServer32</xsl:when>
+        <xsl:otherwise>
+          <xsl:message terminate="yes">
+            <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
+            <xsl:text>module context </xsl:text>
+            <xsl:value-of select="concat('&quot;',../@context,'&quot;')"/>
+            <xsl:text> is invalid!</xsl:text>
+          </xsl:message>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:attribute>
+    <xsl:if test="../@context='InprocServer'">
+      <xsl:variable name="tmodel" select="(./@threadingModel | ../@threadingModel)[last()]"/>
+      <xsl:attribute name="ThreadingModel">
+        <xsl:choose>
+          <xsl:when test="$tmodel='Apartment'">apartment</xsl:when>
+          <xsl:when test="$tmodel='Free'">free</xsl:when>
+          <xsl:when test="$tmodel='Both'">both</xsl:when>
+          <xsl:when test="$tmodel='Neutral'">neutral</xsl:when>
+          <xsl:when test="$tmodel='Single'">single</xsl:when>
+          <xsl:when test="$tmodel='Rental'">rental</xsl:when>
+          <xsl:otherwise>
+            <xsl:message terminate="yes">
+              <xsl:value-of select="concat(../../@name,'::',@name,': ')"/>
+              <xsl:text>class (or module) threading model </xsl:text>
+              <xsl:value-of select="concat('&quot;',$tmodel,'&quot;')"/>
+              <xsl:text> is invalid!</xsl:text>
+            </xsl:message>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:attribute>
+    </xsl:if>
+    <ProgId>
+      <xsl:attribute name="Id">
+        <xsl:value-of select="concat(//library/@name,'.',@name,'.1')"/>
+      </xsl:attribute>
+      <xsl:attribute name="Description"><xsl:value-of select="@name"/> Class</xsl:attribute>
+      <ProgId>
+        <xsl:attribute name="Id">
+          <xsl:value-of select="concat(//library/@name,'.',@name)"/>
+        </xsl:attribute>
+        <xsl:attribute name="Description"><xsl:value-of select="@name"/> Class</xsl:attribute>
+      </ProgId>
+    </ProgId>
+  </Class>
+</xsl:template>
+
+
+<!--
+  Interfaces.
+-->
+<xsl:template match="library/interface | library/if[@target='midl']/interface">
+  <Interface>
+<!-- Interface Id="{00C8F974-92C5-44A1-8F3F-702469FDD04B}" Name="IDHCPServer" ProxyStubClassId32="{0BB3B78C-1807-4249-5BA5-EA42D66AF0BF}" NumMethods="33" -->
+    <xsl:attribute name="Id">
+      <xsl:text>{</xsl:text>
+      <xsl:value-of select="translate(@uuid,'abcdef','ABCDEF')"/>
+      <xsl:text>}</xsl:text>
+    </xsl:attribute>
+    <xsl:attribute name="Name"><xsl:value-of select="@name"/></xsl:attribute>
+    <xsl:attribute name="ProxyStubClassId32"><xsl:value-of select="$g_sProxyStubClsid"/></xsl:attribute>
+    <xsl:attribute name="NumMethods"><xsl:call-template name="fnCountMethods"/></xsl:attribute>
+  </Interface>
+</xsl:template>
+
+
+<!--
+  Count the number of methods.  This must match what midl.exe initializes
+  CInterfaceStubVtbl::header::DispatchTableCount with in VirtualBox_p.c!
+  -->
+<xsl:template name="fnCountMethods">
+  <xsl:variable name="sParent" select="@extends"/>
+
+  <!-- Count immediate methods and attributes by kind. -->
+  <xsl:variable name="cMethods"
+    select="count(child::method)
+          + count(child::if[@target='midl']/method)"/>
+  <xsl:variable name="cReadOnlyAttributes"
+    select="count(child::attribute[@readonly='yes'])
+          + count(child::if[@target='midl']/attribute[@readonly='yes'])"/>
+  <xsl:variable name="cReadWriteAttributes"
+    select="count(child::attribute[not(@readonly) or not(@readonly='yes')])
+          + count(child::if[@target = 'midl']/attribute[not(@readonly) or not(@readonly='yes')])"/>
+  <xsl:variable name="cReservedMethods">
+    <xsl:choose>
+      <xsl:when test="not(@reservedMethods)">0</xsl:when>
+      <xsl:otherwise><xsl:value-of select="@reservedMethods"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="cReservedAttributes">
+    <xsl:choose>
+      <xsl:when test="not(@reservedAttributes)">0</xsl:when>
+      <xsl:otherwise><xsl:value-of select="@reservedAttributes"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <!-- Recursively figure out the parent -->
+  <xsl:variable name="cParent">
+    <xsl:choose>
+    <xsl:when test="@extends = '$unknown'">
+      <xsl:value-of select='7'/>
+    </xsl:when>
+    <xsl:when test="@extends = '$errorinfo'">
+      <xsl:value-of select='8'/> <!-- check this one! -->
+    </xsl:when>
+    <xsl:otherwise>
+        <xsl:if test="count(key('G_keyInterfacesByName', $sParent)) != 1">
+          <xsl:message terminate="yes">Couldn't find parent (<xsl:value-of select="$sParent"/>) to <xsl:value-of select="@name"/></xsl:message>
+        </xsl:if>
+        <xsl:for-each select="key('G_keyInterfacesByName', $sParent)">
+          <xsl:call-template name="fnCountMethods"/>
+        </xsl:for-each>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <!-- Compute the result. -->
+  <xsl:value-of select="$cMethods + $cReservedMethods + $cReadOnlyAttributes + ($cReadWriteAttributes * 2) + $cReservedAttributes + $cParent"/>
+
+  <!-- For debugging! -->
+  <xsl:if test="0">
+    <xsl:message terminate="no">
+      <xsl:text>Debug: cMethods=</xsl:text><xsl:value-of select="$cMethods"/>
+      <xsl:text> cReadOnlyAttributes=</xsl:text><xsl:value-of select="$cReadOnlyAttributes"/>
+      <xsl:text> cReadWriteAttributes=</xsl:text><xsl:value-of select="$cReadWriteAttributes"/>
+      <xsl:text> cReservedMethods=</xsl:text><xsl:value-of select="$cReservedMethods"/>
+      <xsl:text> cReservedAttributes=</xsl:text><xsl:value-of select="$cReservedAttributes"/>
+      <xsl:text> cParent=</xsl:text><xsl:value-of select="$cParent"/>
+      <xsl:text> name=</xsl:text><xsl:value-of select="@name"/>
+      <xsl:text> parent=</xsl:text><xsl:value-of select="$sParent"/>
+    </xsl:message>
+  </xsl:if>
+</xsl:template>
+
+
+
+<!--
+  Eat everything else not explicitly matched.
+-->
+<xsl:template match="*">
+</xsl:template>
+
+
+</xsl:stylesheet>
+
