Skip to content

Commit 67053f9

Browse files
committed
Add EVDP SDW if EVDP is not both
- Introduced new `emptyValueDelimiterPolicyWarning` enumeration in `dafext.xsd`. - Implemented related validation logic in `ElementBaseGrammarMixin`. - Added test cases to cover new behavior for `dfdl:emptyValueDelimiterPolicy`. DAFFODIL-2205
1 parent 252f17c commit 67053f9

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ trait ElementBaseGrammarMixin
5151
with ElementBaseRuntime1Mixin { self: ElementBase =>
5252

5353
requiredEvaluationsIfActivated(checkPrefixedLengthElementDecl)
54+
requiredEvaluationsIfActivated(checkDelimitedLengthEVDP)
5455

5556
private val context = this
5657

@@ -81,6 +82,19 @@ trait ElementBaseGrammarMixin
8182
}
8283
}
8384

85+
final lazy val checkDelimitedLengthEVDP: Unit = {
86+
if (
87+
(hasInitiator || hasTerminator)
88+
&& emptyValueDelimiterPolicy != EmptyValueDelimiterPolicy.Both
89+
) {
90+
SDW(
91+
WarnID.EmptyValueDelimiterPolicyWarning,
92+
"dfdl:emptyValueDelimiterPolicy='%s' will be ignored as it's only implemented for 'both'",
93+
emptyValueDelimiterPolicy
94+
)
95+
}
96+
}
97+
8498
/**
8599
* true if padding will be inserted for this delimited element when unparsing.
86100
*/

daffodil-propgen/src/main/resources/org/apache/daffodil/xsd/dafext.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@
736736
<xs:enumeration value="discouragedDiscriminatorPlacement" />
737737
<xs:enumeration value="discouragedAssertPlacement" />
738738
<xs:enumeration value="emptyElementParsePolicyError" />
739+
<xs:enumeration value="emptyValueDelimiterPolicyWarning"/>
739740
<xs:enumeration value="encodingErrorPolicyError" />
740741
<xs:enumeration value="escapeSchemeRefUndefined" />
741742
<xs:enumeration value="expressionCompilationSkipped" />

daffodil-test/src/test/resources/org/apache/daffodil/usertests/SepTests.tdml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,4 +609,75 @@
609609
</tdml:infoset>
610610
</tdml:parserTestCase>
611611

612+
<tdml:defineSchema name="s7" elementFormDefault="unqualified">
613+
614+
<xs:include schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
615+
<dfdl:format
616+
ref="ex:GeneralFormat"
617+
emptyValueDelimiterPolicy="none"
618+
lengthKind="delimited"
619+
separatorPosition="infix"
620+
separatorSuppressionPolicy="trailingEmpty"
621+
/>
622+
623+
<xs:element name="input">
624+
<xs:complexType>
625+
<xs:sequence
626+
dfdl:separator=","
627+
dfdl:separatorPosition="infix"
628+
dfdl:separatorSuppressionPolicy="trailingEmpty">
629+
<xs:element
630+
name="FirstName"
631+
type="xs:string"/>
632+
<xs:element
633+
name="MiddleName"
634+
type="xs:string"
635+
dfdl:initiator="("
636+
dfdl:terminator=")"
637+
dfdl:emptyValueDelimiterPolicy="none"/>
638+
<xs:element
639+
name="LastName"
640+
type="xs:string"/>
641+
</xs:sequence>
642+
</xs:complexType>
643+
</xs:element>
644+
</tdml:defineSchema>
645+
646+
<tdml:parserTestCase name="test_sep_evdp_1" root="input" model="s7"
647+
implementations="daffodil" roundTrip="onePass">
648+
<tdml:document>
649+
<tdml:documentPart type="text" replaceDFDLEntities="true">John,(),Doe</tdml:documentPart>
650+
</tdml:document>
651+
<tdml:infoset>
652+
<tdml:dfdlInfoset>
653+
<input>
654+
<FirstName>John</FirstName>
655+
<MiddleName></MiddleName>
656+
<LastName>Doe</LastName>
657+
</input>
658+
</tdml:dfdlInfoset>
659+
</tdml:infoset>
660+
<tdml:warnings>
661+
<tdml:warning>emptyValueDelimiterPolicyWarning</tdml:warning>
662+
<tdml:warning>none</tdml:warning>
663+
<tdml:warning>ignored</tdml:warning>
664+
<tdml:warning>both</tdml:warning>
665+
</tdml:warnings>
666+
</tdml:parserTestCase>
667+
668+
<tdml:parserTestCase name="test_sep_evdp_2" root="input" model="s7"
669+
implementations="daffodil">
670+
<tdml:document>
671+
<tdml:documentPart type="text" replaceDFDLEntities="true">John,,Doe</tdml:documentPart>
672+
</tdml:document>
673+
<tdml:infoset>
674+
<tdml:dfdlInfoset>
675+
<input>
676+
<FirstName>John</FirstName>
677+
<MiddleName></MiddleName>
678+
<LastName>Doe</LastName>
679+
</input>
680+
</tdml:dfdlInfoset>
681+
</tdml:infoset>
682+
</tdml:parserTestCase>
612683
</tdml:testSuite>

daffodil-test/src/test/scala/org/apache/daffodil/usertests/TestSepTests.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.apache.daffodil.usertests
2020
import org.apache.daffodil.junit.tdml.TdmlSuite
2121
import org.apache.daffodil.junit.tdml.TdmlTests
2222

23+
import org.junit.Ignore
2324
import org.junit.Test
2425

2526
object TestSepTests extends TdmlSuite {
@@ -48,6 +49,10 @@ class TestSepTests extends TdmlTests {
4849
@Test def test_sep_ssp_never_6 = test
4950
@Test def test_sep_ssp_never_7 = test
5051

52+
// DAFFODIL-2205 - EmptyValueDelimiterPolicy only works with 'both'
53+
@Test def test_sep_evdp_1 = test
54+
@Ignore @Test def test_sep_evdp_2 = test
55+
5156
// DAFFODIL-2791
5257
@Test def test_treatAsAbsent_occursIndex = test
5358
}

0 commit comments

Comments
 (0)