You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by Regis Thomas <re...@nteligen.com> on 2023/04/26 15:01:59 UTC

Help with dfdl:choice and dfdl:group elements

Good Morning Daffodil/DFDL Users,

I am working on the development of intellisense for dfdl in the Apache Daffodil VSCode extension.  As we prepare to release version 1.3.0. I am scouring through the Apache DFDL spec https://daffodil.apache.org/docs/dfdl/ for any items that I have missed implementing in the 1.3.0 release to add to the 1.3.1 release.  I noticed that I was missing the dfdl:choice and dfdl:group elements in the intellisense. From the spec, I don't understand what element(s) might be parents of these elements.  I also don't understand what element might be children of these elements or what attributes they might have.  Usually I have been able to find examples of an element's use that helped clarify how I might add that element to the intellisense, but I haven't been able to find any examples of either dfdl:choice or dfdl:group in use. If anyone could provide an example or additional clarification, that would be greatly appreciated.

Regis Thomas
Nteligen, LLC
6716 Alexander Bell Drive,
Suite 120
Columbia, MD 20146
(240) 864-5042 x126
regis.thomas@nteligen.com


Re: Help with dfdl:choice and dfdl:group elements

Posted by Mike Beckerle <mb...@apache.org>.
I wonder if intellisense should bother supporting these long form, and
element form annotations.

People pretty much don't write them. People write short-form.

These more verbose annotations are really in DFDL because we anticipated
that some XSD infrastrutures would not be happy with short form annotations
littering their DFDL schemas once they have the DFDL aspect figured out. So
using long or element form puts 100% of the DFDL annotations inside appinfo
elements with source="http://www.ogf.org/dfdl/". This makes them easy
to elide/suppress as you just collapse those elements and poof... all DFDL
has disappeared from the schema.

The reason we prefer short form is because we're focused on the DFDL
properties. But once those are "done" and working, then you can focus on
just the infoset, and so having a mode where all the DFDL annotations
become invisible, is attractive. A preprocessor that literally removes all
such annotations is quite simple.

A converter that converts between short form and long form, or even element
form annotations (or the other way to convert back) may be more useful than
intellisense support for these more verbose forms. Certainly if we did
support all 3 syntaxes, short form, long form, and element form, we would
need features to easily and quickly move property bindings between these
styles in bulk or individually.

Also, the whole point of the element form annotations was to stay out of
quoting/escaping hell.

E.g.,

<element name="foo" type="xs:string">
   <annotation><appinfo source="http://www.ogf.org/dfdl/">
       <dfdl:element>
           <dfdl:property name="inputValueCalc"><![CDATA[{
xs:unsignedInt(fn:concat("&<2", '3>')) }]]></dfdl:property>
       </dfdl:element>
    </appinfo></annotation>
</element>

or

<element name="foo" type="xs:string">
   <annotation><appinfo source="http://www.ogf.org/dfdl/">
       <dfdl:element>
           <dfdl:property name="initiator"><![CDATA[&&&&]]></dfdl:property>
       </dfdl:element>
    </appinfo></annotation>
</element>

Note the value part is NOT inside a context of either single or double
quotes, so you can generate this without any thought as to whether the
expression contains single or double quote characters. You can also wrap it
in <![CDATA[ ... ]]> so that you are independent of whether it contains
XML-like syntax inside it also. This is handy for delimiters that contain
XML-special characters like <, or > , or &.



On Wed, Apr 26, 2023 at 1:59 PM Steve Lawrence <sl...@apache.org> wrote:

