Menu

#2384 XmlFile fails to find XPath under certain namespace

future
migrated
nobody
2014-02-18
2010-12-07
Elmar01
No

Given the file web.config:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<settings001>
<common>
</common>
</settings001>
</configuration>

try adding an element using
<util:xmlfile id="user-content-XmlConfigTes" action="createElement" elementpath="/configuration/settings001/common" name="option001" value="value001" file="&lt;span&gt;[#file001]&lt;/span&gt;" selectionlanguage="XPath"></util:xmlfile>

Then ExecXmlFile reports an error:
"MSI (s) (90!08) [19:51:11:654]: Product: _MyProduct01 -- Error 25532. Failed to find node: /configuration/settings001/common in XML file: C:\Programme_MyProduct01\web.config, system error: -2147020584"

The error disappears if the namespace declaration in web.config is removed.

Discussion

  • Elmar01

    Elmar01 - 2010-12-07

    Sample to reproduce the error

     
  • Elmar01

    Elmar01 - 2010-12-07

    XML file to be modified

     
  • Blair

    Blair - 2010-12-08

    This is by correct design of the XPath specification. None of the elements "configuration", "settings001", or "common" are in the empty namespace, much less the combination in the order you requested. Navigating this XML file using XPath requires configuring the namespace manager, but that configuration is not exposed via the current implementation of this extension element.

    What is needed is to add namespace support to the XmlFile (and XmlConfig) elements so that they can access these types of xml items.

     
  • Elmar01

    Elmar01 - 2010-12-08

    For those faced with the same problem, using XmlConfig worked for me:

    <util:xmlconfig id="user-content-XmlConfigTes" file="&lt;span&gt;[#file001]&lt;/span&gt;" action="create" elementpath="/configuration/settings001/common" name="option001" node="element" value="value001" on="install"></util:xmlconfig>

    XmlConfig resolves the ElementPath although strictly speaking it refers to elements in the empty namespace, not the default namespace. Apparently some extra support for files with a default namespace was added to XmlConfig, see tracker ID 2477689.

     
  • Rob Mensching

    Rob Mensching - 2013-08-21
    • Status: open --> migrated