[DFDL-WG] Optional Initiator and Terminator?

Garriss Jr., James P. jgarriss at mitre.org
Tue Mar 12 08:33:11 EDT 2013


> I suggested the use of an escape scheme to handle this

Yes, you did.  :-)  You have correctly perceived the original intentions of these initiators/discriminators; however, in practice, the escape characters never appear, so they are genuinely superfluous, thus I don’t think the escape scheme approach is best.

> The 'sequence' is more flexible as it gives you the possibility of hiding the brackets from the infoset using dfdl:hiddenGroupRef.

This is helpful, and I’ll try it this way.

Thank you!

From: Steve Hanson [mailto:smh at uk.ibm.com]
Sent: Monday, March 11, 2013 5:42 AM
To: Cranford, Jonathan W.
Cc: dfdl-wg at ogf.org; dfdl-wg-bounces at ogf.org; Garriss Jr., James P.
Subject: Re: [DFDL-WG] Optional Initiator and Terminator?

In an earlier email exchange on this subject, I suggested the use of an escape scheme to handle this, assuming that the { } are either both absent or both present, using properties escapeKind 'escapeBlock', escapeBlockStart '{', escapeBlockEnd '}'. The disadvantage of this approach is when serializing - you need to set property generateEscapeBlock to 'always' or 'whenNeeded' - there is no setting for 'remember what it was when parsed'. That may or may not be a requirement here.

If an escape scheme is not appropriate, then whether the 'choice' or 'sequence with optionality' approach is best is really up to you. It all depends on how you want to manipulate the infoset subsequently. The 'sequence' is more flexible as it gives you the possibility of hiding the brackets from the infoset using dfdl:hiddenGroupRef.

To Jonathan's point, if the { } are either both absent or both present. you can place a dfdl:assert on the sequence which throws an error if the brackets are unbalanced.

Regards

Steve Hanson
Architect, Data Format Description Language (DFDL)
Co-Chair, OGF DFDL Working Group<http://www.ogf.org/dfdl/>
IBM SWG, Hursley, UK
smh at uk.ibm.com<mailto:smh at uk.ibm.com>
tel:+44-1962-815848



From:        "Cranford, Jonathan W." <jcranford at mitre.org<mailto:jcranford at mitre.org>>
To:        "Garriss Jr., James P." <jgarriss at mitre.org<mailto:jgarriss at mitre.org>>, "dfdl-wg at ogf.org<mailto:dfdl-wg at ogf.org>" <dfdl-wg at ogf.org<mailto:dfdl-wg at ogf.org>>,
Date:        08/03/2013 21:29
Subject:        Re: [DFDL-WG] Optional Initiator and Terminator?
Sent by:        dfdl-wg-bounces at ogf.org<mailto:dfdl-wg-bounces at ogf.org>
________________________________



I don’t know the answer to the DFDL portion of your question, but I can say your two workarounds aren’t equivalent. The latter will accept an initiator with no terminator, and vice versa (e.g., “{ data” and “data }”, while the former will not.

HTH,

Jonathan


From: dfdl-wg-bounces at ogf.org<mailto:dfdl-wg-bounces at ogf.org> [mailto:dfdl-wg-bounces at ogf.org] On Behalf Of Garriss Jr., James P.
Sent: Friday, March 08, 2013 12:42 PM
To: dfdl-wg at ogf.org<mailto:dfdl-wg at ogf.org>
Subject: [DFDL-WG] Optional Initiator and Terminator?

Is there a way to specify that an initiator/terminator pair is optional?

IOW, these are both valid:

  { data }
  data

If not, which of these workarounds is better (and why)?

Choice
    DataWithInitiatorAndTeminator
   DataWithoutInitiatorAndTeminator

Or

Sequence
  OptionalInitiator (0 to 1)
  Data
  OptionalTerminator (0 to 1)

These seem the same to me, but maybe there’s a reason why one is better.--
 dfdl-wg mailing list
 dfdl-wg at ogf.org<mailto:dfdl-wg at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20130312/fccb457c/attachment.html>


More information about the dfdl-wg mailing list