Adding fn:error means DFDL would have two mechanisms for issuing errors in asserts and discriminators - is that a problem?

Regards

Steve Hanson
Architect, IBM Data Format Description Language (DFDL)
Co-Chair,
OGF DFDL Working Group
IBM SWG, Hursley, UK

smh@uk.ibm.com
tel:+44-1962-815848




From:        Mike Beckerle <mbeckerle.dfdl@gmail.com>
To:        dfdl-wg@ogf.org,
Date:        20/06/2013 18:19
Subject:        [DFDL-WG] proposal: add fn:error function and dfdl:hex function to        DFDL
Sent by:        dfdl-wg-bounces@ogf.org





Proposed: add fn:error function and add dfdl:hex function.

DFDL only needs one of the several variations of fn:error

fn:error($error as xs:QName?, $description as xs:string) as none

dfdl:hex($num as xs:integer) as string


The dfdl:hex function inverts the behavior of the dfdl:byte, and related functions (currently also proposed) which take a string specification of a hex value. The argument to dfdl:hex can be a long, unsignedLong, or any subtype thereof. The number of hex digits in the resulting string is a function of the input type. If byte or unsigned byte, exactly 2 hex digits are produced, for short and unsignedShort, 4 hex digits, and so on. The resulting value contains a prefix 'x' character as its first character. So:

dfdl:short(dfdl:hex(xs:short(208))) eq xs:short(208)


is true, and a corresponding tautology holds for all the other DFDL functions that construct integers from hexadecimal, if you replace the 208 above with a value in range for the corresponding numeric type.

Example:

This allows a meaningful error message that includes the offending parts of data.

fn:error(ex:magic_number, fn:concat("The magic number: 0", dfdl:hex(.), " was not 0xA1B2C3D4 (for bigEndian) or 0xD4C3B2A1 (for littleEndian).")
)

The $error argument (of type QName) is used in an implementation-dependent manner to provide the context of the error. So for example, if namespace prefix 'ex' is bound to '
http://example.com' then the above call might produce:

"Error: {
http://example.com}magic_number - The magic number: 0xFEFF0000 was not 0xA1B2C3D4 (for bigEndian) or 0xD4C3B2A1 (for littleEndian)."

Only the part of the above string after the hyphen is standardized. The hyphen and part before the hyphen is implementation dependent.
--
 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