How to output plain text (CSV) from XQuery
Hi According to what I found it might be quite implementation specific. In http://www.stylusstudio.com/xquerytalk/201004/003992.html I found some instructions Using Saxon: declare namespace saxon = "http://saxon.sf.net/"; declare option saxon:output "indent=no"; declare option saxon:output "method=html"; Using eXist: declare namespace exist = "http://exist.sourceforge.net/NS/exist"; declare option exist:serialize "method=html indent=no" Is there any simple trick to do that? Thanks Jan -- *Jan Vlčinský* Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic tel: +420-597 602 024; mob: +420-608 979 040 skype: janvlcinsky; GoogleTalk: jan.vlcinsky@gmail.com
Hi Jan, XQuery 1.1 (or 3.0) will officially support the definition of serialization parameters within a query. This feature has already been integrated in BaseX; please try this: declare option output:indent "no"; declare option output:method "html"; ... More info is found at: http://www.w3.org/TR/xquery-11/#id-serialization Hope this helps, Christian On Tue, Oct 26, 2010 at 11:04 PM, Jan Vlčinský <jan.vlcinsky@gmail.com> wrote:
Hi According to what I found it might be quite implementation specific. In http://www.stylusstudio.com/xquerytalk/201004/003992.html I found some instructions Using Saxon: declare namespace saxon = "http://saxon.sf.net/"; declare option saxon:output "indent=no"; declare option saxon:output "method=html";
Using eXist: declare namespace exist = "http://exist.sourceforge.net/NS/exist"; declare option exist:serialize "method=html indent=no"
Is there any simple trick to do that? Thanks Jan -- Jan Vlčinský
___________________________ Christian Grün University of Konstanz Department of Computer & Information Science D-78457 Konstanz, Germany Tel: +49-7531-88-4449, Fax: +49-7531-88-3577 http://www.inf.uni-konstanz.de/~gruen
Christian Be sure it helps. I have small problem, that each return adds one space to the end of output string So for XQuery declare option output:indent "no"; declare option output:method "text"; for $doc in //PayloadPublication order by xs:dateTime($doc/@publicationTime) return string(concat("-",xs:dateTime($doc/@publicationTime),";",count($doc/ElaboratedRecord),";",count($doc/ElaboratedRecord),codepoints-to-string(10))) I get output like this -2010-10-25T00:00:05Z;0;0 -2010-10-25T00:01:05Z;0;0 -2010-10-25T00:02:05Z;0;0 In the spec you refer to is not much about text specific serialization and they refer to http://www.w3.org/TR/xslt-xquery-serialization-11/#text-output where they say 8 Text Output Method The Text output method serializes the instance of the data model by outputting the string value<http://www.w3.org/TR/xslt-xquery-serialization-11/#dt-string-value> of the document node<http://www.w3.org/TR/xslt-xquery-serialization-11/#dt-node> created by the markup generation step of the phases of serialization<http://www.w3.org/TR/xslt-xquery-serialization-11/#serphases>without any escaping. A newline character in the instance of the data model *MAY* be output using any character sequence that is conventionally used to represent a line ending in the chosen system environment. It would be nice, if there would be some new line character output and no other spaces placed between output parts (it seems to me like outputing sequence with space as item delimiter) Jan On Wed, Oct 27, 2010 at 7:27 AM, Christian Grün <christian.gruen@gmail.com>wrote:
Hi Jan,
XQuery 1.1 (or 3.0) will officially support the definition of serialization parameters within a query. This feature has already been integrated in BaseX; please try this:
declare option output:indent "no"; declare option output:method "html"; ...
More info is found at: http://www.w3.org/TR/xquery-11/#id-serialization
Hope this helps, Christian
On Tue, Oct 26, 2010 at 11:04 PM, Jan Vlčinský <jan.vlcinsky@gmail.com> wrote:
Hi According to what I found it might be quite implementation specific. In http://www.stylusstudio.com/xquerytalk/201004/003992.html I found some instructions Using Saxon: declare namespace saxon = "http://saxon.sf.net/"; declare option saxon:output "indent=no"; declare option saxon:output "method=html";
Using eXist: declare namespace exist = "http://exist.sourceforge.net/NS/exist"; declare option exist:serialize "method=html indent=no"
Is there any simple trick to do that? Thanks Jan -- Jan Vlčinský
___________________________
Christian Grün University of Konstanz Department of Computer & Information Science D-78457 Konstanz, Germany Tel: +49-7531-88-4449, Fax: +49-7531-88-3577 http://www.inf.uni-konstanz.de/~gruen
-- *Jan Vlčinský* Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic tel: +420-597 602 024; mob: +420-608 979 040 skype: janvlcinsky; GoogleTalk: jan.vlcinsky@gmail.com
participants (2)
-
Christian Grün -
Jan Vlčinský