You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by ji...@gmail.com, ji...@gmail.com on 2018/07/10 16:34:06 UTC

choiceBranchKey - which functions are valid

I am writing a schema for a binary file and wanting to use a byte to direct dispatch a choice. Since choicedispatchkey uses a string, I thought I needed to convert the binary to a string, but it says the function string is not valid. Is there another way? Is there a list of functions that daffodil supports?

..
<xs:element name="Array_Type"      type="xs:unsignedByte" />
<xs:element name="HoldData" " dfdl:occursCountKind="expression" dfdl:occursCount="{../Array_Size}">
<xs:complexType>
<xs:sequence>
<xs:choice dfdl:choiceDispatchKey="{fn:string(/Holding/Array_Type)}">
     <xs:element name="float32" type="xs:float"         dfdl:choiceBranchKey="0"/>
..

Re: choiceBranchKey - which functions are valid

Posted by Jim Welch <ji...@gmail.com>.
Thanks for the help for a DFDL newbie, although I being a programmer since
1976. I had not found that version of the manual.
I tried without a conversion and it seemed to work, but I have not tested
with choice of zero, which would be an edge case.
         <xs:choice dfdl:choiceDispatchKey="{/Holding/Array_Type}">
I have been very pleased with the schema and the daffodil software, so far.
The hard stuff has yet to be tried with handling multiple revisions, with a
built in version number.
Many thanks to all for the hard work.

Re: choiceBranchKey - which functions are valid

Posted by Mike Beckerle <mb...@tresys.com>.
Aha! I believe you are correct Steve. fn:string() is not supported by DFDL xs:string() is.


I'll submit a ticket to the DFDL Working Group re this typo-error in the spec.

________________________________
From: Steve Lawrence <sl...@apache.org>
Sent: Tuesday, July 10, 2018 12:56:07 PM
To: users@daffodil.apache.org; Mike Beckerle
Subject: Re: choiceBranchKey - which functions are valid

The issue might also be that we don't support fn:string, but instead
only support xs:string (note the prefix difference). Using xs:string
should convert the byte to a string of the decimal representation (e.g.
0x00 becomes "0" in the choice dispatch).

It looks like the DFDL spec mentions fn:string() in a few example
snippets, but does not list it in section 23.5. So maybe the fn:string()
instances in the spec are typpos and should be xs:string instead?

- Steve

On 07/10/2018 12:46 PM, Mike Beckerle wrote:
>
> Well one trick is the dfdl:encoding="iso-8859-1"  trick.
>
>
> In this encoding, every byte is a valid character, the character code being the
> value of the byte. This encoding lets you treat any byte-oriented binary data as
> text.
>
>
> So byte value 0x31 becomes character "1" or equivalently (as a DFDL numeric
> character entity) "%#x31;"
>
>
> For example if one of the expected byte values is 0, that would be the ASCII NUL
> character. You can use a DFDL numeric character entity:
>
>
> dfdl:choiceBranchKey="%#x00;"
>
>
> I do actually agree that DFDL is missing a few functions for converting from
> charcode to/from integer values. The list of functions Daffodil supports is
> given in the DFDL spec here:
>
>
> http://daffodil.apache.org/docs/dfdl/#_Toc398030827
>
> --------------------------------------------------------------------------------
> *From:* jimwelchok@gmail.com <ji...@gmail.com>
> *Sent:* Tuesday, July 10, 2018 12:34:06 PM
> *To:* users@daffodil.apache.org
> *Subject:* choiceBranchKey - which functions are valid
> I am writing a schema for a binary file and wanting to use a byte to direct
> dispatch a choice. Since choicedispatchkey uses a string, I thought I needed to
> convert the binary to a string, but it says the function string is not valid. Is
> there another way? Is there a list of functions that daffodil supports?
>
> ..
> <xs:element name="Array_Type"      type="xs:unsignedByte" />
> <xs:element name="HoldData" " dfdl:occursCountKind="expression"
> dfdl:occursCount="{../Array_Size}">
> <xs:complexType>
> <xs:sequence>
> <xs:choice dfdl:choiceDispatchKey="{fn:string(/Holding/Array_Type)}">
>       <xs:element name="float32" type="xs:float"         dfdl:choiceBranchKey="0"/>
> ..
>


