Mark Gritter (markgritter) wrote,
Mark Gritter
markgritter

Document Models

Why, oh, why did the Google Wave folks feel that they needed to invent a brand-new document model? It's XML, sort of. Except from the robots API the document looks like a text string to which you can apply annotations and insert elements. Except that figuring out the correct offsets within that text string is all screwy.

I'm trying to write a simple robot which substitutes card images for card names inside a Wave. There are plenty of examples of people doing something like this, which should make it easy.

However, when I call Document.InsertElement to place an image inside some newly-created text, it works fine for the first image. But the second image is two characters too early, and the next is four characters too early. So I guess the answer is just to insert a 'fudge factor' of 2 characters, but I don't know why.

The best suggestion I've seen so far is to insert the images in reverse order. And there's a bug open which suggests I may run into more problems when I try actually editing text rather than copying it.

Nothing like playing around with somebody else's alpha-quality software to make my work problems seem downright tractable. ;)

Also, debugging Wave robots highlights a weakness of request/response RPC (particularly HTTP-based RPC): there is no way for the client/sender to tell the server that its response was garbage.
Tags: geek, programming, rant, software
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments