From andrew.j.welch at gmail.com Tue Jul 5 12:02:54 2011 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Tue, 5 Jul 2011 20:02:54 +0100 Subject: [xquery-talk] fn to convert rss2.0 date/time string to xs:dateTime In-Reply-To: References: Message-ID: On 5 July 2011 19:45, Gary Lewis wrote: > RSS2.0 feeds return pubDate in the following form: > > Tue, 28 Jun 2011 17:26:20 zzz > > where zzz can be expressed as a timezone (eg, PDT) or a local differential > from UTC (eg, +0000). > > To my knowledge there is no to_date() function in XQuery that would convert > a formatted xs:string into an xs:dateTime based on some pattern match (eg, > to_date("Tue, 28 Jun 2011 17:26:20 +0000", "Dy, dd Mon yyyy hh24:mm:ss > +HHMM") would produce: > > 2011-06-28T17:26:20+00:00 Which xquery processor are you using? If it's eXist there is: http://demo.exist-db.org/exist/functions/datetime/parse-date -- Andrew Welch http://andrewjwelch.com From gfourny at inf.ethz.ch Wed Jul 20 08:58:07 2011 From: gfourny at inf.ethz.ch (Ghislain Fourny) Date: Wed, 20 Jul 2011 15:58:07 +0000 Subject: [xquery-talk] Getting a bare & and > into HTML for Javascript In-Reply-To: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> References: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> Message-ID: <4274A63E-406C-4949-A321-B2599A4A0AC0@inf.ethz.ch> Hi David, I am assuming you are using HTML, not XHTML, since if I am correct, XHTML would recognize the & entity reference. In HTML, entity references in the script tag are not parsed. In XHTML they are. I guess a possibility could be to use a CDATA section that is ignored by JavaScript, like so (in your XQuery code): and to tell the XQuery engine to serialize the contents of the element using a CDATA section, using the cdata-section-elements XML output method: http://www.w3.org/TR/xslt-xquery-serialization/#XML_CDATA-SECTION-ELEMENTS That way, JavaScript would see the intended code - you need to make sure that ]]> does not appear in your JavaScript code though, otherwise there will be extra CDATA tags that the browser will not understand. Does this help? Kind regards, Ghislain From dlee at calldei.com Wed Jul 20 09:01:46 2011 From: dlee at calldei.com (David Lee) Date: Wed, 20 Jul 2011 12:01:46 -0400 Subject: [xquery-talk] Getting a bare & and > into HTML for Javascript In-Reply-To: <4274A63E-406C-4949-A321-B2599A4A0AC0@inf.ethz.ch> References: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> <4274A63E-406C-4949-A321-B2599A4A0AC0@inf.ethz.ch> Message-ID: <00d901cc46f6$54778580$fd669080$@calldei.com> Thanks, I will try this. I am using html tag but in the xhtml namespace ... But in the script tag its obviously not expanding the & I will try the CDATA trick. ---------------------------------------- David A. Lee dlee at calldei.com http://www.xmlsh.org -----Original Message----- From: Ghislain Fourny [mailto:gfourny at inf.ethz.ch] Sent: Wednesday, July 20, 2011 11:58 AM To: David Lee Cc: Subject: Re: [xquery-talk] Getting a bare & and > into HTML for Javascript Hi David, I am assuming you are using HTML, not XHTML, since if I am correct, XHTML would recognize the & entity reference. In HTML, entity references in the script tag are not parsed. In XHTML they are. I guess a possibility could be to use a CDATA section that is ignored by JavaScript, like so (in your XQuery code): and to tell the XQuery engine to serialize the contents of the element using a CDATA section, using the cdata-section-elements XML output method: http://www.w3.org/TR/xslt-xquery-serialization/#XML_CDATA-SECTION-ELEMENTS That way, JavaScript would see the intended code - you need to make sure that ]]> does not appear in your JavaScript code though, otherwise there will be extra CDATA tags that the browser will not understand. Does this help? Kind regards, Ghislain From gfourny at inf.ethz.ch Wed Jul 20 09:02:13 2011 From: gfourny at inf.ethz.ch (Ghislain Fourny) Date: Wed, 20 Jul 2011 16:02:13 +0000 Subject: [xquery-talk] Getting a bare & and > into HTML for Javascript In-Reply-To: <4E26FB21.20909@saxonica.com> References: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> <4E26FB21.20909@saxonica.com> Message-ID: Hi, This should be much more straightforward than what I suggested :-) Kind regards, Ghislain On Jul 20, 2011, at 5:58 PM, Michael Kay wrote: > > If your XQuery implementation supports the HTML serialization method then it should get this right. (It should recognize the script element and treat it specially). But you may have to explicitly select HTML serialization. > > Michael Kay > Saxonica From gfourny at inf.ethz.ch Wed Jul 20 09:19:20 2011 From: gfourny at inf.ethz.ch (Ghislain Fourny) Date: Wed, 20 Jul 2011 16:19:20 +0000 Subject: [xquery-talk] Getting a bare & and > into HTML for Javascript In-Reply-To: <00d901cc46f6$54778580$fd669080$@calldei.com> References: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> <4274A63E-406C-4949-A321-B2599A4A0AC0@inf.ethz.ch> <00d901cc46f6$54778580$fd669080$@calldei.com> Message-ID: <2CB19B9B-3E2A-4FE3-899C-A139BF91CD10@inf.ethz.ch> Hi David, In the current state of HTML5 as I understand it, there are two syntaxes: HTML and XHTML. Using the xmlns="http://www.w3.org/1999/xhtml" attribute in the HTML syntax is allowed but has no effect (more here: http://www.w3.org/TR/html5/elements.html#global-attributes). An HTML parser will not expand & in script tags. As Michael suggests, using the HTML output method is the cleanest way to provide an HTML parser with the right syntax. That way, the XQuery engine will not escape & to & in script tags (quoting from the serialization specification: "The HTML output method MUST NOT perform escaping for the content of the script and style elements."). I hope this helps. Kind regards, Ghislain On Jul 20, 2011, at 6:01 PM, David Lee wrote: > Thanks, I will try this. > I am using html tag but in the xhtml namespace ... > > > > > But in the script tag its obviously not expanding the & > > I will try the CDATA trick. > > > ---------------------------------------- > David A. Lee > dlee at calldei.com > http://www.xmlsh.org > > -----Original Message----- > From: Ghislain Fourny [mailto:gfourny at inf.ethz.ch] > Sent: Wednesday, July 20, 2011 11:58 AM > To: David Lee > Cc: > Subject: Re: [xquery-talk] Getting a bare & and > into HTML for Javascript > > > Hi David, > > I am assuming you are using HTML, not XHTML, since if I am correct, XHTML > would recognize the & entity reference. In HTML, entity references in > the script tag are not parsed. In XHTML they are. > > I guess a possibility could be to use a CDATA section that is ignored by > JavaScript, like so (in your XQuery code): > > > > and to tell the XQuery engine to serialize the contents of the element > using a CDATA section, using the cdata-section-elements XML > output method: > > http://www.w3.org/TR/xslt-xquery-serialization/#XML_CDATA-SECTION-ELEMENTS > > That way, JavaScript would see the intended code - you need to make sure > that ]]> does not appear in your JavaScript code though, otherwise there > will be extra CDATA tags that the browser will not understand. > > Does this help? > > Kind regards, > Ghislain > > From andrew.j.welch at gmail.com Wed Jul 20 09:19:23 2011 From: andrew.j.welch at gmail.com (Andrew Welch) Date: Wed, 20 Jul 2011 17:19:23 +0100 Subject: [xquery-talk] Getting a bare & and > into HTML for Javascript In-Reply-To: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> References: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> Message-ID: On 20 July 2011 16:42, David Lee wrote: > I'm writing out some small javascript using XQuery, within a > > and to tell the XQuery engine to serialize the contents of the element > using a CDATA section, using the cdata-section-elements XML > output method: > > http://www.w3.org/TR/xslt-xquery-serialization/#XML_CDATA-SECTION-ELEMENTS > > That way, JavaScript would see the intended code - you need to make sure > that ]]> does not appear in your JavaScript code though, otherwise there > will be extra CDATA tags that the browser will not understand. > > Does this help? > > Kind regards, > Ghislain > > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > From dlee at calldei.com Wed Jul 20 09:24:33 2011 From: dlee at calldei.com (David Lee) Date: Wed, 20 Jul 2011 12:24:33 -0400 Subject: [xquery-talk] Getting a bare & and > into HTML for Javascript In-Reply-To: References: <00bd01cc46f3$9c199020$d44cb060$@calldei.com> Message-ID: <00e401cc46f9$83289e20$8979da60$@calldei.com> I was afraid of that :) But yes its the obvious answer and I may well do that. This is an experimental prototype so I'm stumbling on new ground ... ---------------------------------------- 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 Andrew Welch Sent: Wednesday, July 20, 2011 12:19 PM To: David Lee Cc: talk at x-query.com Subject: Re: [xquery-talk] Getting a bare & and > into HTML for Javascript On 20 July 2011 16:42, David Lee wrote: > I'm writing out some small javascript using XQuery, within a