> dfdl:group and dfdl:choice are used as "attribute form" annotations to
> xs:group and xs:choice respectively. For example:
>
>    <xs:group name="foo">
>      <xs:annotation>
>        <xs:appinfo source="http://www.ogf.org/dfdl/">
>          <dfdl:group encoding="UTF-8" ... />
>        </xs:appinfo>
>      </xs:annotation>
>      ...
>    </xs:group>
>
> Note that the dfdl: prefix isn't need on the encoding property because
> it is on the dfdl:group element.
>
> The above is equivalent to using "short form" annotations like below,
> which is the most common form since it is so much less verbose:
>
>    <xs:group name="foo" dfdl:encoding="UTF-8" ... />
>      ...
>    </xs:group>
>
> Note that the dfdl: prefix is needed here because it is on the xs:group
> element.
>
> There is also a third form called "element form" which looks like this:
>
>    <xs:group name="foo">
>      <xs:annotation>
>        <xs:appinfo source="http://www.ogf.org/dfdl/">
>          <dfdl:group>
>            <dfdl:property name="encoding">UTF-8"</dfdl:property>
>          </dfdl:group>
>        </xs:appinfo>
>      </xs:annotation>
>      ...
>    </xs:group>
>
> So instead of being attributes on the xs:group or the dfdl:group
> annotation, it appears as a dfdl:propery element that is a child of the
> dfdl:group element.
>
>
> Each property in the spec lists the annotations it can appear on. For
> example, the "encoding" property lists these:
>
> Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice,
> dfdl:group
>
> So the "encoding" property can appear on any of those 5 annotations
> using any of the three property binding forms.
>
> Section 7.1 of the spec lists the different annotations
>
> https://daffodil.apache.org/docs/dfdl/#_Toc62570077
>
> Note that it isn't specific to groups or choices--elements, sequences,
> simleTypes, etc, have similar annotations.
>
>
> On 2023-04-26 11:01 AM, Regis Thomas wrote:
> > Good Morning Daffodil/DFDL Users,
> >
> > I am working on the development of intellisense for dfdl in the Apache
> > Daffodil VSCode extension.  As we prepare to release version 1.3.0. I am
> > scouring through the Apache DFDL spec
> > https://daffodil.apache.org/docs/dfdl/
> > <https://daffodil.apache.org/docs/dfdl/> for any items that I have
> > missed implementing in the 1.3.0 release to add to the 1.3.1 release.  I
> > noticed that I was missing the dfdl:choice and dfdl:group elements in
> > the intellisense. From the spec, I don’t understand what element(s)
> > might be parents of these elements.  I also don’t understand what
> > element might be children of these elements or what attributes they
> > might have.  Usually I have been able to find examples of an element’s
> > use that helped clarify how I might add that element to the
> > intellisense, but I haven’t been able to find any examples of either
> > dfdl:choice or dfdl:group in use. If anyone could provide an example or
> > additional clarification, that would be greatly appreciated.
> >
> > Regis Thomas
> >
> > Nteligen, LLC
> >
> > 6716 Alexander Bell Drive,
> >
> > Suite 120
> >
> > Columbia, MD 20146
> >
> > (240) 864-5042 x126
> >
> > regis.thomas@nteligen.com
> >
>
>

Re: Help with dfdl:choice and dfdl:group elements

Posted by Steve Lawrence <sl...@apache.org>.
dfdl:group and dfdl:choice are used as "attribute form" annotations to 
xs:group and xs:choice respectively. For example:

   <xs:group name="foo">
     <xs:annotation>
       <xs:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:group encoding="UTF-8" ... />
       </xs:appinfo>
     </xs:annotation>
     ...
   </xs:group>

Note that the dfdl: prefix isn't need on the encoding property because 
it is on the dfdl:group element.

The above is equivalent to using "short form" annotations like below, 
which is the most common form since it is so much less verbose:

   <xs:group name="foo" dfdl:encoding="UTF-8" ... />
     ...
   </xs:group>

Note that the dfdl: prefix is needed here because it is on the xs:group 
element.

There is also a third form called "element form" which looks like this:

   <xs:group name="foo">
     <xs:annotation>
       <xs:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:group>
           <dfdl:property name="encoding">UTF-8"</dfdl:property>
         </dfdl:group>
       </xs:appinfo>
     </xs:annotation>
     ...
   </xs:group>

So instead of being attributes on the xs:group or the dfdl:group 
annotation, it appears as a dfdl:propery element that is a child of the 
dfdl:group element.


Each property in the spec lists the annotations it can appear on. For 
example, the "encoding" property lists these:

Annotation: dfdl:element, dfdl:simpleType, dfdl:sequence, dfdl:choice, 
dfdl:group

So the "encoding" property can appear on any of those 5 annotations 
using any of the three property binding forms.

Section 7.1 of the spec lists the different annotations

https://daffodil.apache.org/docs/dfdl/#_Toc62570077

Note that it isn't specific to groups or choices--elements, sequences, 
simleTypes, etc, have similar annotations.


On 2023-04-26 11:01 AM, Regis Thomas wrote:
> Good Morning Daffodil/DFDL Users,
> 
> I am working on the development of intellisense for dfdl in the Apache 
> Daffodil VSCode extension.  As we prepare to release version 1.3.0. I am 
> scouring through the Apache DFDL spec 
> https://daffodil.apache.org/docs/dfdl/ 
> <https://daffodil.apache.org/docs/dfdl/> for any items that I have 
> missed implementing in the 1.3.0 release to add to the 1.3.1 release.  I 
> noticed that I was missing the dfdl:choice and dfdl:group elements in 
> the intellisense. From the spec, I don’t understand what element(s) 
> might be parents of these elements.  I also don’t understand what 
> element might be children of these elements or what attributes they 
> might have.  Usually I have been able to find examples of an element’s 
> use that helped clarify how I might add that element to the 
> intellisense, but I haven’t been able to find any examples of either 
> dfdl:choice or dfdl:group in use. If anyone could provide an example or 
> additional clarification, that would be greatly appreciated.
> 
> Regis Thomas
> 
> Nteligen, LLC
> 
> 6716 Alexander Bell Drive,
> 
> Suite 120
> 
> Columbia, MD 20146
> 
> (240) 864-5042 x126
> 
> regis.thomas@nteligen.com
>