Вопрос

We have a configuration file of the form:

<Container>
    <Item>
        <name>Text</name>
    </Item>
    <Item>
        <name>MoreText</name>
    <Item>
</Container>

and want to add more Item/Name nodes using XMLFile or XMLConfig. While I can add a new empty Item node, I can't select that node itself to add the required name subnode. I've tried using:

ElementPath="/Container/Item[\[]last()[\]]"

After creating the new Item node, but WiX fails to find it.

Have I gone completely off the wall?

Это было полезно?

Решение

Just guessing but the problem may be that the default selection language. IIRC, the old "XSLPattern" selection language is the default and does not support last(). XmlFile lets you set the language. Looks like an oversight on XmlConfig.

Другие советы

In the end I had to hard-code the various numbered s and use Sequence numbers to make sure the order is correct:

<util:XmlConfig Id="NewItem1" Action="create" File="[DIR]\Item.config" ElementPath="/Container" Name="Item" Node="element" On="install" Sequence="50" />
<util:XmlConfig Id="NewName1" Action="create" File="[DIR]\Item.config" ElementPath="/Container/Item[\[]2[\]]" Name="name" Value="MoreText1" Node="element" On="install" Sequence="51" />
<util:XmlConfig Id="CreatePRAlertEmailNode"  Action="create" File="[DIR]\Item.config" ElementPath="/Container" Name="Item" Node="element" On="install" Sequence="52" />
<util:XmlConfig Id="CreatePRAlertEmailName"  Action="create" File="[DIR]\Item.config" ElementPath="/Container/Item[\[]3[\]]" Name="name" Value="MoreText2"  Node="element" On="install" Sequence="53" />
<util:XmlConfig Id="CreatePRAlertRSSNode"    Action="create" File="[DIR]\Item.config" ElementPath="/Container" Name="Item" Node="element" On="install" Sequence="54" />
<util:XmlConfig Id="CreatePRAlertRSSName"    Action="create" File="[DIR]\Item.config" ElementPath="/Container/Item[\[]4[\]]" Name="name" Value="MoreText3"    Node="element" On="install" Sequence="55" />

It's not ideal and needs to changed if the endpoint changes, but it works for now.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top