file:write and include-content-type

Wednesday, 13 January 2016 · 12 messages · last reply 31 Jan 2016
JB
James Ball13 Jan 2016 19:06 #
Hello, I’m getting an unexpected behaviour with the serialization option include-content-type and file:write with HTML. If I write a document without a <head> element then one doesn’t get added and nothing happens.
file:write("test.htm",<html><body/></html>,map {"method":"html", "html-version":"4.0","include-content-type":"yes”})
returns:
<html>
  <body></body>
</html>
Is this correct? If there is a head then the <meta> gets added with no problems - unless there is already a meta element, in which case it gets replaced.
file:write("/Users/jb8748/test.htm",<html><head><meta http-equiv="refresh" content="60" /></head><body/></html>,map {"method":"html", "html-version":"4.0","include-content-type":"yes”})
returns:
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body></body>
</html>
Is this correct? All running Running Beta 8.4 f5341cc Many thanks, James
CG
Christian Grün13 Jan 2016 19:31 #
Hi James,
Quoted text · James Ball · 1 line
> Is this correct?
It should be, at least according to the current specification (“If there is a head element [...]”, see [1]). Hope this helps, Christian [1] https://www.w3.org/TR/2015/CR-xslt-xquery-serialization-31-20151217/#HTML_INCLUDE-CONTENT-TYPE
Quoted text · James Ball · 41 lines
On Wed, Jan 13, 2016 at 7:06 PM, James Ball <basex-talk at jamesball.co.uk> wrote: > Hello, > > I’m getting an unexpected behaviour with the serialization option > include-content-type and file:write with HTML. > > If I write a document without a <head> element then one doesn’t get added > and nothing happens. > > file:write("test.htm",<html><body/></html>,map {"method":"html", > "html-version":"4.0","include-content-type":"yes”}) > > returns: > > <html> > <body></body> > </html> > > Is this correct? > > If there is a head then the <meta> gets added with no problems - unless > there is already a meta element, in which case it gets replaced. > > file:write("/Users/jb8748/test.htm",<html><head><meta http-equiv="refresh" > content="60" /></head><body/></html>,map {"method":"html", > "html-version":"4.0","include-content-type":"yes”}) > > returns: > > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> > </head> > <body></body> > </html> > > Is this correct? > > All running Running Beta 8.4 f5341cc > > Many thanks, James
JB
James Ball13 Jan 2016 19:37 #
Hi Christian, Thank you for that, so the first case is correct. And the second case, where existing <meta> elements are removed? I’ve just read the spec and it looks like only <meta> elements that have http-equiv should be discarded. Regards, James
Quoted text · Christian Grün · 56 lines
> On 13 Jan 2016, at 18:31, Christian Grün <christian.gruen at gmail.com> wrote: > > Hi James, > >> Is this correct? > > It should be, at least according to the current specification (“If > there is a head element [...]”, see [1]). > > Hope this helps, > Christian > > [1] https://www.w3.org/TR/2015/CR-xslt-xquery-serialization-31-20151217/#HTML_INCLUDE-CONTENT-TYPE > > > On Wed, Jan 13, 2016 at 7:06 PM, James Ball <basex-talk at jamesball.co.uk> wrote: >> Hello, >> >> I’m getting an unexpected behaviour with the serialization option >> include-content-type and file:write with HTML. >> >> If I write a document without a <head> element then one doesn’t get added >> and nothing happens. >> >> file:write("test.htm",<html><body/></html>,map {"method":"html", >> "html-version":"4.0","include-content-type":"yes”}) >> >> returns: >> >> <html> >> <body></body> >> </html> >> >> Is this correct? >> >> If there is a head then the <meta> gets added with no problems - unless >> there is already a meta element, in which case it gets replaced. >> >> file:write("/Users/jb8748/test.htm",<html><head><meta http-equiv="refresh" >> content="60" /></head><body/></html>,map {"method":"html", >> "html-version":"4.0","include-content-type":"yes”}) >> >> returns: >> >> <html> >> <head> >> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> >> </head> >> <body></body> >> </html> >> >> Is this correct? >> >> All running Running Beta 8.4 f5341cc >> >> Many thanks, James
CG
Christian Grün13 Jan 2016 19:49 #
Looks suspicious indeed. Thanks for the hint, I’ll track this down this soon [1]. Christian [1] https://github.com/BaseXdb/basex/issues/1240
Quoted text · James Ball · 64 lines
On Wed, Jan 13, 2016 at 7:37 PM, James Ball <basex-talk at jamesball.co.uk> wrote: > Hi Christian, > > Thank you for that, so the first case is correct. And the second case, where existing <meta> elements are removed? I’ve just read the spec and it looks like only <meta> elements that have http-equiv should be discarded. > > Regards, James > >> On 13 Jan 2016, at 18:31, Christian Grün <christian.gruen at gmail.com> wrote: >> >> Hi James, >> >>> Is this correct? >> >> It should be, at least according to the current specification (“If >> there is a head element [...]”, see [1]). >> >> Hope this helps, >> Christian >> >> [1] https://www.w3.org/TR/2015/CR-xslt-xquery-serialization-31-20151217/#HTML_INCLUDE-CONTENT-TYPE >> >> >> On Wed, Jan 13, 2016 at 7:06 PM, James Ball <basex-talk at jamesball.co.uk> wrote: >>> Hello, >>> >>> I’m getting an unexpected behaviour with the serialization option >>> include-content-type and file:write with HTML. >>> >>> If I write a document without a <head> element then one doesn’t get added >>> and nothing happens. >>> >>> file:write("test.htm",<html><body/></html>,map {"method":"html", >>> "html-version":"4.0","include-content-type":"yes”}) >>> >>> returns: >>> >>> <html> >>> <body></body> >>> </html> >>> >>> Is this correct? >>> >>> If there is a head then the <meta> gets added with no problems - unless >>> there is already a meta element, in which case it gets replaced. >>> >>> file:write("/Users/jb8748/test.htm",<html><head><meta http-equiv="refresh" >>> content="60" /></head><body/></html>,map {"method":"html", >>> "html-version":"4.0","include-content-type":"yes”}) >>> >>> returns: >>> >>> <html> >>> <head> >>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> >>> </head> >>> <body></body> >>> </html> >>> >>> Is this correct? >>> >>> All running Running Beta 8.4 f5341cc >>> >>> Many thanks, James >
JB
James Ball13 Jan 2016 21:13 #
Christian, Thank you. I’ve just spotted that I was unclear in my description in the last email. According to the specification only <meta> elements that have @http-equiv with a value of Content-Type should be discarded. Not any with http-equiv. Apologies for any confusion. Regards, James
Quoted text · Christian Grün · 73 lines
> On 13 Jan 2016, at 18:49, Christian Grün <christian.gruen at gmail.com> wrote: > > Looks suspicious indeed. Thanks for the hint, I’ll track this down > this soon [1]. > Christian > > [1] https://github.com/BaseXdb/basex/issues/1240 > > > On Wed, Jan 13, 2016 at 7:37 PM, James Ball <basex-talk at jamesball.co.uk> wrote: >> Hi Christian, >> >> Thank you for that, so the first case is correct. And the second case, where existing <meta> elements are removed? I’ve just read the spec and it looks like only <meta> elements that have http-equiv should be discarded. >> >> Regards, James >> >>> On 13 Jan 2016, at 18:31, Christian Grün <christian.gruen at gmail.com> wrote: >>> >>> Hi James, >>> >>>> Is this correct? >>> >>> It should be, at least according to the current specification (“If >>> there is a head element [...]”, see [1]). >>> >>> Hope this helps, >>> Christian >>> >>> [1] https://www.w3.org/TR/2015/CR-xslt-xquery-serialization-31-20151217/#HTML_INCLUDE-CONTENT-TYPE >>> >>> >>> On Wed, Jan 13, 2016 at 7:06 PM, James Ball <basex-talk at jamesball.co.uk> wrote: >>>> Hello, >>>> >>>> I’m getting an unexpected behaviour with the serialization option >>>> include-content-type and file:write with HTML. >>>> >>>> If I write a document without a <head> element then one doesn’t get added >>>> and nothing happens. >>>> >>>> file:write("test.htm",<html><body/></html>,map {"method":"html", >>>> "html-version":"4.0","include-content-type":"yes”}) >>>> >>>> returns: >>>> >>>> <html> >>>> <body></body> >>>> </html> >>>> >>>> Is this correct? >>>> >>>> If there is a head then the <meta> gets added with no problems - unless >>>> there is already a meta element, in which case it gets replaced. >>>> >>>> file:write("/Users/jb8748/test.htm",<html><head><meta http-equiv="refresh" >>>> content="60" /></head><body/></html>,map {"method":"html", >>>> "html-version":"4.0","include-content-type":"yes”}) >>>> >>>> returns: >>>> >>>> <html> >>>> <head> >>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> >>>> </head> >>>> <body></body> >>>> </html> >>>> >>>> Is this correct? >>>> >>>> All running Running Beta 8.4 f5341cc >>>> >>>> Many thanks, James >>
CG
Christian Grün14 Jan 2016 07:48 #
Quoted text · James Ball · 1 line
> I’ve just spotted that I was unclear in my description in the last email. According to the specification only <meta> elements that have @http-equiv with a value of Content-Type should be discarded. Not any with http-equiv. Apologies for any confusion.
No reason to be sorry; I should simply have spent a few more seconds on reading your mail and the latest version of the spec ;) The problem is now fixed [1,2]. Cheers, Christian [1] https://github.com/BaseXdb/basex/commit/bf81e67322ca898aaeefc107e6bd669955f699ea [2] http://files.basex.org/releases/latest/
Quoted text · Christian Grün · 74 lines
>> On 13 Jan 2016, at 18:49, Christian Grün <christian.gruen at gmail.com> wrote: >> >> Looks suspicious indeed. Thanks for the hint, I’ll track this down >> this soon [1]. >> Christian >> >> [1] https://github.com/BaseXdb/basex/issues/1240 >> >> >> On Wed, Jan 13, 2016 at 7:37 PM, James Ball <basex-talk at jamesball.co.uk> wrote: >>> Hi Christian, >>> >>> Thank you for that, so the first case is correct. And the second case, where existing <meta> elements are removed? I’ve just read the spec and it looks like only <meta> elements that have http-equiv should be discarded. >>> >>> Regards, James >>> >>>> On 13 Jan 2016, at 18:31, Christian Grün <christian.gruen at gmail.com> wrote: >>>> >>>> Hi James, >>>> >>>>> Is this correct? >>>> >>>> It should be, at least according to the current specification (“If >>>> there is a head element [...]”, see [1]). >>>> >>>> Hope this helps, >>>> Christian >>>> >>>> [1] https://www.w3.org/TR/2015/CR-xslt-xquery-serialization-31-20151217/#HTML_INCLUDE-CONTENT-TYPE >>>> >>>> >>>> On Wed, Jan 13, 2016 at 7:06 PM, James Ball <basex-talk at jamesball.co.uk> wrote: >>>>> Hello, >>>>> >>>>> I’m getting an unexpected behaviour with the serialization option >>>>> include-content-type and file:write with HTML. >>>>> >>>>> If I write a document without a <head> element then one doesn’t get added >>>>> and nothing happens. >>>>> >>>>> file:write("test.htm",<html><body/></html>,map {"method":"html", >>>>> "html-version":"4.0","include-content-type":"yes”}) >>>>> >>>>> returns: >>>>> >>>>> <html> >>>>> <body></body> >>>>> </html> >>>>> >>>>> Is this correct? >>>>> >>>>> If there is a head then the <meta> gets added with no problems - unless >>>>> there is already a meta element, in which case it gets replaced. >>>>> >>>>> file:write("/Users/jb8748/test.htm",<html><head><meta http-equiv="refresh" >>>>> content="60" /></head><body/></html>,map {"method":"html", >>>>> "html-version":"4.0","include-content-type":"yes”}) >>>>> >>>>> returns: >>>>> >>>>> <html> >>>>> <head> >>>>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> >>>>> </head> >>>>> <body></body> >>>>> </html> >>>>> >>>>> Is this correct? >>>>> >>>>> All running Running Beta 8.4 f5341cc >>>>> >>>>> Many thanks, James >>> >
JB
James Ball31 Jan 2016 15:50 #
Dear Christian, Sorry to take so long coming back to you but I’ve now had a chance to download the latest snap short (8.4 beta f5341cc) and try this. Unfortunately I’m still getting odd behaviour.
file:write(“test.html",<html><head><meta http-equiv="REFRESH" content="60"/></head><body></body></html>,map {"method":"html","html-version":"5.0","include-content-type":"yes”})
I think this should give me:
<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8”>
    <meta http-equiv="REFRESH" content="600">
  </head>
  <body>
</body></html>
But what it’s still giving me is:
<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
</body></html>
Regards, James
Quoted text · Christian Grün · 9 lines
> On 14 Jan 2016, at 06:48, Christian Grün <christian.gruen at gmail.com> wrote: > > No reason to be sorry; I should simply have spent a few more seconds > on reading your mail and the latest version of the spec ;) The problem > is now fixed [1,2]. > > [1] https://github.com/BaseXdb/basex/commit/bf81e67322ca898aaeefc107e6bd669955f699ea > [2] http://files.basex.org/releases/latest/ >
JB
James Ball31 Jan 2016 16:30 #
Dear Christian, I’ve also found another error when using include-content-type - I don’t know if this is related or will help track down the issue. I get a java.lang.NullPointerException whenever include-content-type is set to yes and there is a text node in the HTML. So for example, this will return an error:
let $html :=
<html>
<head></head>
<body>
<p>yy</p>
</body>
</html>
return file:write("test.html",$html,map {"method":"html","html-version":"5.0","include-content-type":"yes”})
Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk at mailman.uni-konstanz.de Version: BaseX 8.4 beta f5341cc Java: Oracle Corporation, 1.8.0_20 OS: Mac OS X, x86_64 Stack Trace: java.lang.NullPointerException But this will not:
let $html :=
<html>
<head></head>
<body>
<p></p>
</body>
</html>
return file:write("test.html",$html,map {"method":"html","html-version":"5.0","include-content-type":"yes”})
(no yy in the <p> element). Regards, James
Quoted text · James Ball · 39 lines
> On 31 Jan 2016, at 14:50, James Ball <basex-talk at jamesball.co.uk> wrote: > > Dear Christian, > > Sorry to take so long coming back to you but I’ve now had a chance to download the latest snap short (8.4 beta f5341cc) and try this. > > Unfortunately I’m still getting odd behaviour. > > file:write(“test.html",<html><head><meta http-equiv="REFRESH" content="60"/></head><body></body></html>,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) > > I think this should give me: > > <html><head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8”> > <meta http-equiv="REFRESH" content="600"> > </head> > <body> > </body></html> > > But what it’s still giving me is: > > <html><head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> > </head> > <body> > </body></html> > > Regards, James > >> On 14 Jan 2016, at 06:48, Christian Grün <christian.gruen at gmail.com> wrote: >> >> No reason to be sorry; I should simply have spent a few more seconds >> on reading your mail and the latest version of the spec ;) The problem >> is now fixed [1,2]. >> >> [1] https://github.com/BaseXdb/basex/commit/bf81e67322ca898aaeefc107e6bd669955f699ea >> [2] http://files.basex.org/releases/latest/ >> >
CG
Christian Grünin reply to James Ball, 31 Jan 2016, 15:5031 Jan 2016 16:31 #
Hi James,
Quoted text · James Ball · 1 line
> Sorry to take so long coming back to you but I’ve now had a chance to download the latest snap short (8.4 beta f5341cc) and try this.
It seems that you’ve tried an older version [1]… Could you please try again to download the latest snapshot [2]? Thanks in advance, Christian [1] https://github.com/BaseXdb/basex/commit/f5341cc [2] http://files.basex.org/releases/latest/
Quoted text · James Ball · 38 lines
On Sun, Jan 31, 2016 at 3:50 PM, James Ball <basex-talk at jamesball.co.uk> wrote: > Dear Christian, > > Sorry to take so long coming back to you but I’ve now had a chance to download the latest snap short (8.4 beta f5341cc) and try this. > > Unfortunately I’m still getting odd behaviour. > > file:write(“test.html",<html><head><meta http-equiv="REFRESH" content="60"/></head><body></body></html>,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) > > I think this should give me: > > <html><head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8”> > <meta http-equiv="REFRESH" content="600"> > </head> > <body> > </body></html> > > But what it’s still giving me is: > > <html><head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> > </head> > <body> > </body></html> > > Regards, James > >> On 14 Jan 2016, at 06:48, Christian Grün <christian.gruen at gmail.com> wrote: >> >> No reason to be sorry; I should simply have spent a few more seconds >> on reading your mail and the latest version of the spec ;) The problem >> is now fixed [1,2]. >> >> [1] https://github.com/BaseXdb/basex/commit/bf81e67322ca898aaeefc107e6bd669955f699ea >> [2] http://files.basex.org/releases/latest/ >> >
CG
Christian Grünin reply to James Ball, 31 Jan 2016, 16:3031 Jan 2016 16:50 #
Quoted text · James Ball · 1 line
> I get a java.lang.NullPointerException whenever include-content-type is set to yes and there is a text node in the HTML.
Thanks; this one has been fixed. It takes me around 10 minutes to upload the latest snapshot, so… Sorry for letting you wait ;)
Quoted text · James Ball · 75 lines
> > So for example, this will return an error: > > let $html := > <html> > <head></head> > <body> > <p>yy</p> > </body> > </html> > return file:write("test.html",$html,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) > > Improper use? Potential bug? Your feedback is welcome: > Contact: basex-talk at mailman.uni-konstanz.de > Version: BaseX 8.4 beta f5341cc > Java: Oracle Corporation, 1.8.0_20 > OS: Mac OS X, x86_64 > Stack Trace: > java.lang.NullPointerException > > But this will not: > > let $html := > <html> > <head></head> > <body> > <p></p> > </body> > </html> > return file:write("test.html",$html,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) > > (no yy in the <p> element). > > Regards, James > >> On 31 Jan 2016, at 14:50, James Ball <basex-talk at jamesball.co.uk> wrote: >> >> Dear Christian, >> >> Sorry to take so long coming back to you but I’ve now had a chance to download the latest snap short (8.4 beta f5341cc) and try this. >> >> Unfortunately I’m still getting odd behaviour. >> >> file:write(“test.html",<html><head><meta http-equiv="REFRESH" content="60"/></head><body></body></html>,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) >> >> I think this should give me: >> >> <html><head> >> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8”> >> <meta http-equiv="REFRESH" content="600"> >> </head> >> <body> >> </body></html> >> >> But what it’s still giving me is: >> >> <html><head> >> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> >> </head> >> <body> >> </body></html> >> >> Regards, James >> >>> On 14 Jan 2016, at 06:48, Christian Grün <christian.gruen at gmail.com> wrote: >>> >>> No reason to be sorry; I should simply have spent a few more seconds >>> on reading your mail and the latest version of the spec ;) The problem >>> is now fixed [1,2]. >>> >>> [1] https://github.com/BaseXdb/basex/commit/bf81e67322ca898aaeefc107e6bd669955f699ea >>> [2] http://files.basex.org/releases/latest/ >>> >> >
JB
James Ball31 Jan 2016 17:06 #
Quoted text · Christian Grün · 7 lines
> On 31 Jan 2016, at 15:50, Christian Grün <christian.gruen at gmail.com> wrote: > >> I get a java.lang.NullPointerException whenever include-content-type is set to yes and there is a text node in the HTML. > > Thanks; this one has been fixed. It takes me around 10 minutes to > upload the latest snapshot, so… Sorry for letting you wait ;) >
Big smiley face! I don’t know how I’ve managed to test on an older version for the other issue - I very carefully downloaded the new one (I thought) and tested in both the GUI and DBA. Computers! I will be more careful this time I promise. Regards, James
JB
James Ballin reply to Christian Grün, 31 Jan 2016, 16:5031 Jan 2016 20:58 #
Dear Christian, I have downloaded the latest snapshot (for sure this time) and both things are, as you said, fixed. Many thanks, James
Quoted text · Christian Grün · 83 lines
> On 31 Jan 2016, at 15:50, Christian Grün <christian.gruen at gmail.com> wrote: > >> I get a java.lang.NullPointerException whenever include-content-type is set to yes and there is a text node in the HTML. > > Thanks; this one has been fixed. It takes me around 10 minutes to > upload the latest snapshot, so… Sorry for letting you wait ;) > > >> >> So for example, this will return an error: >> >> let $html := >> <html> >> <head></head> >> <body> >> <p>yy</p> >> </body> >> </html> >> return file:write("test.html",$html,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) >> >> Improper use? Potential bug? Your feedback is welcome: >> Contact: basex-talk at mailman.uni-konstanz.de >> Version: BaseX 8.4 beta f5341cc >> Java: Oracle Corporation, 1.8.0_20 >> OS: Mac OS X, x86_64 >> Stack Trace: >> java.lang.NullPointerException >> >> But this will not: >> >> let $html := >> <html> >> <head></head> >> <body> >> <p></p> >> </body> >> </html> >> return file:write("test.html",$html,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) >> >> (no yy in the <p> element). >> >> Regards, James >> >>> On 31 Jan 2016, at 14:50, James Ball <basex-talk at jamesball.co.uk> wrote: >>> >>> Dear Christian, >>> >>> Sorry to take so long coming back to you but I’ve now had a chance to download the latest snap short (8.4 beta f5341cc) and try this. >>> >>> Unfortunately I’m still getting odd behaviour. >>> >>> file:write(“test.html",<html><head><meta http-equiv="REFRESH" content="60"/></head><body></body></html>,map {"method":"html","html-version":"5.0","include-content-type":"yes”}) >>> >>> I think this should give me: >>> >>> <html><head> >>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8”> >>> <meta http-equiv="REFRESH" content="600"> >>> </head> >>> <body> >>> </body></html> >>> >>> But what it’s still giving me is: >>> >>> <html><head> >>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> >>> </head> >>> <body> >>> </body></html> >>> >>> Regards, James >>> >>>> On 14 Jan 2016, at 06:48, Christian Grün <christian.gruen at gmail.com> wrote: >>>> >>>> No reason to be sorry; I should simply have spent a few more seconds >>>> on reading your mail and the latest version of the spec ;) The problem >>>> is now fixed [1,2]. >>>> >>>> [1] https://github.com/BaseXdb/basex/commit/bf81e67322ca898aaeefc107e6bd669955f699ea >>>> [2] http://files.basex.org/releases/latest/ >>>> >>> >>

⚡Generated with XQuery