mbeckerle commented on code in PR #901: URL: https://github.com/apache/daffodil/pull/901#discussion_r1064858887
########## daffodil-runtime2/src/test/resources/org/apache/daffodil/runtime2/variablelen.dfdl.xsd: ########## @@ -0,0 +1,121 @@ +<?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. +--> + +<xs:schema + elementFormDefault="qualified" + xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" + xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <!-- Binary data format bindings --> + + <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/> + <xs:annotation> + <xs:appinfo source="http://www.ogf.org/dfdl/"> + <dfdl:format + ref="GeneralFormat" + binaryBooleanFalseRep="0" + binaryBooleanTrueRep="1" + fillByte="%NUL;" + prefixIncludesPrefixLength="no" + representation="binary"/> + </xs:appinfo> + </xs:annotation> + + <!-- Types for testing --> + + <!-- Unsuitable since variable length array must allow 0 to 16 numbers --> + <xs:complexType name="fixed"> + <xs:sequence> + <xs:element name="before" type="xs:unsignedInt" /> + <xs:element name="variablelen_size" type="xs:unsignedInt" /> + <xs:element name="variablelen" type="xs:unsignedInt" + minOccurs="2" maxOccurs="2" + dfdl:occursCountKind="fixed" /> + <!-- Yes, can have "after" element after "fixed" array --> + <xs:element name="after" type="xs:unsignedInt" + minOccurs="2" maxOccurs="2" + dfdl:occursCountKind="fixed" /> + </xs:sequence> + </xs:complexType> + + <!-- Unsuitable since "implicit" works only at end of binary data --> + <xs:complexType name="implicit"> + <xs:sequence> + <xs:element name="before" type="xs:unsignedInt" /> + <xs:element name="variablelen_size" type="xs:unsignedInt" /> + <xs:element name="variablelen" type="xs:unsignedInt" + minOccurs="0" maxOccurs="16" + dfdl:occursCountKind="implicit" /> + <!-- No, cannot have "after" element after "implicit" array --> + </xs:sequence> + </xs:complexType> + + <!-- Unsuitable since "parsed" works only at end of binary data --> + <xs:complexType name="parsed"> + <xs:sequence> + <xs:element name="before" type="xs:unsignedInt" /> + <xs:element name="variablelen_size" type="xs:unsignedInt" /> + <xs:element name="variablelen" type="xs:unsignedInt" + minOccurs="0" maxOccurs="16" + dfdl:occursCountKind="parsed" /> + <!-- No, cannot have "after" element after "parsed" array --> + </xs:sequence> + </xs:complexType> + + <!-- Suitable, although need to support variable length arrays in C --> + <xs:complexType name="expression"> + <xs:sequence> + <xs:element name="before" type="xs:unsignedInt" /> + <xs:element name="variablelen_size" type="xs:unsignedInt" /> + <xs:element name="variablelen" type="xs:unsignedInt" + minOccurs="0" maxOccurs="16" + dfdl:occursCountKind="expression" + dfdl:occursCount="{ ../variablelen_size }" /> + <!-- Yes, can have "after" element after "expression" array --> + <xs:element name="after" type="xs:unsignedInt" + minOccurs="2" maxOccurs="2" + dfdl:occursCountKind="fixed" /> + </xs:sequence> + </xs:complexType> + + <!-- Unsuitable since "stopValue" adds extra data --> + <xs:complexType name="stopValue"> + <xs:sequence> + <xs:element name="before" type="xs:unsignedInt" /> + <xs:element name="variablelen_size" type="xs:unsignedInt" /> + <xs:element name="variablelen" type="xs:unsignedInt" + minOccurs="0" maxOccurs="16" + dfdl:occursCountKind="stopValue" + dfdl:occursStopValue="0" /> + <!-- Yes, can have "after" element after "stopValue" array --> + <xs:element name="after" type="xs:unsignedInt" + minOccurs="2" maxOccurs="2" + dfdl:occursCountKind="fixed" /> + </xs:sequence> + </xs:complexType> + + <!-- Root elements for testing --> + + <xs:element name="fixed" type="fixed"/> Review Comment: This seemingly straightforward name choice for these elements actually makes the review hard. Can you change these so the names are not exactly the values of properties? E.g., aFixedElt Ditto the types, make them be anImplicitOCKType. That will avoid things in the C code like "array_variablelen_expression_expression__getArraySize" where the relationship of these identifiers to the names in the schema is ambiguous. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
