Binary types
It's impossible to include arbitrary binary files in XML documents because they might contain illegal characters such as a form feed or a null that would make the XML document malformed. Therefore, any such data must first be encoded in legal characters. The W3C XML Schema Language supports two such encodings, xsd:base64Binary and xsd:hexBinary.
Hexadecimal binary encodes each byte of the input as two hexadecimal digits — 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12, and so on. Thus, an entire file can be encoded using only the digits 0 through 9 and the letters A through F. (Lowercase letters are also allowed, but uppercase letters are customary.) On the other hand, each byte is replaced by two bytes so this encoding doubles the size of the data. It's not a very efficient encoding. Hexadecimal binary encoded data tends to look like this:
A4E345EC54CC8D52198000FFEA6C807F41F332127323432147A89979EEF3
Base64 encoding uses a more complex algorithm and a larger character set, 65 ASCII characters chosen for their ability to pass through almost all gateways, mail relays, and terminal servers intact, as well as their existence with the same code points in ASCII, EBCDIC, and most other common character sets. Base64 encodes every three bytes as four characters, typically only increasing file size by a third, so it's somewhat more efficient than xsd:hexBinary. Base64 encoded data tends to look something like this:
6jKpNnmkkWeArsn5Oeeg2njcz+nXdk0f9kZI892ddlR8Lg1aMhPeFTYuoq3I6n BjWzuktNZKiXYBfKsSTB8U09dTiJo2ir3HJuY7eW/p89osKMfixPQsp9vQMgzph6Qa lY7j4MB7y5ROJYsTr1/fFwmj/yhkHwpbpzed1LE=
XML Digital Signatures use Base64 encoding to encode the binary signatures before wrapping them in an XML element.
Caution
I really discourage you from using either of these if at all possible. If you have binary data, it's much more efficient and much less obtuse to link to it using XLink or unparsed entities rather than encoding it in Base64 or hexadecimal binary.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
I think what Jason was looking for is the third option of having the image data directly as part of the CDATA section in his XML document.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |