From russ at acceleration.net Mon May 2 20:50:19 2011 From: russ at acceleration.net (Russ Tyndall) Date: Mon, 02 May 2011 16:50:19 -0400 Subject: [cxml-devel] A bug fix and a refactoring for consideration Message-ID: <4DBF190B.6070601@acceleration.net> I made a small bugfix and a refactoring of dom:map-document that I was hoping could be pulled upstream. Without the change to cxml:attribute*, attributes created with this function will not be serialized without setting the :include-default-values to T while when calling map-document. The map-document->walk refactoring was important so that I could map sub documents. I use this in my templating library (TALCL) to map nodes created in a dom document into a buffer of sax events (that can be played out during serialization). These are available from my github account: git pull git://github.com/bobbysmith007/cxml.git patches-on-upstream https://github.com/bobbysmith007/cxml/commits/patches-on-upstream If you need anything further from me, please don't hesitate to ask. Cheers, Russ Tyndall commit 6fe408e85926329de511cc533c3c670b802df641 Author: Russ Tyndall Date: Mon May 2 16:07:32 2011 -0400 Refactored dom:map-document into methods of dom:walk * dom:map-document now calls dom:walk on the document * walk used to be a labels inside of map-document, now it is a generic function called by map-document commit 0af0575d47379505ee4b89d042d0c7929b6e727e Author: Russ Tyndall Date: Mon May 2 16:06:44 2011 -0400 make cxml:attribute* helper accept and correctly set specified-p (which defaults to T rather than the previous nil) * specified-p determines whether or not an attribute is considered being a default attribute vs one that has been explicitly set. Since this is a builder function, it seems that this should be T by default. From marcoxa at cs.nyu.edu Tue May 10 18:18:49 2011 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: Tue, 10 May 2011 19:18:49 +0100 Subject: [cxml-devel] Ho do I write the following on a sink? Message-ID: Hi I am trying to write "Λ" on a sink. (let ((sink (cxml:make-character-stream-sink *standard-output* :indentation 2 :canonical nil))) (sax:start-document sink) (xhtml-generator:write-doctype sink) (xhtml-generator:with-html sink (:html (:head (:title "Titel")) (:body ((:p "style" "font-weight: bold") "Inhalt") (:ul (:li "Eins") (:li "Zwei") (:li "Λ") (:li "Drei"))))) (sax:end-document sink)) Titel

Inhalt

  • Eins
  • Zwei
  • &Lambda;
  • Drei
# 219C7A3F> How do I get it "right"? Thank -- Marco Antoniotti -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at lichteblau.com Wed May 11 12:22:15 2011 From: david at lichteblau.com (David Lichteblau) Date: Wed, 11 May 2011 14:22:15 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: References: Message-ID: <20110511122215.GJ15928@radon> Hi, Quoting Marco Antoniotti (marcoxa at cs.nyu.edu): > I am trying to write "Λ" on a sink. I don't think either the serializer nor xhtml-generator have special features to support writing entity references. But you can write this: (sax:unescaped sink "Λ")) which will do what you are asking for (but means that you need to take care that the string is actually well-formed; cxml will not do any escaping or checking itself). So is there a reason for the lack of entity reference writing support? Mainly just that I've never needed it myself. Usually I would just write the actual character. Λ means the same thing as the character with the code 923 on any Lisp with Unicode support, and every XML parser can Unicode characters. In contrast, parsers need to have the DTD available to be able to read such an entity reference, and I think that the XML world in general is moving away from DTD use; it's usually more hassle than it's worth to ensure that an XML parser has the DTD available. d. From russ at acceleration.net Wed May 11 12:23:42 2011 From: russ at acceleration.net (Russ Tyndall) Date: Wed, 11 May 2011 08:23:42 -0400 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: References: Message-ID: <4DCA7FCE.7040806@acceleration.net> I think that you might need to generate the sax:unescaped event, rather than the sax:escaped event that is being generated there. How you do that with xhtml-generator:with-html, I am not sure, but perhaps you could get away with: (cxml:unescaped "λ") or failing that perhaps (progn (cxml:unescaped "λ") nil) Hope this helps, Russ Acceleration.net On 5/10/2011 2:18 PM, Marco Antoniotti wrote: > Hi > > I am trying to write "Λ" on a sink. > > (let ((sink (cxml:make-character-stream-sink *standard-output* > :indentation 2 :canonical nil))) > (sax:start-document sink) > (xhtml-generator:write-doctype sink) > (xhtml-generator:with-html sink > (:html > (:head > (:title "Titel")) > (:body > ((:p "style" "font-weight: bold") > "Inhalt") > (:ul > (:li "Eins") > (:li "Zwei") (:li "Λ") > (:li "Drei"))))) > (sax:end-document sink)) > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > > > Titel > > >

> Inhalt

>
    >
  • > Eins
  • >
  • > Zwei
  • >
  • > &Lambda;
  • >
  • > Drei
  • >
> > > # 219C7A3F> > > How do I get it "right"? > > Thank > > > -- > Marco Antoniotti > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rm at tuxteam.de Wed May 11 13:20:47 2011 From: rm at tuxteam.de (rm at tuxteam.de) Date: Wed, 11 May 2011 15:20:47 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: <20110511122215.GJ15928@radon> References: <20110511122215.GJ15928@radon> Message-ID: <20110511132047.GA31515@seid-online.de> On Wed, May 11, 2011 at 02:22:15PM +0200, David Lichteblau wrote: > So is there a reason for the lack of entity reference writing support? > Mainly just that I've never needed it myself. Usually I would just > write the actual character. Λ means the same thing as the > character with the code 923 on any Lisp with Unicode support, and every > XML parser can Unicode characters. The entity 'λ' could mean _anything_ depending on context: ]> Wlecome to the world of λ .... Bundle this with xinclude and you get a lot of reasons to support entity reference writing. Cheers, Ralf Mattes From marcoxa at cs.nyu.edu Mon May 16 07:39:48 2011 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: Mon, 16 May 2011 09:39:48 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: <20110511132047.GA31515@seid-online.de> References: <20110511122215.GJ15928@radon> <20110511132047.GA31515@seid-online.de> Message-ID: <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> Ok. So this boils down to "let's get CXML" handle entities. How do we do that? In general I have found most (X)HTML writing facilities lacking in this or that respect. Since I am using CXM to do the reading, it would be natural not to depend on YAL (Yet Another Library) to do the reading. I am willing to help extending it, instead of rolling out my XHTMΛ (pun intended :) ) html writing facility. One note. Having to write (cxml:unescaped sink "Λ") is a workaround, but it is not really a nice thing, since I have to manually break the string. Especially when we think of the standard SLDJ lover who tries out CXML :) So. Somewhere, a string in a XHTML processor is "compiled" to generate SAX events. That is where the entity processing should go. Where exactly is this bit? Cheers -- Marco On May 11, 2011, at 15:20 , rm at tuxteam.de wrote: > On Wed, May 11, 2011 at 02:22:15PM +0200, David Lichteblau wrote: >> So is there a reason for the lack of entity reference writing support? >> Mainly just that I've never needed it myself. Usually I would just >> write the actual character. Λ means the same thing as the >> character with the code 923 on any Lisp with Unicode support, and every >> XML parser can Unicode characters. > > The entity 'λ' could mean _anything_ depending on context: > > > > > ]> > > > Wlecome to the world of λ > > .... > > Bundle this with xinclude and you get a lot of reasons to support entity > reference writing. > > > Cheers, Ralf Mattes > > -- Marco Antoniotti -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcoxa at cs.nyu.edu Mon May 16 08:58:03 2011 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: Mon, 16 May 2011 10:58:03 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> References: <20110511122215.GJ15928@radon> <20110511132047.GA31515@seid-online.de> <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> Message-ID: On May 16, 2011, at 09:39 , Marco Antoniotti wrote: > ... Since I am using CXM to do the reading, it would be natural not to depend on YAL (Yet Another Library) to do the reading. I meant "writing" :} -- Marco Antoniotti From marcoxa at cs.nyu.edu Fri May 27 16:17:20 2011 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: Fri, 27 May 2011 18:17:20 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: References: <20110511122215.GJ15928@radon> <20110511132047.GA31515@seid-online.de> <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> Message-ID: <43B9A33A-08F2-4FC6-8073-CED6CEC7A021@cs.nyu.edu> Guys! Throw me a bone here!!!!! I don't want to roll out my own XHTML generator! So, the culprit is SAX:CHARACTERS CXML::SINK , which calls CXML::UNPARSE-INDENTED-TEXT, which calls CXML::SINK-WRITE-EXCAPABLE-ROD. This last function seems wrong as it hardcodes behavior. The problem is that nowhere in the chain there is an obvious place where to put entity handling. Or should CXML::SINK-WRITE-EXCAPABLE-ROD be rewritten? If that is the case, where should entities be found? In the sink, in a stash somewhere else? Or maybe TRT is to build a special XHTML sink? Any ideas? Cheers -- Marco On May 16, 2011, at 10:58 , Marco Antoniotti wrote: > > On May 16, 2011, at 09:39 , Marco Antoniotti wrote: > >> ... Since I am using CXM to do the reading, it would be natural not to depend on YAL (Yet Another Library) to do the reading. > > I meant "writing" :} > > > -- > Marco Antoniotti > > > > > -- Marco Antoniotti From david at lichteblau.com Fri May 27 16:43:24 2011 From: david at lichteblau.com (David Lichteblau) Date: Fri, 27 May 2011 18:43:24 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: <43B9A33A-08F2-4FC6-8073-CED6CEC7A021@cs.nyu.edu> References: <20110511122215.GJ15928@radon> <20110511132047.GA31515@seid-online.de> <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> <43B9A33A-08F2-4FC6-8073-CED6CEC7A021@cs.nyu.edu> Message-ID: <20110527164324.GC31054@radon> Quoting Marco Antoniotti (marcoxa at cs.nyu.edu): > Guys! Throw me a bone here!!!!! > > I don't want to roll out my own XHTML generator! > > So, the culprit is SAX:CHARACTERS CXML::SINK , which calls CXML::UNPARSE-INDENTED-TEXT, which calls CXML::SINK-WRITE-EXCAPABLE-ROD. This last function seems wrong as it hardcodes behavior. The problem is that nowhere in the chain there is an obvious place where to put entity handling. Or should CXML::SINK-WRITE-EXCAPABLE-ROD be rewritten? If that is the case, where should entities be found? In the sink, in a stash somewhere else? Or maybe TRT is to build a special XHTML sink? > > Any ideas? [...] > On May 16, 2011, at 10:58 , Marco Antoniotti wrote: > > > > > On May 16, 2011, at 09:39 , Marco Antoniotti wrote: > > > >> ... Since I am using CXM to do the reading, it would be natural not to depend on YAL (Yet Another Library) to do the reading. > > > > I meant "writing" :} cxml:unescaped is the "official" solution to implement this. Please use that. As for xhtmlgen, which you seem to be depending on: That's not an official cxml api. It is sample code based on htmlgen by Franz. I've never been a fan of htmlgen, but others like it, and I developed xhtmlgen for bknr, which needed it. It's basically still sample code. Copy&paste material. If you like it, just put it into your own project, and hack it as desired to add any features you want changed. Don't try to dig into any internals within cxml's package. Just look at xhtmlgen, if that is what you want to use. d. From marcoxa at cs.nyu.edu Mon May 30 17:45:36 2011 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: Mon, 30 May 2011 19:45:36 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: <20110527164324.GC31054@radon> References: <20110511122215.GJ15928@radon> <20110511132047.GA31515@seid-online.de> <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> <43B9A33A-08F2-4FC6-8073-CED6CEC7A021@cs.nyu.edu> <20110527164324.GC31054@radon> Message-ID: On May 27, 2011, at 18:43 , David Lichteblau wrote: > Quoting Marco Antoniotti (marcoxa at cs.nyu.edu): >> Guys! Throw me a bone here!!!!! >> >> I don't want to roll out my own XHTML generator! >> >> So, the culprit is SAX:CHARACTERS CXML::SINK , which calls CXML::UNPARSE-INDENTED-TEXT, which calls CXML::SINK-WRITE-EXCAPABLE-ROD. This last function seems wrong as it hardcodes behavior. The problem is that nowhere in the chain there is an obvious place where to put entity handling. Or should CXML::SINK-WRITE-EXCAPABLE-ROD be rewritten? If that is the case, where should entities be found? In the sink, in a stash somewhere else? Or maybe TRT is to build a special XHTML sink? >> >> Any ideas? > [...] >> On May 16, 2011, at 10:58 , Marco Antoniotti wrote: >> >>> >>> On May 16, 2011, at 09:39 , Marco Antoniotti wrote: >>> >>>> ... Since I am using CXM to do the reading, it would be natural not to depend on YAL (Yet Another Library) to do the reading. >>> >>> I meant "writing" :} > > cxml:unescaped is the "official" solution to implement this. > Please use that. That is not a solution. I do not want to write (:p "And now" (cxml:unescaped "Λ") "!") (which, besides, does not work). > As for xhtmlgen, which you seem to be depending on: That's not an > official cxml api. It is sample code based on htmlgen by Franz. I've > never been a fan of htmlgen, but others like it, and I developed > xhtmlgen for bknr, which needed it. > > It's basically still sample code. Copy&paste material. > > If you like it, just put it into your own project, and hack it as > desired to add any features you want changed. > > Don't try to dig into any internals within cxml's package. Just look at > xhtmlgen, if that is what you want to use. Well, I wouldn't want to do anything with the internals of *any* package :) The problem is that even looking ad XHTML-GENERATOR there are several problems in figuring out how to rewrite it using the SAX handlers. It appears to me that the only way of doing this properly is to subclass the sink class by introducing a XHTML-SINK as a hook for specialized SAX methods. Would this be the way to go? Cheers -- Marco Antoniotti -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at lichteblau.com Mon May 30 20:42:35 2011 From: david at lichteblau.com (David Lichteblau) Date: Mon, 30 May 2011 22:42:35 +0200 Subject: [cxml-devel] Ho do I write the following on a sink? In-Reply-To: References: <20110511122215.GJ15928@radon> <20110511132047.GA31515@seid-online.de> <9DC65697-3DF8-4DFB-90C3-8FB8D095CF33@cs.nyu.edu> <43B9A33A-08F2-4FC6-8073-CED6CEC7A021@cs.nyu.edu> <20110527164324.GC31054@radon> Message-ID: <20110530204235.GA10177@radon> Quoting Marco Antoniotti (marcoxa at cs.nyu.edu): > > On May 27, 2011, at 18:43 , David Lichteblau wrote: > > cxml:unescaped is the "official" solution to implement this. > > Please use that. > > That is not a solution. I do not want to write (:p "And now" (cxml:unescaped "Λ") "!") > (which, besides, does not work). OK; at this level it's called sax:unescaped, not cxml:unescaped. (In my defence, I got this right in the previous email in this thread, where I also gave the full argument list, indicating that it takes two arguments, the sink and the string.) I can only repeat that xhtml-generator is sample-code quality, and I don't really support it. But it's very easy to hack on and extend, and that's what you can do if you are willing to dive into it: (in-package :xhtml-generator) (def-special-html :entity (lambda (ent args argsp body) `(sax:unescaped *html-sink* (format nil "&~(~A~);" ',(car body))))) CL-USER> (let ((s (cxml:make-string-sink))) (sax:end-document (xhtml-generator:with-html s (:html (:body "foo" (:entity :foo) "bar")) s))) "foo&foo;bar"