Embedding binary data in XML
Embedding binary data in XML
?? Raw binary data cannot be embedded in XML 1.0 safely
?? Legal characters are tab, carriage return, line feed, and the legal
characters of Unicode and ISO/IEC 10646
?? Certain binary sequences can make the document ill-formed
// You can't serialize raw binary data here
Encoding binary data
?? One solution is to encode binary data into legal characters
?? Then embed the encoded data into the XML 1.0 document
?? The most common encoding scheme is Base64 (RFC 2045)
sdcfo2JTiXE=...
Decoding Base64 data
?? The other side will need to decode the embedded Base64 data
?? Produces the original binary data again
sdcfo2JTiXE=...
Referencing by URI
?? An alternate approach is to reference binary data by URI
?? XSD provides the anyURI datatype to distinguish from strings
?? Address resolved and data downloaded separately (a la HTML)
?? Resolution problematic in network transitions (firewalls)
