[DFDL-WG] Optional Initiator and Terminator?

Steve Hanson smh at uk.ibm.com
Mon Mar 11 05:42:00 EDT 2013


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
IBM SWG, Hursley, UK
smh at uk.ibm.com
tel:+44-1962-815848



From:   "Cranford, Jonathan W." <jcranford at mitre.org>
To:     "Garriss Jr., James P." <jgarriss at mitre.org>, "dfdl-wg at ogf.org" 
<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



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] On Behalf 
Of Garriss Jr., James P.
Sent: Friday, March 08, 2013 12:42 PM
To: 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
  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/20130311/45a013b4/attachment.html>


More information about the dfdl-wg mailing list