I'm pretty sure that the rules are:
- DFDL expressions must not *contain*
DFDL String Literals. They must be valid XPath 2.0 expressions except that
the list of allowable function names includes the DFDL extension functions.
- A DFDL expression is sometimes allowed
to *return* a DFDL String Literal. In this case, the returned value is
an xs:string that conforms to the DFDL String Literal syntax. But that
does not apply to your example because the dfdl:inputValueCalc must return
a value ( an XML value ) that is valid for the type of the element.
I think that corresponds to your answer
a) ; 'DEADBEEF' is a valid xs:hexBinary lexical value.
regards,
Tim Kimber, Common Transformation Team,
Hursley, UK
Internet: kimbert@uk.ibm.com
Tel. 01962-816742
Internal tel. 246742
From:
Mike Beckerle <mbeckerle.dfdl@gmail.com>
To:
Steve Hanson/UK/IBM@IBMGB
Cc:
dfdl-wg@ogf.org
Date:
19/04/2012 07:42
Subject:
[DFDL-WG] String
literal syntax for hexBinary ?? - Re: String literals - various usage patterns
thereof
Sent by:
dfdl-wg-bounces@ogf.org
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.
--
dfdl-wg mailing list
dfdl-wg@ogf.org
https://www.ogf.org/mailman/listinfo/dfdl-wg
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU