Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 90841 invoked from network); 13 Nov 2008 22:39:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Nov 2008 22:39:44 -0000 Received: (qmail 27603 invoked by uid 500); 13 Nov 2008 22:39:50 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 27567 invoked by uid 500); 13 Nov 2008 22:39:50 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 27556 invoked by uid 99); 13 Nov 2008 22:39:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 14:39:50 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of antony.blakey@gmail.com designates 209.85.142.188 as permitted sender) Received: from [209.85.142.188] (HELO ti-out-0910.google.com) (209.85.142.188) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 22:38:28 +0000 Received: by ti-out-0910.google.com with SMTP id w7so766137tib.6 for ; Thu, 13 Nov 2008 14:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=OAg5BeG8DxmDm7LyUxwHkEhcGO7vWYeejF7MJjv6JI0=; b=AgRD0/l+mAMon211xeYy2XKYFSBQqKLvOGUG3kHo8ddd1OpV+vJun2WJBWhzV0s/8U CgucX/K+y2cP519n/t2aUn9AIVXsuqiwgUF6Z5DTtRbxfpXzvEHMOmnUGrfYZBFLgVNi +8t++ocwG5NBc5iUgDPS7JLhwoas5+8u9s67o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=Ehhk17uVcZ1bZwSWOrpU+8Ay3QZBm6gc0EExBlhc43R9RoPpmi2/qTcEz+VgsFK7bm imtH3FWDKDzuZ3CWow1+Cvf4bSAbTpEhCkdqQi7sNARFhr3mD9TYG2Qg0lTY1piaQ5Dw +p1tOmctdVYatSVlTUSWWLf+iwLdJKNxxl1hk= Received: by 10.110.43.20 with SMTP id q20mr277206tiq.25.1226615950836; Thu, 13 Nov 2008 14:39:10 -0800 (PST) Received: from ?192.168.0.16? (ppp121-45-41-103.lns10.adl2.internode.on.net [121.45.41.103]) by mx.google.com with ESMTPS id w12sm2173387tib.10.2008.11.13.14.39.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 13 Nov 2008 14:39:09 -0800 (PST) Message-Id: From: Antony Blakey To: couchdb-user@incubator.apache.org In-Reply-To: <20081113220313.GG15315@tumbolia.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: Document Updates Date: Fri, 14 Nov 2008 09:09:03 +1030 References: <403828.36717.qm@web52508.mail.re2.yahoo.com> <46837.75533.qm@web52503.mail.re2.yahoo.com> <20081113163808.GA15315@tumbolia.org> <27d8d0930811130840t47269d91o9539fae200bcd380@mail.gmail.com> <20081113164344.GB15315@tumbolia.org> <99294D7F-4D06-47F9-800B-DB9213D929F4@gmail.com> <20081113220313.GG15315@tumbolia.org> X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org On 14/11/2008, at 8:33 AM, Noah Slater wrote: > On Fri, Nov 14, 2008 at 08:19:22AM +1030, Antony Blakey wrote: >> The relevent section from XQuery Update, >> http://www.w3.org/TR/xquery-update-10/#id-update-primitives, might >> be useful >> starting point for defining a JSON-encoded (recursive) EDL-based >> structural >> diff. > > I think an XQuery/XPath type solution would be very interesting. IMO the simplest thing that would work (ignoring representation) looks something like this: insert in insert after insert before delete replace with where jsonpath is roughly as: http://goessner.net/articles/JsonPath/ without the executable expressions. Diff computation would undoubtedly generate a restricted subset of jsonpath selectors, but it's worth supporting the wildcard/recursive descent operations for clients. Representing the update document as json itself would be clean, so an EDL could look like this: [ { "replace":"$.post.comments[2].email" "with":"antony@linkuistics.com" }, { "insert": { "email":.... } "in": "$.post.comments" } { "insert": { "email":.... } "after": "$.post.comments[5]" } ] or, using a meta-encoding (which IMO is unneccessary) [ { "op":"replace" "path":"$.post.comments[2].email" "content":"antony@linkuistics.com " }, { "op":"insert-in" "path":"$.post.comments" "content": { "email":.... } } { "op":"insert-after" "path":"$.post.comments[5]" "content": { "email":.... } } ] I propose that these aren't declarative, but procedural, in the sense that they are applied linearly and hence each path context is the result of the proceeding edits, rather than the original tree. This complicates the encoding of diffs but results in a much simpler apply mechanism. But maybe it would be worth using a declarative form with a constant context - I'm unsure about the tradeoffs. Antony Blakey ------------- CTO, Linkuistics Pty Ltd Ph: 0438 840 787 He who would make his own liberty secure, must guard even his enemy from repression. -- Thomas Paine