tags:

views:

33

answers:

1

How can I get from this:

<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
    <Component Feature="toplevel">
        <File Id="fil8A88F8B155E29670FCA1B83F0E99E635" />
        <TypeLib Id="{DC88F377-25DD-49C8-99D9-1FD8AE484362}" >
            <Interface Id="{5D12ED70-0B5A-49C4-A8A3-FC4C209295BA}" />
            <Interface Id="{73E8EDB7-4293-496D-8ABD-F973F002A033}" />
        </TypeLib>
        <TypeLib Id="{F3C9A192-17C2-4E25-ADB9-89FFEEC0403E}">
            <Interface Id="{89FF44C6-979D-49B6-AF56-EC9509001DE4}" />
        </TypeLib>
    </Component>
</Include>

to this:

<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
    <Component Feature="toplevel">
        <File Id="fil8A88F8B155E29670FCA1B83F0E99E635" >
            <TypeLib Id="{DC88F377-25DD-49C8-99D9-1FD8AE484362}" >
                <Interface Id="{5D12ED70-0B5A-49C4-A8A3-FC4C209295BA}" />
                <Interface Id="{73E8EDB7-4293-496D-8ABD-F973F002A033}" />
            </TypeLib>
            <TypeLib Id="{F3C9A192-17C2-4E25-ADB9-89FFEEC0403E}">
                <Interface Id="{89FF44C6-979D-49B6-AF56-EC9509001DE4}" />
            </TypeLib>
        </File>
    </Component>
</Include>

(move <TypeLib>s inside <File>...)

Thanks,

+1  A: 
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:wi="http://schemas.microsoft.com/wix/2006/wi"
>
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node()[not(self::wi:TypeLib)] | @*" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="wi:File">
    <xsl:copy>
      <xsl:apply-templates select="node() | @* | following-sibling::wi:TypeLib" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

Result:

<Include xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
  <Component Feature="toplevel">
    <File Id="fil8A88F8B155E29670FCA1B83F0E99E635">
      <TypeLib Id="{DC88F377-25DD-49C8-99D9-1FD8AE484362}">
        <Interface Id="{5D12ED70-0B5A-49C4-A8A3-FC4C209295BA}"></Interface>
        <Interface Id="{73E8EDB7-4293-496D-8ABD-F973F002A033}"></Interface>
      </TypeLib>
      <TypeLib Id="{F3C9A192-17C2-4E25-ADB9-89FFEEC0403E}">
        <Interface Id="{89FF44C6-979D-49B6-AF56-EC9509001DE4}"></Interface>
      </TypeLib>
    </File>
  </Component>
</Include>

This works like this:

  1. the identity template (the first one) does explicitly exclude <TypeLib> children
  2. a custom template handles <File> nodes, nesting all the following <TypeLib> nodes, i.e. making them children of <File>
  3. this invokes the identity template for <TypeLib> nodes, which now perfectly copies them
Tomalak
thanks, but that seems to copy the TypeLib's, rather than move them...
I've tested it and it produces exactly the output I show in my answer. Have you tested with the stylesheet as I supplied it, or did you mix and match with your existing code?
Tomalak
mix and match... thing is, I have lots of other templates already defined... would it be useful if I upload the whole .xsl?