[xsd-users] Problemswith hexBinary type in xsd-2.3.1

Roger Goff rgoff at praxiseng.com
Thu Oct 4 13:26:10 EDT 2007


I am  having a problem getting hex_binary types to serialize properly.
I have a set of binary data represented as an unsigned char array.
I create/use a hex_binary type as follows. I have an object from 
generated code myXMLObj that has a hexBinary field called hexField

    unsigned char dataBuf[2] = {0x30, ox82};
    hex_binary hBin((void*)dataBuf, 2,2,false);

    myXMLObj->hexField(hBin); 
    
    if(myXMLObj->hexField().present())
    {
       char * myPtr = myXMLObj->hexField().get().data(); // this return 2 chars, 0x30, 0x82
       
       string myString = myXMLObj->hexField().get().encode(); 
          //      I would expect the string "3082" but instead
          //      returns a corrupt string "30<unprintable>"
    }

Also, when I try to serialize the object using myXMLObj(std::cout ...) I 
get an invalid UTF-8 exception.

I found some info in the archives from Jan 06
***
    > How can I let the library to encode/decode the base64Binary elements? Or
    > should I use my own base64 encoder/decoder?

    At the moment we map base64Binary and hexBinary to strings. We neither
    decode nor encode the date stored in such strings. We didn't implement
    better support for binary data because there wasn't any interest in
    such a feature. I guess now there is ;-).

    If you would like I can implement proper binary support with encoding/
    decoding and send it to you. This shouldn't take longer than a day.

    hth,
***

I this the same issue, and if so, is there a fix available?
The hex_binary types seems to work fine if I am encoding an ascii string, 
but I need to be able to process data from 0x00 to 0xFF, and I seem to be 
limited to the 0x00 to 0x7F range.

any help is appreciated.
thanks
Roger



More information about the xsd-users mailing list