Writing out <?xml

Monday, 16 April 2012 · 7 messages · last reply 18 Apr 2012
DP
Dimitar Popovin reply to Erol Akarsu, 16 Apr 2012, 16:2516 Apr 2012 15:32 #
Quoted text · Erol Akarsu · 51 lines
On Apr 16, 2012, at 2:25 PM, Erol Akarsu wrote: > I would like to write this line into the beginning of an xml file I am generating. This is a must because I am generating csv file in xml form that should be opened Microsoft Excell. > > > > <?xml version="1.0"?> > > > I tried to use "processing-instruction" like this > > processing-instruction {"xml"} {'version="1.0"'} > > But I am getting > > Error: [XQDY0064] Processing instruction has illegal name: 'xml'. > > Erol Akarsu > > On Mon, Apr 9, 2012 at 8:41 PM, Charles Duffy <charles at dyfis.net> wrote: > Howdy -- > > The following is arguably a bug in my REST bindings rather than the server, but it worked as of the 7.2 release but fails as of the current 7.2.1 snapshot. > > A request akin to the following: > POST /rest HTTP/1.1 > Host: 127.0.0.1:8984 > Content-Length: 86 > Authorization: Basic cmVhZG9ubHk6cmVhZG9ubHk= > Content-Type: application/x-www-form-urlencoded > Accept-Encoding: identity, deflate, compress, gzip > Accept: */* > User-Agent: python-requests/0.10.6 > > <rest:query xmlns:rest="http://basex.org/rest"><rest:text>1+1</rest:text></rest:query> > Yields the following response: > HTTP/1.1 400 Bad Request > Content-Length: 40 > Server: Jetty(6.1.26) > > Unknown option '<REST:QUERY XMLNS:REST'. > ...but did not do so previously. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
EA
Erol Akarsu16 Apr 2012 16:25 #
I would like to write this line into the beginning of an xml file I am generating. This is a must because I am generating csv file in xml form that should be opened Microsoft Excell.
<?xml version="1.0"?>
I tried to use "processing-instruction" like this processing-instruction {"xml"} {'version="1.0"'} But I am getting Error: [XQDY0064] Processing instruction has illegal name: 'xml'. Erol Akarsu
Quoted text · Charles Duffy · 36 lines
On Mon, Apr 9, 2012 at 8:41 PM, Charles Duffy <charles at dyfis.net> wrote: > Howdy -- > > The following is arguably a bug in my REST bindings rather than the > server, but it worked as of the 7.2 release but fails as of the current > 7.2.1 snapshot. > > A request akin to the following: > > POST /rest HTTP/1.1 > Host: 127.0.0.1:8984 > Content-Length: 86 > Authorization: Basic cmVhZG9ubHk6cmVhZG9ubHk= > Content-Type: application/x-www-form-urlencoded > Accept-Encoding: identity, deflate, compress, gzip > Accept: */* > User-Agent: python-requests/0.10.6 > > <rest:query xmlns:rest="http://basex.org/rest > "><rest:text>1+1</rest:text></rest:query> > > Yields the following response: > > HTTP/1.1 400 Bad Request > Content-Length: 40 > Server: Jetty(6.1.26) > > Unknown option '<REST:QUERY XMLNS:REST'. > > ...but did not do so previously. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
DP
Dimitar Popovin reply to Erol Akarsu, 17 Apr 2012, 23:2917 Apr 2012 21:29 #
Quoted text · 15:20:02 · 7 lines
Am Dienstag, 17. April 2012, 15:20:02 schrieb Erol Akarsu: > Thanks Dimitar, > > I have one more question. > > Dow we have equivalent function in basex xquery for java static method > URLEncoder.encode ?
I'm not aware of such XQuery function - maybe someone else one the ML would know better. If there isn't, you could very easily create your own by using the Java binding [1]:
declare namespace enc = "java:java.net.URLEncoder";
enc:encode("test data")
CG
Christian Grünin reply to Erol Akarsu, 17 Apr 2012, 23:2917 Apr 2012 21:34 #
Quoted text · Erol Akarsu · 2 lines
> Dow we have equivalent function in basex xquery for java static method > URLEncoder.encode ?
..just try encode-for-uri($uri). Christian
Quoted text · Erol Akarsu · 82 lines
> I need it before sending url request, > > Thanks > > Erol Akarsu > > > On Mon, Apr 16, 2012 at 9:32 AM, Dimitar Popov > <dimitar.popov at uni-konstanz.de> wrote: >> >> http://docs.basex.org/wiki/XQuery_3.0#Serialization >> >> On Apr 16, 2012, at 2:25 PM, Erol Akarsu wrote: >> >> I would like to write this line into the beginning of an xml file I am >> generating. This is a must because I am generating csv file in xml form that >> should be opened Microsoft Excell. >> >> >> <?xml version="1.0"?> >> >> >> I tried to use "processing-instruction" like this >> >> processing-instruction {"xml"} {'version="1.0"'} >> >> But I am getting >> >> Error: [XQDY0064] Processing instruction has illegal name: 'xml'. >> >> Erol Akarsu >> >> On Mon, Apr 9, 2012 at 8:41 PM, Charles Duffy <charles at dyfis.net> wrote: >>> >>> Howdy -- >>> >>> The following is arguably a bug in my REST bindings rather than the >>> server, but it worked as of the 7.2 release but fails as of the current >>> 7.2.1 snapshot. >>> >>> A request akin to the following: >>> >>> POST /rest HTTP/1.1 >>> Host: 127.0.0.1:8984 >>> Content-Length: 86 >>> Authorization: Basic cmVhZG9ubHk6cmVhZG9ubHk= >>> Content-Type: application/x-www-form-urlencoded >>> Accept-Encoding: identity, deflate, compress, gzip >>> Accept: */* >>> User-Agent: python-requests/0.10.6 >>> >>> <rest:query >>> xmlns:rest="http://basex.org/rest"><rest:text>1+1</rest:text></rest:query> >>> >>> Yields the following response: >>> >>> HTTP/1.1 400 Bad Request >>> Content-Length: 40 >>> Server: Jetty(6.1.26) >>> >>> Unknown option '<REST:QUERY XMLNS:REST'. >>> >>> ...but did not do so previously. >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
EA
Erol Akarsuin reply to Dimitar Popov, 16 Apr 2012, 15:3217 Apr 2012 23:29 #
Thanks Dimitar, I have one more question. Dow we have equivalent function in basex xquery for java static method URLEncoder.encode ? I need it before sending url request, Thanks Erol Akarsu
Quoted text · Dimitar Popov · 67 lines
On Mon, Apr 16, 2012 at 9:32 AM, Dimitar Popov < dimitar.popov at uni-konstanz.de> wrote: > http://docs.basex.org/wiki/XQuery_3.0#Serialization > > On Apr 16, 2012, at 2:25 PM, Erol Akarsu wrote: > > I would like to write this line into the beginning of an xml file I am > generating. This is a must because I am generating csv file in xml form > that should be opened Microsoft Excell. > > > <?xml version="1.0"?> > > I tried to use "processing-instruction" like this > > processing-instruction {"xml"} {'version="1.0"'} > > But I am getting > > Error: [XQDY0064] Processing instruction has illegal name: 'xml'. > > Erol Akarsu > > On Mon, Apr 9, 2012 at 8:41 PM, Charles Duffy <charles at dyfis.net> wrote: > >> Howdy -- >> >> The following is arguably a bug in my REST bindings rather than the >> server, but it worked as of the 7.2 release but fails as of the current >> 7.2.1 snapshot. >> >> A request akin to the following: >> >> POST /rest HTTP/1.1 >> Host: 127.0.0.1:8984 >> Content-Length: 86 >> Authorization: Basic cmVhZG9ubHk6cmVhZG9ubHk= >> Content-Type: application/x-www-form-urlencoded >> Accept-Encoding: identity, deflate, compress, gzip >> Accept: */* >> User-Agent: python-requests/0.10.6 >> >> <rest:query xmlns:rest="http://basex.org/rest >> "><rest:text>1+1</rest:text></rest:query> >> >> Yields the following response: >> >> HTTP/1.1 400 Bad Request >> Content-Length: 40 >> Server: Jetty(6.1.26) >> >> Unknown option '<REST:QUERY XMLNS:REST'. >> >> ...but did not do so previously. >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > >
CG
Christian Grünin reply to Erol Akarsu, 18 Apr 2012, 01:2017 Apr 2012 23:29 #
Quoted text · Erol Akarsu · 4 lines
> The following function takes a lot of time execute. If I don't write the > fetched binary image into file with fn:write-binary function, then it is > quick and no delay. > Somehow, write-binary function call is killing performance here.
This sounds surprising to me; could you send me the query without the write-binary function? Christian
Quoted text · Erol Akarsu · 125 lines
> do you have any other suggestion to solve this performance issue? > > declare function local:fetchDigData ($fileName as xs:string,$url as > xs:string,$binFolder as xs:string) as element()* > { > let $content:= > try { > let $uri := fn:encode-for-uri($url) > let $content := http:send-request(<http:request method='get' > status-only='false'/>, $url) > > let $res := > file:write-binary(fn:concat($binFolder,$fileName),$content[2]) > return $res > > } > catch * { > <error>{$err:code, $err:value, " module: ", > $err:module, "(", $err:line-number, ",", $err:column-number, "in > url:",$url,")"}</error> > } > return $content > }; > > > Erol Akarsu > > On Tue, Apr 17, 2012 at 3:34 PM, Christian Grün <christian.gruen at gmail.com> > wrote: >> >> > Dow we have equivalent function in basex xquery for java static method >> > URLEncoder.encode ? >> >> ..just try encode-for-uri($uri). >> Christian >> >> >> > I need it before sending url request, >> > >> > Thanks >> > >> > Erol Akarsu >> > >> > >> > On Mon, Apr 16, 2012 at 9:32 AM, Dimitar Popov >> > <dimitar.popov at uni-konstanz.de> wrote: >> >> >> >> http://docs.basex.org/wiki/XQuery_3.0#Serialization >> >> >> >> On Apr 16, 2012, at 2:25 PM, Erol Akarsu wrote: >> >> >> >> I would like to write this line into the beginning of an xml file I am >> >> generating. This is a must because I am generating csv file in xml form >> >> that >> >> should be opened Microsoft Excell. >> >> >> >> >> >> <?xml version="1.0"?> >> >> >> >> >> >> I tried to use "processing-instruction" like this >> >> >> >> processing-instruction {"xml"} {'version="1.0"'} >> >> >> >> But I am getting >> >> >> >> Error: [XQDY0064] Processing instruction has illegal name: 'xml'. >> >> >> >> Erol Akarsu >> >> >> >> On Mon, Apr 9, 2012 at 8:41 PM, Charles Duffy <charles at dyfis.net> >> >> wrote: >> >>> >> >>> Howdy -- >> >>> >> >>> The following is arguably a bug in my REST bindings rather than the >> >>> server, but it worked as of the 7.2 release but fails as of the >> >>> current >> >>> 7.2.1 snapshot. >> >>> >> >>> A request akin to the following: >> >>> >> >>> POST /rest HTTP/1.1 >> >>> Host: 127.0.0.1:8984 >> >>> Content-Length: 86 >> >>> Authorization: Basic cmVhZG9ubHk6cmVhZG9ubHk= >> >>> Content-Type: application/x-www-form-urlencoded >> >>> Accept-Encoding: identity, deflate, compress, gzip >> >>> Accept: */* >> >>> User-Agent: python-requests/0.10.6 >> >>> >> >>> <rest:query >> >>> >> >>> xmlns:rest="http://basex.org/rest"><rest:text>1+1</rest:text></rest:query> >> >>> >> >>> Yields the following response: >> >>> >> >>> HTTP/1.1 400 Bad Request >> >>> Content-Length: 40 >> >>> Server: Jetty(6.1.26) >> >>> >> >>> Unknown option '<REST:QUERY XMLNS:REST'. >> >>> >> >>> ...but did not do so previously. >> >>> _______________________________________________ >> >>> BaseX-Talk mailing list >> >>> BaseX-Talk at mailman.uni-konstanz.de >> >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >>> >> >> >> >> _______________________________________________ >> >> BaseX-Talk mailing list >> >> BaseX-Talk at mailman.uni-konstanz.de >> >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> >> >> >> > >> > >> > _______________________________________________ >> > BaseX-Talk mailing list >> > BaseX-Talk at mailman.uni-konstanz.de >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > > >
EA
Erol Akarsuin reply to Christian Grün, 17 Apr 2012, 21:3418 Apr 2012 01:20 #
Thanks Christian The following function takes a lot of time execute. If I don't write the fetched binary image into file with fn:write-binary function, then it is quick and no delay. Somehow, write-binary function call is killing performance here. do you have any other suggestion to solve this performance issue?
declare function local:fetchDigData ($fileName as xs:string,$url as
xs:string,$binFolder as xs:string) as element()*
{
    let $content:=
        try {
                let $uri := fn:encode-for-uri($url)
            let $content := http:send-request(<http:request method='get'
status-only='false'/>, $url)

            let $res :=
file:write-binary(fn:concat($binFolder,$fileName),$content[2])
            return $res

        }
        catch * {
            <error>{$err:code, $err:value, " module: ",
            $err:module, "(", $err:line-number, ",", $err:column-number,
"in url:",$url,")"}</error>
        }
        return $content
};
Erol Akarsu On Tue, Apr 17, 2012 at 3:34 PM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 93 lines
> > Dow we have equivalent function in basex xquery for java static method > > URLEncoder.encode ? > > ..just try encode-for-uri($uri). > Christian > > > > I need it before sending url request, > > > > Thanks > > > > Erol Akarsu > > > > > > On Mon, Apr 16, 2012 at 9:32 AM, Dimitar Popov > > <dimitar.popov at uni-konstanz.de> wrote: > >> > >> http://docs.basex.org/wiki/XQuery_3.0#Serialization > >> > >> On Apr 16, 2012, at 2:25 PM, Erol Akarsu wrote: > >> > >> I would like to write this line into the beginning of an xml file I am > >> generating. This is a must because I am generating csv file in xml form > that > >> should be opened Microsoft Excell. > >> > >> > >> <?xml version="1.0"?> > >> > >> > >> I tried to use "processing-instruction" like this > >> > >> processing-instruction {"xml"} {'version="1.0"'} > >> > >> But I am getting > >> > >> Error: [XQDY0064] Processing instruction has illegal name: 'xml'. > >> > >> Erol Akarsu > >> > >> On Mon, Apr 9, 2012 at 8:41 PM, Charles Duffy <charles at dyfis.net> > wrote: > >>> > >>> Howdy -- > >>> > >>> The following is arguably a bug in my REST bindings rather than the > >>> server, but it worked as of the 7.2 release but fails as of the current > >>> 7.2.1 snapshot. > >>> > >>> A request akin to the following: > >>> > >>> POST /rest HTTP/1.1 > >>> Host: 127.0.0.1:8984 > >>> Content-Length: 86 > >>> Authorization: Basic cmVhZG9ubHk6cmVhZG9ubHk= > >>> Content-Type: application/x-www-form-urlencoded > >>> Accept-Encoding: identity, deflate, compress, gzip > >>> Accept: */* > >>> User-Agent: python-requests/0.10.6 > >>> > >>> <rest:query > >>> xmlns:rest="http://basex.org/rest > "><rest:text>1+1</rest:text></rest:query> > >>> > >>> Yields the following response: > >>> > >>> HTTP/1.1 400 Bad Request > >>> Content-Length: 40 > >>> Server: Jetty(6.1.26) > >>> > >>> Unknown option '<REST:QUERY XMLNS:REST'. > >>> > >>> ...but did not do so previously. > >>> _______________________________________________ > >>> BaseX-Talk mailing list > >>> BaseX-Talk at mailman.uni-konstanz.de > >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >>> > >> > >> _______________________________________________ > >> BaseX-Talk mailing list > >> BaseX-Talk at mailman.uni-konstanz.de > >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >> > >> > > > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > >

⚡Generated with XQuery