0

InstallShield プロジェクトで XML システム検索と XML ファイル変更を使用しています。以前のインストールでは、ユーザーがサーバーのホスト名とポートを選択しました。ユーザーが再度インストールするときに、以前の設定が表示されると理想的です。XML システム検索機能を使用して、XML ファイルが存在する場合は、そこから値を読み取るという考え方です。

XML に名前空間情報が含まれていない場合、これを機能させることができます。名前空間のない XML の例を次に示します。

<?xml version="1.0" encoding="UTF-8"?>
<ApplicationSettings ProductVersion="2.4.0.0001" Version="1">
    <Source Mechanism="Server">
        <Server Host="127.0.0.1" Port="11111"></Server>
    </Source>    
</ApplicationSettings>

Server 要素を取得するために使用している XPath クエリは次のとおりです。

/ApplicationSettings/Source/Server

名前空間情報を追加すると、XML システム検索が機能しません。

<?xml version="1.0" encoding="UTF-8"?>
<ApplicationSettings ProductVersion="2.4.0.0001" Version="1" xmlns="http://127.0.0.1/schema/ApplicationSetting.xsd">
    <Source Mechanism="Server">
        <Server Host="127.0.0.1" Port="11111"></Server>
    </Source>    
</ApplicationSettings>

次の XPath 式も試しました。

/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]

これは機能せず、ログでは要素は見つかったようですが、属性は見つかりませんでした:

MSI (c) (84:C8) [10:47:17:836]: Invoking remote custom action. DLL: C:\Users\CZIETS~1\AppData\Local\Temp\MSIFF9E.tmp, Entrypoint: ISXmlAppSearch
InstallShield 10:47:17: Searching for an XML Attribute value using the Element '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]' and the Attribute 'Host'.
InstallShield 10:47:17: Attribute 'Host' not found using the following Element: '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]'. Check for the existence of the Attribute.
InstallShield 10:47:17: Searching for an XML Attribute value using the Element '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]' and the Attribute 'Port'.
InstallShield 10:47:17: Attribute 'Port' not found using the following Element: '/*[local-name() = 'ApplicationSettings' and *[local-name() = 'Source' and *[local-name() = 'Server']]]'. Check for the existence of the Attribute.
Action ended 10:47:17: ISXmlAppSearch. Return value 1.

何か案は?

4

1 に答える 1

2

残念ながら、組み込みのXMLシステム検索は名前空間をサポートしていません。しかし、私はあなたのXPathについて混乱しています。名前空間に依存しない検索は、要素階層を反映するべきではありませんか?せいぜい、子サーバーを持つ子ソースを持つApplicationsSettings要素を見つけるかもしれないと思いますが、Server要素の代わりにApplicationSettings要素を参照してください。それがまったく機能する場合。

変更することをお勧めします:

/ApplicationSettings/Source/Server

代わりにこれに(テストされていない):

/*[local-name() = 'ApplicationSettings']/*[local-name() = 'Source']/*[local-name() = 'Server']
于 2010-11-15T15:25:35.690 に答える