1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
3 // Copyright (C) 2017 - Samuel GOUGEON
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
14 function values = getPreferencesValue(xpath, attributes, doc)
16 warnobsolete("xmlGetValues", "6.1");
19 if (rhs ~= 2 & rhs ~= 3) then
20 msg = _("%s: Wrong number of input arguments: %d or %d expected.\n")
21 error(msprintf(msg, "getPreferencesValue", 2, 3));
24 if type(xpath) <> 10 then
25 msg = _("%s: Wrong type for input argument #%d: String expected.\n")
26 error(msprintf(msg, "getPreferencesValue", 1));
29 if type(attributes) <> 10 then
30 msg = _("%s: Wrong type for input argument #%d: Matrix of strings expected.\n")
31 error(msprintf(msg, "getPreferencesValue", 2));
35 doc = SCIHOME + "/XConfiguration.xml"
38 delDoc = (rhs == 2 | type(doc0)==10)
44 msg = _("%s: Invalid ""%s"" file.\n")
45 error(msprintf(msg, "getPreferencesValue", tokens(doc0,["/" "\"])($)));
48 msg = _("%s: The file ""%s"" does not exist.\n")
49 error(msprintf(msg, "getPreferencesValue", doc));
51 elseif typeof(doc) ~= "XMLDoc" then
52 msg = _("%s: Wrong type for input argument #%d: A XMLDoc expected.\n")
53 error(msprintf(msg, "getPreferencesValue", 3));
57 xp = xmlXPath(doc, xpath);
62 msg = gettext("%s: Invalid XPath request.\n")
63 error(msprintf(msg, "getPreferencesValue"));
70 msg = gettext("%s: Invalid XPath request.")
71 error(msprintf(msg, "getPreferencesValue"));
77 if node.type ~= "XML_ELEMENT_NODE" then
81 msg = gettext("%s: Target node is not a XML_ELEMENT_NODE.")
82 error(msprintf(msg, "getPreferencesValue"));
85 attr = node.attributes;
86 for j = 1:size(attributes,"*")
95 msg = gettext("%s: Invalid attribute name: %s.")
96 error(msprintf(msg, "getPreferencesValue", a));
101 values = matrix(values, size(attributes));