[racket-users] xml vs sxml?
On Sat, Jun 27, 2020 at 12:33:02AM -0400, Neil Van Dyke wrote: > I think anyone using XML or HTML seriously with Racket should probably at > least be told of the SXML family of tools. And warned about the > compatibility problems. > > Though not tell them *everywhere* XML&HTML in the docs. For example, I > figure a tutorial for Racket Web Server shouldn't distract readers with > that. > > As you know, :) there are some useful tools using SXML, and Oleg's SSAX > parser has some different properties than core Racket's XML parser. > > Complication: The incompatibility between SXML and core Racket's > representations of XML&HTML is an unfortunate accident of parallel > invention, and I think will tend to be confusing to new people. I once > tried to address the confusion in the `sxml-intro` documentation package, > "https://www.neilvandyke.org/racket/sxml-intro/";, and I'm unhappy with the > result. The details in my document say more than perhaps anyone will ever > want to know, and, "optics"-wise, make the situation look worse than it > actually is in practice. I think you could do a more graceful job of this. On the contrary; this is the kind of information I need when choosing between the various representations. But in section 4. Appendix there is one bit of pervasive confusion: you present several differences, but do not make it clear which way the difference goes. When you say, for example, "The SXML keyword symbols may be lowercase", do you mean that SXML itseld allows this to be done to its keywords, or that it does not but that xexpr allows its SXML keywords to be lower case? > > (Someday, someone might undertake the large task of SXML-ifying all the many > non-SXML bits of Racket, and incidentally reunite Racket with the rest of > the Scheme community in that regard. I started, with one piece, but got > interrupted. "https://www.neilvandyke.org/racket/rws-html-template/" :) >From this, and from the general drift of your sxml-intro, I surmise that the intent is for Racket to become fully SXML compliant, and new software should be written for SXML, not xexpr, if at all possible. Is this correct, and is this Racket policy? If so, it should be stated explicitly in the sxml-intro. A statement like this (if not gainsaid by the opposite camp (if any)) would eliminate much of the confusion experienced by new users. It should of course also be said in the xexpr documentation. Finally, I seem to remember that one of the tools mentioned somewhere for handling xml turned out not to be findable. I don't know any more if it was mentioned in your document or elsewhere, but it might be worth checking that the ones you mention are still available. -- hendrik -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/20200627123304.p437hr3nykhfjs45%40topoi.pooq.com.
Re: [racket-users] xml vs sxml?
Hendrik Boom wrote on 6/27/20 8:33 AM: But in section 4. Appendix there is one bit of pervasive confusion: you present several differences, but do not make it clear which way the difference goes. When you say, for example, "The SXML keyword symbols may be lowercase", do you mean that SXML itseld allows this to be done to its keywords, or that it does not but that xexpr allows its SXML keywords to be lower case? Thank you. I didn't phrase that well. In section "Appendix: SXML/xexp", that bulleted list is describing "SXML/xexp", relative to canonical SXML. That first bulletpoint is something on which I think SXML was ambiguous. (Some Scheme readers or symbol tables forced or disregarded case, but others thankfully didn't. Although, IIRC, Oleg's code was consistent in how it used case, the ambiguity of the case of the symbols in SXML presented portability problems when other people wrote code, especially if they interpreted it differently, and exercised their preferences, then you tried to combine their code. Many Scheme programmers emphasized personal preference, and we can imagine that a small language with powerful linguistic extension, and a convention of writing one's own interpreter, might attract rugged individualists.) "SXML/xexp" tried to mitigate that in a portable way, by saying both all-uppercase and all-lowercase were supported, and that no other mixing of case was permitted. From this, and from the general drift of your sxml-intro, I surmise that the intent is for Racket to become fully SXML compliant, and new software should be written for SXML, not xexpr, if at all possible. There's no policy that I know of. I think switching would be better overall, but switching is a lot of work. And, in a sense, there's less focus in practice on XML and HTML than there used to be, so less reason than before to invest in switching. I suspect any switch won't happen wholesale, but telling people about the separate `sxml` package might result in some future projects choosing to use SXML. I don't know how much activity future projects will be. When I first started with Scheme, I was actually lucky in my timing, in avoiding fragmenting the XML/HTML representations even worse. The first Scheme code I wrote was an HTML parser, and, initially, I made my own obvious s-expression encoding of HTML, which turned out to be very similar to Racket's `xexpr`. But I quickly saw Oleg's XML work, and so reworked my code to emit SXML, so that the fancy XML tools could also be used with real-world HTML. The switch to SXML was trivial for me then, but the switch would've been hard for Racket (aka PLT Scheme), by the time SXML became a de facto standard for the Scheme community. Finally, I seem to remember that one of the tools mentioned somewhere for handling xml turned out not to be findable. I don't know any more if it was mentioned in your document or elsewhere, but it might be worth checking that the ones you mention are still available. Are you thinking of Jim Bender's `sxml-match`? I need to fix that dead link (can't release a new version at the moment), probably to point to the PLaneT package that the text mentions. http://planet.racket-lang.org/display.ss?package=sxml-match.plt&owner=jim -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/9fa1be59-64af-c3dd-9f3f-d49cf693a0d8%40neilvandyke.org.
[racket-users] Re: note about parsing speed of xml vs sxml?
Looking at the source for `read-xml`, it seems to be using `list->string` in several places. That is, it reads characters one-by-one and constructs a list by appending a character to the end of it, than calls `list->string` to produce the string. I suspect read-xml could be made faster by using `string-append` in these cases. https://github.com/racket/racket/blob/master/racket/collects/xml/private/reader.rkt Alex. On Saturday, June 27, 2020 at 11:05:42 AM UTC+8 'John Clements' via users-redirect wrote: > I’m parsing a large-ish apple plist file, (18 megabytes), and I find that > the built-in xml parsing (read-xml) takes about five times as long as the > sxml version (11 seconds vs 2.4 seconds on my machine), and that the plist > parser is way longer, at 18 seconds. > > Would anyone object if I added a margin note to this effect to the xml > docs? > > John > > > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/f079d5ff-27c0-43be-b0dd-f999e8ee561cn%40googlegroups.com.
[racket-users] Re: Pasting an Image from windows clipboard and annotating it
You can get the bitmap from the clipboard using "(send the-clipboard get-clipboard-bitmap)" and you can use the bitmap dimensions (see get-with and get-height methods of the bitmap% object) to make the canvas the same size as the bitmap by constructing it with stretchable-width and stretchable-height set to #f and setting the min-width and min-height to the bitmap dimensions. To draw the bitmap onto the canvas, you can use the draw-bitmap method in the paint callback. For the mouse clicks, you will need to override the `on-subwindow-event` on the canvas to look at the mouse events and record where the user clicked. You can draw the letters at the click positions in the paint-callback of the canvas using the draw-text method. Hope this helps, Alex. On Saturday, June 27, 2020 at 10:44:44 AM UTC+8 frangonve wrote: > Hello, A newbie here: > > I want to insert an image from windows clipboard to a rectangular widget > that will take the image size. Then when repeatedly clicking the mouse on > different coordinates of the image I want to superimpose each time the next > letter in alphabetic order with transparent background: > > This is the type of images to insert: > > [image: Clever Mines 20200318.png] > > This is what I want to show after clicking several times on the image > high-left corner: > > [image: Clever Mines 20200318 id.png] > > Please can you help me? > > Cheers > > Francisco > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/b5ad5b07-ae85-40e6-b072-8c71e5a68dd2n%40googlegroups.com.