From mmcrae at iqsolutions.com Wed Jan 6 10:28:35 2016 From: mmcrae at iqsolutions.com (Mary McRae) Date: Wed, 6 Jan 2016 18:28:35 +0000 Subject: [xquery-talk] trying to retrieve element value Message-ID: Sorry for what is probably a very basic question; I've read through a number of XQuery tutorials but haven't been able to come up with something that yields the expected results. I have a MarkLogic database, which contains a few thousand XML documents. I'm trying to return the value of the ML UID (captured in the XML document as ) for a known document identifier . I've tried several variants of the following, but each returns the full set of system-pub-ids rather than the one matching the specified id value. I've tried running through oXygen as well as the MarkLogic console; I get the same results (which I suppose is a good thing). I'm pretty certain that I'm missing something obvious, and appreciate any pointers. I started with this: xquery version "1.0-ml"; for $mlid in /samhsa-doc//system-pub-id where /samhsa-doc//article-title[@id="AVD210_art1"] return $mlid but when I got the full list back (some 14,000 items - many of which don't have an article-title) I thought I'd try starting at the root ... XQuery: xquery version "1.0-ml"; for $mlid in /samhsa-doc where /samhsa-doc//article-title[@id='AVD210_art1'] return $mlid//system-pub-id XML: Archived 100001 Internal and External
... ... Thank you in advance, Mary Mary McRae, PMP?| XML Strategist / Technical Project Manager?| mmcrae at iqsolutions.com From patrick at durusau.net Wed Jan 6 11:38:22 2016 From: patrick at durusau.net (Patrick Durusau) Date: Wed, 6 Jan 2016 14:38:22 -0500 Subject: [xquery-talk] trying to retrieve element value In-Reply-To: References: Message-ID: <568D6D2E.7090901@durusau.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mary, Try moving the extended predicate to your for statement: for $mlid in doc("YOUR-File-Name")//article-title[@id="AVD210_art1"] return $mlid (untested) Hope you are having a great day! Patrick On 01/06/2016 01:28 PM, Mary McRae wrote: > Sorry for what is probably a very basic question; I've read through > a number of XQuery tutorials but haven't been able to come up with > something that yields the expected results. I have a MarkLogic > database, which contains a few thousand XML documents. I'm trying > to return the value of the ML UID (captured in the XML document as > ) for a known document identifier id="value">. > > I've tried several variants of the following, but each returns the > full set of system-pub-ids rather than the one matching the > specified id value. > > I've tried running through oXygen as well as the MarkLogic console; > I get the same results (which I suppose is a good thing). I'm > pretty certain that I'm missing something obvious, and appreciate > any pointers. > > I started with this: xquery version "1.0-ml"; for $mlid in > /samhsa-doc//system-pub-id where > /samhsa-doc//article-title[@id="AVD210_art1"] return $mlid > > but when I got the full list back (some 14,000 items - many of > which don't have an article-title) I thought I'd try starting at > the root ... > > XQuery: xquery version "1.0-ml"; for $mlid in /samhsa-doc where > /samhsa-doc//article-title[@id='AVD210_art1'] return > $mlid//system-pub-id > > > XML: > Archived > 100001 Internal and > External >
id="AVD210_art1"> ... ... > > > Thank you in advance, > > Mary > > Mary McRae, PMP | XML Strategist / Technical Project Manager | > mmcrae at iqsolutions.com > > > > _______________________________________________ talk at x-query.com > http://x-query.com/mailman/listinfo/talk > - -- Patrick Durusau patrick at durusau.net Technical Advisory Board, OASIS (TAB) OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor 13250-5 (Topic Maps) Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWjW0tAAoJEFPGsgi3MgycOVoP+wa3Y7OJeD5HNguP1cGjYH4P sTJSnvuKjSjksxne6bnZSvcDk+NydF2e20nWArC3isy7qh00ubc7M1qrObAM2kk+ trbrads1ZaDMO8CtZCVTLgKkxC0FsM4eU0McifIKO6gyeh2HnHjgwREfUwKiPTa4 HygJFscHJ63X4VOmrRy9KLBYhOK58N8MyYStGcFz0RMsMQgFWyOwKpqzFVGPOFMM Z6OFuYx73QrvQZjvgG0ZfKBwguoytLL5VIX7wg9L8Xn5sUCRSV0a8aReDZfCtg+w wmzt/UFDMn34x3Lv84wZ6PoUFmkWGKgZJ6A6nYbYQCKjHzkbPaW38ccTE8uz+mPL ZxpViZrABgZ9c3weWPxUHO48GvUJMw41xoiuLSLpUdtJ1xtaftXXJIyT6NtlD8mU lUWRr3QhbLl1/zVbkSq9GQblXp732e3GsWkHW2ti4hlehpn77vk52Q20LhqE6CkG T/aOHszVRHuChKzrKqehY0HPAXJfRKvxPlloeVA2U4hAH+4ISGGtNdjRHki1ADXR pdBlywLPWc/DZpJcrwhVJLOxmKPmbmoF2GCRvyP4FEWZrxTKQIw1vGvkCP8Pvce4 fIRxZLkDXgWomuc99BqiUHUOuL7uxouLf+vuVUauGVCwJCGrRarLRRlXxbj1oanq MJ/Q7xa0NrHdey/QxuPn =6xE8 -----END PGP SIGNATURE----- From jmdyck at ibiblio.org Wed Jan 6 12:09:28 2016 From: jmdyck at ibiblio.org (Michael Dyck) Date: Wed, 6 Jan 2016 15:09:28 -0500 Subject: [xquery-talk] trying to retrieve element value In-Reply-To: References: Message-ID: <568D7478.8050807@ibiblio.org> Hi Mary, In your queries, the where clause where /samhsa-doc//article-title[@id="AVD210_art1"] means (roughly): where some document in the collection has an with id="AVD210_art1" Apparently, there *is* such a document in your collection, so the where-condition is always true, *regardless* of what's been bound to $mlid in the 'for' clause. That is, your second query is effectively equivalent to: for $mlid in /samhsa-doc where true() return $mlid//system-pub-id or just: for $mlid in /samhsa-doc return $mlid//system-pub-id which is why you're getting a result item for each document in the database. Instead, you want to make the 'where' condition examine the document that's currently in hand, i.e. the one bound to $mlid in the 'for' clause. In your second query, in the where clause, just change "/samhsa-doc" to "$mlid", and I think it'll work: for $mlid in /samhsa-doc where $mlid//article-title[@id='AVD210_art1'] return $mlid//system-pub-id (Incidentally, since this is a fairly simple use of for-where-return, you could replace it with just a path expression, e.g. /samhsa-doc[.//article-title[@id='AVD210_art1']]//system-pub-id would work, I think.) -Michael From adam.retter at googlemail.com Sun Jan 10 11:30:08 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Sun, 10 Jan 2016 19:30:08 +0000 Subject: [xquery-talk] Is this a valid query? Message-ID: Given this valid XQuery (1): map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )(function($k, $v) { "$k=" || $k }) I am wondering, if rewriting it to the following form results in a valid query with the same execution result (2): function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() In my mind it does, however I can't find a current implementation (eXist, BaseX, Saxon-EE) which will execute it, I guess this is due to evaluation order of the expressions (although I get parser errors). If I add some brackets to (2), to add precedence to the evaluation order so that I have (3): function($k, $v) { "$k=" || $k } => ( map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ))() Then it does seem to execute on BaseX and Saxon, but it feels like I shouldn't need to add the brackets and that (2) should work! Can someone add some comment/insight for me as to whether the XQuery spec requires these brackets to make the parse and execution correct? Somehow, I can't see it at the moment... Thanks Adam. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From mike at saxonica.com Sun Jan 10 13:51:48 2016 From: mike at saxonica.com (Michael Kay) Date: Sun, 10 Jan 2016 21:51:48 +0000 Subject: [xquery-talk] Is this a valid query? In-Reply-To: References: Message-ID: There's an open bug against the spec on the use of ?-placeholders in conjunction with the arrow operator. https://www.w3.org/Bugs/Public/show_bug.cgi?id=29346 The grammar allows it, but the semantics have not been specified. My own view is that X => map:for-each(A, ?) should mean map:for-each(X, A, ?) which is an error because there are too many arguments. But we need to await the WG decision on this bug. Michael Kay Saxonica > On 10 Jan 2016, at 19:30, Adam Retter wrote: > > Given this valid XQuery (1): > > map:for-each( > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > )(function($k, $v) { > "$k=" || $k > }) > > I am wondering, if rewriting it to the following form results in a > valid query with the same execution result (2): > > function($k, $v) { > "$k=" || $k > } => > map:for-each( > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > )() > > In my mind it does, however I can't find a current implementation > (eXist, BaseX, Saxon-EE) which will execute it, I guess this is due to > evaluation order of the expressions (although I get parser errors). > > If I add some brackets to (2), to add precedence to the evaluation > order so that I have (3): > > function($k, $v) { > "$k=" || $k > } => > ( > map:for-each( > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > ))() > > > Then it does seem to execute on BaseX and Saxon, but it feels like I > shouldn't need to add the brackets and that (2) should work! Can > someone add some comment/insight for me as to whether the XQuery spec > requires these brackets to make the parse and execution correct? > Somehow, I can't see it at the moment... > > > Thanks Adam. > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From adam.retter at googlemail.com Sun Jan 10 14:03:41 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Sun, 10 Jan 2016 22:03:41 +0000 Subject: [xquery-talk] Is this a valid query? In-Reply-To: References: Message-ID: Thanks Mike, that is exactly the kinda detail I needed, and the bug report has many good comments. Personally I do like the idea and syntax from an XQuery authoring perspective of being able to do: X => map:for-each(A, ?) meaning map:for-each(A, X) However, I am not precious about it. So whichever way it is decided, as long as the spec defines, I will be both happy and informed ;-) Thanks again. Adam. On 10 January 2016 at 21:51, Michael Kay wrote: > There's an open bug against the spec on the use of ?-placeholders in conjunction with the arrow operator. > > https://www.w3.org/Bugs/Public/show_bug.cgi?id=29346 > > The grammar allows it, but the semantics have not been specified. > > My own view is that > > X => map:for-each(A, ?) > > should mean > > map:for-each(X, A, ?) > > which is an error because there are too many arguments. > > But we need to await the WG decision on this bug. > > Michael Kay > Saxonica > > >> On 10 Jan 2016, at 19:30, Adam Retter wrote: >> >> Given this valid XQuery (1): >> >> map:for-each( >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> )(function($k, $v) { >> "$k=" || $k >> }) >> >> I am wondering, if rewriting it to the following form results in a >> valid query with the same execution result (2): >> >> function($k, $v) { >> "$k=" || $k >> } => >> map:for-each( >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> )() >> >> In my mind it does, however I can't find a current implementation >> (eXist, BaseX, Saxon-EE) which will execute it, I guess this is due to >> evaluation order of the expressions (although I get parser errors). >> >> If I add some brackets to (2), to add precedence to the evaluation >> order so that I have (3): >> >> function($k, $v) { >> "$k=" || $k >> } => >> ( >> map:for-each( >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> ))() >> >> >> Then it does seem to execute on BaseX and Saxon, but it feels like I >> shouldn't need to add the brackets and that (2) should work! Can >> someone add some comment/insight for me as to whether the XQuery spec >> requires these brackets to make the parse and execution correct? >> Somehow, I can't see it at the moment... >> >> >> Thanks Adam. >> >> -- >> Adam Retter >> >> skype: adam.retter >> tweet: adamretter >> http://www.adamretter.org.uk >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From james.fuller.2007 at gmail.com Sun Jan 10 14:07:16 2016 From: james.fuller.2007 at gmail.com (James Fuller) Date: Sun, 10 Jan 2016 23:07:16 +0100 Subject: [xquery-talk] Is this a valid query? In-Reply-To: References: Message-ID: +1 for X => map:for-each(A, ?) meaning map:for-each(A, X) Jim Fuller On Sun, Jan 10, 2016 at 11:03 PM, Adam Retter wrote: > Thanks Mike, that is exactly the kinda detail I needed, and the bug > report has many good comments. > > Personally I do like the idea and syntax from an XQuery authoring > perspective of being able to do: > > X => map:for-each(A, ?) meaning map:for-each(A, X) > > However, I am not precious about it. So whichever way it is decided, > as long as the spec defines, I will be both happy and informed ;-) > > Thanks again. Adam. > > On 10 January 2016 at 21:51, Michael Kay wrote: > > There's an open bug against the spec on the use of ?-placeholders in > conjunction with the arrow operator. > > > > https://www.w3.org/Bugs/Public/show_bug.cgi?id=29346 > > > > The grammar allows it, but the semantics have not been specified. > > > > My own view is that > > > > X => map:for-each(A, ?) > > > > should mean > > > > map:for-each(X, A, ?) > > > > which is an error because there are too many arguments. > > > > But we need to await the WG decision on this bug. > > > > Michael Kay > > Saxonica > > > > > >> On 10 Jan 2016, at 19:30, Adam Retter > wrote: > >> > >> Given this valid XQuery (1): > >> > >> map:for-each( > >> map { > >> "a" : "1", > >> "b" : "2", > >> "c" : "3" > >> }, > >> ? > >> )(function($k, $v) { > >> "$k=" || $k > >> }) > >> > >> I am wondering, if rewriting it to the following form results in a > >> valid query with the same execution result (2): > >> > >> function($k, $v) { > >> "$k=" || $k > >> } => > >> map:for-each( > >> map { > >> "a" : "1", > >> "b" : "2", > >> "c" : "3" > >> }, > >> ? > >> )() > >> > >> In my mind it does, however I can't find a current implementation > >> (eXist, BaseX, Saxon-EE) which will execute it, I guess this is due to > >> evaluation order of the expressions (although I get parser errors). > >> > >> If I add some brackets to (2), to add precedence to the evaluation > >> order so that I have (3): > >> > >> function($k, $v) { > >> "$k=" || $k > >> } => > >> ( > >> map:for-each( > >> map { > >> "a" : "1", > >> "b" : "2", > >> "c" : "3" > >> }, > >> ? > >> ))() > >> > >> > >> Then it does seem to execute on BaseX and Saxon, but it feels like I > >> shouldn't need to add the brackets and that (2) should work! Can > >> someone add some comment/insight for me as to whether the XQuery spec > >> requires these brackets to make the parse and execution correct? > >> Somehow, I can't see it at the moment... > >> > >> > >> Thanks Adam. > >> > >> -- > >> Adam Retter > >> > >> skype: adam.retter > >> tweet: adamretter > >> http://www.adamretter.org.uk > >> _______________________________________________ > >> talk at x-query.com > >> http://x-query.com/mailman/listinfo/talk > > > > > > > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bdysonsmith at gmail.com Mon Jan 18 08:09:33 2016 From: bdysonsmith at gmail.com (Bridger Dyson-Smith) Date: Mon, 18 Jan 2016 11:09:33 -0500 Subject: [xquery-talk] Recursion or not - how to (re)query an API Message-ID: Hi all, I'm struggling with getting a working example of the following problem: I'm sending a query to an API that returns some data and, if the data set is large enough, a resumption token to requery the API. I'm stuck at the point of how to generate the new query URL, while still processing the new data. Is the best idea to create a function that will update a new request to the API, or is there a different approach that can be used? I've made several attempts with functions -- the latest non-working examples are below -- and I'm missing... something, but I don't know what. Thanks for any guidance you can provide. Cheers, Bridger (: sample query :) (: http://server:8080/fedora/objects?query=pid~{$collection}*&resultFormat=xml&pid=true :) declare variable $query external := ' http://our.server:8080/fedora/objects?query=pid~gamble*&resultFormat=xml&pid=true '; declare variable $sessionToken := '&sessionToken='; declare variable $resToken := ''; (:functions:) (:doesn't work:) declare function local:getPID($in as document-node()) as xs:anyAtomicType* { data($in/*:resultList/*:objectFields/*:pid) }; (:doesn't work:) declare function local:reQuery( $in as document-node(), $rQ as xs:untypedAtomic*) as document-node() { let $rQ := $in/*:listSession/*:token/text() return ( if ($rQ) then local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) else () ) }; (: this works processing the descendant elements but doesn't recurse :) for $result in fn:doc($query)/*:result let $resToken := $result/*:listSession/*:token/text() let $pid := $result/*:resultList/*:objectFields/*:pid/text() return ( $result, $resToken, $pid ) (: sample returned from query; e.g. $result :) 63c0762b5eb3d4b46c58add843b7b3e6 0 2016-01-18T01:40:05.381Z gamble:1 gamble:10 -------------- next part -------------- An HTML attachment was scrubbed... URL: From christian.gruen at gmail.com Mon Jan 18 08:32:26 2016 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Mon, 18 Jan 2016 17:32:26 +0100 Subject: [xquery-talk] Recursion or not - how to (re)query an API In-Reply-To: References: Message-ID: Hi Bridger, I know too little about the API you are working, and your query processor (parts of the semantics of fn:doc are implementation-defined), but I noticed that the URL construction might need to be revised: OLD: local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) NEW: local:getPID(doc($in || "&sessionToken=" || encode-for-uri($rQ))) Possibly, $in (or a part of it) needs to be encoded as well. Hope this helps, Christian On Mon, Jan 18, 2016 at 5:09 PM, Bridger Dyson-Smith wrote: > Hi all, > > I'm struggling with getting a working example of the following problem: I'm > sending a query to an API that returns some data and, if the data set is > large enough, a resumption token to requery the API. > > I'm stuck at the point of how to generate the new query URL, while still > processing the new data. Is the best idea to create a function that will > update a new request to the API, or is there a different approach that can > be used? > > I've made several attempts with functions -- the latest non-working examples > are below -- and I'm missing... something, but I don't know what. > > Thanks for any guidance you can provide. > Cheers, > Bridger > > (: sample query :) > (: > http://server:8080/fedora/objects?query=pid~{$collection}*&resultFormat=xml&pid=true > :) > > declare variable $query external := > 'http://our.server:8080/fedora/objects?query=pid~gamble*&resultFormat=xml&pid=true'; > declare variable $sessionToken := '&sessionToken='; > declare variable $resToken := ''; > > (:functions:) > (:doesn't work:) > declare function local:getPID($in as document-node()) as xs:anyAtomicType* > { > data($in/*:resultList/*:objectFields/*:pid) > }; > > (:doesn't work:) > declare function local:reQuery( > $in as document-node(), > $rQ as xs:untypedAtomic*) as document-node() > { > let $rQ := $in/*:listSession/*:token/text() > return ( > if ($rQ) then > local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) > else () > ) > }; > > (: this works processing the descendant elements but doesn't recurse :) > for $result in fn:doc($query)/*:result > let $resToken := $result/*:listSession/*:token/text() > let $pid := $result/*:resultList/*:objectFields/*:pid/text() > return ( > $result, > $resToken, > $pid > ) > > (: sample returned from query; e.g. $result :) > xmlns:types="http://www.fedora.info/definitions/1/0/types/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.fedora.info/definitions/1/0/types/ > http://localhost:8080/fedora/schema/findObjects.xsd"> > > 63c0762b5eb3d4b46c58add843b7b3e6 > 0 > 2016-01-18T01:40:05.381Z > > > > gamble:1 > > > gamble:10 > > > > > > > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From bdysonsmith at gmail.com Mon Jan 18 08:58:35 2016 From: bdysonsmith at gmail.com (Bridger Dyson-Smith) Date: Mon, 18 Jan 2016 11:58:35 -0500 Subject: [xquery-talk] Recursion or not - how to (re)query an API In-Reply-To: References: Message-ID: Hi Christian, thank you for your help. I'm using BaseX 8.3.1 as my query processor. I'm guilty, I'm afraid, of presenting a poorly framed question to the list. I need to mull over the problem a little more. Thanks again! Bridger On Mon, Jan 18, 2016 at 11:32 AM, Christian Gr?n wrote: > Hi Bridger, > > I know too little about the API you are working, and your query > processor (parts of the semantics of fn:doc are > implementation-defined), but I noticed that the URL construction might > need to be revised: > > OLD: > local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) > > NEW: > local:getPID(doc($in || "&sessionToken=" || encode-for-uri($rQ))) > > Possibly, $in (or a part of it) needs to be encoded as well. > > Hope this helps, > Christian > > > > On Mon, Jan 18, 2016 at 5:09 PM, Bridger Dyson-Smith > wrote: > > Hi all, > > > > I'm struggling with getting a working example of the following problem: > I'm > > sending a query to an API that returns some data and, if the data set is > > large enough, a resumption token to requery the API. > > > > I'm stuck at the point of how to generate the new query URL, while still > > processing the new data. Is the best idea to create a function that will > > update a new request to the API, or is there a different approach that > can > > be used? > > > > I've made several attempts with functions -- the latest non-working > examples > > are below -- and I'm missing... something, but I don't know what. > > > > Thanks for any guidance you can provide. > > Cheers, > > Bridger > > > > (: sample query :) > > (: > > > http://server:8080/fedora/objects?query=pid~{$collection}*&resultFormat=xml&pid=true > > :) > > > > declare variable $query external := > > ' > http://our.server:8080/fedora/objects?query=pid~gamble*&resultFormat=xml&pid=true > '; > > declare variable $sessionToken := '&sessionToken='; > > declare variable $resToken := ''; > > > > (:functions:) > > (:doesn't work:) > > declare function local:getPID($in as document-node()) as > xs:anyAtomicType* > > { > > data($in/*:resultList/*:objectFields/*:pid) > > }; > > > > (:doesn't work:) > > declare function local:reQuery( > > $in as document-node(), > > $rQ as xs:untypedAtomic*) as document-node() > > { > > let $rQ := $in/*:listSession/*:token/text() > > return ( > > if ($rQ) then > > local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) > > else () > > ) > > }; > > > > (: this works processing the descendant elements but doesn't recurse :) > > for $result in fn:doc($query)/*:result > > let $resToken := $result/*:listSession/*:token/text() > > let $pid := $result/*:resultList/*:objectFields/*:pid/text() > > return ( > > $result, > > $resToken, > > $pid > > ) > > > > (: sample returned from query; e.g. $result :) > > > xmlns:types="http://www.fedora.info/definitions/1/0/types/" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://www.fedora.info/definitions/1/0/types/ > > http://localhost:8080/fedora/schema/findObjects.xsd"> > > > > 63c0762b5eb3d4b46c58add843b7b3e6 > > 0 > > 2016-01-18T01:40:05.381Z > > > > > > > > gamble:1 > > > > > > gamble:10 > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > talk at x-query.com > > http://x-query.com/mailman/listinfo/talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bdysonsmith at gmail.com Mon Jan 18 13:14:39 2016 From: bdysonsmith at gmail.com (Bridger Dyson-Smith) Date: Mon, 18 Jan 2016 16:14:39 -0500 Subject: [xquery-talk] Recursion or not - how to (re)query an API In-Reply-To: References: Message-ID: Winona, this sounds like an interesting direction -- I'm mostly in the dark on modules, so this is really neat. Thanks! Bridger On Mon, Jan 18, 2016 at 1:11 PM, Winona Salesky wrote: > Have you considered using the EXPath http client rather then the doc() > function, I find it to be a more flexible option for handling API > interactions? http://expath.org/modules/http-client/samples > > You can then run your query, and base subsequent action on the http status > code, do a if/else for http status code 200, if 200, then test for a > resumption token. If there is a resumption token, resubmit same query with > resumption token parameter added otherwise (if no resumption token) your > query is done. > > Does that help? Or are you looking for something a little more step by > step? > -Winona > > > On Mon, Jan 18, 2016 at 11:58 AM, Bridger Dyson-Smith < > bdysonsmith at gmail.com> wrote: > >> Hi Christian, >> >> thank you for your help. I'm using BaseX 8.3.1 as my query processor. I'm >> guilty, I'm afraid, of presenting a poorly framed question to the list. I >> need to mull over the problem a little more. >> >> Thanks again! >> Bridger >> >> On Mon, Jan 18, 2016 at 11:32 AM, Christian Gr?n < >> christian.gruen at gmail.com> wrote: >> >>> Hi Bridger, >>> >>> I know too little about the API you are working, and your query >>> processor (parts of the semantics of fn:doc are >>> implementation-defined), but I noticed that the URL construction might >>> need to be revised: >>> >>> OLD: >>> local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) >>> >>> NEW: >>> local:getPID(doc($in || "&sessionToken=" || encode-for-uri($rQ))) >>> >>> Possibly, $in (or a part of it) needs to be encoded as well. >>> >>> Hope this helps, >>> Christian >>> >>> >>> >>> On Mon, Jan 18, 2016 at 5:09 PM, Bridger Dyson-Smith >>> wrote: >>> > Hi all, >>> > >>> > I'm struggling with getting a working example of the following >>> problem: I'm >>> > sending a query to an API that returns some data and, if the data set >>> is >>> > large enough, a resumption token to requery the API. >>> > >>> > I'm stuck at the point of how to generate the new query URL, while >>> still >>> > processing the new data. Is the best idea to create a function that >>> will >>> > update a new request to the API, or is there a different approach that >>> can >>> > be used? >>> > >>> > I've made several attempts with functions -- the latest non-working >>> examples >>> > are below -- and I'm missing... something, but I don't know what. >>> > >>> > Thanks for any guidance you can provide. >>> > Cheers, >>> > Bridger >>> > >>> > (: sample query :) >>> > (: >>> > >>> http://server:8080/fedora/objects?query=pid~{$collection}*&resultFormat=xml&pid=true >>> > :) >>> > >>> > declare variable $query external := >>> > ' >>> http://our.server:8080/fedora/objects?query=pid~gamble*&resultFormat=xml&pid=true >>> '; >>> > declare variable $sessionToken := '&sessionToken='; >>> > declare variable $resToken := ''; >>> > >>> > (:functions:) >>> > (:doesn't work:) >>> > declare function local:getPID($in as document-node()) as >>> xs:anyAtomicType* >>> > { >>> > data($in/*:resultList/*:objectFields/*:pid) >>> > }; >>> > >>> > (:doesn't work:) >>> > declare function local:reQuery( >>> > $in as document-node(), >>> > $rQ as xs:untypedAtomic*) as document-node() >>> > { >>> > let $rQ := $in/*:listSession/*:token/text() >>> > return ( >>> > if ($rQ) then >>> > local:getPID(doc("$in" || "&sessionToken=" || "$rQ")) >>> > else () >>> > ) >>> > }; >>> > >>> > (: this works processing the descendant elements but doesn't recurse :) >>> > for $result in fn:doc($query)/*:result >>> > let $resToken := $result/*:listSession/*:token/text() >>> > let $pid := $result/*:resultList/*:objectFields/*:pid/text() >>> > return ( >>> > $result, >>> > $resToken, >>> > $pid >>> > ) >>> > >>> > (: sample returned from query; e.g. $result :) >>> > >> > xmlns:types="http://www.fedora.info/definitions/1/0/types/" >>> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> > xsi:schemaLocation="http://www.fedora.info/definitions/1/0/types/ >>> > http://localhost:8080/fedora/schema/findObjects.xsd"> >>> > >>> > 63c0762b5eb3d4b46c58add843b7b3e6 >>> > 0 >>> > 2016-01-18T01:40:05.381Z >>> > >>> > >>> > >>> > gamble:1 >>> > >>> > >>> > gamble:10 >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > _______________________________________________ >>> > talk at x-query.com >>> > http://x-query.com/mailman/listinfo/talk >>> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.retter at googlemail.com Tue Jan 26 08:26:17 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Tue, 26 Jan 2016 16:26:17 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another Message-ID: Given two simple XPaths, say: 1. //w 2. /x/y/z/w[@a = 'v'] As a human I can very easily tell without evaluating the expressions that (2) will return a subset (or the same set) of the results that (1) would return *should* they both be evaluated. My goal here is given any two simple arbitrary XPaths expressed as strings, and without evaluating them against a context, to determine whether one would return a subset of the results of the other. I wondered if there might be an algorithm or library that someone already had or has written which might be able to give me the answer? I realise that I can only probably cover a subset of XPath itself, but it is only the path steps with predicates which I am interested in. Ideally I am looking for something in Java. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From wshager at gmail.com Tue Jan 26 08:40:52 2016 From: wshager at gmail.com (W.S. Hager) Date: Tue, 26 Jan 2016 17:40:52 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: Message-ID: Hi Adam, Perhaps it helps to start with rewriting the xpath expressions as pure lambda expressions. Maybe that way you could apply lambda calculus? Cheers, Wouter 2016-01-26 17:26 GMT+01:00 Adam Retter : > Given two simple XPaths, say: > > 1. //w > > 2. /x/y/z/w[@a = 'v'] > > As a human I can very easily tell without evaluating the expressions > that (2) will return a subset (or the same set) of the results that > (1) would return *should* they both be evaluated. > > My goal here is given any two simple arbitrary XPaths expressed as > strings, and without evaluating them against a context, to determine > whether one would return a subset of the results of the other. > > I wondered if there might be an algorithm or library that someone > already had or has written which might be able to give me the answer? > > I realise that I can only probably cover a subset of XPath itself, but > it is only the path steps with predicates which I am interested in. > > Ideally I am looking for something in Java. > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.retter at googlemail.com Tue Jan 26 08:41:50 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Tue, 26 Jan 2016 16:41:50 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: Message-ID: Any chance you could offer me an example? ;-) On 26 January 2016 at 16:40, W.S. Hager wrote: > Hi Adam, > > Perhaps it helps to start with rewriting the xpath expressions as pure > lambda expressions. Maybe that way you could apply lambda calculus? > > Cheers, > Wouter > > 2016-01-26 17:26 GMT+01:00 Adam Retter : >> >> Given two simple XPaths, say: >> >> 1. //w >> >> 2. /x/y/z/w[@a = 'v'] >> >> As a human I can very easily tell without evaluating the expressions >> that (2) will return a subset (or the same set) of the results that >> (1) would return *should* they both be evaluated. >> >> My goal here is given any two simple arbitrary XPaths expressed as >> strings, and without evaluating them against a context, to determine >> whether one would return a subset of the results of the other. >> >> I wondered if there might be an algorithm or library that someone >> already had or has written which might be able to give me the answer? >> >> I realise that I can only probably cover a subset of XPath itself, but >> it is only the path steps with predicates which I am interested in. >> >> Ideally I am looking for something in Java. >> >> -- >> Adam Retter >> >> skype: adam.retter >> tweet: adamretter >> http://www.adamretter.org.uk >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From wshager at gmail.com Tue Jan 26 09:06:44 2016 From: wshager at gmail.com (W.S. Hager) Date: Tue, 26 Jan 2016 18:06:44 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: Message-ID: Not really, no. But my guess is that the path is not relevant, as its steps simply contain variable names. The proof you want to have is a formal one, and I think it doesn't have to do with the path expression, but rather the formalism it implements. 2016-01-26 17:41 GMT+01:00 Adam Retter : > Any chance you could offer me an example? ;-) > > On 26 January 2016 at 16:40, W.S. Hager wrote: > > Hi Adam, > > > > Perhaps it helps to start with rewriting the xpath expressions as pure > > lambda expressions. Maybe that way you could apply lambda calculus? > > > > Cheers, > > Wouter > > > > 2016-01-26 17:26 GMT+01:00 Adam Retter : > >> > >> Given two simple XPaths, say: > >> > >> 1. //w > >> > >> 2. /x/y/z/w[@a = 'v'] > >> > >> As a human I can very easily tell without evaluating the expressions > >> that (2) will return a subset (or the same set) of the results that > >> (1) would return *should* they both be evaluated. > >> > >> My goal here is given any two simple arbitrary XPaths expressed as > >> strings, and without evaluating them against a context, to determine > >> whether one would return a subset of the results of the other. > >> > >> I wondered if there might be an algorithm or library that someone > >> already had or has written which might be able to give me the answer? > >> > >> I realise that I can only probably cover a subset of XPath itself, but > >> it is only the path steps with predicates which I am interested in. > >> > >> Ideally I am looking for something in Java. > >> > >> -- > >> Adam Retter > >> > >> skype: adam.retter > >> tweet: adamretter > >> http://www.adamretter.org.uk > >> _______________________________________________ > >> talk at x-query.com > >> http://x-query.com/mailman/listinfo/talk > > > > > > > > > > -- > > > > W.S. Hager > > Lagua Web Solutions > > http://lagua.nl > > > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From wshager at gmail.com Tue Jan 26 13:12:07 2016 From: wshager at gmail.com (W.S. Hager) Date: Tue, 26 Jan 2016 22:12:07 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: Message-ID: Hi Adam, I'm looking at the formal specification of xpath/xquery: http://www.w3.org/TR/xquery-semantics It would really help to start with a function that implements the actual selection in steps. Do you know such a function? Thanks, Wouter Op dinsdag 26 januari 2016 heeft W.S. Hager het volgende geschreven: > Not really, no. But my guess is that the path is not relevant, as its > steps simply contain variable names. The proof you want to have is a formal > one, and I think it doesn't have to do with the path expression, but rather > the formalism it implements. > > 2016-01-26 17:41 GMT+01:00 Adam Retter >: > >> Any chance you could offer me an example? ;-) >> >> On 26 January 2016 at 16:40, W.S. Hager > > wrote: >> > Hi Adam, >> > >> > Perhaps it helps to start with rewriting the xpath expressions as pure >> > lambda expressions. Maybe that way you could apply lambda calculus? >> > >> > Cheers, >> > Wouter >> > >> > 2016-01-26 17:26 GMT+01:00 Adam Retter > >: >> >> >> >> Given two simple XPaths, say: >> >> >> >> 1. //w >> >> >> >> 2. /x/y/z/w[@a = 'v'] >> >> >> >> As a human I can very easily tell without evaluating the expressions >> >> that (2) will return a subset (or the same set) of the results that >> >> (1) would return *should* they both be evaluated. >> >> >> >> My goal here is given any two simple arbitrary XPaths expressed as >> >> strings, and without evaluating them against a context, to determine >> >> whether one would return a subset of the results of the other. >> >> >> >> I wondered if there might be an algorithm or library that someone >> >> already had or has written which might be able to give me the answer? >> >> >> >> I realise that I can only probably cover a subset of XPath itself, but >> >> it is only the path steps with predicates which I am interested in. >> >> >> >> Ideally I am looking for something in Java. >> >> >> >> -- >> >> Adam Retter >> >> >> >> skype: adam.retter >> >> tweet: adamretter >> >> http://www.adamretter.org.uk >> >> _______________________________________________ >> >> talk at x-query.com >> >> http://x-query.com/mailman/listinfo/talk >> > >> > >> > >> > >> > -- >> > >> > W.S. Hager >> > Lagua Web Solutions >> > http://lagua.nl >> >> >> >> -- >> Adam Retter >> >> skype: adam.retter >> tweet: adamretter >> http://www.adamretter.org.uk >> > > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From wshager at gmail.com Tue Jan 26 13:15:18 2016 From: wshager at gmail.com (W.S. Hager) Date: Tue, 26 Jan 2016 22:15:18 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: Message-ID: Here's the entry on steps: http://www.w3.org/TR/xquery-semantics/#id-axis-steps I missed it before. To be continued I guess. I'd love the idea of a sound formal proof. Op dinsdag 26 januari 2016 heeft W.S. Hager het volgende geschreven: > Hi Adam, > > I'm looking at the formal specification of xpath/xquery: > > http://www.w3.org/TR/xquery-semantics > > It would really help to start with a function that implements the actual > selection in steps. Do you know such a function? > > Thanks, > > Wouter > Op dinsdag 26 januari 2016 heeft W.S. Hager > het volgende > geschreven: > >> Not really, no. But my guess is that the path is not relevant, as its >> steps simply contain variable names. The proof you want to have is a formal >> one, and I think it doesn't have to do with the path expression, but rather >> the formalism it implements. >> >> 2016-01-26 17:41 GMT+01:00 Adam Retter : >> >>> Any chance you could offer me an example? ;-) >>> >>> On 26 January 2016 at 16:40, W.S. Hager wrote: >>> > Hi Adam, >>> > >>> > Perhaps it helps to start with rewriting the xpath expressions as pure >>> > lambda expressions. Maybe that way you could apply lambda calculus? >>> > >>> > Cheers, >>> > Wouter >>> > >>> > 2016-01-26 17:26 GMT+01:00 Adam Retter : >>> >> >>> >> Given two simple XPaths, say: >>> >> >>> >> 1. //w >>> >> >>> >> 2. /x/y/z/w[@a = 'v'] >>> >> >>> >> As a human I can very easily tell without evaluating the expressions >>> >> that (2) will return a subset (or the same set) of the results that >>> >> (1) would return *should* they both be evaluated. >>> >> >>> >> My goal here is given any two simple arbitrary XPaths expressed as >>> >> strings, and without evaluating them against a context, to determine >>> >> whether one would return a subset of the results of the other. >>> >> >>> >> I wondered if there might be an algorithm or library that someone >>> >> already had or has written which might be able to give me the answer? >>> >> >>> >> I realise that I can only probably cover a subset of XPath itself, but >>> >> it is only the path steps with predicates which I am interested in. >>> >> >>> >> Ideally I am looking for something in Java. >>> >> >>> >> -- >>> >> Adam Retter >>> >> >>> >> skype: adam.retter >>> >> tweet: adamretter >>> >> http://www.adamretter.org.uk >>> >> _______________________________________________ >>> >> talk at x-query.com >>> >> http://x-query.com/mailman/listinfo/talk >>> > >>> > >>> > >>> > >>> > -- >>> > >>> > W.S. Hager >>> > Lagua Web Solutions >>> > http://lagua.nl >>> >>> >>> >>> -- >>> Adam Retter >>> >>> skype: adam.retter >>> tweet: adamretter >>> http://www.adamretter.org.uk >>> >> >> >> >> -- >> >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl >> > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at saxonica.com Wed Jan 27 00:27:43 2016 From: mike at saxonica.com (Michael Kay) Date: Wed, 27 Jan 2016 08:27:43 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> Message-ID: <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> > > > If you want to do a formal proof, you might want to use simplified notions of XML documents and path expressions. It seems to be a long-standing tradition that computer scientists, when asked to prove a difficult conjecture C, respond by giving a proof for a simplified conjecture C'. While this might lead to progress in the long run, and enables them to get papers published in the academic literature, it is totally useless to practical engineeers who want to know whether they can safely rely on C. Michael Kay Saxonica From wshager at gmail.com Wed Jan 27 01:12:36 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 10:12:36 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: I think simplifying notions of path expressions aren't necessary. IMO the challenge here is to come to discreet formal steps. I'd start with applying all normalisations in http://www.w3.org/TR/xquery-semantics/#id-axis-steps, from which a single evaluable function could be derived. The function should be rewritable as yielding the same set (for /x/w and //w). Next the relation to the subset should become obvious. Op woensdag 27 januari 2016 heeft Michael Kay > het volgende geschreven: > > > > > > > If you want to do a formal proof, you might want to use simplified > notions of XML documents and path expressions. > > It seems to be a long-standing tradition that computer scientists, when > asked to prove a difficult conjecture C, respond by giving a proof for a > simplified conjecture C'. While this might lead to progress in the long > run, and enables them to get papers published in the academic literature, > it is totally useless to practical engineeers who want to know whether they > can safely rely on C. > > Michael Kay > Saxonica > > > > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Wed Jan 27 01:25:31 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 12:25:31 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: >> >> If you want to do a formal proof, you might want to use simplified notions of XML documents and path expressions. > > It seems to be a long-standing tradition that computer scientists, when asked to prove a difficult conjecture C, respond by giving a proof for a simplified conjecture C'. While this might lead to progress in the long run, and enables them to get papers published in the academic literature, it is totally useless to practical engineeers who want to know whether they can safely rely on C. Its a common practice for everybody, who needs to come up with formal proofs. You start with the most simplified definitions possible, that capture the essence of the problem. Then you get the skeleton of the proof that is hopefully very simple. Then you can add details back, hoping that the proof remains simple and tractable. So imagine starting the proof while considering all the possible variations of path expressions, all the Infoset stuff, all XML Schema details. I think its hopeless. > > Michael Kay > Saxonica > > > From christian.gruen at gmail.com Wed Jan 27 01:37:21 2016 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Wed, 27 Jan 2016 10:37:21 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: > Its a common practice for everybody, who needs to come up with formal proofs. You start with the most simplified definitions possible, that capture the essence of the problem. > Then you get the skeleton of the proof that is hopefully very simple. Then you can add details back, hoping that the proof remains simple and tractable. > > So imagine starting the proof while considering all the possible variations of path expressions, all the Infoset stuff, all XML Schema details. I think its hopeless. I?m completely in line with Michael?s observations. It would obviously be nice to have proofs for the full rule sets of the discussed languages; but as experience shows, no one will do it (the rare exception might prove the rule), so we are stuck with the work that is of limited practical use. From pavel.velikhov at gmail.com Wed Jan 27 01:51:46 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 12:51:46 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: > On 27 Jan 2016, at 12:37, Christian Gr?n wrote: > >> Its a common practice for everybody, who needs to come up with formal proofs. You start with the most simplified definitions possible, that capture the essence of the problem. >> Then you get the skeleton of the proof that is hopefully very simple. Then you can add details back, hoping that the proof remains simple and tractable. >> >> So imagine starting the proof while considering all the possible variations of path expressions, all the Infoset stuff, all XML Schema details. I think its hopeless. > > I?m completely in line with Michael?s observations. It would obviously > be nice to have proofs for the full rule sets of the discussed > languages; but as experience shows, no one will do it (the rare > exception might prove the rule), so we are stuck with the work that is > of limited practical use. I can?t agree with you. There are a lot of results that automatically hold for the full specification, even though they are proved on a clean and easy-to-use subset: undecidability and np-completeness or np-hardness for instance. For the full specifications its sometimes hard to grasp the semantics, so proving anything serious is impossible. Example: try proving that SQL-2003 queries are equivalent to some superset of relational algebra. From wshager at gmail.com Wed Jan 27 01:54:37 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 10:54:37 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: Can't we formally proof something as obvious Adam's case? 2016-01-27 10:51 GMT+01:00 Pavel Velikhov : > > > On 27 Jan 2016, at 12:37, Christian Gr?n > wrote: > > > >> Its a common practice for everybody, who needs to come up with formal > proofs. You start with the most simplified definitions possible, that > capture the essence of the problem. > >> Then you get the skeleton of the proof that is hopefully very simple. > Then you can add details back, hoping that the proof remains simple and > tractable. > >> > >> So imagine starting the proof while considering all the possible > variations of path expressions, all the Infoset stuff, all XML Schema > details. I think its hopeless. > > > > I?m completely in line with Michael?s observations. It would obviously > > be nice to have proofs for the full rule sets of the discussed > > languages; but as experience shows, no one will do it (the rare > > exception might prove the rule), so we are stuck with the work that is > > of limited practical use. > > I can?t agree with you. There are a lot of results that automatically hold > for the full specification, even though they are > proved on a clean and easy-to-use subset: undecidability and > np-completeness or np-hardness for instance. > > For the full specifications its sometimes hard to grasp the semantics, so > proving anything serious is impossible. > Example: try proving that SQL-2003 queries are equivalent to some superset > of relational algebra. > > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Wed Jan 27 02:04:06 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 13:04:06 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> > On 27 Jan 2016, at 12:54, W.S. Hager wrote: > > Can't we formally proof something as obvious Adam's case? In Adam?s case we want to test whether path expression p1 subsumes path expression p2. If we don?t put any conditions on p1 and p2, the problem is undecidable: p1 and p2 may include function calls, so the expressive power of p1 and p2 are that of a Turing Machine. From wshager at gmail.com Wed Jan 27 02:09:01 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 11:09:01 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> Message-ID: Isn't the constraint in this case the test: is p2 a subset of p1? 2016-01-27 11:04 GMT+01:00 Pavel Velikhov : > > > On 27 Jan 2016, at 12:54, W.S. Hager wrote: > > > > Can't we formally proof something as obvious Adam's case? > > In Adam?s case we want to test whether path expression p1 subsumes path > expression p2. > If we don?t put any conditions on p1 and p2, the problem is undecidable: > p1 and p2 may include > function calls, so the expressive power of p1 and p2 are that of a Turing > Machine. -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From wshager at gmail.com Wed Jan 27 02:10:10 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 11:10:10 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> Message-ID: Or simplified: is the set selected by p1 equal to the set selected by p2? 2016-01-27 11:09 GMT+01:00 W.S. Hager : > Isn't the constraint in this case the test: is p2 a subset of p1? > > 2016-01-27 11:04 GMT+01:00 Pavel Velikhov : > >> >> > On 27 Jan 2016, at 12:54, W.S. Hager wrote: >> > >> > Can't we formally proof something as obvious Adam's case? >> >> In Adam?s case we want to test whether path expression p1 subsumes path >> expression p2. >> If we don?t put any conditions on p1 and p2, the problem is undecidable: >> p1 and p2 may include >> function calls, so the expressive power of p1 and p2 are that of a Turing >> Machine. > > > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Wed Jan 27 02:11:36 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 13:11:36 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> Message-ID: > > Or simplified: is the set selected by p1 equal to the set selected by p2? If we allow p1 and p2 to be arbitrary XQuery path expressions, then its undecidable. I can reduce the halting problem of Turing machines to this test. > > 2016-01-27 11:09 GMT+01:00 W.S. Hager >: > Isn't the constraint in this case the test: is p2 a subset of p1? > > 2016-01-27 11:04 GMT+01:00 Pavel Velikhov >: > > > On 27 Jan 2016, at 12:54, W.S. Hager > wrote: > > > > Can't we formally proof something as obvious Adam's case? > > In Adam?s case we want to test whether path expression p1 subsumes path expression p2. > If we don?t put any conditions on p1 and p2, the problem is undecidable: p1 and p2 may include > function calls, so the expressive power of p1 and p2 are that of a Turing Machine. > > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From wshager at gmail.com Wed Jan 27 02:17:31 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 11:17:31 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> Message-ID: Indeed, the expressions should terminate. 2016-01-27 11:11 GMT+01:00 Pavel Velikhov : > > > Or simplified: is the set selected by p1 equal to the set selected by p2? > > > If we allow p1 and p2 to be arbitrary XQuery path expressions, then its > undecidable. > I can reduce the halting problem of Turing machines to this test. > > > 2016-01-27 11:09 GMT+01:00 W.S. Hager : > >> Isn't the constraint in this case the test: is p2 a subset of p1? >> >> 2016-01-27 11:04 GMT+01:00 Pavel Velikhov : >> >>> >>> > On 27 Jan 2016, at 12:54, W.S. Hager wrote: >>> > >>> > Can't we formally proof something as obvious Adam's case? >>> >>> In Adam?s case we want to test whether path expression p1 subsumes path >>> expression p2. >>> If we don?t put any conditions on p1 and p2, the problem is undecidable: >>> p1 and p2 may include >>> function calls, so the expressive power of p1 and p2 are that of a >>> Turing Machine. >> >> >> >> >> -- >> >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl >> > > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Wed Jan 27 02:24:12 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 13:24:12 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> Message-ID: <203D33C0-BBAD-42AF-A76F-640840EFBFBC@gmail.com> > > Indeed, the expressions should terminate. Since you can include a function call in your path expression, and you can include your own custom function, there is no guarantee that the expression will terminate. I.e. you need to take a subset of possible path expression already, in general case the problem is undecidable. > > 2016-01-27 11:11 GMT+01:00 Pavel Velikhov >: > >> >> Or simplified: is the set selected by p1 equal to the set selected by p2? > > If we allow p1 and p2 to be arbitrary XQuery path expressions, then its undecidable. > I can reduce the halting problem of Turing machines to this test. > >> >> 2016-01-27 11:09 GMT+01:00 W.S. Hager >: >> Isn't the constraint in this case the test: is p2 a subset of p1? >> >> 2016-01-27 11:04 GMT+01:00 Pavel Velikhov >: >> >> > On 27 Jan 2016, at 12:54, W.S. Hager > wrote: >> > >> > Can't we formally proof something as obvious Adam's case? >> >> In Adam?s case we want to test whether path expression p1 subsumes path expression p2. >> If we don?t put any conditions on p1 and p2, the problem is undecidable: p1 and p2 may include >> function calls, so the expressive power of p1 and p2 are that of a Turing Machine. >> >> >> >> -- >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl >> >> >> >> -- >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl > > > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From wshager at gmail.com Wed Jan 27 02:31:38 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 11:31:38 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <203D33C0-BBAD-42AF-A76F-640840EFBFBC@gmail.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> <203D33C0-BBAD-42AF-A76F-640840EFBFBC@gmail.com> Message-ID: There's the notion of co-inductive types. I think in Haskell you could proof the case, so why not in xquery? 2016-01-27 11:24 GMT+01:00 Pavel Velikhov : > > > Indeed, the expressions should terminate. > > > Since you can include a function call in your path expression, and you can > include your own custom function, there is > no guarantee that the expression will terminate. > > I.e. you need to take a subset of possible path expression already, in > general case the problem is undecidable. > > > 2016-01-27 11:11 GMT+01:00 Pavel Velikhov : > >> >> >> Or simplified: is the set selected by p1 equal to the set selected by p2? >> >> >> If we allow p1 and p2 to be arbitrary XQuery path expressions, then its >> undecidable. >> I can reduce the halting problem of Turing machines to this test. >> >> >> 2016-01-27 11:09 GMT+01:00 W.S. Hager : >> >>> Isn't the constraint in this case the test: is p2 a subset of p1? >>> >>> 2016-01-27 11:04 GMT+01:00 Pavel Velikhov : >>> >>>> >>>> > On 27 Jan 2016, at 12:54, W.S. Hager wrote: >>>> > >>>> > Can't we formally proof something as obvious Adam's case? >>>> >>>> In Adam?s case we want to test whether path expression p1 subsumes path >>>> expression p2. >>>> If we don?t put any conditions on p1 and p2, the problem is >>>> undecidable: p1 and p2 may include >>>> function calls, so the expressive power of p1 and p2 are that of a >>>> Turing Machine. >>> >>> >>> >>> >>> -- >>> >>> W.S. Hager >>> Lagua Web Solutions >>> http://lagua.nl >>> >> >> >> >> -- >> >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl >> >> >> > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Wed Jan 27 02:39:37 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 13:39:37 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <4D0D2C26-CDAD-407B-AF7F-6DBFBE613057@gmail.com> <203D33C0-BBAD-42AF-A76F-640840EFBFBC@gmail.com> Message-ID: <1D7472E9-6312-4131-BC34-3F302E1D0F0B@gmail.com> A user-defined function in any reasonable language (including Haskell and XQuery) is Turing-complete. So you cannot prove that: - two functions are equivalent - the functions terminate - basically any non-trivial fact Unless you make some strong assumptions about these functions. > On 27 Jan 2016, at 13:31, W.S. Hager wrote: > > There's the notion of co-inductive types. I think in Haskell you could proof the case, so why not in xquery? > > 2016-01-27 11:24 GMT+01:00 Pavel Velikhov >: > >> >> Indeed, the expressions should terminate. > > Since you can include a function call in your path expression, and you can include your own custom function, there is > no guarantee that the expression will terminate. > > I.e. you need to take a subset of possible path expression already, in general case the problem is undecidable. > >> >> 2016-01-27 11:11 GMT+01:00 Pavel Velikhov >: >> >>> >>> Or simplified: is the set selected by p1 equal to the set selected by p2? >> >> If we allow p1 and p2 to be arbitrary XQuery path expressions, then its undecidable. >> I can reduce the halting problem of Turing machines to this test. >> >>> >>> 2016-01-27 11:09 GMT+01:00 W.S. Hager >: >>> Isn't the constraint in this case the test: is p2 a subset of p1? >>> >>> 2016-01-27 11:04 GMT+01:00 Pavel Velikhov >: >>> >>> > On 27 Jan 2016, at 12:54, W.S. Hager > wrote: >>> > >>> > Can't we formally proof something as obvious Adam's case? >>> >>> In Adam?s case we want to test whether path expression p1 subsumes path expression p2. >>> If we don?t put any conditions on p1 and p2, the problem is undecidable: p1 and p2 may include >>> function calls, so the expressive power of p1 and p2 are that of a Turing Machine. >>> >>> >>> >>> -- >>> W.S. Hager >>> Lagua Web Solutions >>> http://lagua.nl >>> >>> >>> >>> -- >>> W.S. Hager >>> Lagua Web Solutions >>> http://lagua.nl >> >> >> >> >> -- >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl > > > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at saxonica.com Wed Jan 27 02:50:39 2016 From: mike at saxonica.com (Michael Kay) Date: Wed, 27 Jan 2016 10:50:39 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: <6D8F3D5A-444C-4D57-A60F-A26F6445861D@saxonica.com> To take an example, if someone proves that a particular equivalence holds on a simplified data model with no attribute, namespace, comment, or processing instruction nodes, then that is of absolutely no use to someone writing an optimizer for a product in which such nodes can be encountered. Michael Kay Saxonica > On 27 Jan 2016, at 09:51, Pavel Velikhov wrote: > > >> On 27 Jan 2016, at 12:37, Christian Gr?n wrote: >> >>> Its a common practice for everybody, who needs to come up with formal proofs. You start with the most simplified definitions possible, that capture the essence of the problem. >>> Then you get the skeleton of the proof that is hopefully very simple. Then you can add details back, hoping that the proof remains simple and tractable. >>> >>> So imagine starting the proof while considering all the possible variations of path expressions, all the Infoset stuff, all XML Schema details. I think its hopeless. >> >> I?m completely in line with Michael?s observations. It would obviously >> be nice to have proofs for the full rule sets of the discussed >> languages; but as experience shows, no one will do it (the rare >> exception might prove the rule), so we are stuck with the work that is >> of limited practical use. > > I can?t agree with you. There are a lot of results that automatically hold for the full specification, even though they are > proved on a clean and easy-to-use subset: undecidability and np-completeness or np-hardness for instance. > > For the full specifications its sometimes hard to grasp the semantics, so proving anything serious is impossible. > Example: try proving that SQL-2003 queries are equivalent to some superset of relational algebra. > From pavel.velikhov at gmail.com Wed Jan 27 03:03:53 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 14:03:53 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <6D8F3D5A-444C-4D57-A60F-A26F6445861D@saxonica.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <6D8F3D5A-444C-4D57-A60F-A26F6445861D@saxonica.com> Message-ID: > > To take an example, if someone proves that a particular equivalence holds on a simplified data model with no attribute, namespace, comment, or processing instruction nodes, then that is of absolutely no use to someone writing an optimizer for a product in which such nodes can be encountered. > > Michael Kay > Saxonica > Michael, even in this case, with these simplifying assumptions, there is a very good chance that the equivalence will hold on the full data model. You can also do a 1-to-1 mapping of the full data model to the simplifed one. And an optimiser developer can read the proof procedure and extend it pretty easily with all the gory details. But if somebody proves that the equivalence is undecidable - it definitely will hold for the full data model. So you can forget about a general method in the optimiser and immediately go for special cases. So I don?t agree that all proofs are useless. And also we see that a lot of functional languages cleaned up their semantics precisely because they wanted to prove things. > >> On 27 Jan 2016, at 09:51, Pavel Velikhov wrote: >> >> >>> On 27 Jan 2016, at 12:37, Christian Gr?n wrote: >>> >>>> Its a common practice for everybody, who needs to come up with formal proofs. You start with the most simplified definitions possible, that capture the essence of the problem. >>>> Then you get the skeleton of the proof that is hopefully very simple. Then you can add details back, hoping that the proof remains simple and tractable. >>>> >>>> So imagine starting the proof while considering all the possible variations of path expressions, all the Infoset stuff, all XML Schema details. I think its hopeless. >>> >>> I?m completely in line with Michael?s observations. It would obviously >>> be nice to have proofs for the full rule sets of the discussed >>> languages; but as experience shows, no one will do it (the rare >>> exception might prove the rule), so we are stuck with the work that is >>> of limited practical use. >> >> I can?t agree with you. There are a lot of results that automatically hold for the full specification, even though they are >> proved on a clean and easy-to-use subset: undecidability and np-completeness or np-hardness for instance. >> >> For the full specifications its sometimes hard to grasp the semantics, so proving anything serious is impossible. >> Example: try proving that SQL-2003 queries are equivalent to some superset of relational algebra. >> > > From christian.gruen at gmail.com Wed Jan 27 03:08:04 2016 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Wed, 27 Jan 2016 12:08:04 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <6D8F3D5A-444C-4D57-A60F-A26F6445861D@saxonica.com> Message-ID: > So I don?t agree that all proofs are useless. And also we see that a lot of functional languages cleaned up their semantics precisely because they wanted to prove things. ?absolutely. If theory is applied at the very beginning, it may prevent you from doing things that no one wants to prove later on. >>> On 27 Jan 2016, at 09:51, Pavel Velikhov wrote: >>> >>> >>>> On 27 Jan 2016, at 12:37, Christian Gr?n wrote: >>>> >>>>> Its a common practice for everybody, who needs to come up with formal proofs. You start with the most simplified definitions possible, that capture the essence of the problem. >>>>> Then you get the skeleton of the proof that is hopefully very simple. Then you can add details back, hoping that the proof remains simple and tractable. >>>>> >>>>> So imagine starting the proof while considering all the possible variations of path expressions, all the Infoset stuff, all XML Schema details. I think its hopeless. >>>> >>>> I?m completely in line with Michael?s observations. It would obviously >>>> be nice to have proofs for the full rule sets of the discussed >>>> languages; but as experience shows, no one will do it (the rare >>>> exception might prove the rule), so we are stuck with the work that is >>>> of limited practical use. >>> >>> I can?t agree with you. There are a lot of results that automatically hold for the full specification, even though they are >>> proved on a clean and easy-to-use subset: undecidability and np-completeness or np-hardness for instance. >>> >>> For the full specifications its sometimes hard to grasp the semantics, so proving anything serious is impossible. >>> Example: try proving that SQL-2003 queries are equivalent to some superset of relational algebra. >>> >> >> > From dflorescu at me.com Wed Jan 27 08:10:28 2016 From: dflorescu at me.com (daniela florescu) Date: Wed, 27 Jan 2016 08:10:28 -0800 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: > > It seems to be a long-standing tradition that computer scientists, when asked to prove a difficult conjecture C, respond by giving a proof for a simplified conjecture C'. While this might lead to progress in the long run, and enables them to get papers published in the academic literature, it is totally useless to practical engineeers who want to know whether they can safely rely on C. Michael, what you say is nice and true. However given that: 1. path expressions point (syntactically hence esemantically) into XQuery?s expressions 2. XQuery expression language is Turing complete 3. Subsumption for a Turing complete language is undecidable. Well, I can hardly see a way to decide this problem other then by introducing SOME restrictions of some sort? but of course some restrictions that would not nullify the original problem all together and make the solution useless. Best, Dana From wshager at gmail.com Wed Jan 27 08:41:55 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 17:41:55 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: Well, so, to continue, let's assume that there are no user-defined functions, and in fact the only thing we want to proof is select+filter, where a filter is limited to the default operators. From that is it follows that -path1: select-child-nodes-by-name(select-child-nodes-by-name($context,'x'),'w') -path2: select-descendant-nodes-by-name($context,'w') And we need to proof that those functions are somehow equivalent. Can it be done? Op woensdag 27 januari 2016 heeft daniela florescu het volgende geschreven: > > > > It seems to be a long-standing tradition that computer scientists, when > asked to prove a difficult conjecture C, respond by giving a proof for a > simplified conjecture C'. While this might lead to progress in the long > run, and enables them to get papers published in the academic literature, > it is totally useless to practical engineeers who want to know whether they > can safely rely on C. > > Michael, > > > what you say is nice and true. > > However given that: > 1. path expressions point (syntactically hence esemantically) into > XQuery?s expressions > 2. XQuery expression language is Turing complete > 3. Subsumption for a Turing complete language is undecidable. > > Well, I can hardly see a way to decide this problem other then by > introducing SOME restrictions > of some sort? but of course some restrictions that would not nullify the > original problem all together > and make the solution useless. > > Best, > Dana -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Wed Jan 27 08:45:10 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Wed, 27 Jan 2016 19:45:10 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: <38AC34DC-4A2E-4CBE-879F-C8A341A7F951@gmail.com> > Well, so, to continue, let's assume that there are no user-defined functions, and in fact the only thing we want to proof is select+filter, where a filter is limited to the default operators. From that is it follows that > > -path1: select-child-nodes-by-name(select-child-nodes-by-name($context,'x'),'w') > -path2: select-descendant-nodes-by-name($context,'w') > > And we need to proof that those functions are somehow equivalent. Can it be done? Its easy to prove that they are not equivalent. You can have nodes with ?w? label at multiple levels, including children on $context. From christian.gruen at gmail.com Wed Jan 27 08:46:07 2016 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Wed, 27 Jan 2016 17:46:07 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: > Well, so, to continue, let's assume that there are no user-defined > functions, and in fact the only thing we want to proof is select+filter, > where a filter is limited to the default operators. From that is it follows > that > > -path1: > select-child-nodes-by-name(select-child-nodes-by-name($context,'x'),'w') > -path2: select-descendant-nodes-by-name($context,'w') Just to complete this: The predicate must not be numeric (//w[1] is not equivalent to /descendant::w[1]). > Op woensdag 27 januari 2016 heeft daniela florescu het > volgende geschreven: >> >> > >> > It seems to be a long-standing tradition that computer scientists, when >> > asked to prove a difficult conjecture C, respond by giving a proof for a >> > simplified conjecture C'. While this might lead to progress in the long run, >> > and enables them to get papers published in the academic literature, it is >> > totally useless to practical engineeers who want to know whether they can >> > safely rely on C. >> >> Michael, >> >> >> what you say is nice and true. >> >> However given that: >> 1. path expressions point (syntactically hence esemantically) into >> XQuery?s expressions >> 2. XQuery expression language is Turing complete >> 3. Subsumption for a Turing complete language is undecidable. >> >> Well, I can hardly see a way to decide this problem other then by >> introducing SOME restrictions >> of some sort? but of course some restrictions that would not nullify the >> original problem all together >> and make the solution useless. >> >> Best, >> Dana > > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From wshager at gmail.com Wed Jan 27 10:42:59 2016 From: wshager at gmail.com (W.S. Hager) Date: Wed, 27 Jan 2016 19:42:59 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: Finally, can it be proved that /w[@a=b] is a subset of /w, taking into account that the filter can only contain standard operators (eq, gt, lt, etc as defined in the op namespace)? 2016-01-27 17:46 GMT+01:00 Christian Gr?n : > > Well, so, to continue, let's assume that there are no user-defined > > functions, and in fact the only thing we want to proof is select+filter, > > where a filter is limited to the default operators. From that is it > follows > > that > > > > -path1: > > select-child-nodes-by-name(select-child-nodes-by-name($context,'x'),'w') > > -path2: select-descendant-nodes-by-name($context,'w') > > Just to complete this: The predicate must not be numeric (//w[1] is > not equivalent to /descendant::w[1]). > > > > > Op woensdag 27 januari 2016 heeft daniela florescu > het > > volgende geschreven: > >> > >> > > >> > It seems to be a long-standing tradition that computer scientists, > when > >> > asked to prove a difficult conjecture C, respond by giving a proof > for a > >> > simplified conjecture C'. While this might lead to progress in the > long run, > >> > and enables them to get papers published in the academic literature, > it is > >> > totally useless to practical engineeers who want to know whether they > can > >> > safely rely on C. > >> > >> Michael, > >> > >> > >> what you say is nice and true. > >> > >> However given that: > >> 1. path expressions point (syntactically hence esemantically) into > >> XQuery?s expressions > >> 2. XQuery expression language is Turing complete > >> 3. Subsumption for a Turing complete language is undecidable. > >> > >> Well, I can hardly see a way to decide this problem other then by > >> introducing SOME restrictions > >> of some sort? but of course some restrictions that would not nullify the > >> original problem all together > >> and make the solution useless. > >> > >> Best, > >> Dana > > > > > > > > -- > > > > W.S. Hager > > Lagua Web Solutions > > http://lagua.nl > > > > > > > > _______________________________________________ > > talk at x-query.com > > http://x-query.com/mailman/listinfo/talk > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From dflorescu at me.com Wed Jan 27 11:40:22 2016 From: dflorescu at me.com (daniela florescu) Date: Wed, 27 Jan 2016 11:40:22 -0800 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: <692371F1-DF69-4CC0-8F42-7715A3111785@me.com> > On Jan 27, 2016, at 8:41 AM, W.S. Hager wrote: > > Well, so, to continue, let's assume that there are no user-defined functions, The Turing completeness of XQuery doesn?t come from the user defined functions. It?s intrinsic to the rest of XQuery. Even without user defined functions, XQuery is still Turing complete. Dana -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Thu Jan 28 01:55:40 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Thu, 28 Jan 2016 12:55:40 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> Message-ID: <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> > Finally, can it be proved that /w[@a=b] is a subset of /w, taking into account that the filter can only contain standard operators (eq, gt, lt, etc as defined in the op namespace)? Okay, now we are close! However now formal do you want the proof to be? I can give this informal proof: The first path expression selects some subset of the children of the node that it applies, where the label is 'w'. The second one selects all descendants with label 'w', hence it's result contains all nodes of the first path expression. But if you want to go formal, you need to use the semantics of XQuery path expressions, as well as the formal specification of the data model. There used to be a formal document on XQuery data model. > 2016-01-27 17:46 GMT+01:00 Christian Gr?n : >> > Well, so, to continue, let's assume that there are no user-defined >> > functions, and in fact the only thing we want to proof is select+filter, >> > where a filter is limited to the default operators. From that is it follows >> > that >> > >> > -path1: >> > select-child-nodes-by-name(select-child-nodes-by-name($context,'x'),'w') >> > -path2: select-descendant-nodes-by-name($context,'w') >> >> Just to complete this: The predicate must not be numeric (//w[1] is >> not equivalent to /descendant::w[1]). >> >> >> >> > Op woensdag 27 januari 2016 heeft daniela florescu het >> > volgende geschreven: >> >> >> >> > >> >> > It seems to be a long-standing tradition that computer scientists, when >> >> > asked to prove a difficult conjecture C, respond by giving a proof for a >> >> > simplified conjecture C'. While this might lead to progress in the long run, >> >> > and enables them to get papers published in the academic literature, it is >> >> > totally useless to practical engineeers who want to know whether they can >> >> > safely rely on C. >> >> >> >> Michael, >> >> >> >> >> >> what you say is nice and true. >> >> >> >> However given that: >> >> 1. path expressions point (syntactically hence esemantically) into >> >> XQuery?s expressions >> >> 2. XQuery expression language is Turing complete >> >> 3. Subsumption for a Turing complete language is undecidable. >> >> >> >> Well, I can hardly see a way to decide this problem other then by >> >> introducing SOME restrictions >> >> of some sort? but of course some restrictions that would not nullify the >> >> original problem all together >> >> and make the solution useless. >> >> >> >> Best, >> >> Dana >> > >> > >> > >> > -- >> > >> > W.S. Hager >> > Lagua Web Solutions >> > http://lagua.nl >> > >> > >> > >> > _______________________________________________ >> > talk at x-query.com >> > http://x-query.com/mailman/listinfo/talk > > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.retter at googlemail.com Thu Jan 28 04:18:09 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Thu, 28 Jan 2016 12:18:09 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> Message-ID: Okay thanks to everyone for the replies. I think the scope of what I was looking for got thrown out in all the discussion, or perhaps I wasn't clear enough early in my initial post. I am not interested in XQuery, and I am only interested in a small subset of XPath. I am concerned with comparing two path expressions, these path expressions may have predicates, what I didn't make clear is that those predicates may not contain functions, only the comparison operators eq, ne, gt, ge, lt, le, and =, !=, >, >=, <, <=. As Christian observed, [1] is not the same as [@a eq 'b']. In my original post, I posed these two path expressions: 1. //w 2. /x/y/z/w[@a = 'v'] In this instance I can actually ignore the predicate, as I can see that /x/y/z/w would already produce the subset of //w and the predicate only serves to restrict that further. I am not looking for a formal proof in any sense. I am looking for something practical that I can use in code. On 28 January 2016 at 09:55, Pavel Velikhov wrote: > > Finally, can it be proved that /w[@a=b] is a subset of /w, taking into > account that the filter can only contain standard operators (eq, gt, lt, etc > as defined in the op namespace)? > > > Okay, now we are close! However now formal do you want the proof to be? I > can give this informal proof: > > The first path expression selects some subset of the children of the node > that it applies, where the label is 'w'. The second one selects all > descendants with label 'w', hence it's result contains all nodes of the > first path expression. > > But if you want to go formal, you need to use the semantics of XQuery path > expressions, as well as the formal specification of the data model. There > used to be a formal document on XQuery data model. > > > > 2016-01-27 17:46 GMT+01:00 Christian Gr?n : >> >> > Well, so, to continue, let's assume that there are no user-defined >> > functions, and in fact the only thing we want to proof is select+filter, >> > where a filter is limited to the default operators. From that is it >> > follows >> > that >> > >> > -path1: >> > select-child-nodes-by-name(select-child-nodes-by-name($context,'x'),'w') >> > -path2: select-descendant-nodes-by-name($context,'w') >> >> Just to complete this: The predicate must not be numeric (//w[1] is >> not equivalent to /descendant::w[1]). >> >> >> >> > Op woensdag 27 januari 2016 heeft daniela florescu >> > het >> > volgende geschreven: >> >> >> >> > >> >> > It seems to be a long-standing tradition that computer scientists, >> >> > when >> >> > asked to prove a difficult conjecture C, respond by giving a proof >> >> > for a >> >> > simplified conjecture C'. While this might lead to progress in the >> >> > long run, >> >> > and enables them to get papers published in the academic literature, >> >> > it is >> >> > totally useless to practical engineeers who want to know whether they >> >> > can >> >> > safely rely on C. >> >> >> >> Michael, >> >> >> >> >> >> what you say is nice and true. >> >> >> >> However given that: >> >> 1. path expressions point (syntactically hence esemantically) into >> >> XQuery?s expressions >> >> 2. XQuery expression language is Turing complete >> >> 3. Subsumption for a Turing complete language is undecidable. >> >> >> >> Well, I can hardly see a way to decide this problem other then by >> >> introducing SOME restrictions >> >> of some sort? but of course some restrictions that would not nullify >> >> the >> >> original problem all together >> >> and make the solution useless. >> >> >> >> Best, >> >> Dana >> > >> > >> > >> > -- >> > >> > W.S. Hager >> > Lagua Web Solutions >> > http://lagua.nl >> > >> > >> > >> > _______________________________________________ >> > talk at x-query.com >> > http://x-query.com/mailman/listinfo/talk > > > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From pavel.velikhov at gmail.com Thu Jan 28 04:28:12 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Thu, 28 Jan 2016 15:28:12 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> Message-ID: <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> > > Okay thanks to everyone for the replies. > > I think the scope of what I was looking for got thrown out in all the > discussion, or perhaps I wasn't clear enough early in my initial post. > > I am not interested in XQuery, and I am only interested in a small > subset of XPath. I am concerned with comparing two path expressions, > these path expressions may have predicates, what I didn't make clear > is that those predicates may not contain functions, only the > comparison operators eq, ne, gt, ge, lt, le, and =, !=, >, >=, <, <=. So you need an algorithm to test subsumption of path expressions (with the given limitations)? Or just that one case? From adam.retter at googlemail.com Thu Jan 28 04:35:16 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Thu, 28 Jan 2016 12:35:16 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: > So you need an algorithm to test subsumption of path expressions (with the given limitations)? Yes. > Or just that one case? No I want to cover any case where the set which would be selected by the path expression is statically known (i.e. no function calls). -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From wshager at gmail.com Thu Jan 28 04:37:31 2016 From: wshager at gmail.com (W.S. Hager) Date: Thu, 28 Jan 2016 13:37:31 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: @Pavel do you mean the link I send before? http://www.w3.org/TR/xquery-semantics What would be the difference between a proof and a test, in this case? 2016-01-28 13:35 GMT+01:00 Adam Retter : > > So you need an algorithm to test subsumption of path expressions (with > the given limitations)? > > Yes. > > > Or just that one case? > > No I want to cover any case where the set which would be selected by > the path expression is statically known (i.e. no function calls). > > > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Thu Jan 28 04:47:00 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Thu, 28 Jan 2016 15:47:00 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: <06E56710-99B8-4891-B890-057D1012E941@gmail.com> > @Pavel do you mean the link I send before? http://www.w3.org/TR/xquery-semantics Yes! That?s it. > What would be the difference between a proof and a test, in this case? Well, proving a specific case is usually very easy, assuming the proof isn?t too formal. A test is a general procedure. Shouldn?t be that hard, unless we try to prove its correctness (and depending on how formal we want to proof to be). > > 2016-01-28 13:35 GMT+01:00 Adam Retter >: > > So you need an algorithm to test subsumption of path expressions (with the given limitations)? > > Yes. > > > Or just that one case? > > No I want to cover any case where the set which would be selected by > the path expression is statically known (i.e. no function calls). > > > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Thu Jan 28 05:09:33 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Thu, 28 Jan 2016 16:09:33 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: > On 28 Jan 2016, at 15:35, Adam Retter wrote: > >> So you need an algorithm to test subsumption of path expressions (with the given limitations)? > > Yes. > >> Or just that one case? > > No I want to cover any case where the set which would be selected by > the path expression is statically known (i.e. no function calls). I think this should work: So suppose you have 2 path expressions, p1 and p2, and you allow only /x or //x as path steps and each path step can have a predicate: p1 = axis_1 pred_1, ?, axis_n pred_n p2 = axis_1 pred_1, ? , axis_m pred_m subsumes(p1, p2): /* recursion base case */ if p1 is empty: return true if p2 is empty: return false a_1 = first axis of p1 a_2 = first axis of p2 if a_1 is a child axis ?/? label l : if a_2 is a child axis ?/' with the same label l, and the predicates are equivalent: return subsumes(p1 - a_1, p2 - a_2) else: return false if a_1 is a descendants axis ?//? with label l: if p2 contains an axis with label l: p2? = remove all axes of p2 from the head, until you find an axis with label l p2? = remove the axis with label l from p2' return subsumes( p_1 - a_1, p2? ) return false > > > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk From pavel.velikhov at gmail.com Thu Jan 28 05:17:01 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Thu, 28 Jan 2016 16:17:01 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: No, the first line in the base case should also return false, sorry > > > So suppose you have 2 path expressions, p1 and p2, and you allow only /x or //x as path steps > and each path step can have a predicate: > > p1 = axis_1 pred_1, ?, axis_n pred_n > p2 = axis_1 pred_1, ? , axis_m pred_m > > subsumes(p1, p2): > /* recursion base case */ > if p1 is empty: return true > if p2 is empty: return false > > a_1 = first axis of p1 > a_2 = first axis of p2 > > if a_1 is a child axis ?/? label l : > if a_2 is a child axis ?/' with the same label l, and the predicates are equivalent: > return subsumes(p1 - a_1, p2 - a_2) > else: > return false > > if a_1 is a descendants axis ?//? with label l: > if p2 contains an axis with label l: > p2? = remove all axes of p2 from the head, until you find an axis with label l > p2? = remove the axis with label l from p2' > return subsumes( p_1 - a_1, p2? ) > > return false From g at 28.io Thu Jan 28 05:44:47 2016 From: g at 28.io (Ghislain Fourny) Date: Thu, 28 Jan 2016 14:44:47 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: Hi Adam, This may sound stupid, but: have you considered that (and would it be relevant to you that) the second expression may raise errors that the first one wouldn't have raised, rather than returning a subset? Consider the case where b has a numeric type, and the attribute a cannot be cast to double? Kind regards, Ghislain On Thu, Jan 28, 2016 at 2:17 PM, Pavel Velikhov wrote: > No, the first line in the base case should also return false, sorry > > > > > > > So suppose you have 2 path expressions, p1 and p2, and you allow only /x > or //x as path steps > > and each path step can have a predicate: > > > > p1 = axis_1 pred_1, ?, axis_n pred_n > > p2 = axis_1 pred_1, ? , axis_m pred_m > > > > subsumes(p1, p2): > > /* recursion base case */ > > if p1 is empty: return true > > if p2 is empty: return false > > > > a_1 = first axis of p1 > > a_2 = first axis of p2 > > > > if a_1 is a child axis ?/? label l : > > if a_2 is a child axis ?/' with the same label l, and the predicates > are equivalent: > > return subsumes(p1 - a_1, p2 - a_2) > > else: > > return false > > > > if a_1 is a descendants axis ?//? with label l: > > if p2 contains an axis with label l: > > p2? = remove all axes of p2 from the head, until you find an axis > with label l > > p2? = remove the axis with label l from p2' > > return subsumes( p_1 - a_1, p2? ) > > > > return false > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.retter at googlemail.com Thu Jan 28 05:56:23 2016 From: adam.retter at googlemail.com (Adam Retter) Date: Thu, 28 Jan 2016 13:56:23 +0000 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: Hi Ghislain, No I have not considered error cases, for the moment it is enough for me to just raise an error if the path is invalid. Although in this case I can assume that all paths I am provided are correct. On 28 January 2016 at 13:44, Ghislain Fourny wrote: > Hi Adam, > > This may sound stupid, but: have you considered that (and would it be > relevant to you that) the second expression may raise errors that the first > one wouldn't have raised, rather than returning a subset? > > Consider the case where b has a numeric type, and the attribute a cannot be > cast to double? > > Kind regards, > Ghislain > > > On Thu, Jan 28, 2016 at 2:17 PM, Pavel Velikhov > wrote: >> >> No, the first line in the base case should also return false, sorry >> >> > >> > >> > So suppose you have 2 path expressions, p1 and p2, and you allow only /x >> > or //x as path steps >> > and each path step can have a predicate: >> > >> > p1 = axis_1 pred_1, ?, axis_n pred_n >> > p2 = axis_1 pred_1, ? , axis_m pred_m >> > >> > subsumes(p1, p2): >> > /* recursion base case */ >> > if p1 is empty: return true >> > if p2 is empty: return false >> > >> > a_1 = first axis of p1 >> > a_2 = first axis of p2 >> > >> > if a_1 is a child axis ?/? label l : >> > if a_2 is a child axis ?/' with the same label l, and the predicates >> > are equivalent: >> > return subsumes(p1 - a_1, p2 - a_2) >> > else: >> > return false >> > >> > if a_1 is a descendants axis ?//? with label l: >> > if p2 contains an axis with label l: >> > p2? = remove all axes of p2 from the head, until you find an axis >> > with label l >> > p2? = remove the axis with label l from p2' >> > return subsumes( p_1 - a_1, p2? ) >> > >> > return false >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From pavel.velikhov at gmail.com Thu Jan 28 08:20:34 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Thu, 28 Jan 2016 19:20:34 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: Hmm.. testing subsumption is not as trivial as I thought. Here's a cleaner way to do it: represent both path expressions as DFAs and then test subsumption. You'll get DFAs A and B and then test if minimized(B-A) is empty. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wshager at gmail.com Fri Jan 29 09:53:36 2016 From: wshager at gmail.com (W.S. Hager) Date: Fri, 29 Jan 2016 18:53:36 +0100 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: This is the best I (actually Google) can do. Proof: https://coq.inria.fr/library/Coq.MSets.MSetGenTree.html Test: http://www.geeksforgeeks.org/check-if-a-binary-tree-is-subtree-of-another-binary-tree/ At some point I'll look into this myself, it's a nice challenge. donderdag 28 januari 2016 heeft Pavel Velikhov het volgende geschreven: > Hmm.. testing subsumption is not as trivial as I thought. Here's a cleaner > way to do it: represent both path expressions as DFAs and then test > subsumption. You'll get DFAs A and B and then test if minimized(B-A) is > empty. > -- W.S. Hager Lagua Web Solutions http://lagua.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.velikhov at gmail.com Fri Jan 29 14:29:16 2016 From: pavel.velikhov at gmail.com (Pavel Velikhov) Date: Sat, 30 Jan 2016 01:29:16 +0300 Subject: [xquery-talk] Function for determining one XPath as subset of another In-Reply-To: References: <117C8FBF-A51A-4DE2-8655-77D614242088@gmail.com> <8F63EA56-D631-4CA8-9DB8-4E545BF5D8BE@saxonica.com> <59DB66C2-39D1-44E2-9E64-D83A4351BF24@gmail.com> <253CB5F3-FB51-4272-9E42-C3BAD54D0EA4@gmail.com> Message-ID: <7D5E32FA-F00A-4A55-8B82-450BEC6A0BB6@gmail.com> Trees won?t help much here. The difficulty with path expression is due to the // step, which adds non-determinism. //w/x subsumes /w/x/y/z/w/x //w/w doesn?t subsume /w/x/w Regular languages also have determinism and all the algorithms for them are exceptionally well-studied. Or you can do an algorithm with backtracking, but it could get hairy. > On 29 Jan 2016, at 20:53, W.S. Hager wrote: > > This is the best I (actually Google) can do. > > Proof: > https://coq.inria.fr/library/Coq.MSets.MSetGenTree.html > Test: > > http://www.geeksforgeeks.org/check-if-a-binary-tree-is-subtree-of-another-binary-tree/ > At some point I'll look into this myself, it's a nice challenge. > > > donderdag 28 januari 2016 heeft Pavel Velikhov > het volgende geschreven: > Hmm.. testing subsumption is not as trivial as I thought. Here's a cleaner way to do it: represent both path expressions as DFAs and then test subsumption. You'll get DFAs A and B and then test if minimized(B-A) is empty. > > > -- > W.S. Hager > Lagua Web Solutions > http://lagua.nl > -------------- next part -------------- An HTML attachment was scrubbed... URL: