Re: Unable to round-trip tab character using XMLHttpRequest and XMLSerializer
"Mark A. Ziesemer" <[email protected]> Sun, 30 Sep 2007 14:17:44 -0500
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Message-ID | <[email protected]> |
Boris Zbarsky wrote: > Is there a testcase somewhere that shows your problem? You should be > able to use XMLHttpRequest in a web page just as well as in an extension > to construct such a testcase... I'll work on creating a simple test case and including it here. However, I'm pretty sure that this is a problem with the functionality of the XMLSerializer, not the XMLHttpRequest. >> This should be expected, but the question remains: How can a character >> entity be written using XMLSerializer? > > It can't. The point of XMLSerializer is to expose a very simple easy to > use serialization model. Trusted callers who need something more > complicated can use nsIDocumentEncoder with all its complexity directly > (though I'm not sure even that will let you entity-encode tabs, > necessarily). I'm fine with "very simple" and "easy to use", but then it should work by default - even for the not-so-common but within-spec cases. Without any options to set, it seems impossible to call it a configuration/usage issue. The fact that it uses some character entities (e.g. "&") but not others seems to be a little bit of an issue. (Are there any comments with how the Xalan-J implementation handles this?) (While I'm looking for supporting a tab character, it seems that this could also affect a number of other non-"word" characters. In this particular case, I'm trying to backup lines out of the hostperm.1 file, which is clearly specified to contain tab-separated fields. Replacing with spaces on both the read/write ends seems to be a bad idea, in case a space would become valid within one of the fields.) I'm open to using an alternate serialization method, as long as it is guaranteed to be available for use within a Firefox 2.x extension. Per the note at http://developer.mozilla.org/en/docs/XMLSerializer, "it's not part of any standard and level of support in other browsers is unknown". Unfortunately, your suggestion to use nsIDocumentEncoder seems much easier said than done. Searching for "nsIDocumentEncoder" or even "DocumentEncoder" on the MDC Wiki currently yields 0 results. A global Google search seems almost as disappointing. A simple example of serializing a XML Document using it from within JavaScript would be most ideal. The only other alternative I can think of at the moment is to place these types of values inside of CDATA elements rather than attributes, which will end up making my XML structure much longer and more complex.