* Bug 15433 fixed: getPreferencesValue() => xmlGetValues() in [xml] 17/19817/4
Samuel GOUGEON [Thu, 1 Mar 2018 00:42:45 +0000 (01:42 +0100)]
  http://bugzilla.scilab.org/15433

Change-Id: I450a412a03df311c0695a570af48aa4189f09e7f

18 files changed:
scilab/CHANGES.md
scilab/modules/atoms/macros/atomsGetConfig.sci
scilab/modules/atoms/macros/atomsRestoreConfig.sci
scilab/modules/atoms/macros/atomsSaveConfig.sci
scilab/modules/demo_tools/macros/demo_gui.sci
scilab/modules/functions/macros/tree2code.sci
scilab/modules/functions/tests/unit_tests/tree2code.tst
scilab/modules/gui/macros/main_menubar_cb.sci
scilab/modules/helptools/data/configuration/scilab_macros.txt
scilab/modules/preferences/help/en_US/getPreferencesValue.xml
scilab/modules/preferences/help/en_US/setPreferencesValue.xml
scilab/modules/preferences/help/ja_JP/getPreferencesValue.xml
scilab/modules/preferences/help/ja_JP/setPreferencesValue.xml
scilab/modules/preferences/macros/getPreferencesValue.sci
scilab/modules/slint/src/cpp/DeprecatedChecker.cpp
scilab/modules/xml/help/en_US/xmlGetValues.xml [new file with mode: 0644]
scilab/modules/xml/help/ja_JP/xmlGetValues.xml [new file with mode: 0644]
scilab/modules/xml/macros/xmlGetValues.sci [new file with mode: 0644]

index 282e207..23267aa 100644 (file)
@@ -370,6 +370,7 @@ Obsolete functions or features
 * `numer` is obsolete and will be removed in Scilab 6.1. Please use the `.num` rational attribute instead.
 * `with_tk` is obsolete and will be removed in Scilab 6.1. Please use the `with_module` instead.
 * `datatipToggle` is obsolete and will be removed in Scilab 6.1. Please use the `datatipManagerMode` instead.
+* `getPreferencesValue` is obsolete and will be removed in Scilab 6.2. Please use `xmlGetValues` instead.
 
 
 Removed Functions
