Subject: [xsl] Transform help From: "Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 27 Jun 2017 16:51:35 -0000 |
I have an XML file with the following format: <?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Fragment> <DirectoryRef Id="WIXUI_INSTALLDIR"> <Component Id="cmpD21EA675EFA6996C0BC35D1EBF6D2457" Guid="*"> <File Id="fil23AD96741A175261995FF2E150D0D117" KeyPath="yes" Source="$(var.SomeVar)\Bar.exe" /> </Component> <Component Id="cmp4CFE705322C198BF47866FF19D0186CC" Guid="*"> <File Id="fil75F8456D557F48D20C117E74D90A6065" KeyPath="yes" Source="$(var.SomeVar)\Baz.exe" /> </Component> <Component Id="cmp90C9500BC764786BCBA4DD0D0E134F54" Guid="*"> <File Id="fil2DB44905B644507065B8C7C6B97B2A02" KeyPath="yes" Source="$(var.SomeVar)\Foo.exe" /> </Component> </DirectoryRef> </Fragment> <Fragment> <ComponentGroup Id="ComponentGroup.Service"> <ComponentRef Id="cmpD21EA675EFA6996C0BC35D1EBF6D2457" /> <ComponentRef Id="cmp4CFE705322C198BF47866FF19D0186CC" /> <ComponentRef Id="cmp90C9500BC764786BCBA4DD0D0E134F54" /> </ComponentGroup> </Fragment> </Wix> I need to apply a transform to re-order the DirectoryRef child elements such that Component/File[@Source="$(var.SomeVar)\Foo.exe"] appears first. I am not really clear on the semantics of template and copy actions as well as template specificity. The following omits the outer Component elements from the File elements; <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output encoding="UTF-8" indent="yes" method="xml" /> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="//wix:DirectoryRef[@Id = 'WIXUI_INSTALLDIR']"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates select="//wix:Component/wix:File[@Id = '$(var.SomeVar)\Foo.exe']" /> <xsl:apply-templates select="//wix:Component/wix:File[@Id != '$(var.SomeVar)\Foo.exe']" /> </xsl:copy> </xsl:template> </xsl:stylesheet> Any idea what I am missing? Thanks, jlc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSLT at the XML Summer School, Priscilla Walmsley p | Thread | Re: [xsl] Transform help, Martin Honnen martin |
Re: [xsl] XSL Condition is not work, Imsieke, Gerrit, le- | Date | Re: [xsl] Transform help, Martin Honnen martin |
Month |