From geert.josten at dayon.nl Thu Dec 1 06:58:58 2011 From: geert.josten at dayon.nl (Geert Josten) Date: Thu, 1 Dec 2011 15:58:58 +0100 Subject: [xquery-talk] FLWOR in XSLT 2.0? Message-ID: Funny, I always thought the FLWOR was an XQuery only thing... xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:b="books"> > > > > > "(for $m in max(for $n in distinct-values(/*/b:book/(b:author | >b:editor) > /b:name/concat(b:fname, '|', >b:lname)), > $cnt in count(/*/b:book/(b:author | b:editor) > /b:name[$n eq concat(b:fname, '|', >b:lname) ]) > >... > >(Looks quite horrible to me, like someone couldn't decide between XQuery >and XSLT.. :-/) Well, in 2.0 it isn't a full FLWOR expression ... no "let", no "where" (though this can often be done with a predicate) and no "order by". That is the difference between the XPath "for expression" and XQuery "FLWOR expression". But I have found it useful to say things like: or: . . . . . . . . Ken -- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ G. Ken Holman mailto:gkholman at CraneSoftwrights.com Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal From Evan.Lenz at marklogic.com Thu Dec 1 07:10:55 2011 From: Evan.Lenz at marklogic.com (Evan Lenz) Date: Thu, 1 Dec 2011 07:10:55 -0800 Subject: [xquery-talk] FLWOR in XSLT 2.0? In-Reply-To: References: Message-ID: <7D32F3A9-E8AC-49A0-989C-2AE492F135B8@marklogic.com> It's the XPath subset of XQuery, which supports "for" expressions but not full FLWOR statements, to the sometime consternation of XSLT developers (e.g. having to switch to and when all you really wanted was "let"). Evan On Dec 1, 2011, at 7:03 AM, "Geert Josten" > wrote: Funny, I always thought the FLWOR was an XQuery only thing... References: <87r50n8l85.fsf@jidanni.org> Message-ID: <40b58ecd79b508fd4a455b6c74205d9c@mail.gmail.com> I think the most elegant way would be something like: let $today := current-date() let $year := year-from-date($today) let $month := month-from-date($today) let $day := day-from-date($today) return concat($year, '-', $month, '-', $day) Kind regards, Geert -----Oorspronkelijk bericht----- Van: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] Namens jidanni at jidanni.org Verzonden: vrijdag 2 december 2011 8:52 Aan: talk at x-query.com Onderwerp: [xquery-talk] the least stupid way to just print the current date in xquery Gentlemen, its my "virgin" post to the list. Allow me to test the waters by asking what's the least stupid way to just print the current date in xquery? (Without the ugly timezone baggage.) $ basex -q 'tokenize(string(current-date()),"\+")[1]' 2011-12-02 gives me exactly what I want, but it is rather 'expensive'. Other solutions involving fn:substring might break in 10000-2011=7989 years. Yes, something like the opposite of http://www.w3.org/TR/xpath-functions/#func-timezone-from-date or something(s) that would NOT just give me 2011-12-2 Hmm, fn:substring-before might break if I move to the other side of Greenwich, as will my tokenize without [+-] erg... Enough. How do you guys just print the current date? _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From jidanni at jidanni.org Fri Dec 2 00:27:28 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Fri, 02 Dec 2011 16:27:28 +0800 Subject: [xquery-talk] the least stupid way to just print the current date in xquery References: <40b58ecd79b508fd4a455b6c74205d9c@mail.gmail.com> Message-ID: <87liqv8jkf.fsf@jidanni.org> >>>>> "GJ" == Geert Josten writes: GJ> I think the most elegant... dj> or something(s) that would NOT just give me dj> 2011-12-2 so we see we would even need more lines just to give me back the 0 in 2011-12-02 Oy vey :-( From Gunther.Rademacher at softwareag.com Fri Dec 2 00:51:46 2011 From: Gunther.Rademacher at softwareag.com (Rademacher, Gunther) Date: Fri, 2 Dec 2011 09:51:46 +0100 Subject: [xquery-talk] the least stupid way to just print the current datein xquery In-Reply-To: <87r50n8l85.fsf@jidanni.org> References: <87r50n8l85.fsf@jidanni.org> Message-ID: It would be adjust-date-to-timezone(current-date(), ()) See http://www.w3.org/TR/xquery-operators/#func-adjust-date-to-timezone Software AG - Group Executive Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Arnd Zinnhardt, Mark Edwards, Dr. Wolfram Jost, Kamyar Niroumand, Darren Roos, Jonathan Smith, Ivo Totev Sitz/Registered office: Uhlandstra?e 12, 64297 Darmstadt, Germany - Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt http://www.softwareag.com/ -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of jidanni at jidanni.org Sent: Freitag, 2. Dezember 2011 08:52 To: talk at x-query.com Subject: [xquery-talk] the least stupid way to just print the current datein xquery Gentlemen, its my "virgin" post to the list. Allow me to test the waters by asking what's the least stupid way to just print the current date in xquery? (Without the ugly timezone baggage.) $ basex -q 'tokenize(string(current-date()),"\+")[1]' 2011-12-02 gives me exactly what I want, but it is rather 'expensive'. Other solutions involving fn:substring might break in 10000-2011=7989 years. Yes, something like the opposite of http://www.w3.org/TR/xpath-functions/#func-timezone-from-date or something(s) that would NOT just give me 2011-12-2 Hmm, fn:substring-before might break if I move to the other side of Greenwich, as will my tokenize without [+-] erg... Enough. How do you guys just print the current date? _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From jidanni at jidanni.org Fri Dec 2 01:40:18 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Fri, 02 Dec 2011 17:40:18 +0800 Subject: [xquery-talk] the least stupid way to just print the current datein xquery References: Message-ID: <87fwh38g71.fsf@jidanni.org> >>>>> "RG" == Rademacher, Gunther writes: RG> It would be RG> adjust-date-to-timezone(current-date(), ()) RG> See http://www.w3.org/TR/xquery-operators/#func-adjust-date-to-timezone $ basex -vq 'current-date()' 2011-12-02+08:00 Query executed in 36.88 ms. $ basex -vq 'adjust-date-to-timezone(current-date(), ())' 2011-12-02 Query executed in 35.33 ms. I'm sold! Thanks! From jidanni at jidanni.org Sat Dec 3 05:20:41 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Sat, 03 Dec 2011 21:20:41 +0800 Subject: [xquery-talk] why must one have something inside {} ? Message-ID: <87iplxvljq.fsf@jidanni.org> Gentlemen, what a spiteful language xquery is, not allowing an empty statement. I want to "comment out" a line, {doc("p.xml")//STYLES/*} <--- Let's comment out this line {(: doc("p.xml")//STYLES/* :)} BaseX makes [XPST0003] Expecting valid expression after "{". Works but ends up in output. It's all because {} for some reason needs to be filled with some junk. OK, adding "" works: {""(: doc("p.xml")//STYLES/* :)} From gkholman at CraneSoftwrights.com Sat Dec 3 05:29:01 2011 From: gkholman at CraneSoftwrights.com (G. Ken Holman) Date: Sat, 03 Dec 2011 08:29:01 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <87iplxvljq.fsf@jidanni.org> References: <87iplxvljq.fsf@jidanni.org> Message-ID: <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> At 2011-12-03 21:20 +0800, jidanni at jidanni.org wrote: >Gentlemen, what a spiteful language xquery is, not allowing an empty >statement. I want to "comment out" a line, > > > {doc("p.xml")//STYLES/*} <--- Let's comment out this line > > > {(: doc("p.xml")//STYLES/* :)} >BaseX makes [XPST0003] Expecting valid expression after "{". > > > >Works but ends up in output. > >It's all because {} for some reason needs to be filled with some junk. >OK, adding "" works: > > {""(: doc("p.xml")//STYLES/* :)} In XPath syntax, the empty string is not a valid expression: http://www.w3.org/TR/2007/REC-xpath20-20070123/#prod-xpath-XPath Your use of curly braces has to be populated with an XPath expression. An XPath expression is evaluated after comments have been removed. http://www.w3.org/TR/2007/REC-xpath20-20070123/#comments "Comments are lexical constructs only, and do not affect expression processing." Thus you need *something* to prevent the contents of the curly braces to be empty after removing comments. I tell my students to use () rather than "". This is an explicit lesson in the class because of the intuition that a comment is an expression, when it isn't. I hope this explanation helps. . . . . . . . . . Ken -- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ G. Ken Holman mailto:gkholman at CraneSoftwrights.com Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal From dlee at calldei.com Sat Dec 3 05:40:05 2011 From: dlee at calldei.com (David Lee) Date: Sat, 3 Dec 2011 08:40:05 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> Message-ID: <003e01ccb1c1$1185af00$34910d00$@calldei.com> While certainly I agree with the solution ... use this form { (: comment :) () } Or this { () (: comment :) } I think the question still stands as valid (although almost pointless except historical interest asking 'why' questions from standards bodies ..) Why is {} not equal to { () } >From a syntax and readability point of view I don't see why {} can be equivalent to {()} ... but it's not. ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of G. Ken Holman Sent: Saturday, December 03, 2011 8:29 AM To: talk at x-query.com Subject: Re: [xquery-talk] why must one have something inside {} ? At 2011-12-03 21:20 +0800, jidanni at jidanni.org wrote: >Gentlemen, what a spiteful language xquery is, not allowing an empty >statement. I want to "comment out" a line, > > > {doc("p.xml")//STYLES/*} <--- Let's comment out this line > > > {(: doc("p.xml")//STYLES/* :)} >BaseX makes [XPST0003] Expecting valid expression after "{". > > > >Works but ends up in output. > >It's all because {} for some reason needs to be filled with some junk. >OK, adding "" works: > > {""(: doc("p.xml")//STYLES/* :)} In XPath syntax, the empty string is not a valid expression: http://www.w3.org/TR/2007/REC-xpath20-20070123/#prod-xpath-XPath Your use of curly braces has to be populated with an XPath expression. An XPath expression is evaluated after comments have been removed. http://www.w3.org/TR/2007/REC-xpath20-20070123/#comments "Comments are lexical constructs only, and do not affect expression processing." Thus you need *something* to prevent the contents of the curly braces to be empty after removing comments. I tell my students to use () rather than "". This is an explicit lesson in the class because of the intuition that a comment is an expression, when it isn't. I hope this explanation helps. . . . . . . . . . Ken -- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ G. Ken Holman mailto:gkholman at CraneSoftwrights.com Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From gkholman at CraneSoftwrights.com Sat Dec 3 06:22:34 2011 From: gkholman at CraneSoftwrights.com (G. Ken Holman) Date: Sat, 03 Dec 2011 09:22:34 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <003e01ccb1c1$1185af00$34910d00$@calldei.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> Message-ID: <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> At 2011-12-03 08:40 -0500, David Lee wrote: >While certainly I agree with the solution ... use this form > > { (: comment :) () } >Or this > { () (: comment :) } > >I think the question still stands as valid (although almost pointless except >historical interest asking 'why' questions from standards bodies ..) > > >Why is {} not equal to { () } > > From a syntax and readability point of view I don't see why {} can be >equivalent to {()} ... but it's not. I suspect because there are many places for XPath expressions where the empty string does not make sense. If "" were allowed, then this would be a valid expression: item[] ... which would evaluate to nothing if the empty predicate XPath expression is interpreted as (). Or this, which would also be deemed as valid and also produce nothing: price[. > ] I think it is better to get an error message in such cases than to accept something that always does nothing and produce results unexpected for the user. The absence of an XPath expression is, today, always considered an error because I think that when it is absent it really is an error. The above two expressions are "bad" expressions that should be caught at compile time, rather than being deemed acceptable syntax because one of the valid expressions in XPath is to say nothing. There are many places in XPath where an XPath expression is allowed. I don't see why one case, and that of a comment of all things, should invalidate all other "bad" expression writing cases. Think of how many poorly-written expressions would be considered acceptable, thus causing the user grief by having it execute what the user doesn't expect. The specification is rigourous in order to account for all the places where expressions are used. Special cases in specifications are awkward to specify and difficult to implement. Remember that the brace brackets "{" and "}" are *not* part of XPath, they are part of the expression language that uses XPath. In XSLT these are used in attribute value templates to wrap a valid XPath expression. In XQuery these are used in attributes or in elements to wrap a valid XPath expression. The braces themselves are not part of the XPath expression. When you say ... At 2011-12-03 08:40 -0500, David Lee wrote: >Why is {} not equal to { () } ... you are mixing apples and oranges. You are mixing the XPath expression language with the language that is using XPath. What would you say to some other language that uses XPath with a different wrapping syntax? You would have to special-case that as well. I think XPath is very well specified to be intuitive to the user in 99.44% of the cases ... that the user has the "burden" (as implied by you and jidanni) just for the one case, where an empty string is intuitive but not lexically allowed, seems extreme to me. I hope this explanation is considered helpful. I'm not criticizing that some people have this intuition, as I see it in the classroom every class ... but I think simply throwing in a special case for this one situation is really inappropriate. You seem to knock my quoting of the specification, but I think that really is where the answer lies. . . . . . . . . . . . . . Ken -- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ G. Ken Holman mailto:gkholman at CraneSoftwrights.com Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal From dlee at calldei.com Sat Dec 3 06:57:24 2011 From: dlee at calldei.com (David Lee) Date: Sat, 3 Dec 2011 09:57:24 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> Message-ID: <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> Ken Says --- ----- When you say ... At 2011-12-03 08:40 -0500, David Lee wrote: >Why is {} not equal to { () } ... you are mixing apples and oranges. You are mixing the XPath expression language with the language that is using XPath. What would you say to some other language that uses XPath with a different wrapping syntax? You would have to special-case that as well. ------ I'm referring to XQuery not XPath thus (IMHO) not mixing things up. I am asking why in *XQuery* the expression {} is not equivalent to {()} This has nothing to do with XPath specifically ... as in XQuery { "" } is perfectly valid. the value inside { "" } is an XQuery expression not an XPath expression. So why shouldnt. { } be valid ? and equivalent to {()} This has nothing to do with comments either. Its not a special case just for comments. Its actually (IMHO) not a special case at all, its just "how it is" and I dont yet see any fundimental reason why, except "that's what the language designers decided". Is there a case in *XQuery* where this would be problematic ? ---------------------------------------- David A. Lee Senior Principal Software Engineer Epocrates, Inc. dlee at epocrates.com 812-482-5224 From jidanni at jidanni.org Sat Dec 3 07:30:26 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Sat, 03 Dec 2011 23:30:26 +0800 Subject: [xquery-talk] why must one have something inside {} ? References: <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> Message-ID: <87iplxvfjh.fsf@jidanni.org> It's just like saying all files must be at least one byte long. Yuck! And why can't they just "treat it like whitespace"? I don't recall any other languages with this problem. From jidanni at jidanni.org Sat Dec 3 07:34:13 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Sat, 03 Dec 2011 23:34:13 +0800 Subject: [xquery-talk] why must one have something inside {} ? References: <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> Message-ID: <87hb1hvfd6.fsf@jidanni.org> Certainly they can relax this in the next version of the language. At least "have the algorithm internally feed itself a biscuit if it finds none" or something, to keep it from bothering users. From jidanni at jidanni.org Sat Dec 3 08:31:20 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Sun, 04 Dec 2011 00:31:20 +0800 Subject: [xquery-talk] why must one have something inside {} ? References: <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> Message-ID: <874nxhehwn.fsf@jidanni.org> GKH> price[. > ] Well perl catches such things while allowing empty things at the same time, but you are right in that we are dealing with (at least :) two languages in the same input file instead of just one with perl. From liam at w3.org Sat Dec 3 09:48:21 2011 From: liam at w3.org (Liam R E Quin) Date: Sat, 03 Dec 2011 12:48:21 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <87hb1hvfd6.fsf@jidanni.org> References: <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <87hb1hvfd6.fsf@jidanni.org> Message-ID: <1322934501.5100.112.camel@localhost.localdomain> On Sat, 2011-12-03 at 23:34 +0800, jidanni at jidanni.org wrote: > Certainly they can relax this in the next version of the language. If you look at the Status section of the latest XQuery 3.0 draft you'll see how to submit such suggestions to the Working Group. Thanks, Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ From jmdyck at ibiblio.org Sat Dec 3 11:28:17 2011 From: jmdyck at ibiblio.org (Michael Dyck) Date: Sat, 03 Dec 2011 11:28:17 -0800 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> Message-ID: <4EDA7851.7040702@ibiblio.org> David Lee wrote: > > I am asking why in *XQuery* the expression {} is not equivalent to {()} It might simply be that no-one suggested it. > Is there a case in *XQuery* where this would be problematic ? I don't think so. Probably the least-impact way for the spec to accomplish this would be to alter the syntax of EnclosedExpr, from EnclosedExpr ::= "{" Expr "}" to EnclosedExpr ::= "{" Expr? "}" and then say that, if the Expr is omitted, the EnclosedExpr yields the empty sequence. Note that, in addition to element and attribute content, this would also take effect when an EnclosedExpr is used as a function body, which may or may not be something you'd like as well. -Michael From dlee at calldei.com Sat Dec 3 11:41:11 2011 From: dlee at calldei.com (David Lee) Date: Sat, 3 Dec 2011 14:41:11 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <4EDA7851.7040702@ibiblio.org> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <4EDA7851.7040702@ibiblio.org> Message-ID: <006001ccb1f3$838088f0$8a819ad0$@calldei.com> Yes exactly ! Function bodies should be able to be empty too ... its so simple ! declare function notimplementedyet() {}; ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Michael Dyck Sent: Saturday, December 03, 2011 2:28 PM To: talk at x-query.com Subject: Re: [xquery-talk] why must one have something inside {} ? David Lee wrote: > > I am asking why in *XQuery* the expression {} is not equivalent to {()} It might simply be that no-one suggested it. > Is there a case in *XQuery* where this would be problematic ? I don't think so. Probably the least-impact way for the spec to accomplish this would be to alter the syntax of EnclosedExpr, from EnclosedExpr ::= "{" Expr "}" to EnclosedExpr ::= "{" Expr? "}" and then say that, if the Expr is omitted, the EnclosedExpr yields the empty sequence. Note that, in addition to element and attribute content, this would also take effect when an EnclosedExpr is used as a function body, which may or may not be something you'd like as well. -Michael _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From sokolov at ifactory.com Sat Dec 3 14:53:13 2011 From: sokolov at ifactory.com (Michael Sokolov) Date: Sat, 03 Dec 2011 17:53:13 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <006001ccb1f3$838088f0$8a819ad0$@calldei.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <4EDA7851.7040702@ibiblio.org> <006001ccb1f3$838088f0$8a819ad0$@calldei.com> Message-ID: <4EDAA859.9020902@ifactory.com> How about element {} {} text {} attribute {} {} should those be no-ops too? I don't think so, because element {} {"not empty"} would be problematic On 12/3/2011 2:41 PM, David Lee wrote: > Yes exactly ! > Function bodies should be able to be empty too ... its so simple ! > > declare function notimplementedyet() {}; > > > > ---------------------------------------- > David A. Lee > dlee at calldei.com > http://www.xmlsh.org > > > -----Original Message----- > From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf > Of Michael Dyck > Sent: Saturday, December 03, 2011 2:28 PM > To: talk at x-query.com > Subject: Re: [xquery-talk] why must one have something inside {} ? > > > David Lee wrote: >> I am asking why in *XQuery* the expression {} is not equivalent to {()} > It might simply be that no-one suggested it. > >> Is there a case in *XQuery* where this would be problematic ? > I don't think so. > > Probably the least-impact way for the spec to accomplish this would be > to alter the syntax of EnclosedExpr, from > EnclosedExpr ::= "{" Expr "}" > to > EnclosedExpr ::= "{" Expr? "}" > and then say that, if the Expr is omitted, the EnclosedExpr yields the > empty sequence. Note that, in addition to element and attribute content, > this would also take effect when an EnclosedExpr is used as a function > body, which may or may not be something you'd like as well. > > -Michael > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From dlee at calldei.com Sat Dec 3 15:15:43 2011 From: dlee at calldei.com (David Lee) Date: Sat, 3 Dec 2011 18:15:43 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <4EDAA859.9020902@ifactory.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <4EDA7851.7040702@ibiblio.org> <006001ccb1f3$838088f0$8a819ad0$@calldei.com> <4EDAA859.9020902@ifactory.com> Message-ID: <009701ccb211$7be44f50$73acedf0$@calldei.com> No they would be errors, but I dont see why its more problematic than element {()} {()} text {()} attribute {()} {()} which would be what they would equate to. making {} == {()} doesnt cause a problem in itself in these cases IMHO. ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Michael Sokolov Sent: Saturday, December 03, 2011 5:53 PM To: David Lee Cc: talk at x-query.com Subject: Re: [xquery-talk] why must one have something inside {} ? How about element {} {} text {} attribute {} {} should those be no-ops too? I don't think so, because element {} {"not empty"} would be problematic On 12/3/2011 2:41 PM, David Lee wrote: > Yes exactly ! > Function bodies should be able to be empty too ... its so simple ! > > declare function notimplementedyet() {}; > > > > ---------------------------------------- > David A. Lee > dlee at calldei.com > http://www.xmlsh.org > > > -----Original Message----- > From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On > Behalf Of Michael Dyck > Sent: Saturday, December 03, 2011 2:28 PM > To: talk at x-query.com > Subject: Re: [xquery-talk] why must one have something inside {} ? > > > David Lee wrote: >> I am asking why in *XQuery* the expression {} is not equivalent to >> {()} > It might simply be that no-one suggested it. > >> Is there a case in *XQuery* where this would be problematic ? > I don't think so. > > Probably the least-impact way for the spec to accomplish this would be > to alter the syntax of EnclosedExpr, from > EnclosedExpr ::= "{" Expr "}" > to > EnclosedExpr ::= "{" Expr? "}" > and then say that, if the Expr is omitted, the EnclosedExpr yields the > empty sequence. Note that, in addition to element and attribute > content, this would also take effect when an EnclosedExpr is used as a > function body, which may or may not be something you'd like as well. > > -Michael > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From dlee at calldei.com Sat Dec 3 15:27:00 2011 From: dlee at calldei.com (David Lee) Date: Sat, 3 Dec 2011 18:27:00 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <4EDAA859.9020902@ifactory.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <4EDA7851.7040702@ibiblio.org> <006001ccb1f3$838088f0$8a819ad0$@calldei.com> <4EDAA859.9020902@ifactory.com> Message-ID: <001f01ccb213$0f8048d0$2e80da70$@calldei.com> I'm not suggesting "{}" is a 'no-op' I'm suggesting it parses equivalent to {()} Maybe in the next week or two I'll study the BNF in more detail and make a formal suggestion as per Liam's suggestion for XQuery 3.0 So far I haven't seen any reason why it would be either 1) Ambiguous 2) Cause parser confusion 3) Cause reader confusion 4) Cause 'unexpected' things to happen So far all the cases I can think of it would either be beneficial, closer to what a programmer would expect and easier on the eye and hand. Things like element {} {} would still be static errors just like element {()} {()} ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Michael Sokolov Sent: Saturday, December 03, 2011 5:53 PM To: David Lee Cc: talk at x-query.com Subject: Re: [xquery-talk] why must one have something inside {} ? How about element {} {} text {} attribute {} {} should those be no-ops too? I don't think so, because element {} {"not empty"} would be problematic On 12/3/2011 2:41 PM, David Lee wrote: > Yes exactly ! > Function bodies should be able to be empty too ... its so simple ! > > declare function notimplementedyet() {}; > > > > ---------------------------------------- > David A. Lee > dlee at calldei.com > http://www.xmlsh.org > > > -----Original Message----- > From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf > Of Michael Dyck > Sent: Saturday, December 03, 2011 2:28 PM > To: talk at x-query.com > Subject: Re: [xquery-talk] why must one have something inside {} ? > > > David Lee wrote: >> I am asking why in *XQuery* the expression {} is not equivalent to {()} > It might simply be that no-one suggested it. > >> Is there a case in *XQuery* where this would be problematic ? > I don't think so. > > Probably the least-impact way for the spec to accomplish this would be > to alter the syntax of EnclosedExpr, from > EnclosedExpr ::= "{" Expr "}" > to > EnclosedExpr ::= "{" Expr? "}" > and then say that, if the Expr is omitted, the EnclosedExpr yields the > empty sequence. Note that, in addition to element and attribute content, > this would also take effect when an EnclosedExpr is used as a function > body, which may or may not be something you'd like as well. > > -Michael > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk From jidanni at jidanni.org Sat Dec 3 18:16:41 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Sun, 04 Dec 2011 10:16:41 +0800 Subject: [xquery-talk] why must one have something inside {} ? References: <001f01ccb213$0f8048d0$2e80da70$@calldei.com> Message-ID: <87k46d2i9i.fsf@jidanni.org> >>>>> "DL" == David Lee writes: DL> I'm not suggesting "{}" is a 'no-op' Hey, I'm the "OP" here :) DL> Maybe in the next week or two I'll study the BNF in more detail and make a DL> formal suggestion as per Liam's suggestion for XQuery 3.0 Yes, please do. Even though I'm the Original Poster I'm very glad somebody will do this. From mike at saxonica.com Sun Dec 4 03:26:27 2011 From: mike at saxonica.com (Michael Kay) Date: Sun, 04 Dec 2011 11:26:27 +0000 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <87iplxvfjh.fsf@jidanni.org> References: <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <87iplxvfjh.fsf@jidanni.org> Message-ID: <4EDB58E3.5030003@saxonica.com> >I don't recall any other languages with this problem. Well, if I have a Java program that does public String display(Object x) { return x.toString(); } and I decide to comment it out like this public String display(Object x) { // return x.toString(); } then I will get a syntax error. Which seems a pretty close analogy to what you are doing. Michael Kay Saxonica From mike at saxonica.com Sun Dec 4 03:37:13 2011 From: mike at saxonica.com (Michael Kay) Date: Sun, 04 Dec 2011 11:37:13 +0000 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <001f01ccb213$0f8048d0$2e80da70$@calldei.com> References: <87iplxvljq.fsf@jidanni.org> <7.0.1.0.2.20111203082321.024491c0@wheresmymailserver.com> <003e01ccb1c1$1185af00$34910d00$@calldei.com> <7.0.1.0.2.20111203090714.024f9b38@wheresmymailserver.com> <004601ccb1cb$de66d3a0$9b347ae0$@calldei.com> <4EDA7851.7040702@ibiblio.org> <006001ccb1f3$838088f0$8a819ad0$@calldei.com> <4EDAA859.9020902@ifactory.com> <001f01ccb213$0f8048d0$2e80da70$@calldei.com> Message-ID: <4EDB5B69.1080701@saxonica.com> On 03/12/2011 23:27, David Lee wrote: > I'm not suggesting "{}" is a 'no-op' I'm suggesting it parses equivalent to > {()} > Maybe in the next week or two I'll study the BNF in more detail and make a > formal suggestion as per Liam's suggestion for XQuery 3.0 > > So far I haven't seen any reason why it would be either > 1) Ambiguous > 2) Cause parser confusion > 3) Cause reader confusion > 4) Cause 'unexpected' things to happen > > There are other objections the WG might want to consider: Assigning a meaning to constructs that are currently disallowed (a) can make it more difficult to produce good diagnostics for queries that are actually wrong (ultimately, you end up with the HTML5 situation where everything you write means something, so there are no compile-time errors, only run-time errors), and (b) can "use up" syntactic space that might be needed in the future for new features. For example, one might want "{}" to represent an empty map - which is not necessarily inconsistent with this proposal, but in general, when you give a syntactic construct a meaning you remove the option of giving it a different meaning in the future. Michael Kay Saxonica From jidanni at jidanni.org Mon Dec 5 17:18:59 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Tue, 06 Dec 2011 09:18:59 +0800 Subject: [xquery-talk] why must one have something inside {} ? References: <008c01ccb389$1b8f9d70$52aed850$@calldei.com> Message-ID: <87d3c2wl8c.fsf@jidanni.org> I guess the chances of getting an additional "quick comment to the end of line character(s)" like # in perl. Or // in... are slim too. One needs both (: and :) ... Barfolomew! From sokolov at ifactory.com Mon Dec 5 17:57:22 2011 From: sokolov at ifactory.com (Michael Sokolov) Date: Mon, 05 Dec 2011 20:57:22 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <87d3c2wl8c.fsf@jidanni.org> References: <008c01ccb389$1b8f9d70$52aed850$@calldei.com> <87d3c2wl8c.fsf@jidanni.org> Message-ID: <4EDD7682.6090603@ifactory.com> Yes, one might regret the inability to nest comments; single line comments in C-derived languages have the nice property that they could live inside block comments, which can be handy when you want to temporarily hide a block of code possibly containing comments; say when reformatting/restructuring a large piece of code, and working to get it to compile piece by piece. But nested comments would be superior still, although maybe a bit more irritating to parse. -Mike On 12/5/2011 8:18 PM, jidanni at jidanni.org wrote: > I guess the chances of getting an additional > "quick comment to the end of line character(s)" like # in perl. Or // in... > are slim too. One needs both (: and :) ... Barfolomew! > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk From davidc at nag.co.uk Tue Dec 6 01:36:50 2011 From: davidc at nag.co.uk (David Carlisle) Date: Tue, 06 Dec 2011 09:36:50 +0000 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <4EDD7682.6090603@ifactory.com> References: <008c01ccb389$1b8f9d70$52aed850$@calldei.com> <87d3c2wl8c.fsf@jidanni.org> <4EDD7682.6090603@ifactory.com> Message-ID: <4EDDE232.5080903@nag.co.uk> On 06/12/2011 01:57, Michael Sokolov wrote: > But nested comments would be superior still, would be? Xquery/Xpath comments can be nested. David -- google plus: https:/profiles.google.com/d.p.carlisle ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________ From Gunther.Rademacher at softwareag.com Tue Dec 6 01:44:40 2011 From: Gunther.Rademacher at softwareag.com (Rademacher, Gunther) Date: Tue, 6 Dec 2011 10:44:40 +0100 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <4EDD7682.6090603@ifactory.com> References: <008c01ccb389$1b8f9d70$52aed850$@calldei.com><87d3c2wl8c.fsf@jidanni.org> <4EDD7682.6090603@ifactory.com> Message-ID: (: commenting out a (: comment :) may be confusing, but often helpful :) is a legal Comment, since balanced nesting of comments is allowed. (from http://www.w3.org/TR/xquery/#parse-note-comments ) Software AG - Group Executive Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Arnd Zinnhardt, Mark Edwards, Dr. Wolfram Jost, Kamyar Niroumand, Darren Roos, Jonathan Smith, Ivo Totev Sitz/Registered office: Uhlandstra?e 12, 64297 Darmstadt, Germany, - Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt http://www.softwareag.com/ -----Original Message----- From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Michael Sokolov Sent: Dienstag, 6. Dezember 2011 02:57 To: jidanni at jidanni.org Cc: talk at x-query.com; dlee at calldei.com; henryluo at candlescript.org Subject: Re: [xquery-talk] why must one have something inside {} ? Yes, one might regret the inability to nest comments; single line comments in C-derived languages have the nice property that they could live inside block comments, which can be handy when you want to temporarily hide a block of code possibly containing comments; say when reformatting/restructuring a large piece of code, and working to get it to compile piece by piece. But nested comments would be superior still, although maybe a bit more irritating to parse. -Mike On 12/5/2011 8:18 PM, jidanni at jidanni.org wrote: > I guess the chances of getting an additional > "quick comment to the end of line character(s)" like # in perl. Or // in... > are slim too. One needs both (: and :) ... Barfolomew! From sokolov at ifactory.com Tue Dec 6 04:31:38 2011 From: sokolov at ifactory.com (Michael Sokolov) Date: Tue, 06 Dec 2011 07:31:38 -0500 Subject: [xquery-talk] why must one have something inside {} ? In-Reply-To: <4EDDE232.5080903@nag.co.uk> References: <008c01ccb389$1b8f9d70$52aed850$@calldei.com> <87d3c2wl8c.fsf@jidanni.org> <4EDD7682.6090603@ifactory.com> <4EDDE232.5080903@nag.co.uk> Message-ID: <4EDE0B2A.2040700@ifactory.com> OK, um I swear I tried this and it didn't work, but I must have been operating in some other universe where up is down. :) Oh now I see - I tried executing a script containing only a comment, which apparently is an error. -Mike On 12/6/2011 4:36 AM, David Carlisle wrote: > On 06/12/2011 01:57, Michael Sokolov wrote: >> But nested comments would be superior still, > > would be? > > Xquery/Xpath comments can be nested. > > > David > From jidanni at jidanni.org Tue Dec 6 11:34:09 2011 From: jidanni at jidanni.org (jidanni at jidanni.org) Date: Wed, 07 Dec 2011 03:34:09 +0800 Subject: [xquery-talk] why must one have something inside {} ? References: Message-ID: <87ty5dv6j2.fsf@jidanni.org> >>>>> "RG" == Rademacher, Gunther writes: RG> (from http://www.w3.org/TR/xquery/#parse-note-comments ) where it says + {$i//title} is not syntactically valid. + (: an example:) is syntactically valid, but the characters that look like a comment are in fact literal element content. but forgets to add + {(: an example:)()} is what you must use if you really must insist on having a comment there, believe it or not. They should make a note of it. Anyway, I'm beginning to fear poking the perhaps 'house of cards' syntax at this late stage of the game. From james.fuller.2007 at gmail.com Thu Dec 22 13:27:11 2011 From: james.fuller.2007 at gmail.com (James Fuller) Date: Thu, 22 Dec 2011 22:27:11 +0100 Subject: [xquery-talk] problem with saxon PE support of XQuery 3.0 try/catch Message-ID: running XQuery 3.0 spec example try { fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000')) } catch * { $err:code, $err:value, " module: ", $err:module, "(", $err:line-number, ",", $err:column-number, ")" with saxon SaxonPE9-4-0-1 (w/ paid for license installed), got the xquery 3.0 flag engaged -qversion:3.0 and just in case I have declared namespace err="http://www.w3.org/2005/xqt-errors"; getting an odd error XPST0008: Variable $err:code has not been declared It says clearly in saxon feature support matrix http://www.saxonica.com/feature-matrix.html that saxon PE supports try/catch XQuery 3.0 feature. any thoughts ? I have been running xquery 3.0 for a while now so I think I am not doing anything overly stupid (but always a possibility!). Jim Fuller From jmdyck at ibiblio.org Thu Dec 22 15:50:01 2011 From: jmdyck at ibiblio.org (Michael Dyck) Date: Thu, 22 Dec 2011 15:50:01 -0800 Subject: [xquery-talk] problem with saxon PE support of XQuery 3.0 try/catch In-Reply-To: References: Message-ID: <4EF3C229.2090207@ibiblio.org> James Fuller wrote: > running XQuery 3.0 spec example > > try { > fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000')) > } > catch * { > $err:code, $err:value, " module: ", > $err:module, "(", $err:line-number, ",", $err:column-number, ")" > > getting an odd error > > XPST0008: Variable $err:code has not been declared Up until a couple drafts ago, the syntax of try/catch was different, and the various $err:* variables were not auto-declared: http://www.w3.org/TR/2009/WD-xquery-11-20091215/#id-try-catch Perhaps that's the version of try/catch that the processor supports. -Michael From mike at saxonica.com Thu Dec 22 16:01:15 2011 From: mike at saxonica.com (Michael Kay) Date: Fri, 23 Dec 2011 00:01:15 +0000 Subject: [xquery-talk] problem with saxon PE support of XQuery 3.0 try/catch In-Reply-To: <4EF3C229.2090207@ibiblio.org> References: <4EF3C229.2090207@ibiblio.org> Message-ID: <4EF3C4CB.7090409@saxonica.com> > Up until a couple drafts ago, the syntax of try/catch was different, > and the various $err:* variables were not auto-declared: > http://www.w3.org/TR/2009/WD-xquery-11-20091215/#id-try-catch > > Perhaps that's the version of try/catch that the processor supports. > There's a note in the source code that the catch variables are not yet supported - I think they were omitted because the spec was in flux at the time, and failure to implement them in 9.4 was an oversight (aided and abetted by the absence of any tests in the test suite). Michael Kay Saxonica From james.fuller.2007 at gmail.com Fri Dec 23 00:08:38 2011 From: james.fuller.2007 at gmail.com (James Fuller) Date: Fri, 23 Dec 2011 09:08:38 +0100 Subject: [xquery-talk] problem with saxon PE support of XQuery 3.0 try/catch In-Reply-To: <4EF3C4CB.7090409@saxonica.com> References: <4EF3C229.2090207@ibiblio.org> <4EF3C4CB.7090409@saxonica.com> Message-ID: On Fri, Dec 23, 2011 at 1:01 AM, Michael Kay wrote: > There's a note in the source code that the catch variables are not yet > supported - I think they were omitted because the spec was in flux at the > time, and failure to implement them in 9.4 was an oversight (aided and > abetted by the absence of any tests in the test suite). thanks for the quick response and explains my (non)results. so far very impressed with saxon xquery 3 support that it does have, but would be great to get access to catch variables. Jim Fuller From jakob.fix at gmail.com Tue Dec 27 15:13:08 2011 From: jakob.fix at gmail.com (Jakob Fix) Date: Wed, 28 Dec 2011 00:13:08 +0100 Subject: [xquery-talk] xquery library design Message-ID: Hello, I'm about to write an xquery library and I'm curious whether there are best practices around regarding the inclusion of other library modules (a quick Google search didn't turn up anything useful). In particular, I'm interested in how one would implement this: - a library module (out of several) that uses configuration data specific for each application it is used in, and that itself makes use of lower-level functions. for example, a library module with a number of publicly exposed api functions that each would take an "api_key" argument that is specific to the application and probably stored in a separated configuration file. Itself, it may make use of an http-get function defined in yet another library module. I would like to avoid the case where each function signature needs to have a required argument (the api_key and maybe others too) that could be added much more elegantly by looking up a global variable read from the configuration file. For example, for the functions documented here (http://developer.marklogic.com/pubs/5.0/apidocs/ec2-2009-11-30.html) each function has always the same three arguments that serve to identify the caller. In my case, there can be three such arguments, but only one is required. instead of this d:get-data($api_key as xs:string, $secret as xs:string?, $from as xs:string, $to as xs:string) as element(result) {}; I'd like this d:get-data($from as xs:string, $to as xs:string) as element(result) { http:get($config:url, $config:api_key, $config:secret, $from, $to) }; where the authentication arguments would be retrieved from the configuration file when necessary and added to the http get request inside the function body. so, would it be advisable to have this (where only application.xqy has all information necessary, but minimal inclusion takes place) - application.xqy that includes - configuration.xqy - library1.xqy - library2.xqy - lowlevelfunctions.xqy or rather this (where each library module is independent as it includes what's needed) - application.xqy that includes - library1.xqy which includes - configuration.xqy - lowlevelfunctions.xqy - library2.xqy which includes - configuration.xqy - lowlevelfunctions.xqy or still another scenario? sorry if that sounds confusing, Jakob. From mike at saxonica.com Tue Dec 27 15:35:09 2011 From: mike at saxonica.com (Michael Kay) Date: Tue, 27 Dec 2011 23:35:09 +0000 Subject: [xquery-talk] xquery library design In-Reply-To: References: Message-ID: <4EFA562D.2000105@saxonica.com> On 27/12/2011 23:13, Jakob Fix wrote: > Hello, > > I'm about to write an xquery library and I'm curious whether there are > best practices around regarding the inclusion of other library modules > (a quick Google search didn't turn up anything useful). > > In particular, I'm interested in how one would implement this: > > - a library module (out of several) > that uses configuration data specific for each application it is used in, and > that itself makes use of lower-level functions. > > A lot depends on whether you want to allow multiple "applications" (clients of your library) to coexist. If you don't, you can put the configuration data in global variables, which makes things a lot simpler. If you do, you will need a "context" or "configuration" argument added to each relevant function. Michael Kay Saxonica From jakob.fix at gmail.com Tue Dec 27 15:45:18 2011 From: jakob.fix at gmail.com (Jakob Fix) Date: Wed, 28 Dec 2011 00:45:18 +0100 Subject: [xquery-talk] xquery library design In-Reply-To: References: Message-ID: Eric, right now, the configuration data would simply contain a number of details such as - endpoint_url - api_key - secret - user_id the question really is whether one would want to use the library in the same application with different configuration details. I hadn't originally envisaged this, but Michael Kay makes this point in a future message, so I'll think about this. thanks, Jakob. On Wed, Dec 28, 2011 at 00:25, Eric Bloch wrote: > I presume persistent state (like configuration) is managed and specified differently for each xquery processor - as such, whatever you do may have some processor dependent code. > > E > > Eric Bloch > eric.bloch at marklogic.com > > > > On Dec 27, 2011, at 3:13 PM, Jakob Fix wrote: > >> Hello, >> >> I'm about to write an xquery library and I'm curious whether there are >> best practices around regarding the inclusion of other library modules >> (a quick Google search didn't turn up anything useful). >> >> In particular, I'm interested in how one would implement this: >> >> - a library module (out of several) >> ?that uses configuration data specific for each application it is used in, and >> ?that itself makes use of lower-level functions. >> >> for example, a library module with a number of publicly exposed api >> functions that each would take an "api_key" argument that is specific >> to the application and probably stored in a separated configuration >> file. Itself, it may make use of an http-get function defined in yet >> another library module. >> >> I would like to avoid the case where each function signature needs to >> have a required argument (the api_key and maybe others too) that could >> be added much more elegantly by looking up a global variable read from >> the configuration file. ?For example, for the functions documented >> here (http://developer.marklogic.com/pubs/5.0/apidocs/ec2-2009-11-30.html) >> each function has always the same three arguments that serve to >> identify the caller. In my case, there can be three such arguments, >> but only one is required. >> >> instead of this >> d:get-data($api_key as xs:string, $secret as xs:string?, $from as >> xs:string, $to as xs:string) as element(result) {}; >> >> I'd like this >> d:get-data($from as xs:string, $to as xs:string) as element(result) { >> http:get($config:url, $config:api_key, $config:secret, $from, $to) }; >> >> where the authentication arguments would be retrieved from the >> configuration file when necessary and added to the http get request >> inside the function body. >> >> >> so, would it be advisable to have this (where only application.xqy has >> all information necessary, but minimal inclusion takes place) >> >> - application.xqy that includes >> ?- configuration.xqy >> ?- library1.xqy >> ?- library2.xqy >> ?- lowlevelfunctions.xqy >> >> or rather this (where each library module is independent as it >> includes what's needed) >> >> - application.xqy that includes >> ?- library1.xqy which includes >> ? ?- configuration.xqy >> ? ?- lowlevelfunctions.xqy >> ?- library2.xqy which includes >> ? ?- configuration.xqy >> ? ?- lowlevelfunctions.xqy >> >> or still another scenario? >> >> sorry if that sounds confusing, >> Jakob. >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > From james.fuller.2007 at gmail.com Tue Dec 27 23:59:15 2011 From: james.fuller.2007 at gmail.com (James Fuller) Date: Wed, 28 Dec 2011 08:59:15 +0100 Subject: [xquery-talk] xquery library design In-Reply-To: References: Message-ID: On Wed, Dec 28, 2011 at 12:13 AM, Jakob Fix wrote: > so, would it be advisable to have this (where only application.xqy has > all information necessary, but minimal inclusion takes place) > > - application.xqy that includes > ?- configuration.xqy > ?- library1.xqy > ?- library2.xqy > ?- lowlevelfunctions.xqy > > or rather this (where each library module is independent as it > includes what's needed) > > - application.xqy that includes > ?- library1.xqy which includes > ? ?- configuration.xqy > ? ?- lowlevelfunctions.xqy > ?- library2.xqy which includes > ? ?- configuration.xqy > ? ?- lowlevelfunctions.xqy > > or still another scenario? > > sorry if that sounds confusing, no not at all ... a few things; I would advise using an application level configuration library that is global to your application as a starting point. from there, depending on how you want to encapsulate your libraries, you could take advantage of ML support for private annotations http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/xml/xquery/enhanced.xml%2376225 which you can use to indicate where you would not want certain variables to be protected from changing as author intention. If you are to create standalone libraries then I would suggest that you try to keep the imports to a minimum, pref to 1 so I would stump up for placing variables within the library module themselves and declare those which I would like to redefine by marking them external. hth, Jim Fuller