Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7854709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:09:22+00:00 2026-06-02T20:09:22+00:00

I need to remove all Component elements and their corresponding ComponentRef elements, where the

  • 0
  • I need to remove all Component elements and their corresponding ComponentRef elements, where the Component child element File attribute Source is NOT a dll file?
  • I have the evaluation function for the Source string value i.e. {substring(wix:File/@Source, string-length(wix:File/@Source) - 2)}='dll' returns true for Source values that contain dll
  • But I don’t know how to use the function to remove the last two Component elements (with their children) as well as the corresponding last two ComponentRef elements (mapped by Id attribute)?

Source XML

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="TARGETFOLDER">
            <Component Id="cmpA733DB49D89AC9CEA2EDFAAEE51992E7" Guid="{F3412A8F-5718-45AB-9E6F-7B802BCC0EED}">
                <File Source="$(var.WixSlave.TargetDir)\protobuf-net.dll" Id="fil910D6DB28382BAB5A9DF0ACBD5095ADE" KeyPath="yes" />
            </Component>
            <Component Id="cmpF1D751B9621E283AD7BDAA8BC6997338" Guid="{20C09DBB-C8D6-43CF-A9D6-C823850F86F6}">
                <File Source="$(var.WixSlave.TargetDir)\client.wyc" Id="fil7454A527FA7C3918A537EB96235C9F5F" KeyPath="yes"  />
            </Component>
            <Component Id="cmp8CDA926DD93F7CEFBF8FFF444D5828F4" Guid="{2243D9D8-C172-4FFE-AEBE-43659294E55D}">
                <File Source="$(var.WixSlave.TargetDir)\protobuf-net.pdb" Id="fil3EA19C07C51C4E31D37065B3A8620713" KeyPath="yes"  />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="Dlls">
            <ComponentRef Id="cmpA733DB49D89AC9CEA2EDFAAEE51992E7" />
            <ComponentRef Id="cmpF1D751B9621E283AD7BDAA8BC6997338" />
            <ComponentRef Id="cmp8CDA926DD93F7CEFBF8FFF444D5828F4" />
        </ComponentGroup>
    </Fragment>
</Wix>

Dysfunctional XSLT Stub

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="wix:File[{substring(wix:File/@Source, string-length(wix:File/@Source) - 2)}!='dll']"/>
</xsl:stylesheet>
  • This XSLT does not work in many ways, firstly the second match complains, and I’m not sure what is wrong with the expression..

  • Even if that worked, how would you always retain DirectoryRef while removing the mismatching Component and child File elements?

  • Removing the corresponding ComponentRef elements is missing altogether?

Desired XML Output

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="TARGETFOLDER">
            <Component Id="cmpA733DB49D89AC9CEA2EDFAAEE51992E7" Guid="{F3412A8F-5718-45AB-9E6F-7B802BCC0EED}">
                <File Source="$(var.WixSlave.TargetDir)\protobuf-net.dll" Id="fil910D6DB28382BAB5A9DF0ACBD5095ADE" KeyPath="yes" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="Dlls">
            <ComponentRef Id="cmpA733DB49D89AC9CEA2EDFAAEE51992E7" />
        </ComponentGroup>
    </Fragment>
</Wix>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:09:25+00:00Added an answer on June 2, 2026 at 8:09 pm

    Here’s how I would go about it:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
        <xsl:key name="component-id" match="//wix:Component[substring(wix:File/@Source, string-length(wix:File/@Source) - 2) != 'dll']" use="@Id"/>
    
        <xsl:template match="node()|@*">
            <xsl:copy>
                <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="wix:Component[@Id = key('component-id', @Id)/@Id]"/>
    
        <xsl:template match="wix:ComponentRef[@Id = key('component-id', @Id)/@Id]"/>
    </xsl:stylesheet>
    

    The idea is rather simple. Tell XSLT processor to build an index of those Component nodes we want removed and then suppress the xsl:copy with a matching template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large list [[1,.., ..],[2,...,...],[5,...,...],[1,...,...]] I need to remove all elements that
File: /home/USER/DIR/a http://www.here.is.a.hyper.link.net/ /home/USER/DIR/b http://www.here.is.another.hyper.link.net/ Need to remove all the odd lines in this
I need to remove all entries in a dictionary accordingly to a specified lower
I have a problem where I need to remove all code and triggers from
In my application, _collection is a List from which I need to remove all
I'm adding dynamically labels to hbox, and i need to remove all spaces between
I need a way to remove ALL using statements from code and fully qualify
I need to remove the following script from my page(ASP.NET 3.5), leaving all other
I need to remove the Component in the Center of the JPanel , but
I need to remove all the links in my document that start with /{tag_

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.