5 ms·
It's a lot cheaper to insert your markup by position than to parse the XML on every read. Of course, caching would mitigate much of that, but still I admire the
by pradocchia 17y ago
It's a lot cheaper to insert your markup by position than to parse the XML on every read. Of course, caching would mitigate much of that, but still I admire the design.
- patio11 17y agoYou wouldn't even have to parse the XML -- just anoint one form the canonical internal representation and then have filters which turn the internal representation into other formats. For example, if you store all documents in a restricted version of HTML, then you can generate a text-only version by replacing all <em> and </em> with star, etc. This is much cheaper than actually parsing XML (no need to build up a data structure representation of the document, just assume it is mostly right already and apply textual transformations). Then, once you have the plaintext version, cache it. Journalism sites are going to have an absurd number of reads to writes. (One guy writes the article, one guy edits it, 50,000 people see it within a minute of it being posted.) Caching is cheap and easy. Caching is robust against the article changing, too -- you purge the cache (or potentially just let it expire) and bam your new article is mostly right, whereas tracking the offset of <em>s seems to intuitively have a lot of possible failure modes to me. (For example, the first time one of your reporters tries to add a bit of local color with Japanese text in an article, I'll bet dollars to donuts that every tag after the Japanese breaks and the surrounding content gets corrupted.)