{"action":"created","issue":{"url":"https://api.github.com/repos/eXist-db/exist/issues/755","labels_url":"https://api.github.com/repos/eXist-db/exist/issues/755/labels{/name}","comments_url":"https://api.github.com/repos/eXist-db/exist/issues/755/comments","events_url":"https://api.github.com/repos/eXist-db/exist/issues/755/events","html_url":"https://github.com/eXist-db/exist/issues/755","id":97963921,"number":755,"title":"XML RPC, query vs retrieveAll","user":{"login":"ambs","id":118547,"avatar_url":"https://avatars.githubusercontent.com/u/118547?v=3","gravatar_id":"","url":"https://api.github.com/users/ambs","html_url":"https://github.com/ambs","followers_url":"https://api.github.com/users/ambs/followers","following_url":"https://api.github.com/users/ambs/following{/other_user}","gists_url":"https://api.github.com/users/ambs/gists{/gist_id}","starred_url":"https://api.github.com/users/ambs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambs/subscriptions","organizations_url":"https://api.github.com/users/ambs/orgs","repos_url":"https://api.github.com/users/ambs/repos","events_url":"https://api.github.com/users/ambs/events{/privacy}","received_events_url":"https://api.github.com/users/ambs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-29T15:35:20Z","updated_at":"2015-08-12T13:23:55Z","closed_at":null,"body":"Looking to `src/org/exist/xmlrpc/RpcConnection.java`, there are mainly two approaches to query eXist:\r\n\r\n   1. Using the pair `executeQuery` + `retrieve(All)` methods.\r\n   2. Using the `query` method.\r\n\r\nThe second has two interfaces, one returning a byte array, and marked as deprecated in the website, and another one returning a string, that I am not sure if it is deprecated or not. \r\n\r\nNevertheless, using `retrieveAll` or `query` behaves differently. If the query return a set of text() values, the result is the same from both methods: a `<exist:result>` with the strings concatenated. In the other hand, if the query returns a set of URI (for example, mapping `fn:base-uri` to a set of resources), `retrieveAll` returns a `exist:result` with the URI concatenated. If using `query`, the result is a `exist:result` that contain `exist:value` elements.\r\n\r\nIf this difference is the desired one, then I need to know if `query` returning a string is or not deprecated (and I hope it is not). In the other hand, if the difference is not desired, probably this should be fixed.\r\n\r\nLooking to the code, the main different is that `retrieveAll` uses `retrieveAllAsString` that does the following code for each answer:\r\n\r\n``````java\r\n                   if (Type.subTypeOf(current.getType(), Type.NODE)) {\r\n                        current.toSAX(broker, handler, null);\r\n                    } else {\r\n                        value = current.toString().toCharArray();\r\n                        handler.characters(value, 0, value.length);\r\n                    }\r\n``````\r\nthat is, if the result is a XML fragment, return it, if not, string the string without any outer tag.\r\n\r\nIn the other hand, `query` uses `printAll` that has a similar iteration, with this code:\r\n`````java\r\n            if (item.getType() == Type.ELEMENT) {\r\n                final NodeValue node = (NodeValue) item;\r\n                writer.write(serializer.serialize(node));\r\n            } else {\r\n                writer.write(\"<exist:value type=\\\"\");\r\n                writer.write(Type.getTypeName(item.getType()));\r\n                writer.write(\"\\\">\");\r\n                writer.write(item.getStringValue());\r\n                writer.write(\"</exist:value>\");\r\n            }\r\n``````\r\nI am not sure what the difference between a `Type.ELEMENT` or a `Type.NODE`, but I would say the second option is better and should be used in both situations.\r\n\r\nNote that when using the REST API, the structured result is what is obtained. Using the XML-RPC, it depends on what method you call.\r\n\r\n(not sure if I made myself clear, also happy for any extra explanation)"},"comment":{"url":"https://api.github.com/repos/eXist-db/exist/issues/comments/130300092","html_url":"https://github.com/eXist-db/exist/issues/755#issuecomment-130300092","issue_url":"https://api.github.com/repos/eXist-db/exist/issues/755","id":130300092,"user":{"login":"ambs","id":118547,"avatar_url":"https://avatars.githubusercontent.com/u/118547?v=3","gravatar_id":"","url":"https://api.github.com/users/ambs","html_url":"https://github.com/ambs","followers_url":"https://api.github.com/users/ambs/followers","following_url":"https://api.github.com/users/ambs/following{/other_user}","gists_url":"https://api.github.com/users/ambs/gists{/gist_id}","starred_url":"https://api.github.com/users/ambs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambs/subscriptions","organizations_url":"https://api.github.com/users/ambs/orgs","repos_url":"https://api.github.com/users/ambs/repos","events_url":"https://api.github.com/users/ambs/events{/privacy}","received_events_url":"https://api.github.com/users/ambs/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T13:23:55Z","updated_at":"2015-08-12T13:23:55Z","body":"I am working on this, and have code already working, but I am trying to work with Perl XML::eXistDB author in order to make it behaving correctly (I hope).\r\n\r\nBut as far as I cold tell, eXist behavior on some things is quie ad-hoc, and difficult to convince the Perl module of the changed I am proposing.\r\n\r\nTherefore, it would happen if there is a schema describing the `<exist:result>` element.\r\nThe schema it is being used is this one: http://cpansearch.perl.org/src/MARKOV/XML-ExistDB-0.14/lib/XML/eXistDB/xsd-exist/existdb.xsd\r\n\r\nbut as you might notice, it doesn't allow `<exist:result>` to include `<exist:value>`.\r\n\r\nIs there such a document? If not, are you willing to help me to define one?\r\n(in that case I might open another issue to work on that)"}}