Oops,....Yes, you are correct. That one will absorb (and discard) the NL initiator at parse time, and at unparse time, it is never created, so that NL will never be unparsed. This removes the NL from the unparsed representation, which means the canonical form of this data does not have such NL at the end.
Your initial example had a dfdl:outputValueCalc on it, which can never make sense on an optional hidden element, but is necessary on a required hidden element. On Thu, Oct 12, 2023 at 3:36 AM Roger L Costello <coste...@mitre.org> wrote: > Mike, isn’t this an example of a hidden optional element: > > > > <xs:sequence dfdl:hiddenGroupRef="hidden-newline" /> > > … > > <xs:group name="hidden-newline"> > <xs:sequence> > <xs:element name="EOL" type="xs:string" minOccurs="0" > dfdl:initiator="%NL;" dfdl:lengthKind="explicit" > dfdl:length="0" /> > </xs:sequence> > </xs:group> > > > > > > *From:* Mike Beckerle <mbecke...@apache.org> > *Sent:* Tuesday, October 10, 2023 2:55 PM > *To:* users@daffodil.apache.org > *Subject:* Re: Can optional elements be hidden? > > > > Nope. You can't have hidden optional elements. It makes no sense. They're > hidden, so they do not exist at the time you start unparsing. Since they > are optional there's nothing to make them come into existence when > unparsing. On > > ZjQcmQRYFpfptBannerStart > > Nope. You can't have hidden optional elements. It makes no sense. They're > hidden, so they do not exist at the time you start unparsing. > > > > Since they are optional there's nothing to make them come into existence > when unparsing. > > > > On Mon, Oct 9, 2023, 10:50 AM Roger L Costello <coste...@mitre.org> wrote: > > <xs:sequence dfdl:hiddenGroupRef="hideH" /> > ... > <xs:group name="hideH"> > <xs:sequence> > <xs:element name="h" > dfdl:length="1" > dfdl:lengthKind="explicit" > type="xs:string" > dfdl:outputValueCalc="{'H'}" > minOccurs="0"/> > </xs:sequence> > </xs:group> > > Results in this error: dfdl:outputValueCalc cannot be defined on optional > elements. > > Is there a way to hide optional elements? > >