How to find and change a registry value in WIX using XSL

This is the xml...

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment><DirectoryRef Id="InstallDirx64" /></Fragment>
    <Fragment><ComponentGroup Id="LouComponentx64"><Component Directory="InstallDirx64" Id="cmp123321" Guid="{0B7441C0-A876-41BA-87C9-077CED712FAA}" Win64="yes">
<Condition>VersionNT64</Condition>
                <File KeyPath="yes" Source="$(var.louDLL.TargetDir)\louDLL.dll" Id="fil123321">
                    <TypeLib Id="{90BB27B2-9EB2-4B8D-930F-58B7F74D686E}" Description="louDLLLib" HelpDirectory="InstallDirx64" Language="0" MajorVersion="1" MinorVersion="0"><Class Id="{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}" Context="InprocServer32" Description="lou Class" ThreadingModel="apartment" Version="1.0" Programmable="yes" Control="yes"><ProgId Id="lou.1" Description="lou Class"><ProgId Id="lou" Description="lou Class" /></ProgId></Class><Interface Id="{51154861-52EE-40AA-96B0-5DF53324E7F8}" Name="IShareImage" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" /><Interface Id="{8FE4941F-EE44-4389-A083-344B392FE2FF}" Name="Ilou" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" /></TypeLib>
                </File>
                <RegistryValue Root="HKCR" Key="*\ShellEx\ContextMenuHandlers\lou" Value="{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}" Type="string" Action="write" />
                <RegistryValue Root="HKCR" Key="CLSID\{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}\MiscStatus\1" Value="132497" Type="string" Action="write" />
                <RegistryValue Root="HKCR" Key="CLSID\{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}\MiscStatus" Value="0" Type="string" Action="write" />
                <RegistryValue Root="HKCR" Key="CLSID\{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}\ToolboxBitmap32" Value="[#fil4E063919C21DFFABD05CADC857B9D549], 106" Type="string" Action="write" />
                <RegistryValue Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Explorer" Name="GlobalAssocChangedCounter" Value="1" Type="integer" Action="write" />
            </Component></ComponentGroup></Fragment>
</Wix>

Open in new window


I have already modified a number of values using xsl, here is part of that...

 
<xsl:template match="wix:Component">
    <xsl:copy>
      <xsl:apply-templates select="@*" />
        <!-- Adding the Win64-attribute as we have a x64 application -->
        <xsl:attribute name="Id">
          <xsl:text>cmp123321</xsl:text>
        </xsl:attribute>		
        <xsl:attribute name="Guid">
          <xsl:text>{0B7441C0-A666-41BA-87C9-098CED712FAA}</xsl:text>
        </xsl:attribute>		
		<xsl:attribute name="Win64">yes</xsl:attribute>
		<xsl:text>&#xa;</xsl:text>
		<xsl:element name="Condition">VersionNT64</xsl:element>
        <!-- Now take the rest of the inner tag -->
        <xsl:apply-templates select="node()" />
    </xsl:copy>
  </xsl:template>
   
   <xsl:template match="wix:File">
   <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:attribute name="Id">
         <xsl:text>fil123321</xsl:text>
      </xsl:attribute>
      <xsl:apply-templates/>
   </xsl:copy>
   </xsl:template>
   
   <xsl:template match="wix:RegistryValue">
   <xsl:copy>
 </xsl:copy>
   </xsl:template>

Open in new window


What I want to do now is change "Value="[#fil4E063919C21DFFABD05CADC857B9D549]" (the fourth RegistryValue down), to Value="[#filfil123321]" , to agree with the file id of above (which I will provide in the replace statement)

I have started the xsl:template match, but do not know how to search\get to, that particular value, and replace it.

Please give me the exact code, please do not point me to something that might help.  I have done searches, and have not found what I am looking for.
eelouAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

eelouAuthor Commented:
Some additional information.  The xml is harvested using WIX heat, every time the installer is build.  So, the number of registryvalue records could change (if the product developer made changes to the dll).  So, counting down to the fourth record is not an option.  Actually, it would be preferable to search for "[#fil", and change the entire value of that "value=", value.
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Try replacing the last template from what you posted above (the match="wix:RegistryValue" one) to the below...
    <xsl:template match="wix:RegistryValue/@Value[fn:starts-with(., '[#fil')]">
        <xsl:attribute name="Value">[#fil123321]</xsl:attribute>
    </xsl:template>

Open in new window

(Note that this is assuming that somewhere else in your XSL you have a default "copy" template that is already copying everything else)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eelouAuthor Commented:
I am fairly new to XML and XSL, I am missing something here.  
I added the xpath-function...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
    xmlns="http://schemas.microsoft.com/wix/2006/wi"
  exclude-result-prefixes="wix">

Now I get Heat error, "error applying transform...Cannot find a script or an extension object associated with namespace 'http://www.w3.org/2005/xpath-functions'"

Open in new window

0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

eelouAuthor Commented:
Could not use that code, removed the xpath-functions, had to do this...

<xsl:template match="wix:RegistryValue[substring(@Value, 1, 5) = '[#fil' ]">
      <xsl:copy>
	    <xsl:apply-templates select="@*"/>
          <xsl:attribute name="Value">[#fil123321]</xsl:attribute>
		<xsl:apply-templates/>
	  </xsl:copy>
    </xsl:template> 
	

Open in new window

0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Now I get Heat error, "error applying transform...Cannot find a script or an extension object associated with namespace 'http://www.w3.org/2005/xpath-functions'
Unfortunately, I don't know anything about Heat in particular so I can't help there, other than to say that some processors MAY let you leave off the fn: prefix on the starts-with function and then you can omit the xmlns:fn declaration.

However, if you are able to use the substring method without qualifying it (which makes me think that you can do the same with starts-with) then you should still be able to do it much like the first post that I gave, ie...
    <xsl:template match="wix:RegistryValue/@Value[substring(., 1, 5) = '[#fil']">
        <xsl:attribute name="Value">[#fil123321]</xsl:attribute>
    </xsl:template>

Open in new window

0
eelouAuthor Commented:
WIX does not work with 2.0 yet.   That is why your code does not work.
0
eelouAuthor Commented:
Could not use the code provided.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.