[DFDL-WG] String literal syntax for hexBinary ?? - Re: String literals - various usage patterns thereof

Mike Beckerle mbeckerle.dfdl at gmail.com
Wed Apr 18 12:37:48 EDT 2012


What is the DFDL string literal syntax for a hexBinary type value?

E.g.,  I want a hex binary whose value is the 4 bytes described by this
hex: DE AD BE EF.

<element name="myHexBin" type="xs:hexBinary" dfdl:inputValueCalc="{ ... }"/>

So, what can one syntactically put, for literal constant values, in the
input value calculation expression?

Note that this is legal pure (non-DFDL) XSD (I think)

<element name="aHexBin" type="xs:hexBinary" fixed="DeadBeef"/>

That is, the fixed/default are allowed and one specifies these values as
just strings of hex digits. Notice no special escaping or anything. You
just use a string that just so happens to contain hex digits.

I think there are three possibilites
(a) we allow "DEADBEEF" i.e., because the type of the expression is
hexBinary, a string is cast to hexBinary by interpreting it as hex nibbles.
(b) we require a special kind of string literal - a bytes-only string
literal, so for example: "%#rDE;%#rAD;%#rBE;%#rEF;" is the way you create 4
bytes. If you just put characters, then that's a processing error - like a
cast failure. Only raw-bytes allowed.
(c) Anything you return from the expression is converted to a hexBinary by
unparsing it to bytes (using current properties), then using the bytes as
the hexBinary data. So you could have an expression that returns a double,
and that would create 8 bytes if representation="binary".  In this case the
decimal number 3735928559 (hex 0xdeadbeef) as a binary bigEndian int would
produce the 4 bytes I want.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20120418/d435ac60/attachment.html>


More information about the dfdl-wg mailing list