Re: choiceBranchKey - which functions are valid

Posted by Steve Lawrence <sl...@apache.org>.
The issue might also be that we don't support fn:string, but instead
only support xs:string (note the prefix difference). Using xs:string
should convert the byte to a string of the decimal representation (e.g.
0x00 becomes "0" in the choice dispatch).

It looks like the DFDL spec mentions fn:string() in a few example
snippets, but does not list it in section 23.5. So maybe the fn:string()
instances in the spec are typpos and should be xs:string instead?

- Steve

On 07/10/2018 12:46 PM, Mike Beckerle wrote:
> 
> Well one trick is the dfdl:encoding="iso-8859-1"  trick.
> 
> 
> In this encoding, every byte is a valid character, the character code being the 
> value of the byte. This encoding lets you treat any byte-oriented binary data as 
> text.
> 
> 
> So byte value 0x31 becomes character "1" or equivalently (as a DFDL numeric 
> character entity) "%#x31;"
> 
> 
> For example if one of the expected byte values is 0, that would be the ASCII NUL 
> character. You can use a DFDL numeric character entity:
> 
> 
> dfdl:choiceBranchKey="%#x00;"
> 
> 
> I do actually agree that DFDL is missing a few functions for converting from 
> charcode to/from integer values. The list of functions Daffodil supports is 
> given in the DFDL spec here:
> 
> 
> http://daffodil.apache.org/docs/dfdl/#_Toc398030827
> 
> --------------------------------------------------------------------------------
> *From:* jimwelchok@gmail.com <ji...@gmail.com>
> *Sent:* Tuesday, July 10, 2018 12:34:06 PM
> *To:* users@daffodil.apache.org
> *Subject:* choiceBranchKey - which functions are valid
> I am writing a schema for a binary file and wanting to use a byte to direct 
> dispatch a choice. Since choicedispatchkey uses a string, I thought I needed to 
> convert the binary to a string, but it says the function string is not valid. Is 
> there another way? Is there a list of functions that daffodil supports?
> 
> ..
> <xs:element name="Array_Type"      type="xs:unsignedByte" />
> <xs:element name="HoldData" " dfdl:occursCountKind="expression" 
> dfdl:occursCount="{../Array_Size}">
> <xs:complexType>
> <xs:sequence>
> <xs:choice dfdl:choiceDispatchKey="{fn:string(/Holding/Array_Type)}">
>       <xs:element name="float32" type="xs:float"         dfdl:choiceBranchKey="0"/>
> ..
> 


Re: choiceBranchKey - which functions are valid

Posted by Mike Beckerle <mb...@tresys.com>.
Well one trick is the dfdl:encoding="iso-8859-1"  trick.


In this encoding, every byte is a valid character, the character code being the value of the byte. This encoding lets you treat any byte-oriented binary data as text.


So byte value 0x31 becomes character "1" or equivalently (as a DFDL numeric character entity) "%#x31;"


For example if one of the expected byte values is 0, that would be the ASCII NUL character. You can use a DFDL numeric character entity:


dfdl:choiceBranchKey="%#x00;"


I do actually agree that DFDL is missing a few functions for converting from charcode to/from integer values. The list of functions Daffodil supports is given in the DFDL spec here:


http://daffodil.apache.org/docs/dfdl/#_Toc398030827

________________________________
From: jimwelchok@gmail.com <ji...@gmail.com>
Sent: Tuesday, July 10, 2018 12:34:06 PM
To: users@daffodil.apache.org
Subject: choiceBranchKey - which functions are valid

I am writing a schema for a binary file and wanting to use a byte to direct dispatch a choice. Since choicedispatchkey uses a string, I thought I needed to convert the binary to a string, but it says the function string is not valid. Is there another way? Is there a list of functions that daffodil supports?

..
<xs:element name="Array_Type"      type="xs:unsignedByte" />
<xs:element name="HoldData" " dfdl:occursCountKind="expression" dfdl:occursCount="{../Array_Size}">
<xs:complexType>
<xs:sequence>
<xs:choice dfdl:choiceDispatchKey="{fn:string(/Holding/Array_Type)}">
     <xs:element name="float32" type="xs:float"         dfdl:choiceBranchKey="0"/>
..