views:

31

answers:

1

I'm using WiX to author a Windows Installation database for my application. I've got an XML file that is installed along with my app, which needs to be filled with information obtained during installation. The WiXUtilExtension tags util:XmlFile and util:XmlConfig are great ways to do this, in principle, but they don't quite solve my problem. Specifically, I need to insert some javascript:

<?js
    //some javascript that must include formatted string properties
    //so that [PropertyName] evaluates to its value during installation
?>

but with that text as the value of the util:XmlFile/@Value attribute, it won't compile (no surprise - error CNDL0104). And neither backslash nor [\ ] (escape sequence for square bracket) seem to escape the greater-than or less-than characters.

I also tried placing the inserted text into the inner text of the util:XmlConfig element, but with the Javascript tag present, it just ignores the text. Wrapping the inner text in CDATA tags inserts the text, but replaces the greater- and less-than characters with their entities "& gt;" and "& lt;", without the quotes and spaces.

What's the trick?

EDIT: Still struggling with this problem, but some more details might help clarify further. Here's an example of an XML file with the structure I need to modify on install.

<?xml version="1.0"?>
<RootElement>
    <SubElement>
        <?js
            //insert Javascript here with formatted property values e.g. [PropertyName]
        ?>
    </SubElement>
</RootElement>

In my WiX code, I had:

<util:XmlConfig Id="EditXml" File="foo.xml" Action="create" Node="value" On="install" ElementPath="//RootElement/SubElement" Sequence="1" >
    <![CDATA[//the Javascript code]]>
</util:XmlConfig>

which, of course, placed the text next to the Javascript processing instruction, rather than within it. So I looked into accessing XML processing instruction tags with XPath, thinking that perhaps I wasn't using the correct value for the util:XmlConfig/@ElementPath attribute. I've never used XPath before, but I thought one of the following changes would work:

ElementPath="//RootElement/SubElement/processing-instruction('js')"
ElementPath="processing-instruction('js')//RootElement/SubElement"
ElementPath="//processing-instruction('js')"
ElementPath="processing-instruction('js')"

but to no avail. Am I just off with this syntax, or is there another solution altogether?

Thanks in advance for the help!

+1  A: 

I don't have the tools to verify that this works, but I would try replacing them with their entities (&gt; and &lt;), but don't wrap it in a CDATA block. Entities essentially are the "escape sequence" for raw XML.

Matt Bridges
I did try that, but the XML retained only the entities, rather than the greater- and less-than characters that I need.
Michael Repucci