From adam.retter at googlemail.com Fri Jun 3 21:26:20 2011 From: adam.retter at googlemail.com (Adam Retter) Date: Sat, 4 Jun 2011 06:26:20 +0200 Subject: [xquery-talk] Question about xml databse app design and xml file merging (using xquery maybe) In-Reply-To: References: Message-ID: Hi Josh, I think the problem here is not the XQuery but perhaps the approach to solving the problem that you have taken. You mention that your using eXist-db, in eXist-db you can do what you want very simply because we integrate betterForm with eXist-db. betterForm is an XForms engines, and such engines already do what I think you want transparently. That is to say that you can have your XForm store your instance at any point into the db, upon reloading that instance (at some point in the future) into the XForm model you will be presented with the form in the state as the user left it, i.e. partially completed. You can of course also have your XForm load its instance from the result of an XQuery if you wish to do some pre-processing or have it POST submit your instance onto an XQuery script if you wish to do some post-processing of your instance. As this is now focusing more on eXist-db specifics than XQuery itself, it may be better to move this discussion to the exist-open mailing list. Thanks Adam. On 4 June 2011 02:38, Josh Story wrote: > Just joined this mailing list so I hope I'm submitting this item correctly. > I have fairly rudimentary knowledge of xquery, xpath, and xslt and am in the > process of exploring a XRX implementation of an existing application that > collects insurance quote information. The current application is about 12 > years old, uses poorly formed html with javascript and a java backend. I'm > experimenting with the XRX pattern using eXist but am having trouble > retraining myself to think declaratively rather than procedurally. > > Here is my current 'problem'. I'm hoping to get some feedback on whether I'm > constructing the app in a decent way or if it should be revamped completely > and also looking for a technical solution to something that I think should > be possible in xquery but seems to be difficult to implement. > > First, imagine you can create multiple quotes which store information about > the insurance risk (let's say its home insurance so you are storing info on > the property as well as the person living there). in the xml database I'll > be storing new instances of quotes as they're created with certain data > present and other data missing as the user may not have answered all > questions yet. > > So if the user creates a new quote (xml data instance created) and gets > partway through (xml data instance saved partially complete) and then > reopens the quote and modifies some info and leaves again (xml data instance > changed and saved again) and the reopens and completes the quote (xml data > changed for a final time) the xml goes through a few stages before it is > final. Now since this takes time (minutes, hours, days, or even weeks) there > is the possibility that the model of information we need to properly quote > changes. So let's say I started with this model: > > > ?? > ?? > ?? > > > and the original quote was created with this xml structure. And let's > pretend I only have to answer the fname question > > > ?? Josh > ?? > ?? > > > ?Now the model changes and I want to capture and store work phone so any new > quotes are created with the following model: > > > ?? > ?? > ?? > ?? > > > I would want any quote that was being edited to include the new field from > the updated model (this would be to allow an XFroms binding to that node and > presumably the application forces the user to now answer this new question > prior to making the submission final) > > I would want the xquery to serve up an xml nodeset like > > > ?? Josh > ?? > ?? > ?? > > > So my question is can xquery be used to traverse a 'current state' model and > try to grab data from a data-instance that looks similar but won't > necessarily be identical and load it up so that when the user saves their > quote they're actually saving a representation of the most recent valid > model but with information remembered from their prior saves? I find it very > difficult to dynamically traverse an xml in xquery and grab text() from > atomic elements that match the same xpath as the node I'm currently focused > on. I've tried declaring a local function that does a recursive loop through > the model and dynamically evaluates the data instance using xpath pulled > from each model element using > > util:eval(...) > and > util:node-xpath(...) > > but I can't seem to get it to work. > > Ok so back to the beginning. Am I designing this app all wrong (the idea of > a model that can change and potentially outdated instances of data based on > whatever model was in use a the last time the quotes was loaded/saved in the > application)? > > And the if this is a decent design is there a relatively easy way to do this > xml merging or whatever it should be called (xml extrusion maybe?). maybe I > should be looking to xslt or something else in combination with xquery to > get this done? > > Thanks, > Josh > > _______________________________________________ > 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 mike at saxonica.com Sat Jun 4 03:18:50 2011 From: mike at saxonica.com (Michael Kay) Date: Sat, 04 Jun 2011 11:18:50 +0100 Subject: [xquery-talk] Question about xml databse app design and xml file merging (using xquery maybe) In-Reply-To: References: Message-ID: <4DEA068A.2090901@saxonica.com> On 04/06/2011 01:38, Josh Story wrote: > So my question is can xquery be used to traverse a 'current state' > model and try to grab data from a data-instance that looks similar but > won't necessarily be identical and load it up It can; but the processing model you are describing is essentially the XSLT processing model rather than the XQuery model. XQuery makes it easy to select data from your input and perform computations on it; XSLT makes it easy to transform your input into an output that is structurally similar. The functionality of the two languages overlaps and most jobs that can be done with one can also be done with the other, but some jobs are much easier in XSLT and others are easier in XQuery. Michael Kay Saxonica From geert.josten at daidalos.nl Tue Jun 21 04:32:06 2011 From: geert.josten at daidalos.nl (Geert Josten) Date: Tue, 21 Jun 2011 13:32:06 +0200 Subject: [xquery-talk] Convert diacritics to low-ascii Message-ID: Hi, Does anyone know a simple trick to convert characters like ? and ? to their low-ascii counterparts? Kind regards, Geert From andrew.j.welch at gmail.com Tue Jun 21 04:59:14 2011 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Tue, 21 Jun 2011 12:59:14 +0100 Subject: [xquery-talk] Convert diacritics to low-ascii In-Reply-To: References: Message-ID: > Does anyone know a simple trick to convert characters like ? and ? to their low-ascii counterparts? codepoints-to-string(string-to-codepoints(normalize-unicode('normalis?', 'NFD'))[. ne 769]) -- Andrew Welch http://andrewjwelch.com From geert.josten at daidalos.nl Tue Jun 21 05:33:11 2011 From: geert.josten at daidalos.nl (Geert Josten) Date: Tue, 21 Jun 2011 14:33:11 +0200 Subject: [xquery-talk] Convert diacritics to low-ascii In-Reply-To: <6548F17059905B48B2A6F28CE3692BAA26E97C@OAEXCH4SERVER.oa.oclc.org> References: <6548F17059905B48B2A6F28CE3692BAA26E97C@OAEXCH4SERVER.oa.oclc.org> Message-ID: Thanx Andy! Works just fine in XQuery too. But have to admit that it looks a bit funny to me. Replace something with nothing and still end up with all characters? Can anyone explain what this \p{M} is matching? Unicode spec isn't making it much clearer to me.. :-P Kind regards, Geert -----Oorspronkelijk bericht----- Van: Houghton,Andrew [mailto:houghtoa at oclc.org] Verzonden: dinsdag 21 juni 2011 14:18 Aan: Geert Josten Onderwerp: Re: [xquery-talk] Convert diacritics to low-ascii If you are using XSLT 2.0 then convert the string to Unicode NFD or NFKD with normalize-unicode, then use regex replace with a unicode category to remove the diacritics. For example: Hope that helps, Andy ----- Original Message ----- From: talk-bounces at x-query.com To: talk at x-query.com Sent: Tue Jun 21 07:32:06 2011 Subject: [xquery-talk] Convert diacritics to low-ascii Hi, Does anyone know a simple trick to convert characters like ? and ? to their low-ascii counterparts? Kind regards, Geert _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From andrew.j.welch at gmail.com Tue Jun 21 05:53:21 2011 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Tue, 21 Jun 2011 13:53:21 +0100 Subject: [xquery-talk] Convert diacritics to low-ascii In-Reply-To: References: <6548F17059905B48B2A6F28CE3692BAA26E97C@OAEXCH4SERVER.oa.oclc.org> Message-ID: On 21 June 2011 13:33, Geert Josten wrote: > Thanx Andy! > > Works just fine in XQuery too. But have to admit that it looks a bit funny to me. Replace something with nothing and still end up with all characters? Can anyone explain what this \p{M} is matching? Unicode spec isn't making it much clearer to me.. :-P > Taken from: http://www.regular-expressions.info/unicode.html "\p{M} or \p{Mark}: a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.)." When NFD or NFKD is used, then the diacritics are represented by a character following the letter, so for example e accute is the letter e followed by the character for the accute... so you can just remove that character and be left with the e. (in my post earlier you can see the accute is unicode character 769) -- Andrew Welch http://andrewjwelch.com From geert.josten at daidalos.nl Tue Jun 21 05:58:15 2011 From: geert.josten at daidalos.nl (Geert Josten) Date: Tue, 21 Jun 2011 14:58:15 +0200 Subject: [xquery-talk] Convert diacritics to low-ascii In-Reply-To: <4E0094A7.6050103@gmx.de> References: <6548F17059905B48B2A6F28CE3692BAA26E97C@OAEXCH4SERVER.oa.oclc.org> <4E0094A7.6050103@gmx.de> Message-ID: Thanks! I now notice I just didn?t looked close enough. The XQuery engine was returning: "abcdëf", I didn't notice the 'e' in front of the &#x..; :) -----Oorspronkelijk bericht----- Van: Martin Honnen [mailto:Martin.Honnen at gmx.de] Verzonden: dinsdag 21 juni 2011 14:55 Aan: Geert Josten Onderwerp: Re: [xquery-talk] Convert diacritics to low-ascii Geert Josten wrote: > Works just fine in XQuery too. But have to admit that it looks a bit > funny to me. Replace something with nothing and still end up with all > characters? Can anyone explain what this \p{M} is matching? Unicode > spec isn't making it much clearer to me.. :-P Well when you do e.g. normalize-unicode('??', 'NFD') you get a string with four characters 'a', ' ?', 'e', and '?'. And the replace(normalize-unicode('abcd?f', 'NFD'), '[\p{M}]', '') removes the second and fourth character. -- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/ From geert.josten at daidalos.nl Tue Jun 21 08:30:44 2011 From: geert.josten at daidalos.nl (Geert Josten) Date: Tue, 21 Jun 2011 17:30:44 +0200 Subject: [xquery-talk] Convert diacritics to low-ascii In-Reply-To: References: <6548F17059905B48B2A6F28CE3692BAA26E97C@OAEXCH4SERVER.oa.oclc.org> Message-ID: And thnx to Andrew as well.. :) -----Oorspronkelijk bericht----- Van: Andrew Welch [mailto:andrew.j.welch at gmail.com] Verzonden: dinsdag 21 juni 2011 14:53 Aan: Geert Josten CC: Houghton,Andrew; talk at x-query.com Onderwerp: Re: [xquery-talk] Convert diacritics to low-ascii On 21 June 2011 13:33, Geert Josten wrote: > Thanx Andy! > > Works just fine in XQuery too. But have to admit that it looks a bit funny to me. Replace something with nothing and still end up with all characters? Can anyone explain what this \p{M} is matching? Unicode spec isn't making it much clearer to me.. :-P > Taken from: http://www.regular-expressions.info/unicode.html "\p{M} or \p{Mark}: a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.)." When NFD or NFKD is used, then the diacritics are represented by a character following the letter, so for example e accute is the letter e followed by the character for the accute... so you can just remove that character and be left with the e. (in my post earlier you can see the accute is unicode character 769) -- Andrew Welch http://andrewjwelch.com From andrew.j.welch at gmail.com Thu Jun 23 05:00:43 2011 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Thu, 23 Jun 2011 13:00:43 +0100 Subject: [xquery-talk] node comparison based on qualified name In-Reply-To: References: Message-ID: On 23 June 2011 12:32, Kunal Chauhan wrote: > Hi, > > I have two different sequences of elements and I want to compare those two. > How can I compare these two sequences based on their qualified name. > ?attributes,content values doesn't matter. > > for example, > > let $seq1 := > ?????? > ??????aaa > ??????aaa > ??????? > > let $seq2 := > ???? > ??????bbb > ??????bbb > ??????? > > let $seq3 := > > ???? > ??????ddd > ?????? > > When I compare $seq1 and $seq2 it should not return any element, but when I > compare $seq1 and $seq3 it should return aaa > How can I achieve this ? The basic comparison is: $seq1/*[not(name() = $seq3/*/name())] -- Andrew Welch http://andrewjwelch.com From gfourny at inf.ethz.ch Thu Jun 23 05:16:51 2011 From: gfourny at inf.ethz.ch (Ghislain Fourny) Date: Thu, 23 Jun 2011 12:16:51 +0000 Subject: [xquery-talk] node comparison based on qualified name In-Reply-To: References: Message-ID: Hi, Would the following function help (you would need to adapt the output of course)? I made the following assumptions: - the order is not important - the output should contain a list of what was "inserted", as well as a list of what was "deleted" - QNames might occur multiple times in each sequence (to be general) - if QNames occur multiple times and their count is different, then it does not matter which of the nodes with this QName are taken for the delta (the function below takes the last abs($count-right - $count-left) ones). Does it make sense? Kind regards, Ghislain declare function local:compare($seq1, $seq2) { let $qnames1 := distinct-values($seq1/name()) let $qnames2 := distinct-values($seq2/name()) return ( { for $qname-in-common in $qnames1[. = $qnames2] let $count-left := count($seq1[name() = $qname-in-common]) let $count-right := count($seq2[name() = $qname-in-common]) where $count-left lt $count-right return $seq2[name() = $qname-in-common][position() gt last() - ($count-right - $count-left)], for $qname-right-only in $qnames2[not(. = $qnames1)] return $seq2[name() = $qname-right-only] }, { for $qname-in-common in $qnames1[. = $qnames2] let $count-left := count($seq1[name() = $qname-in-common]) let $count-right := count($seq2[name() = $qname-in-common]) where $count-right lt $count-left return $seq1[name() = $qname-in-common][position() gt last() - ($count-left - $count-right)], for $qname-left-only in $qnames1[not(. = $qnames2)] return $seq1[name() = $qname-left-only] } ) }; This returns for your $seq1/* and $seq2/*: (no difference) and for your $seq1/* and $seq3/*: aaa With a more complicated example: let $seq4 := aaa aaa aaa aaa let $seq5 := bbb bbb bbb bbb return local:compare($seq4/*, $seq5/*) returns bbb bbb aaa aaa From wcandillon at gmail.com Thu Jun 23 10:50:58 2011 From: wcandillon at gmail.com (William Candillon) Date: Thu, 23 Jun 2011 10:50:58 -0700 Subject: [xquery-talk] Second Zurich XQuery Meetup, July 7th 2011 In-Reply-To: References: Message-ID: Hi, Please don't forget this meetup if you're around Zurich ;-) Best, William On Wed, May 11, 2011 at 7:14 AM, William Candillon wrote: > Hi gang, > > The second Zurich XQuery Meetup will be held in ETH Dozentenfoyer on > July 7th 2011. More > details at http://xquery.pbworks.com/Zurich-Meetup-2. > Registration is done on the wiki. > > You can checkout pictures and talks from last year meetup at > http://xquery.pbworks.com/Zurich-Meetup > > Best regards, > > William > From christian.gruen at gmail.com Thu Jun 30 09:30:33 2011 From: christian.gruen at gmail.com (=?ISO-8859-1?Q?Christian_Gr=FCn?=) Date: Thu, 30 Jun 2011 18:30:33 +0200 Subject: [xquery-talk] [ANN] Release BaseX 6.7 Message-ID: Dear list, once more, we are glad to announce a new version of BaseX. Beside continuous tweaks, fixes, minor changes and alignments with the XQuery 3.0 specification, it offers the following enhancements: Main Features: [ADD] Native EXPath Packaging system support: http://docs.basex.org/wiki/Packaging [ADD] Client/server event notification: http://docs.basex.org/wiki/Events [ADD] Persistent document index added to speed up access to large collections XQuery: [ADD] New database and full-text functions: http://docs.basex.org/wiki/Database_Functions http://docs.basex.org/wiki/Full-Text_Functions [ADD] Event function added to fire events [MOD] Index optimizations, better cost estimations Commands: [ADD] Glob syntax added to database commands: http://docs.basex.org/wiki/Commands [ADD] New commands added: REPLACE, RENAME, REPO DELETE/INSTALL/LIST, CREATE/DROP EVENT [MOD] BACKUP optimized, renamed to CREATE BACKUP Looking forward to your feedback, Christian ___________________________ BaseX Team Christian Gr?n Uni KN, Box 188 D-78457 Konstanz http://www.basex.org