3 ms·
That's a feature, not a bug. Control codes aren't text. Heck, HTML doesn't even support tabs -- whitespace is just generic whitespace, interpreted as a regular
by crazygringo 4y ago
That's a feature, not a bug.
Control codes aren't text. Heck, HTML doesn't even support tabs -- whitespace is just generic whitespace, interpreted as a regular space.
If you want to insert non-typographic elements that affect the layout/presentation, that's what <elements> are for.
While if you need to encode binary data that can represent ASCII text, then yes -- Base64 is an ideal solution. That guarantees it won't be garbled by other XML processors.
The W3 basically says all this here [1]. ("Use of control codes in HTML and XHTML is never appropriate, since these markup languages are for representing text, not data.")
[1] https://www.w3.org/International/questions/qa-controls https://www.w3.org/International/questions/qa-controls
- chrismorgan 4y ago> HTML doesn't even support tabs Sure it does. As does XML. You just have to choose deliberately to use it, via such means as <pre> or the CSS `white-space: pre`, or, in XML, the xml:space attribute. Incidentally, HTML and the web is a place where the superiority of tab-based indentation to space-based is particularly apparent, because you’re far more likely to encounter very narrow viewports, where reducing the width of tabs is useful, while still keeping a reasonable indentation level on wide enough screens. I do something similar to this, for example: :root { tab-size: 4; @media (max-width: 50rem) { tab-size: 2; } }
- vivegi 4y agoExactly. If you do want to encode control characters, the way to do that would be as character entities (which are simply text like &) and handle the translation of these entities at the application level. As an example, if we want a newline to be removed for presentation (or translated into a newline symbol like in Microsoft Word), the right place to do that would be at the rendering time and not in the data representation layer (which is where XML operates). You could also use tags, for example <br> tag in HTML. After all it is Extensible Markup Language and the functionality for adding custom tags is the basic feature. And as suggested above, base64 encoding and application level decoding is also an accepted practice. All these techniques point to handling the rendering at the application level.
- smarks 4y ago> base64 encoding and application level decoding is also an accepted practice I feel seen. I remember suggesting this during a design discussion where the issue was how to embed an arbitrary document in another, where the embedded document could even be ill-formed. Everybody told me it was a gross and dirty hack and ignored the suggestion.
- vivegi 4y agoIt is quite a common pragmatic architectural pattern in the HTML architecture. For example, data urls where a MIME type representation is encoded in the URL format is used for embedding images and other MIME types. So, if one is building an application and needs to render a proprietary data object, this is a good way (not the only one) to handle it using a client library.
- victor106 4y ago> Use of control codes in HTML and XHTML is never appropriate, since these markup languages are for representing text, not data Is XML meant to represent only text and not data?
- deleted 4y ago[deleted]