Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ abstract class SequenceGroupTermBase(xml: Node, lexicalParent: SchemaComponent,
with SeparatorSuppressionPolicyMixin {

requiredEvaluationsIfActivated(checkIfValidUnorderedSequence)
requiredEvaluationsIfActivated(checkValidityOccursCountKind)
requiredEvaluationsIfActivated(checkIfNonEmptyAndDiscrimsOrAsserts)
requiredEvaluationsIfActivated(checkIfMultipleChildrenWithSameName)

Expand Down Expand Up @@ -160,6 +161,24 @@ abstract class SequenceGroupTermBase(xml: Node, lexicalParent: SchemaComponent,
}
}.value

lazy val checkValidityOccursCountKind: Unit = {
if (hasSeparator && (separatorSuppressionPolicy ne SeparatorSuppressionPolicy.AnyEmpty)) {
val optInvalidChild = groupMembers.find {
case e: ElementBase => e.occursCountKind == OccursCountKind.Parsed
case _ => false
}
if (optInvalidChild.isDefined) {
optInvalidChild.get.SDW(
WarnID.SeparatorSuppressionPolicyError,
"Member of a sequence with dfdl:occursCountKind='parsed' must have a " +
"containing sequence with dfdl:separatorSuppressionPolicy='anyEmpty', " +
"but was %s. This may be changed to an error in a future version of Daffodil.",
separatorSuppressionPolicy
)
}
}
}

/**
* Provides validation for assert and discriminator placement
*/
Expand All @@ -181,12 +200,12 @@ abstract class SequenceGroupTermBase(xml: Node, lexicalParent: SchemaComponent,
protected final lazy val checkIfValidUnorderedSequence: Unit = {
if (!isOrdered) {
checkMembersAreAllElementOrElementRef
checkMembersHaveValidOccursCountKind
checkUnorderedSequenceMembersHaveValidOccursCountKind
checkUnorderedSequenceMembersHaveUniqueNamesInNamespaces
}
}

private lazy val checkMembersHaveValidOccursCountKind: Unit = {
private lazy val checkUnorderedSequenceMembersHaveValidOccursCountKind: Unit = {
val validChildren: Seq[ElementBase] =
groupMembers
.filter { m => m.isInstanceOf[LocalElementDecl] || m.isInstanceOf[ElementRef] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@
<xs:enumeration value="patternEncodingSlashW" />
<xs:enumeration value="queryStylePathExpression" />
<xs:enumeration value="regexPatternZeroLength" />
<xs:enumeration value="separatorSuppressionPolicyError" />
<xs:enumeration value="signedBinaryIntegerLength1Bit" />
<xs:enumeration value="textBidiError" />
<xs:enumeration value="textNumberPatternWarning" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tdml:testSuite xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
xmlns:ex="http://example.com" suiteName="rothrsreq" description="testing otg gold schemas" defaultRoundTrip="true">
<tdml:defineSchema name="otg-schema" elementFormDefault="unqualified" useDefaultNamespace="false">
<xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
<dfdl:defineFormat name="DefaultPropertiesFormat">
<dfdl:format ref="ex:GeneralFormat"
emptyValueDelimiterPolicy="none"
fillByte="0"
lengthKind="delimited"
lengthUnits="characters"
nilKind="literalValue"
nilValue="%ES;"
nilValueDelimiterPolicy="none"
representation="text"
separatorPosition="infix"
separatorSuppressionPolicy="anyEmpty"
textNumberPadCharacter="0"
textNumberPattern="###0.###;-###0.###"
textPadKind="none"
textStandardZeroRep="" />
</dfdl:defineFormat>
<dfdl:format ref="ex:DefaultPropertiesFormat"/>

<xs:element name="e1">
<xs:complexType>
<xs:sequence dfdl:separator="/" dfdl:separatorPosition="prefix" dfdl:terminator="%NL;">
<xs:element name="se1" type="xs:int"/>
<xs:element name="se2" type="xs:int"/>
<xs:element name="arre1" maxOccurs="3" dfdl:occursCountKind="parsed">
<xs:complexType>
<xs:sequence dfdl:separator="-">
<xs:choice>
<xs:element name="ie1" type="xs:int"/>
<xs:element name="ie2" type="xs:float"/>
</xs:choice>
<xs:element name="ie3" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="se5" type="xs:string"/>
<xs:element name="se6" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="e2">
<xs:complexType>
<xs:sequence dfdl:separator="/" dfdl:separatorPosition="prefix" dfdl:terminator="%NL;">
<xs:element name="se1" type="xs:int"/>
<xs:element name="se2" type="xs:int"/>
<xs:element name="arre1" maxOccurs="3" dfdl:occursCountKind="implicit">
<xs:complexType>
<xs:sequence dfdl:separator="-">
<xs:choice>
<xs:element name="ie1" type="xs:int"/>
<xs:element name="ie2" type="xs:float"/>
</xs:choice>
<xs:element name="ie3" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="se5" type="xs:string"/>
<xs:element name="se6" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</tdml:defineSchema>

<tdml:parserTestCase name="test_array_parsed" root="e1" model="otg-schema" roundTrip="none">
<tdml:document><![CDATA[/1/2/3.5-one/4-two/a/6
]]></tdml:document>
<tdml:infoset>
<tdml:dfdlInfoset>
<ex:e1>
<se1>1</se1>
<se2>2</se2>
<arre1>
<ie2>3.5</ie2>
<ie3>one</ie3>
</arre1>
<arre1>
<ie1>4</ie1>
<ie3>two</ie3>
</arre1>
<se5>a</se5>
<se6>6</se6>
</ex:e1>
</tdml:dfdlInfoset>
</tdml:infoset>
</tdml:parserTestCase>

<tdml:parserTestCase name="test_array_implicit" root="e2" model="otg-schema" roundTrip="none">
<tdml:document><![CDATA[/1/2/3.5-one/4-two/a/6
]]></tdml:document>
<tdml:infoset>
<tdml:dfdlInfoset>
<ex:e2>
<se1>1</se1>
<se2>2</se2>
<arre1>
<ie2>3.5</ie2>
<ie3>one</ie3>
</arre1>
<arre1>
<ie1>4</ie1>
<ie3>two</ie3>
</arre1>
<se5>a</se5>
<se6>6</se6>
</ex:e2>
</tdml:dfdlInfoset>
</tdml:infoset>
</tdml:parserTestCase>

</tdml:testSuite>
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,11 @@

<xs:element name="root" dfdl:initiator="RECORD">
<xs:complexType>
<xs:sequence dfdl:separator="/" dfdl:separatorPosition="prefix" dfdl:terminator="%NL;">
<xs:sequence dfdl:separator="/" dfdl:separatorPosition="prefix" dfdl:terminator="%NL;" dfdl:separatorSuppressionPolicy="anyEmpty">
<xs:element name="field1" type="xs:string" />
<xs:element name="field2" type="xs:string" minOccurs="0" />
<xs:element name="field3" type="xs:string" minOccurs="0" />
<xs:element name="groupOfFields" minOccurs="1" maxOccurs="3" dfdl:occursCountKind="parsed">
<xs:element name="groupOfFields" minOccurs="1" maxOccurs="3">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes both SSP and OCK. Why change both? Could we jsut change SSP to anyEmpty (which should work with OKC=parsed) or change OCK=implicit with the existing SSP? I'm not sure what the test is trying to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed both since I think "parsed" was not the right option what with the min/maxOccurs, so implicit seemed like the better option. I also changed SSP because "never" would add in the additional prefix separator for the missing groupOfFields element. Technically nothing needed to change, but OCK=implicit and SSP=anyEmpty seems like the correct thing based on the attributes and the data/infoset

<xs:complexType>
<xs:sequence>
<xs:sequence dfdl:separator="/" dfdl:separatorPosition="infix" dfdl:separatorSuppressionPolicy="never">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.daffodil.section14.occursCountKind

import org.apache.daffodil.junit.tdml.TdmlSuite
import org.apache.daffodil.junit.tdml.TdmlTests

import org.junit.Test

object TestImplicitvParsed extends TdmlSuite {
val tdmlResource = "org/apache/daffodil/section14/occursCountKind/implicitvparsed.tdml"
}

class TestImplicitvParsed extends TdmlTests {
val tdmlSuite = TestImplicitvParsed

@Test def test_array_parsed = test
@Test def test_array_implicit = test

}
Loading