XMLDoc==XMLDoc definition

classic Classic list List threaded Threaded
4 messages Options
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

XMLDoc==XMLDoc definition

Hello,

Before posting any report on Bugzilla, i would like to understand why we get [%t %t] instead of %t when we compare 2 XMLDoc objects. Is it a bug, or is it intentional?:
--> doc = xmlReadStr("<root><a att=""foo"" rib=""bar""><b>Hello</b></a></root>")
 doc  =
XML Document
url: Undefined
root: XML Element

--> doc2 = doc;
--> doc==doc2
 ans  =
  T T           <<<<<<<<<<<<<<<<<<<<<< Here
--> xmlDelete(doc), clear doc doc2


Since XMLDoc objects are of type 17, i was naively searching for a %XMLDoc_o_XMLDoc() overload.
But the XML module does not have such a macro overload.
I also searched in the XML src and gateway source directories, without success.
XML overloads are not documented. The only overload having a unit test is for size().

Any clue where the XMLDoc==XMLDoc comparison is defined?

If XMLDoc objects are not regular mlists, why a specific type code distinct from 17 has not been ascribed to them?

Thanks
Samuel


_______________________________________________
dev mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/dev
Antoine ELIAS-2 Antoine ELIAS-2
Reply | Threaded
Open this post in threaded view
|

Re: XMLDoc==XMLDoc definition

Hello Samuel,

Example outside of xml "object" (lot of overloads)
a = mlist(["toto", "id"], 1);
b = mlist(["toto", "id"], 1);
a == b -> [%t %t]

For mlist we compare the type ("toto") and fields  ("id" in this case)

Regards,
Antoine
Le 28/07/2018 à 16:47, Samuel Gougeon a écrit :
Hello,

Before posting any report on Bugzilla, i would like to understand why we get [%t %t] instead of %t when we compare 2 XMLDoc objects. Is it a bug, or is it intentional?:
--> doc = xmlReadStr("<root><a att=""foo"" rib=""bar""><b>Hello</b></a></root>")
 doc  =
XML Document
url: Undefined
root: XML Element

--> doc2 = doc;
--> doc==doc2
 ans  =
  T T           <<<<<<<<<<<<<<<<<<<<<< Here
--> xmlDelete(doc), clear doc doc2


Since XMLDoc objects are of type 17, i was naively searching for a %XMLDoc_o_XMLDoc() overload.
But the XML module does not have such a macro overload.
I also searched in the XML src and gateway source directories, without success.
XML overloads are not documented. The only overload having a unit test is for size().

Any clue where the XMLDoc==XMLDoc comparison is defined?

If XMLDoc objects are not regular mlists, why a specific type code distinct from 17 has not been ascribed to them?

Thanks
Samuel



_______________________________________________
dev mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/dev


_______________________________________________
dev mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/dev
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: XMLDoc==XMLDoc definition

Hello Antoine,

Thanks for your quick answer:

Le 28/07/2018 à 18:28, Antoine ELIAS a écrit :
Hello Samuel,

Example outside of xml "object" (lot of overloads)
a = mlist(["toto", "id"], 1);
b = mlist(["toto", "id"], 1);
a == b -> [%t %t]

For mlist we compare the type ("toto") and fields  ("id" in this case)

and
--> a = mlist(["aBcD", "id" "id2"], 1, 2);
--> a==a
 ans  =
  T T T

OK: so
a) there is actually a default equality definition
b) it is actually type+fields-wise
c) it looks not documented: none of the list, mlist, tlist, overloading, comparison, and equal pages indicate it.
d) it is overloadable:
function r = %aBcD_o_aBcD(a, b)
    r = typeof(a)==typeof(b);
    af = fieldnames(a);
    r = r & and(af==fieldnames(b));
    for f = af'
        r = r & and(a(f)==b(f))
    end
endfunction
--> a==a
 ans  =
  T

Thanks
Samuel

_______________________________________________
dev mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/dev
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: XMLDoc==XMLDoc definition

Le 28/07/2018 à 18:54, Samuel Gougeon a écrit :
Hello Antoine,

Thanks for your quick answer:

Le 28/07/2018 à 18:28, Antoine ELIAS a écrit :
Hello Samuel,

Example outside of xml "object" (lot of overloads)
a = mlist(["toto", "id"], 1);
b = mlist(["toto", "id"], 1);
a == b -> [%t %t]

For mlist we compare the type ("toto") and fields  ("id" in this case)

and
--> a = mlist(["aBcD", "id" "id2"], 1, 2);
--> a==a
 ans  =
  T T T

OK: so
a) there is actually a default equality definition
b) it is actually type+fields-wise
c) it looks not documented: none of the list, mlist, tlist, overloading, comparison, and equal pages indicate it.
d) it is overloadable:
function r = %aBcD_o_aBcD(a, b)
    r = typeof(a)==typeof(b);
    af = fieldnames(a);
    r = r & and(af==fieldnames(b));
    for f = af'
        r = r & and(a(f)==b(f))
    end
endfunction
--> a==a
 ans  =
  T

For a overall lists comparison, we may also use directly
--> isequal(a,a)
 ans  =
  T


_______________________________________________
dev mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/dev