[
https://issues.apache.org/jira/browse/DAFFODIL-2205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18029831#comment-18029831
]
Olabusayo Kilo commented on DAFFODIL-2205:
------------------------------------------
>From my investigation, only EVDP both is implemented, as the code just assumes
>both initator/terminator must always be present. To implement the other
>options, Steve L recommended a combinator class that attempts parsing the
>parameters and acts approciately based on the evdp in case of failure to
>parse. Something like the below.
lazy val parsedValue = prod("parsedValue", isSimpleType) {
EmptyValueDelimiterCombinator(
initiatorRegion,
valueMTA ~ sharedSimpleParsedValue,
terminatorRegion
)
}
Note that this will require teasing out terminatorRegion from
sharedSimpleParsedValue.
>From Mike B
The plan should take into account one of the DFDL features we never fully
implemented which is value defaulting. It partly works on parsing, but not at
all on unparsing. (https://issues.apache.org/jira/browse/DAFFODIL-115 Created
May 2012 !)
Things that are “empty” (regardless of whether that is via EVDP, or there are
no initiators/terminator) are required (per max/min occurs) and have a default
(or fixed) value are supposed to get filled in by the unparser.
The suggestion to create a specific EmptyValueDelimiterCombinator makes sense
to me as it sounds like it would provide a place for the defaulting logic to
live. Though for unparsing, the ticket DAFFODIL-115 seems to say this logic has
to be involved with the NextElementResolver class
> emptyValueDelimiterPolicy only works per specification for 'both'
> ------------------------------------------------------------------
>
> Key: DAFFODIL-2205
> URL: https://issues.apache.org/jira/browse/DAFFODIL-2205
> Project: Daffodil
> Issue Type: Bug
> Affects Versions: 2.4.0
> Environment: Daffodil 2.4 on Windows 10
> Reporter: Shashi Ramaka
> Assignee: Olabusayo Kilo
> Priority: Major
> Fix For: 4.1.0
>
> Attachments: bug01-input-fails.txt, bug01-input-works.txt,
> bug01.dfdl.xsd
>
>
> This bug report is based on a message Roger Costello posted to the Daffodil
> Users group.
> From the DFDL specification, when emptyValueDelimiterPolicy is set to 'none':
> {quote}'none' indicates that if the content region is empty neither the
> dfdl:initiator or dfdl:terminator must be present. On unparsing when
> the content region is empty nothing will be output.
> {quote}
> Based on the above, if in the schema an element has an initiator and a
> terminator, and if the emptyValueDelimiterPolicy is set to 'none', to
> represent an empty value neither the initiator nor the terminator should be
> present in the input.
> In the attached test case,
> * the element *MiddleName* has an initiator and a terminator
> * *emptyValueDelimiterPolicy* is set to 'none'
> * For the test input, John,,Doe we are getting the parse error: [error]
> Parse Error: Found out of scope delimiter: ',' ','
> * Test input John,(),Doe parses successfully
> {code:xml}
> <xs:element name="input">
> <xs:complexType>
> <xs:sequence
> dfdl:separator=","
> dfdl:separatorPosition="infix"
> dfdl:separatorSuppressionPolicy="trailingEmpty">
> <xs:element
> name="FirstName"
> type="xs:string" />
> <xs:element
> name="MiddleName"
> type="xs:string"
> dfdl:initiator="("
> dfdl:terminator=")"
> dfdlx:emptyElementParsePolicy="treatAsEmpty"
> dfdl:emptyValueDelimiterPolicy="initiator" />
> <xs:element
> name="LastName"
> type="xs:string" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> {code}
>
> Input:
> John,(),Doe – parse successful
> John,,Doe – Parse error.
> [error] Parse Error: Found out of scope delimiter: ',' ','
>
> The files used for testing this scenario are attached.
> It also appears that it does not work for 'initiator' and 'terminator' as
> well so this ticket will be about implementing this feature instead of fixing
> a bug.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)