On http://docs.basex.org/wiki/Serialization we see newline. But we have no idea how to make it work. Please add an example to that page!
declare option output:method "text"; declare option output:newline "\n"; for $m in (1,2,3) return $m
Nope no idea.
basex: Installed: 7.1.1-2
On 3/8/2012 8:58 PM, jidanni@jidanni.org wrote:
On http://docs.basex.org/wiki/Serialization we see newline. But we have no idea how to make it work. Please add an example to that page!
declare option output:method "text"; declare option output:newline "\n"; for $m in (1,2,3) return $m
Nope no idea.
basex: Installed: 7.1.1-2
The newline option just indicates which kind of newlines to use in places where newlines would normally be selected -- it doesn't make lists automatically newline-separated.
Maybe you want something more like this:
declare option output:format "no"; declare option output:method "text"; string-join(("one", "two", "three"), " ")
"CD" == Charles Duffy charles@dyfis.net writes:
CD> The newline option just indicates which kind of newlines to use in CD> places where newlines would normally be selected -- it doesn't make CD> lists automatically newline-separated.
CD> Maybe you want something more like this:
CD> declare option output:format "no"; CD> declare option output:method "text"; CD> string-join(("one", "two", "three"), " ")
What an embarrassment that one must hardcode record separators or whatever. I feel like I am back forty years ago with http://en.wikipedia.org/wiki/NOS_(software) Let me out of here!
It should be as easy as $ seq 1 3 1 2 3 $ perl -le 'print for 1..3' 1 2 3
Please fix this!
What an embarrassment that one must hardcode record separators or whatever. I feel like I am back forty years ago with http://en.wikipedia.org/wiki/NOS_(software) Let me out of here!
It may help to issue a general XQuery feature request..
https://www.w3.org/Bugs/Public/
..or discuss this on:
talk@x-query.com
Hope this helps, Christian
Dear talk@x-query.com, there should be a way to get 'items' back out of Xquery, one per line, without having to hardwire 0x0A (you know, $ perl -wle 'printf "%08b\n" , ord"\n"' 00001010 into the code, as discussed in https://mailman.uni-konstanz.de/pipermail/basex-talk/2012-March/002738.html )
...or require a post-processor.
There is, but you have to call XQuery natively instead of via "the command line"
-----Original Message----- From: talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] On Behalf Of jidanni@jidanni.org Sent: Saturday, March 10, 2012 5:42 PM To: talk@x-query.com Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [xquery-talk] say how to get "newline" working
Dear talk@x-query.com, there should be a way to get 'items' back out of Xquery, one per line, without having to hardwire 0x0A (you know, $ perl -wle 'printf "%08b\n" , ord"\n"' 00001010 into the code, as discussed in https://mailman.uni-konstanz.de/pipermail/basex-talk/2012-March/002738.html )
...or require a post-processor. _______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk
"DL" == David Lee dlee@calldei.com writes:
DL> There is, but you have to call XQuery natively instead of via "the command line"
Running the output through a tag stripper, perl -pwle 's/<[^>]+>//g' sounds a 1000 times easier than trying to figure out how to do it whatever is that way you mention.
On Sat, 2012-03-10 at 22:56 +0000, David Lee wrote:
There is, but you have to call XQuery natively instead of via "the command line"
??!?
you can use string-join( your query here, "
")
or you may be able to use serialization options from the command line.
Lia
-----Original Message----- From: talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] On Behalf Of jidanni@jidanni.org Sent: Saturday, March 10, 2012 5:42 PM To: talk@x-query.com Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [xquery-talk] say how to get "newline" working
Dear talk@x-query.com, there should be a way to get 'items' back out of Xquery, one per line, without having to hardwire 0x0A (you know, $ perl -wle 'printf "%08b\n" , ord"\n"' 00001010 into the code, as discussed in https://mailman.uni-konstanz.de/pipermail/basex-talk/2012-March/002738.html )
...or require a post-processor. _______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk
talk@x-query.com http://x-query.com/mailman/listinfo/talk
"LREQ" == Liam R E Quin liam@w3.org writes:
LREQ> On Sat, 2012-03-10 at 22:56 +0000, David Lee wrote:
There is, but you have to call XQuery natively instead of via "the command line"
LREQ> ??!?
LREQ> you can use string-join( your query here, "
")
Haven't had to make my own newlines since using those Control Data computers back in the 80's. But if you insist...
LREQ> or you may be able to use serialization options from the command line.
That would be nice.
Curious, are you looking for help or just to insult people ? No one is insisting on anything If you actually want help then we need some more information like what processor you are using , what you are trying to achieve and what you've tried and what are the results. If you just want to insult people you've done that already successfully and we can't help much more.
-David
-----Original Message----- From: jidanni@jidanni.org [mailto:jidanni@jidanni.org] Sent: Saturday, March 10, 2012 9:15 PM To: liam@w3.org Cc: David Lee; talk@x-query.com; basex-talk@mailman.uni-konstanz.de Subject: Re: [xquery-talk] say how to get "newline" working
"LREQ" == Liam R E Quin liam@w3.org writes:
LREQ> On Sat, 2012-03-10 at 22:56 +0000, David Lee wrote:
There is, but you have to call XQuery natively instead of via "the command line"
LREQ> ??!?
LREQ> you can use string-join( your query here, "
")
Haven't had to make my own newlines since using those Control Data computers back in the 80's. But if you insist...
LREQ> or you may be able to use serialization options from the command line.
That would be nice.
On Sun, 2012-03-11 at 10:14 +0800, jidanni@jidanni.org wrote:
Haven't had to make my own newlines since using those Control Data computers back in the 80's. But if you insist...
XQuery is not really a line-oriented language. I don't agree with you that "it should be as easy as seq 1 3" any more than it should be easy to process XML documents recursively an element at a time with sed, or to use grep only within certain elements. Unix is line-oriented, XQuery is XML-oriented.
This is true regardless of whether you used Control Data computers.
Having said that, I can imagine a BaseX feature request - or maybe even an XQuery feature request - for how to separate items in a sequence when serializing. Such a request could be filed against the 3.0 serialization spec at https://www.w3.org/Bugs/Public/ and the XQuery and XSLT Working Groups will discuss it.
Liam
OK, I submitted https://www.w3.org/Bugs/Public/show_bug.cgi?id=16311 However as I have a rather hard time expressing myself, perhaps those who know what I am saying could add some detail to the bug. In the rare case the detail is wrong, I will chime in there. Thanks.
It looks like the CLP of DB2 gives you the behaviour you are asking for
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom....
But as mentioned before this is outside XQuery itself it's the environment , API , or processor that adds this bit
I personally feel it would have been a better choice to have used new lines ( whatever they are ) instead of spaces as the default XDM serialization separator for sequences but that's really a tiny thing in the grand scheme of things. Xmlsh does this but it's vastly more useful to NOT serialize sequences but rather keep them in internal form so You can pick them apart Before handing them off to a non XDM aware process. Hence the suggestion of using an API that can get at the results of XQuery aka XDM before serialization. Xmlsh also supports this .. Getting the results of any XDM process in an internal form without serialization. But that's again the province of the processor and/or API. Not XQuery itself.
Again back to the unanswered questions What processor are you using What results do you expect and why What is your end goal
Maybe there is a better way to accomplish your end goals then text serialization tweaks to XDM
Sent from my iPad (excuse the terseness) David A Lee dlee@calldei.com
On Mar 10, 2012, at 10:24 PM, "jidanni@jidanni.org" jidanni@jidanni.org wrote:
OK, I submitted https://www.w3.org/Bugs/Public/show_bug.cgi?id=16311 However as I have a rather hard time expressing myself, perhaps those who know what I am saying could add some detail to the bug. In the rare case the detail is wrong, I will chime in there. Thanks. _______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk
"DL" == David Lee dlee@calldei.com writes:
DL> It looks like the CLP of DB2 gives you the behaviour you are asking for DL> http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.... OK maybe BaseX could do something like that, if that could indeed help me toward my goal. DL> What is your end goal http://x-query.com/pipermail/talk/2012-March/003828.html I just thought I could do it all in Xquery, not needing to perl postprocess.
OK, I submitted https://www.w3.org/Bugs/Public/show_bug.cgi?id=16311 However as I have a rather hard time expressing myself, perhaps those who know what I am saying could add some detail to the bug. In the rare case the detail is wrong, I will chime in there. Thanks.
I've added the following suggestion to the Bugzilla entry:
I've looked up the XQuery Serialization Spec.: Step 3 in Section 2, "Sequence Normalization", contains the sub-sentence "separated by a single space" [1], which would probably have to be extended to take an additional serialization parameter into account. An XQuery 3.0 expression that uses the parameter could e.g. look as follows:
declare option output:separator " "; (1 to 10)
Opinions are welcome. Christian
[1] http://www.w3.org/TR/xslt-xquery-serialization-30/#serdm
fyi: I have added the suggestion [1] to the latest snapshot [2]. feedback is welcome.
[1] http://docs.basex.org/wiki/Serialization#Version_7.2 [2] http://files.basex.org/releases/latest/ ___________________________
On Sun, Mar 11, 2012 at 1:09 PM, Christian Grün christian.gruen@gmail.com wrote:
OK, I submitted https://www.w3.org/Bugs/Public/show_bug.cgi?id=16311 However as I have a rather hard time expressing myself, perhaps those who know what I am saying could add some detail to the bug. In the rare case the detail is wrong, I will chime in there. Thanks.
I've added the following suggestion to the Bugzilla entry:
I've looked up the XQuery Serialization Spec.: Step 3 in Section 2, "Sequence Normalization", contains the sub-sentence "separated by a single space" [1], which would probably have to be extended to take an additional serialization parameter into account. An XQuery 3.0 expression that uses the parameter could e.g. look as follows:
declare option output:separator " "; (1 to 10)
Opinions are welcome. Christian
[1] http://www.w3.org/TR/xslt-xquery-serialization-30/#serdm
On Sat, 2012-03-10 at 22:56 +0000, David Lee wrote:
There is, but you have to call XQuery natively instead of via "the command line"
??!?
My reading was the OP wanted newlines without having to add them in XQuery code. That is beyond XQuery itself so my suggestion of using a native API. But alas I belive I've misunderstood the entire post.
-David dlee@calldei.com
So exactly what is your question ? What you wrote is a statement not a question. To help:
What XQuery processor are you using ? And is this a question about that processor only or ALL XQuery implementations? What are you trying to accomplish ? What results are you getting ? How are you accomplishing them (code sample please)? How does that differ from what you want ? What would you like to achieve ?
There are answers and people willing to help if you ask with the right information.
-----Original Message----- From: talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] On Behalf Of jidanni@jidanni.org Sent: Saturday, March 10, 2012 5:42 PM To: talk@x-query.com Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [xquery-talk] say how to get "newline" working
Dear talk@x-query.com, there should be a way to get 'items' back out of Xquery, one per line, without having to hardwire 0x0A (you know, $ perl -wle 'printf "%08b\n" , ord"\n"' 00001010 into the code, as discussed in https://mailman.uni-konstanz.de/pipermail/basex-talk/2012-March/002738.html )
...or require a post-processor. _______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk
All I know is using $ cat file.xq (: Make bus timetable going westbound past Zaokeng :) declare option db:parser "html"; declare option output:method "html"; (: etc., not poorly supported "text" though :) declare function local:d($M){ doc(concat("http://www.fybus.com.tw/data/", $M)) }; let $line:=("1/067b.htm","city/90.htm","city/207.htm", "city/259.htm", "city/267.htm") let $name:=("6572"," 90"," 207", " 259", " 267") let $correction:=(23,4,23,2,29) for $l at $c in $line, $i in distinct-values(local:d($l)//*:tr/*:td[position()=2 and contains(.,":")]) let $t := xs:time(concat($i, ':00')) + xs:dayTimeDuration('PT1M') * $correction[$c] order by $t return <TD>{if(contains($l,"259") or (contains($l,"90")and contains($i,":00")))then "平" else "每",substring(string($t), 1, 5), $name[$c]}</TD>
I need to convert to text mode by hand: $ basex file.xq|perl -pwle 's/<[^>]+>//g' As all text serialization in Xquery can't deal with the same line concept... unless one hardwires the line separators (0x0A) in via string-join, which doesn't sound much like serialization to me.
I need to convert to text mode by hand: $ basex file.xq|perl -pwle 's/<[^>]+>//g' As all text serialization in Xquery can't deal with the same line concept... unless one hardwires the line separators (0x0A) in via string-join, which doesn't sound much like serialization to me.
There are 2 ways of approaching this, one is a query returning multiple items that must then be combined somehow outside of the query, or a query that returns a single item.
Because you've gone with the former, you've now hit a problem of how those items are being combined. You want newlines, but other people might want something else, like a single space, or no space at all.
So the easy way, is to just return a single item using string-join.
That said, the code you posted had an output method of html and returned <td> elements... which suggests you just want indent set?
"AW" == Andrew Welch andrew.j.welch@gmail.com writes:
AW> So the easy way, is to just return a single item using string-join. Which means we text wanters don't get to enjoy the benefits of all that serialization work one single bit.
AW> ...which suggests you just want indent set?
All I know is I just added an example of what I want "a flip of a switch" declaration change to cause in https://www.w3.org/Bugs/Public/show_bug.cgi?id=16311#c2
basex-talk@mailman.uni-konstanz.de