3 ms·
A strategy I've seen for dealing the inability of XML to handle overlapping tags, is to treat the tagging as an annotation layer on top of the node with the dat
by meepmorp 3y ago
A strategy I've seen for dealing the inability of XML to handle overlapping tags, is to treat the tagging as an annotation layer on top of the node with the data:
<doc>
<data type="text">
This is some sample text.
</data>
<annotations>
<tag1 start="1" end="3" comment="foo"/>
<tag2 start="2" end="4" type="bar" />
</annotations>
</doc>
The start and end are usually byte offsets from the start of the text content in the data node. It still sucks, but at least you could apply the same general stragegy to more than just text data - I've seen it used with audio/video where the offsets are treated as time offsets into the media.
- JodieBenitez 3y agoGood idea. You would have to edit your annotation layer in case the text data changes though.
- euroderf 3y agoIt seems klutzy and yet fully in the spirit of XML.
- yencabulator 3y agoNow you've lost human editability/readability and could just as well encode that in a non-XML format.
- meepmorp 3y agoYep. In my experience, the traditional solution for editing with these kinds of hacks is to write a buggy piece of shit custom GUI so people can edit documents. That way, the complaints shift away from your lousy data format to your lousy UI. Problem solved!