@@ -549,6 +550,7 @@ Known issues
 * [#15422](http://bugzilla.scilab.org/show_bug.cgi?id=15422): `strsubst("ab", "", "cd")` crashed Scilab.
 * [#15423](http://bugzilla.scilab.org/show_bug.cgi?id=15423): `tbx_make(myModule,sections)` executed the existing builder (if any), instead of targeting only selected module sections. Otherwise, tbx_make(myModule, "help"|"macros") yielded an error, and tbx_make(myModule,"localization") never built it.
 * [#15430](http://bugzilla.scilab.org/show_bug.cgi?id=15430): 47 `Scierror()` errors messages had mismatching input data.
+* [#15433](http://bugzilla.scilab.org/show_bug.cgi?id=15433): `getPreferencesValue` is a general xml utility function and should be renamed and moved to the XML module.
 * [#15440](http://bugzilla.scilab.org/show_bug.cgi?id=15440): Scilab debug help page linked to Xcos debug.
 * [#15441](http://bugzilla.scilab.org/show_bug.cgi?id=15441): `mprintf("%%")` crashed Scilab
 * [#15442](http://bugzilla.scilab.org/show_bug.cgi?id=15442): `printf` could not handle uint64 integers greater than 2^32-1.
index ef30c6d..2e89507 100644 (file)
@@ -65,7 +65,7 @@ function result = atomsGetConfig(field)
     else
         i = find(pref_attrs(1, :) == field);
         if ~isempty(i) then
-            result = getPreferencesValue("//web/body/proxy", pref_attrs(2, i));
+            result = xmlGetValues("//web/body/proxy", pref_attrs(2, i));
             if result == "true" then
                 result = "True";
             elseif result == "false" then
@@ -88,7 +88,7 @@ function result = atomsGetConfig(field)
         config_lines = mgetl(atoms_directory + "config");
     else
         if (rhs == 0)
-            values = getPreferencesValue("//web/body/proxy", pref_attrs(2, :));
+            values = xmlGetValues("//web/body/proxy", pref_attrs(2, :));
             for i = 1:size(pref_attrs, "c")
                 if ~isempty(values(i)) then
                     if values(i) == "true" then
@@ -129,7 +129,7 @@ function result = atomsGetConfig(field)
     end
 
     if (rhs == 0)
-        values = getPreferencesValue("//web/body/proxy", pref_attrs(2, :));
+        values = xmlGetValues("//web/body/proxy", pref_attrs(2, :));
         for i = 1:size(pref_attrs, "c")
             if ~isempty(values(i)) then
                 if values(i) == "true" then
index 3b1dce1..4a484f6 100644 (file)
@@ -27,7 +27,7 @@ function atomsRestoreConfig(quiet)
     end
 
     proxy_attrs = ["enabled", "host", "port", "user", "password"];
-    setPreferencesValue("//web/body/proxy", [proxy_attrs ; getPreferencesValue("//web/body/previous-proxy", proxy_attrs)]);
+    setPreferencesValue("//web/body/proxy", [proxy_attrs ; xmlGetValues("//web/body/previous-proxy", proxy_attrs)]);
 
     pathsystemuser = atomsPath("system", "user");
 
index d9f31b6..d47cb3c 100644 (file)
@@ -29,7 +29,7 @@ function atomsSaveConfig(force)
     pathsystemuser = atomsPath("system", "user");
 
     proxy_attrs = ["enabled", "host", "port", "user", "password"];
-    setPreferencesValue("//web/body/previous-proxy", [proxy_attrs ; getPreferencesValue("//web/body/proxy", proxy_attrs)]);
+    setPreferencesValue("//web/body/previous-proxy", [proxy_attrs ; xmlGetValues("//web/body/proxy", proxy_attrs)]);
 
     if isfile(pathsystemuser + "config.bak") then
         if ~force then
index bbf4700..cb94ccb 100644 (file)
@@ -48,7 +48,7 @@ function demo_gui()
     // =========================================================================
     // We get the user Preferences for the GUI: dockable / not dockable
     File = SCIHOME + "/XConfiguration.xml";
-    r = getPreferencesValue("//general/demonstrations/body/demos","demoGUIisDockable", File);
+    r = xmlGetValues("//general/demonstrations/body/demos","demoGUIisDockable", File);
 
     // We tune accordingly the predefined demo GUI
     File = SCI + "/modules/demo_tools/gui/demo_gui.xml";
index c33b8cb..0da64c8 100644 (file)
@@ -68,7 +68,7 @@ function C = tree2code(P, bprettyprintformat)
         File = "SCIHOME/XConfiguration.xml"
         if isfile(File)
             path = "//interface/scinotes/display/body/scinotes-display"
-            tmp = evstr(getPreferencesValue(path, "indent-size", File))
+            tmp = evstr(xmlGetValues(path, "indent-size", File))
         else
             tmp = 4
         end
index 7d5cd94..8604898 100644 (file)
@@ -47,5 +47,5 @@ function test()
 endfunction
 txt = tree2code(macr2tree(test), %t);
 path = "//interface/scinotes/display/body/scinotes-display";
-tmp = evstr(getPreferencesValue(path, "indent-size", "SCIHOME/XConfiguration.xml"));
+tmp = evstr(xmlGetValues(path, "indent-size", "SCIHOME/XConfiguration.xml"));
 assert_checkequal(txt(2), blanks(tmp)+"disp(2)");
index c007c1b..aef107d 100644 (file)
@@ -34,7 +34,7 @@ function main_menubar_cb(key)
             elseif ext==".scg"
                 load(%fileToOpen);
             elseif basename(%fileToOpen)=="lib"
-                libname = getPreferencesValue("/scilablib","name",%fileToOpen);
+                libname = xmlGetValues("/scilablib","name",%fileToOpen);
                 load(%fileToOpen);
                 mprintf(libname+" loaded.\n");
                 execstr(libname+"=return("+libname+")");
@@ -56,19 +56,19 @@ function main_menubar_cb(key)
         prefFile = SCIHOME + "/scinotesConfiguration.xml";
         try
             tagPath = "//Profile/favoriteDirectories/Directory";
-            r = getPreferencesValue(tagPath, "path", prefFile);
+            r = xmlGetValues(tagPath, "path", prefFile);
         catch
             r = []
         end
         try
             tagPath = "//Profile/recentFiles/document";
-            r2 = getPreferencesValue(tagPath, "path", prefFile);
+            r2 = xmlGetValues(tagPath, "path", prefFile);
         catch
             r2 = []
         end
         try
             tagPath = "//Profile/openFiles/document";
-            r2 = [r2 ; getPreferencesValue(tagPath, "path", prefFile)];
+            r2 = [r2 ; xmlGetValues(tagPath, "path", prefFile)];
         end
 
         if isempty([r;r2]) then
index 6f1e0b7..c2015bd 100644 (file)
@@ -20,7 +20,9 @@
           xmlns:scilab="http://www.scilab.org" xml:id="getPreferencesValue" xml:lang="en">
     <refnamediv>
         <refname>getPreferencesValue</refname>
-        <refpurpose>Parses and gets values of chosen tags attributes in a XML file of preferences</refpurpose>
+        <refpurpose>Parses and gets values of chosen tags attributes in a XML file of preferences
+            <emphasis role="bold">(obsolete)</emphasis>
+        </refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Syntax</title>
     </refsection>
     <refsection>
         <title>Description</title>
+        <warning>
+            <literal>getPreferencesValue()</literal> is obsolete. It is cloned into
+            <code>xmlGetValues()</code>. It will be removed from Scilab 6.2.
+        </warning>
         <para>
             When an XML handle returned by <code>xmlRead(..)</code> is provided as
             <varname>XMLsource</varname>, <function>getPreferencesValue()</function> uses it
@@ -218,6 +224,9 @@ C:\Path\to\another\working\dir2\clf.sci
         <title>See also</title>
         <simplelist type="inline">
             <member>
+                <link linkend="xmlGetValues">xmlGetValues</link>
+            </member>
+            <member>
                 <link linkend="setPreferencesValue">setPreferencesValue</link>
             </member>
             <member>
@@ -264,6 +273,12 @@ C:\Path\to\another\working\dir2\clf.sci
                     </itemizedlist>
                 </revdescription>
             </revision>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revdescription>getPreferencesValue() is cloned into xmlGetValues(). It is
+                    declared obsolete and will be removed from Scilab 6.2.
+                </revdescription>
+            </revision>
         </revhistory>
     </refsection>
 </refentry>
index daa8727..8217a4a 100644 (file)
         <title>Examples</title>
         <programlisting role="example"><![CDATA[
 // Get the current values
-prev = getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"]);
+prev = xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]);
 setPreferencesValue("//web/body/proxy", ["enabled", "host", "port"; "true", "my.proxy.org", "1234"]);
 
 // Ok that's work
-getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"])
+xmlGetValues("//web/body/proxy", ["enabled", "host", "port"])
 
 // We restore the previous values
 setPreferencesValue("//web/body/proxy", ["enabled", "host", "port" ; prev]);
-getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"])
+xmlGetValues("//web/body/proxy", ["enabled", "host", "port"])
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>See also</title>
         <simplelist type="inline">
             <member>
-                <link linkend="getPreferencesValue">getPreferencesValue</link>
+                <link linkend="xmlGetValues">xmlGetValues</link>
             </member>
         </simplelist>
     </refsection>
index c1b59dd..0096c2e 100644 (file)
@@ -16,7 +16,7 @@
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getPreferencesValue" xml:lang="ja">
     <refnamediv>
         <refname>getPreferencesValue</refname>
-        <refpurpose>設定値を取得</refpurpose>
+        <refpurpose>設定値を取得 <emphasis role="bold">(非推奨)</emphasis></refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>呼び出し手順</title>
     </refsection>
     <refsection>
         <title>説明</title>
+        <warning>
+            <literal>getPreferencesValue()</literal> is obsolete. It is cloned into
+            <code>xmlGetValues()</code>. It will be removed from Scilab 6.2.
+        </warning>
         <para>
             設定ファイル(<literal>SCIHOME+'/XConfiguration.xml'</literal>)の
             属性の値を取得します.
@@ -92,7 +96,7 @@
     </web>
     ...
 </interface>
-             ]]></programlisting>
+          ]]></programlisting>
                 <para>
                     パスは<literal>"/interface/web/body/proxy"</literal>
                     (または簡単化するために<literal>"//web/body/proxy"</literal>)
@@ -111,8 +115,40 @@ getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"]);
         <title>参照</title>
         <simplelist type="inline">
             <member>
+                <link linkend="xmlGetValues">xmlGetValues</link>
+            </member>
+            <member>
                 <link linkend="setPreferencesValue">setPreferencesValue</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection role="history">
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revdescription>getPreferencesValue() introduced.
+                </revdescription>
+            </revision>
+            <revision>
+                <revnumber>6.0.0</revnumber>
+                <revdescription>
+                    <itemizedlist>
+                        <listitem>
+                            XMLsource can now be the path + filename of the preferences file.
+                        </listitem>
+                        <listitem>
+                            A tag with multiple occurrences can now be read.
+                        </listitem>
+                    </itemizedlist>
+                </revdescription>
+            </revision>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revdescription>getPreferencesValue() is cloned into xmlGetValues(). It is
+                    declared obsolete and will be removed from Scilab 6.2.
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index b65f5c8..d29415a 100644 (file)
         <title>例</title>
         <programlisting role="example"><![CDATA[
 // カレントの値を取得
-prev = getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"]);
+prev = xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]);
 setPreferencesValue("//web/body/proxy", ["enabled", "host", "port"; "true", "my.proxy.org", "1234"]);
 // 確認します
-getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"])
+xmlGetValues("//web/body/proxy", ["enabled", "host", "port"])
 // 前の値に戻します
 setPreferencesValue("//web/body/proxy", ["enabled", "host", "port" ; prev]);
-getPreferencesValue("//web/body/proxy", ["enabled", "host", "port"])
+xmlGetValues("//web/body/proxy", ["enabled", "host", "port"])
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>参照</title>
         <simplelist type="inline">
             <member>
-                <link linkend="getPreferencesValue">getPreferencesValue</link>
+                <link linkend="xmlGetValues">xmlGetValues</link>
             </member>
         </simplelist>
     </refsection>
index 77c6b07..f8e2275 100644 (file)
@@ -12,6 +12,8 @@
 // along with this program.
 
 function values = getPreferencesValue(xpath, attributes, doc)
+
+    warnobsolete("xmlGetValues", "6.1");
     rhs = argn(2);
 
     if (rhs ~= 2 & rhs ~= 3) then
@@ -79,7 +81,7 @@ function values = getPreferencesValue(xpath, attributes, doc)
             msg = gettext("%s: Target node is not a XML_ELEMENT_NODE.")
             error(msprintf(msg, "getPreferencesValue"));
         end
-    
+
         attr = node.attributes;
         for j = 1:size(attributes,"*")
             a = attributes(j)
index 4275d03..1866a74 100644 (file)
@@ -97,6 +97,7 @@ std::unordered_map<std::wstring, std::wstring> DeprecatedChecker::initDep()
     map.emplace(L"dgettext", L"gettext");
     map.emplace(L"datatipToggle", L"datatipManagerMode");
     map.emplace(L"denom", L".den");
+    map.emplace(L"getPreferencesValue", L"xmlGetValues");
     map.emplace(L"hypermat", L"zeros|matrix");
     map.emplace(L"lstsize", L"size");
     map.emplace(L"nanmin", L"min");
diff --git a/scilab/modules/xml/help/en_US/xmlGetValues.xml b/scilab/modules/xml/help/en_US/xmlGetValues.xml
new file mode 100644 (file)
index 0000000..ad9438b
--- /dev/null
@@ -0,0 +1,256 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+ * Copyright (C) 2017 - Samuel GOUGEON
+ *
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
+          xmlns:scilab="http://www.scilab.org" xml:id="xmlGetValues" xml:lang="en">
+    <refnamediv>
+        <refname>xmlGetValues</refname>
+        <refpurpose>Parses and gets values of chosen tags attributes in a XML file of preferences</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Syntax</title>
+        <synopsis>
+            Values = xmlGetValues(path2tag, attributes)
+            Values = xmlGetValues(path2tag, attributes, XMLsource)
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>path2tag</term>
+                <listitem>
+                    <para>
+                        unique string: in the XML source file, path targeting a chosen tag whose
+                        attributes must be read. The path is the list of nested tags leading to the
+                        required one, such as <literal>"/a/b/c/d"</literal>, or equivalently
+                        <literal>"//b/c/d"</literal>. It is case-sensitive.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>attributes</term>
+                <listitem>
+                    <para>
+                        vector or matrix of strings: names of attributes of the chosen tag, whose values
+                        must be read. The order of attributes does not matter wrt their actual order in
+                        the tag.
+                        <note>
+                            <itemizedlist>
+                                <listitem>
+                                    Attributes names are case-sensitive.
+                                </listitem>
+                                <listitem>
+                                    If needed, the name of a given attribute may be specified several times.
+                                </listitem>
+                            </itemizedlist>
+                        </note>
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>XMLsource</term>
+                <listitem>
+                    <para>
+                        points to the XML document from which informations must be extracted. It
+                        can be one of the following:
+                        <itemizedlist>
+                            <listitem>
+                                unique string: path to the XML source file (where preferences are
+                                registered). By default,
+                                <literal>SCIHOME+'/XConfiguration.xml'</literal> is considered.
+                            </listitem>
+                            <listitem>
+                                XML handle of type <literal>XMLdoc</literal>, as returned by a
+                                prior <code>xmlRead(XMLsource)</code> external instruction.
+                            </listitem>
+                        </itemizedlist>
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>Values</term>
+                <listitem>
+                    <para>
+                        matrix of strings: Values of the chosen attributes of the chosen tag:
+                        <itemizedlist>
+                            <listitem>
+                                If the set of chosen <varname>attributes</varname> is provided as a
+                                matrix with several rows, then only the first occurrence of the chosen
+                                tag is considered, and <varname>Values(i,j)</varname> is the value of
+                                its <varname>attributes(i,j)</varname>.
+                            </listitem>
+                            <listitem>
+                                Otherwise, if the names of <varname>attributes</varname> are
+                                provided in a row vector, then
+                                <emphasis role="italic">all occurences</emphasis> of the chosen tag
+                                are considered: Results are returned with one row per occurrence,
+                                and one colum per attribute. Thus, <varname>Values(i,j)</varname>
+                                is the value of the <varname>attributes(j)</varname> for the
+                                <literal>
+                                    i<superscript>th</superscript>
+                                </literal>
+                                occurrence of the
+                                tag in the document.
+                            </listitem>
+                        </itemizedlist>
+                        If some final values are expected to be numeric rather than literal (text),
+                        <code>evstr()</code> may be applied to them to get expected numbers.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            When an XML handle returned by <code>xmlRead(..)</code> is provided as
+            <varname>XMLsource</varname>, <function>xmlGetValues()</function> uses it
+            directly to parse the XML Preferences document opened by this prior
+            <code>xmlRead(..)</code>. This is useful when the same document must be parsed with
+            multiple calls to <function>xmlGetValues()</function>, typically to address
+            different XML tags. In this case, one should not forget to close the XML document after
+            its whole processing.
+        </para>
+        <para>
+            When the path of the XML Preferences file is provided as <varname>XMLsource</varname>,
+            <function>xmlGetValues()</function> opens the file, builds its DOM tree, parses
+            the tree for the chosen tag and attributes, and finally deletes the tree and closes the
+            file before returning results. This is what occurs with the default Xconfiguration.xml
+            file when no explicit <varname>XMLsource</varname> is specified.
+        </para>
+        <para>
+            The <varname>path2tag</varname> argument must be a valid "XPath" according to the
+            <ulink url="https://www.w3.org/TR/1999/REC-xpath-19991116/">W3C recommandations</ulink>.
+            Examples are given herebelow. If the path uses a intermediate or a final tag that does
+            not exist, or if one of the queried attributes does not exist, an error is yielded.
+        </para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <emphasis role="bold">Example 1:</emphasis>
+        <para>
+            Your web and proxy settings for Scilab are stored in the default
+            <literal>SCIHOME+'/XConfiguration.xml'</literal> preferences file. Let's consider the
+            following excerpt of the file:
+            <programlisting role="xml"><![CDATA[
+    <?xml version="1.0" encoding="utf-8" standalone="no"?>
+    <interface height="600" path="1/" version="0.17" width="800">
+        <general title="_(General)">
+        ...
+        </general>
+        <web title="_(Web)">
+            <body>
+                <web command-browser="" command-mailer="" default-browser="true" default-mailer="true"/>
+                <proxy enabled="false" host="" password="" port="" user=""/>
+                <previous-proxy enabled="false" host="" password="" port="" user=""/>
+            </body>
+        </web>
+        ...
+    </interface>
+              ]]></programlisting>
+        </para>
+        <para>
+            To get some informations about the proxy parameters (proxy tag), the required code
+            will be:
+            <programlisting role="scilab"><![CDATA[
+            proxy = xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]);
+     ]]></programlisting>
+        </para>
+        <para>
+            <emphasis role="bold">Example 2:</emphasis>
+        </para>
+        <para>
+            <function>xmlGetValues()</function> can also be used to get values of a tag
+            having multiple occurrences in the <literal>XMLsource</literal> file. For instance,
+            your preferences for the Scilab's editor Scinotes are stored in the
+            <literal>SCIHOME\scinotesConfiguration.xml</literal> file. The list of most recent files
+            opened in Scinotes is stored in the following part and path:
+            <programlisting role="xml"><![CDATA[
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<Setting version="0.42">
+    <!-- SCINOTES configuration -->
+    <Profile name="scinotes">
+        <!-- .../... -->
+        <!-- Recent Opened Files Section  -->
+        <recentFiles>
+            <document path="C:\Path\to\my\first\working\dir\ged_move_entity.sci"/>
+            <document path="C:\Path\to\my\first\working\dir\ged_loop.sci"/>
+            <document path="C:\Path\to\my\first\working\dir\test_legend_move.sce"/>
+            <document path="C:\Path\to\another\working\dir2\clf.sci"/>
+        </recentFiles>
+        <!-- .../... -->
+    </Profile>
+</Setting>
+              ]]></programlisting>
+        </para>
+        <para>
+            Then, the following code will extract, return and display the column of recent files:
+            <programlisting role="example"><![CDATA[
+            scinotesFile = SCIHOME + "/scinotesConfiguration.xml";
+            recent = xmlGetValues("//Setting/Profile/recentFiles/document", "path", scinotesFile);
+            mprintf("%s\n", recent)
+     ]]></programlisting>
+            <screen><![CDATA[
+C:\Path\to\my\first\working\dir\ged_move_entity.sci
+C:\Path\to\my\first\working\dir\ged_loop.sci
+C:\Path\to\my\first\working\dir\test_legend_move.sce
+C:\Path\to\another\working\dir2\clf.sci
+]]></screen>
+        </para>
+    </refsection>
+    <refsection role="see also">
+        <title>See also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="setPreferencesValue">setPreferencesValue</link>
+            </member>
+            <member>
+                <link linkend="xmlXPath">xmlXPath</link>
+            </member>
+            <member>
+                <ulink url="https://www.w3.org/TR/1999/REC-xpath-19991116/">XML path language</ulink>
+            </member>
+            <member>
+                <link linkend="xmlRead">xmlRead</link>
+            </member>
+            <member>
+                <link linkend="xmlDelete">xmlDelete</link>
+            </member>
+            <member>
+                <link linkend="atomsGetConfig">atomsGetConfig</link>
+            </member>
+            <member>
+                <link linkend="printsetupbox">printsetupbox</link>
+            </member>
+            <member>
+                <link linkend="csvDefault">csvDefault</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection role="history">
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revdescription>xmlGetValues() introduced, was formerly getPreferencesValue().
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/xml/help/ja_JP/xmlGetValues.xml b/scilab/modules/xml/help/ja_JP/xmlGetValues.xml
new file mode 100644 (file)
index 0000000..bae3a21
--- /dev/null
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+ *
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="xmlGetValues" xml:lang="ja">
+    <refnamediv>
+        <refname>xmlGetValues</refname>
+        <refpurpose>設定値を取得</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>呼び出し手順</title>
+        <synopsis>
+            xmlGetValues(xpath, attributes [, doc])
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>引数</title>
+        <variablelist>
+            <varlistentry>
+                <term>xpath</term>
+                <listitem>
+                    <para>文字列,
+                        設定ファイルのノードを取得する
+                        XPathリクエストを表す.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>attributes</term>
+                <listitem>
+                    <para>文字列の行列, 属性名.</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+        <variablelist>
+            <varlistentry>
+                <term>doc</term>
+                <listitem>
+                    <para>XMLDoc型のmlist, 設定ファイルのXML文書.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>説明</title>
+               <warning>This page is not up-to-date. Please consider the english version.</warning>
+        <para>
+            設定ファイル(<literal>SCIHOME+'/XConfiguration.xml'</literal>)の
+            属性の値を取得します.
+        </para>
+        <para>
+            docを指定した場合, 値はこの文書内で探されます.
+            複数のリクエストを実行する必要がある際,
+            同じ設定ファイルを重複してパースすることを避けるために
+            有用です.
+        </para>
+        <para>
+            有効な任意のXPathリクエストを指定できます.
+            例えば,proxy設定を取得するXPathリクエストは以下のように
+            記述できます:
+        </para>
+        <simplelist type="inline">
+            <member>
+                <para>
+                    ファイル<literal>SCIHOME+'/XConfiguration.xml'</literal>
+                    を開き,指定したノードにアクセスするためのノード名を
+                    取得します:
+                </para>
+                <programlisting role="xml"><![CDATA[
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<interface height="600" path="1/" version="0.17" width="800">
+    <general title="_(General)">
+    ...
+    </general>
+    <web title="_(Web)">
+        <body>
+            <web command-browser="" command-mailer="" default-browser="true" default-mailer="true"/>
+            <proxy enabled="false" host="" password="" port="" user=""/>
+            <previous-proxy enabled="false" host="" password="" port="" user=""/>
+        </body>
+    </web>
+    ...
+</interface>
+             ]]></programlisting>
+                <para>
+                    パスは<literal>"/interface/web/body/proxy"</literal>
+                    (または簡単化するために<literal>"//web/body/proxy"</literal>)
+                    となります.
+                </para>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>例</title>
+        <programlisting role="example"><![CDATA[
+xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]);
+ ]]></programlisting>
+    </refsection>
+    <refsection role="see also">
+        <title>参照</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="setPreferencesValue">setPreferencesValue</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection role="history">
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>6.0.2</revnumber>
+                <revdescription>xmlGetValues() introduced, was formerly getPreferencesValue().
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/xml/macros/xmlGetValues.sci b/scilab/modules/xml/macros/xmlGetValues.sci
new file mode 100644 (file)
index 0000000..a1fb295
--- /dev/null
@@ -0,0 +1,104 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+// Copyright (C) 2017 - Samuel GOUGEON
+//
+// Copyright (C) 2012 - 2016 - Scilab Enterprises
+//
+// This file is hereby licensed under the terms of the GNU GPL v2.0,
+// pursuant to article 5.3.4 of the CeCILL v.2.1.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// For more information, see the COPYING file which you should have received
+// along with this program.
+
+function values = xmlGetValues(xpath, attributes, doc)
+    rhs = argn(2);
+
+    if (rhs ~= 2 & rhs ~= 3) then
+        msg = _("%s: Wrong number of input arguments: %d or %d expected.\n")
+        error(msprintf(msg, "xmlGetValues", 2, 3));
+    end
+
+    if type(xpath) <> 10 then
+        msg = _("%s: Wrong type for input argument #%d: String expected.\n")
+        error(msprintf(msg, "xmlGetValues", 1));
+    end
+
+    if type(attributes) <> 10 then
+        msg = _("%s: Wrong type for input argument #%d: Matrix of strings expected.\n")
+        error(msprintf(msg, "xmlGetValues", 2));
+    end
+
+    if rhs == 2 then
+        doc = SCIHOME + "/XConfiguration.xml"
+    end
+    doc0 = doc
+    delDoc = (rhs == 2 | type(doc0)==10)
+    if type(doc)==10 then
+        if isfile(doc)
+            try
+                doc = xmlRead(doc0);
+            catch
+                msg = _("%s: Invalid ""%s"" file.\n")
+                error(msprintf(msg, "xmlGetValues", tokens(doc0,["/" "\"])($)));
+            end
+        else
+            msg = _("%s: The file ""%s"" does not exist.\n")
+            error(msprintf(msg, "xmlGetValues", doc));
+        end
+    elseif typeof(doc) ~= "XMLDoc" then
+        msg = _("%s: Wrong type for input argument #%d: A XMLDoc expected.\n")
+        error(msprintf(msg, "xmlGetValues", 3));
+    end
+
+    try
+        xp = xmlXPath(doc, xpath);
+    catch
+        if delDoc then
+            xmlDelete(doc);
+        end
+        msg = gettext("%s: Invalid XPath request.\n")
+        error(msprintf(msg, "xmlGetValues"));
+    end
+
+    if xp.size == 0 then
+        if delDoc then
+            xmlDelete(doc);
+        end
+        msg = gettext("%s: Invalid XPath request.")
+        error(msprintf(msg, "xmlGetValues"));
+    end
+
+    values = [];
+    for i = 1 : xp.size
+        node = xp(i);
+        if node.type ~= "XML_ELEMENT_NODE" then
+            if delDoc then
+                xmlDelete(doc);
+            end
+            msg = gettext("%s: Target node is not a XML_ELEMENT_NODE.")
+            error(msprintf(msg, "xmlGetValues"));
+        end
+
+        attr = node.attributes;
+        for j = 1:size(attributes,"*")
+            a = attributes(j)
+            v = attr(a);
+            if v ~= [] then
+                values(i,j) = v;
+            else
+                if delDoc then
+                    xmlDelete(doc);
+                end
+                msg = gettext("%s: Invalid attribute name: %s.")
+                error(msprintf(msg, "xmlGetValues", a));
+            end
+        end
+    end
+    if xp.size==1 then
+        values = matrix(values, size(attributes));
+    end
+    if delDoc then
+        xmlDelete(doc);
+    end
+endfunction