DFDL Expressions and hex literal constants

I haven't found a way in XPath to specify a hexadecimal integer number. E.g., I want to write expressions like { if (../magicNum eq 0xa1b2c3d4) then 'bigEndian' else if (.../magicNum eq 0xd4c3b2a1) then 'littleEndian' else error() } But it rejects the 0x notation. Do I really have to write decimal everywhere? When dealing with binary data this is a bit of a nightmare. I think the above code is clear to anyone, but if I convert those numbers to decimal it becomes completely obscure. ...mike -- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com

Mike I think there might be a wider problem in specifying any hex in XPath expressions. Tim's been looking into this as part of an IBM DFDL defect. 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: 13/06/2013 00:24 Subject: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org I haven't found a way in XPath to specify a hexadecimal integer number. E.g., I want to write expressions like { if (../magicNum eq 0xa1b2c3d4) then 'bigEndian' else if (.../magicNum eq 0xd4c3b2a1) then 'littleEndian' else error() } But it rejects the 0x notation. Do I really have to write decimal everywhere? When dealing with binary data this is a bit of a nightmare. I think the above code is clear to anyone, but if I convert those numbers to decimal it becomes completely obscure. ...mike -- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com -- 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

XPath uses XML schema lexical formats for all simple types. The XML Schema lexical format for an integer does not allow a hexadecimal option. The standard solution is to create a pair of custom XPath functions that convert between hex and decimal lexical formats. But that's not a viable solution for a DFDL modeller because they cannot define custom XPath functions. regards, Tim Kimber, DFDL Team, Hursley, UK Internet: kimbert@uk.ibm.com Tel. 01962-816742 Internal tel. 37246742 From: Steve Hanson/UK/IBM@IBMGB To: Mike Beckerle <mbeckerle.dfdl@gmail.com>, Cc: dfdl-wg@ogf.org, dfdl-wg-bounces@ogf.org Date: 13/06/2013 10:39 Subject: Re: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org Mike I think there might be a wider problem in specifying any hex in XPath expressions. Tim's been looking into this as part of an IBM DFDL defect. 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: 13/06/2013 00:24 Subject: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org I haven't found a way in XPath to specify a hexadecimal integer number. E.g., I want to write expressions like { if (../magicNum eq 0xa1b2c3d4) then 'bigEndian' else if (.../magicNum eq 0xd4c3b2a1) then 'littleEndian' else error() } But it rejects the 0x notation. Do I really have to write decimal everywhere? When dealing with binary data this is a bit of a nightmare. I think the above code is clear to anyone, but if I convert those numbers to decimal it becomes completely obscure. ...mike -- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com -- 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 -- 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

So I think DFDL needs to add such functions to its list of functions in 23.5.3. 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: Tim Kimber/UK/IBM@IBMGB To: dfdl-wg@ogf.org, Date: 13/06/2013 11:27 Subject: Re: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org XPath uses XML schema lexical formats for all simple types. The XML Schema lexical format for an integer does not allow a hexadecimal option. The standard solution is to create a pair of custom XPath functions that convert between hex and decimal lexical formats. But that's not a viable solution for a DFDL modeller because they cannot define custom XPath functions. regards, Tim Kimber, DFDL Team, Hursley, UK Internet: kimbert@uk.ibm.com Tel. 01962-816742 Internal tel. 37246742 From: Steve Hanson/UK/IBM@IBMGB To: Mike Beckerle <mbeckerle.dfdl@gmail.com>, Cc: dfdl-wg@ogf.org, dfdl-wg-bounces@ogf.org Date: 13/06/2013 10:39 Subject: Re: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org Mike I think there might be a wider problem in specifying any hex in XPath expressions. Tim's been looking into this as part of an IBM DFDL defect. 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: 13/06/2013 00:24 Subject: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org I haven't found a way in XPath to specify a hexadecimal integer number. E.g., I want to write expressions like { if (../magicNum eq 0xa1b2c3d4) then 'bigEndian' else if (.../magicNum eq 0xd4c3b2a1) then 'littleEndian' else error() } But it rejects the 0x notation. Do I really have to write decimal everywhere? When dealing with binary data this is a bit of a nightmare. I think the above code is clear to anyone, but if I convert those numbers to decimal it becomes completely obscure. ...mike -- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com -- 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 -- 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 -- 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

Isn't this where you use the xs:hexBinary constructor? I have examples in my IBM4690 TLOG ACE schema where I need to check that the content of a hexBinary field is a certain value and it works as desired with IBM DFDL. <xs:element dfdl:length="1" dfdl:lengthKind="explicit" fixed="13" name="SubStringType" type="type_PS"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator>{. eq xs:hexBinary('13')}</dfdl:discriminator> </xs:appinfo> </xs:annotation> </xs:element> <xs:element dfdl:length="1" dfdl:lengthKind="explicit" fixed="BB" name="SubStringType" type="type_PS"> <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator>{. eq xs:hexBinary('BB')}</dfdl:discriminator> </xs:appinfo> </xs:annotation> </xs:element> Then Mike's example would look like: { if (xs:hexBinary(../magicNum) eq xs:hexBinary('a1b2c3d4') then 'bigEndian' else if (xs:hexBinary(../magicNum) eq xs:hexBinary('d4c3b2a1') then 'littleEndian' else error() } 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: Tim Kimber/UK/IBM@IBMGB To: dfdl-wg@ogf.org, Date: 13/06/2013 11:27 Subject: Re: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org XPath uses XML schema lexical formats for all simple types. The XML Schema lexical format for an integer does not allow a hexadecimal option. The standard solution is to create a pair of custom XPath functions that convert between hex and decimal lexical formats. But that's not a viable solution for a DFDL modeller because they cannot define custom XPath functions. regards, Tim Kimber, DFDL Team, Hursley, UK Internet: kimbert@uk.ibm.com Tel. 01962-816742 Internal tel. 37246742 From: Steve Hanson/UK/IBM@IBMGB To: Mike Beckerle <mbeckerle.dfdl@gmail.com>, Cc: dfdl-wg@ogf.org, dfdl-wg-bounces@ogf.org Date: 13/06/2013 10:39 Subject: Re: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org Mike I think there might be a wider problem in specifying any hex in XPath expressions. Tim's been looking into this as part of an IBM DFDL defect. 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: 13/06/2013 00:24 Subject: [DFDL-WG] DFDL Expressions and hex literal constants Sent by: dfdl-wg-bounces@ogf.org I haven't found a way in XPath to specify a hexadecimal integer number. E.g., I want to write expressions like { if (../magicNum eq 0xa1b2c3d4) then 'bigEndian' else if (.../magicNum eq 0xd4c3b2a1) then 'littleEndian' else error() } But it rejects the 0x notation. Do I really have to write decimal everywhere? When dealing with binary data this is a bit of a nightmare. I think the above code is clear to anyone, but if I convert those numbers to decimal it becomes completely obscure. ...mike -- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com -- 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 -- 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 -- 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
participants (3)
-
Mike Beckerle
-
Steve Hanson
-
Tim Kimber