[openbeostranslationkit] Re: Structured Text Translation

I left off a B_UTF8_ESCAPE marker.  Maybe some other
character instead of '!' would be better.  Like '.'.
Then it looks really sweet in DiskProbe. (because all the escape markers look 
like '.' as well)

---------------------------- <internal format>
_<_$tag_=html_>
_<_$tag_=head_<_$tag_=title_.OpenBeOS Translator Kit_>_>
_<_$tag_=body_$onLoad_=doJavaScript();_<
_<_$tag_=h1_.It Rules._>
_>
_>
----------------------------

Anyway, just wanted to add a few things.  I'd be willing  to write code to 
generate starting HTML, XML translators, and possibly RTF if I can find a spec.

Also it'd probably be "nice" to provide some functions to turn the internal 
representation into a navigable internal representation.  Such functions 
wouldn't be necessary to write a translator.  For example, the above can be 
done in a mostly serial fashion.  However, it may be useful for some other 
translators, or for code that wants to load a file using a translator and then 
manipulate it.  I've included some toy code below.  (People who know DOM will 
recognize these..)

Andrew

====================================================

StructuredTextNode * getStructuredTextNode(char * text) {
  StructuredTextNode * node = new StructuredTextNode();
  node->parse(text);
  return node;
}

class TextNode {
  virtual char * getText() = 0;
}

class StructuredTextNode : TextNode {
  char * getText(); // returns above internal representation for this subtree
  void parse(char * text); // parses the text, adding appropriate properties 
and subnodes to this node
  TextPropertyList * properties;
  TextNodeList * children;
}

Class PlainTextNode : TextNode {
  char * getText(); // returns an ordinary string
}

class TextProperty {
  char * name;
  char * value;
}



Other related posts: