I have a WXS file that was generated by WiX's heat utility. I'm trying to modify it with an (existing) exclusions.xslt file to automatically exclude certain components based on the contents of another XML file (I'll call this parts.xml). The xslt file is currently used to remove some components/files/directories from the installer, but for a relatively static list.
However, for right now, my primary concern is just getting it to load and store the correct path from the parameter and store its contents in a variable.
This is how the transform is applied (once WiX is finished harvesting with heat to a file "before.wxs"):
msxsl.exe "before.wxs" "exclusions.xslt" -o "after.wxs" src="$(Src)"
I passed in src to be a parameter within the XSLT file that will be used to find parts.xml on the user's machine.
To get the parameter from the command line and replace all back slashes with forward slashes:
<!-- Adapted from http://stackoverflow.com/a/30153713/5605122 and http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx--> <xsl:param name="src" /> <xsl:variable name="filename"> <xsl:call-template name="string-replace-all"> <xsl:with-param name="text" select="concat('file://', $srcroot, '/foo/parts.xml')" /> <xsl:with-param name="replace" select='\\' /> <xsl:with-param name="by" select='/' /> </xsl:call-template> </xsl:variable> <xsl:variable name="myparts" select="document($filename)" />
The string-replace-all that I got from here is:
<!-- XSL 1.0 string-replace-all, taken from: http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx --> <xsl:template name="string-replace-all"> <xsl:param name="text" /> <xsl:param name="replace" /> <xsl:param name="by" /> <xsl:choose> <xsl:when test="contains($text, $replace)"> <xsl:value-of select="substring-before($text,$replace)" /> <xsl:value-of select="$by" /> <xsl:call-template name="string-replace-all"> <xsl:with-param name="text" select="substring-after($text,$replace)" /> <xsl:with-param name="replace" select="$replace" /> <xsl:with-param name="by" select="$by" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text" /> </xsl:otherwise> </xsl:choose> </xsl:template>
I am getting a rather unhelpful error:
Code: 0x80004005 Unexpected character in query string.
but if I remove just the code snippets I've posted, the error goes away. I'm not sure how to debug into this and figure out what's going on, but after looking through it, I believe I have a fundamental misunderstanding of what I think should happen, rather than just a typo or syntax error.
Ultimately, I want the contents of parts.xml to be stored in "myparts". What am I missing here?
Thanks!
No comments:
Post a Comment