wix xsl transform to conditionally remove components












1















I'm creating a transform for WiX's heat utility that needs to suppress the harvesting of folders matching a specific name (.PayloadData) under the tree being harvested.



I can easily get it to suppress the Directory and Component elements but the ComponentRef element is proving tricky.



The folder is called .PayloadData and this successfully suppresses the Directory and Component elements:



  <xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:Directory[@Name='.PayloadData']/*" />


I tried something similar for the ComponentRef element but it matches everything.



<xsl:template match="wix:ComponentRef[//wix:Directory[@Name='.PayloadData']/wix:Component[@Id=@Id]]">


I think @Id might be ambiguous in the xpath expression but I don't know how to tell it that the ComponentRef's Id attribute is trying to match the Component's Id attribute.



Here's the input:



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirFD22039A64AC1D31F568C1632B5AF8A3" Name=".PayloadData">
<Component Id="cmp846A29F6413B27E8777DD68E6026E461" Guid="*">
<File Id="fil9227EFCE377E7FEBB63A4BD121F278AE" KeyPath="yes" Source="$(var.SampleDataDir).PayloadDataSampleData.xml" />
</Component>
</Directory>
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp846A29F6413B27E8777DD68E6026E461" />
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


And this is the desired output



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


It needs to strip out:




  • Directory dirFD22039A64AC1D31F568C1632B5AF8A3

  • Component cmp846A29F6413B27E8777DD68E6026E461

  • ComponentRef cmp846A29F6413B27E8777DD68E6026E461










share|improve this question

























  • Do you know what // means?

    – michael.hor257k
    Nov 27 '18 at 11:40











  • You will probably get help sooner if you add an example of an input document into the question.

    – Ainar-G
    Nov 27 '18 at 11:46











  • Yes, // means search the entire document. I'll post the sample documents shortly. I need a before and intended result document. For those that don't know, heat applies the transform in memory so I don't get the before document unless I remove my transform from the flow.

    – daughey
    Nov 27 '18 at 13:35











  • "Yes, // means search the entire document." Exactly. So if the condition is true, it will be true for alll ComponentRef nodes.

    – michael.hor257k
    Nov 27 '18 at 14:36






  • 1





    P.S. If you need to match the ComponentRef and Component based on common id, define and use a key.

    – michael.hor257k
    Nov 27 '18 at 14:39


















1















I'm creating a transform for WiX's heat utility that needs to suppress the harvesting of folders matching a specific name (.PayloadData) under the tree being harvested.



I can easily get it to suppress the Directory and Component elements but the ComponentRef element is proving tricky.



The folder is called .PayloadData and this successfully suppresses the Directory and Component elements:



  <xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:Directory[@Name='.PayloadData']/*" />


I tried something similar for the ComponentRef element but it matches everything.



<xsl:template match="wix:ComponentRef[//wix:Directory[@Name='.PayloadData']/wix:Component[@Id=@Id]]">


I think @Id might be ambiguous in the xpath expression but I don't know how to tell it that the ComponentRef's Id attribute is trying to match the Component's Id attribute.



Here's the input:



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirFD22039A64AC1D31F568C1632B5AF8A3" Name=".PayloadData">
<Component Id="cmp846A29F6413B27E8777DD68E6026E461" Guid="*">
<File Id="fil9227EFCE377E7FEBB63A4BD121F278AE" KeyPath="yes" Source="$(var.SampleDataDir).PayloadDataSampleData.xml" />
</Component>
</Directory>
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp846A29F6413B27E8777DD68E6026E461" />
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


And this is the desired output



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


It needs to strip out:




  • Directory dirFD22039A64AC1D31F568C1632B5AF8A3

  • Component cmp846A29F6413B27E8777DD68E6026E461

  • ComponentRef cmp846A29F6413B27E8777DD68E6026E461










share|improve this question

























  • Do you know what // means?

    – michael.hor257k
    Nov 27 '18 at 11:40











  • You will probably get help sooner if you add an example of an input document into the question.

    – Ainar-G
    Nov 27 '18 at 11:46











  • Yes, // means search the entire document. I'll post the sample documents shortly. I need a before and intended result document. For those that don't know, heat applies the transform in memory so I don't get the before document unless I remove my transform from the flow.

    – daughey
    Nov 27 '18 at 13:35











  • "Yes, // means search the entire document." Exactly. So if the condition is true, it will be true for alll ComponentRef nodes.

    – michael.hor257k
    Nov 27 '18 at 14:36






  • 1





    P.S. If you need to match the ComponentRef and Component based on common id, define and use a key.

    – michael.hor257k
    Nov 27 '18 at 14:39
















1












1








1








I'm creating a transform for WiX's heat utility that needs to suppress the harvesting of folders matching a specific name (.PayloadData) under the tree being harvested.



I can easily get it to suppress the Directory and Component elements but the ComponentRef element is proving tricky.



The folder is called .PayloadData and this successfully suppresses the Directory and Component elements:



  <xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:Directory[@Name='.PayloadData']/*" />


I tried something similar for the ComponentRef element but it matches everything.



<xsl:template match="wix:ComponentRef[//wix:Directory[@Name='.PayloadData']/wix:Component[@Id=@Id]]">


I think @Id might be ambiguous in the xpath expression but I don't know how to tell it that the ComponentRef's Id attribute is trying to match the Component's Id attribute.



Here's the input:



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirFD22039A64AC1D31F568C1632B5AF8A3" Name=".PayloadData">
<Component Id="cmp846A29F6413B27E8777DD68E6026E461" Guid="*">
<File Id="fil9227EFCE377E7FEBB63A4BD121F278AE" KeyPath="yes" Source="$(var.SampleDataDir).PayloadDataSampleData.xml" />
</Component>
</Directory>
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp846A29F6413B27E8777DD68E6026E461" />
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


And this is the desired output



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


It needs to strip out:




  • Directory dirFD22039A64AC1D31F568C1632B5AF8A3

  • Component cmp846A29F6413B27E8777DD68E6026E461

  • ComponentRef cmp846A29F6413B27E8777DD68E6026E461










share|improve this question
















I'm creating a transform for WiX's heat utility that needs to suppress the harvesting of folders matching a specific name (.PayloadData) under the tree being harvested.



I can easily get it to suppress the Directory and Component elements but the ComponentRef element is proving tricky.



The folder is called .PayloadData and this successfully suppresses the Directory and Component elements:



  <xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:Directory[@Name='.PayloadData']/*" />


I tried something similar for the ComponentRef element but it matches everything.



<xsl:template match="wix:ComponentRef[//wix:Directory[@Name='.PayloadData']/wix:Component[@Id=@Id]]">


I think @Id might be ambiguous in the xpath expression but I don't know how to tell it that the ComponentRef's Id attribute is trying to match the Component's Id attribute.



Here's the input:



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirFD22039A64AC1D31F568C1632B5AF8A3" Name=".PayloadData">
<Component Id="cmp846A29F6413B27E8777DD68E6026E461" Guid="*">
<File Id="fil9227EFCE377E7FEBB63A4BD121F278AE" KeyPath="yes" Source="$(var.SampleDataDir).PayloadDataSampleData.xml" />
</Component>
</Directory>
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp846A29F6413B27E8777DD68E6026E461" />
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


And this is the desired output



<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)..CommonCommon.wxi?>
<Fragment>
<DirectoryRef Id="SampleDataDir">
<Directory Id="dirA4E41FB410D214A14F0C8A302E5E70D2" Name="AlternativePBS">
<Component Id="cmp3E04EEF702FDD121FD225ABF32550EDB" Guid="*">
<File Id="filF1367714C6CE3472899C32E78D3D6D0C" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS1-ADMIN_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp6732C6415C5574DB586333DE13FAFD1C" Guid="*">
<File Id="fil7F1A16AA0DA338664312C832796DD228" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBS2-SCHEMA_Update_PBSHierarchy.xml" />
</Component>
<Component Id="cmp01BD73A317794376E5323FA329D1BFEB" Guid="*">
<File Id="filFD2213EB9E67560F25B506695650F7B0" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSProcedureForAltPBSStructure.doc" />
</Component>
<Component Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" Guid="*">
<File Id="filC02D64539D33E6B5250C883EFF6357DD" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSSPFAdapter_PBS.xml" />
</Component>
<Component Id="cmp428BA2587DEE28B22239181E175B108B" Guid="*">
<File Id="fil8D32FED82C161537AE2432BFA7F89310" KeyPath="yes" Source="$(var.SampleDataDir)AlternativePBSUpdatePBSHierarchyGraphDef.xmlldr" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_SampleData">
<ComponentRef Id="cmp3E04EEF702FDD121FD225ABF32550EDB" />
<ComponentRef Id="cmp6732C6415C5574DB586333DE13FAFD1C" />
<ComponentRef Id="cmp01BD73A317794376E5323FA329D1BFEB" />
<ComponentRef Id="cmp1E93AAFF75E01670D20E84280E7B9B5C" />
<ComponentRef Id="cmp428BA2587DEE28B22239181E175B108B" />
</ComponentGroup>
</Fragment>
</Wix>


It needs to strip out:




  • Directory dirFD22039A64AC1D31F568C1632B5AF8A3

  • Component cmp846A29F6413B27E8777DD68E6026E461

  • ComponentRef cmp846A29F6413B27E8777DD68E6026E461







xslt wix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 13:51







daughey

















asked Nov 27 '18 at 11:17









daugheydaughey

43039




43039













  • Do you know what // means?

    – michael.hor257k
    Nov 27 '18 at 11:40











  • You will probably get help sooner if you add an example of an input document into the question.

    – Ainar-G
    Nov 27 '18 at 11:46











  • Yes, // means search the entire document. I'll post the sample documents shortly. I need a before and intended result document. For those that don't know, heat applies the transform in memory so I don't get the before document unless I remove my transform from the flow.

    – daughey
    Nov 27 '18 at 13:35











  • "Yes, // means search the entire document." Exactly. So if the condition is true, it will be true for alll ComponentRef nodes.

    – michael.hor257k
    Nov 27 '18 at 14:36






  • 1





    P.S. If you need to match the ComponentRef and Component based on common id, define and use a key.

    – michael.hor257k
    Nov 27 '18 at 14:39





















  • Do you know what // means?

    – michael.hor257k
    Nov 27 '18 at 11:40











  • You will probably get help sooner if you add an example of an input document into the question.

    – Ainar-G
    Nov 27 '18 at 11:46











  • Yes, // means search the entire document. I'll post the sample documents shortly. I need a before and intended result document. For those that don't know, heat applies the transform in memory so I don't get the before document unless I remove my transform from the flow.

    – daughey
    Nov 27 '18 at 13:35











  • "Yes, // means search the entire document." Exactly. So if the condition is true, it will be true for alll ComponentRef nodes.

    – michael.hor257k
    Nov 27 '18 at 14:36






  • 1





    P.S. If you need to match the ComponentRef and Component based on common id, define and use a key.

    – michael.hor257k
    Nov 27 '18 at 14:39



















Do you know what // means?

– michael.hor257k
Nov 27 '18 at 11:40





Do you know what // means?

– michael.hor257k
Nov 27 '18 at 11:40













You will probably get help sooner if you add an example of an input document into the question.

– Ainar-G
Nov 27 '18 at 11:46





You will probably get help sooner if you add an example of an input document into the question.

– Ainar-G
Nov 27 '18 at 11:46













Yes, // means search the entire document. I'll post the sample documents shortly. I need a before and intended result document. For those that don't know, heat applies the transform in memory so I don't get the before document unless I remove my transform from the flow.

– daughey
Nov 27 '18 at 13:35





Yes, // means search the entire document. I'll post the sample documents shortly. I need a before and intended result document. For those that don't know, heat applies the transform in memory so I don't get the before document unless I remove my transform from the flow.

– daughey
Nov 27 '18 at 13:35













"Yes, // means search the entire document." Exactly. So if the condition is true, it will be true for alll ComponentRef nodes.

– michael.hor257k
Nov 27 '18 at 14:36





"Yes, // means search the entire document." Exactly. So if the condition is true, it will be true for alll ComponentRef nodes.

– michael.hor257k
Nov 27 '18 at 14:36




1




1





P.S. If you need to match the ComponentRef and Component based on common id, define and use a key.

– michael.hor257k
Nov 27 '18 at 14:39







P.S. If you need to match the ComponentRef and Component based on common id, define and use a key.

– michael.hor257k
Nov 27 '18 at 14:39














1 Answer
1






active

oldest

votes


















0














Thank you for your help. I now have the answer. Key was the key (pun intended):



  <xsl:key name="ComponentsToSuppress" match="wix:Component[ancestor::wix:Directory[@Name='.PayloadData']]" use="@Id" />
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:ComponentRef[key('ComponentsToSuppress', @Id)]" />


This allows me to suppress the Component and ComponentRef of items appearing under a Directory named ".PayloadData" regardless of where it appears (or how often it appears).






share|improve this answer





















  • 1





    I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

    – michael.hor257k
    Nov 27 '18 at 16:29











  • Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

    – daughey
    Nov 27 '18 at 21:15











  • Answer updated. Thank you.

    – daughey
    Nov 27 '18 at 21:30











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53498481%2fwix-xsl-transform-to-conditionally-remove-components%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Thank you for your help. I now have the answer. Key was the key (pun intended):



  <xsl:key name="ComponentsToSuppress" match="wix:Component[ancestor::wix:Directory[@Name='.PayloadData']]" use="@Id" />
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:ComponentRef[key('ComponentsToSuppress', @Id)]" />


This allows me to suppress the Component and ComponentRef of items appearing under a Directory named ".PayloadData" regardless of where it appears (or how often it appears).






share|improve this answer





















  • 1





    I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

    – michael.hor257k
    Nov 27 '18 at 16:29











  • Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

    – daughey
    Nov 27 '18 at 21:15











  • Answer updated. Thank you.

    – daughey
    Nov 27 '18 at 21:30
















0














Thank you for your help. I now have the answer. Key was the key (pun intended):



  <xsl:key name="ComponentsToSuppress" match="wix:Component[ancestor::wix:Directory[@Name='.PayloadData']]" use="@Id" />
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:ComponentRef[key('ComponentsToSuppress', @Id)]" />


This allows me to suppress the Component and ComponentRef of items appearing under a Directory named ".PayloadData" regardless of where it appears (or how often it appears).






share|improve this answer





















  • 1





    I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

    – michael.hor257k
    Nov 27 '18 at 16:29











  • Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

    – daughey
    Nov 27 '18 at 21:15











  • Answer updated. Thank you.

    – daughey
    Nov 27 '18 at 21:30














0












0








0







Thank you for your help. I now have the answer. Key was the key (pun intended):



  <xsl:key name="ComponentsToSuppress" match="wix:Component[ancestor::wix:Directory[@Name='.PayloadData']]" use="@Id" />
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:ComponentRef[key('ComponentsToSuppress', @Id)]" />


This allows me to suppress the Component and ComponentRef of items appearing under a Directory named ".PayloadData" regardless of where it appears (or how often it appears).






share|improve this answer















Thank you for your help. I now have the answer. Key was the key (pun intended):



  <xsl:key name="ComponentsToSuppress" match="wix:Component[ancestor::wix:Directory[@Name='.PayloadData']]" use="@Id" />
<xsl:template match="wix:Directory[@Name='.PayloadData']" />
<xsl:template match="wix:ComponentRef[key('ComponentsToSuppress', @Id)]" />


This allows me to suppress the Component and ComponentRef of items appearing under a Directory named ".PayloadData" regardless of where it appears (or how often it appears).







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 27 '18 at 21:30

























answered Nov 27 '18 at 15:27









daugheydaughey

43039




43039








  • 1





    I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

    – michael.hor257k
    Nov 27 '18 at 16:29











  • Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

    – daughey
    Nov 27 '18 at 21:15











  • Answer updated. Thank you.

    – daughey
    Nov 27 '18 at 21:30














  • 1





    I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

    – michael.hor257k
    Nov 27 '18 at 16:29











  • Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

    – daughey
    Nov 27 '18 at 21:15











  • Answer updated. Thank you.

    – daughey
    Nov 27 '18 at 21:30








1




1





I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

– michael.hor257k
Nov 27 '18 at 16:29





I believe your 2nd template is redundant. Also. // doesn't do anything in a match pattern.

– michael.hor257k
Nov 27 '18 at 16:29













Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

– daughey
Nov 27 '18 at 21:15





Yeah, I think you're right. I was thinking about it after I'd posted it. I'll try it to make sure it doesn't change the outcome and update the answer accordingly.

– daughey
Nov 27 '18 at 21:15













Answer updated. Thank you.

– daughey
Nov 27 '18 at 21:30





Answer updated. Thank you.

– daughey
Nov 27 '18 at 21:30




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53498481%2fwix-xsl-transform-to-conditionally-remove-components%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks