(See the submitted bug report to Mozilla: Bug 398272 – Unable to round-trip tab character using XMLHttpRequest and XMLSerializer)
I just finished working on a Firefox extension, after battling with Firefox's XML support. Don't get me wrong - it's a rather good implementation, just with a few issues such as this one.
I was attempting to use an XML file as backup storage for some of Firefox's configuration options when making other changes from within the extension. Some of these values consist of tab-separated values. Unfortunately, the current XML support doesn't allow for a successful round-trip of these tab characters between a save using XMLSerializer and a read using XMLHttpRequest. Part of the reason seems to be that XMLHttpRequest normalizes the attributes on read, and the tabs are read-back as spaces. It seems that the best resolution would be for the XMLSerializer to somehow escape the tabs (and possibly other similar characters) with XML character entities, e.g. 	
for the tab character, which assures that the characters are read back as intended.
Fortunately, Firefox is open-source and is constantly improving, so hopefully this will be resolved in the near future.
My work-around at the moment is to store the data within CDATA
elements, rather than XML attributes, which properly maintains all whitespace - including the tab characters. Another option would have been splitting the value and storing the individual parts as separate attributes or elements. However, this would have resulted in keying to the specifics of the values, while I want to avoid such strong coupling and work with the values more generically. (This way, if the values later change to use spaces, commas, or some other separation, no change is required for my extension.)
No comments:
Post a Comment