[ 
https://issues.apache.org/jira/browse/DAFFODIL-2211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17753313#comment-17753313
 ] 

Steve Lawrence commented on DAFFODIL-2211:
------------------------------------------

I've roughly implement this suggestion, and I've found that we do have a number 
of tests that have a repType that is a primitive type. However, they are all 
related to inputTypeCalc and outputTypeCalc, which is deprecated and planned 
for removal. And this is clearly a special exception since (I think?) elements 
that are used in input/outputTypeCalcs don't actually need representations 
since they are never actually parsed/unparsed, they are used purely for 
transformation. So a primitive repType doesn't run into any issues like other 
uses.

So some options:
# Allow an exception so that if an element/simpleType defines 
dfdlx:inputTypeCalc or dfdlx:outputTypeCalc attributes, then we allow the 
dfdlx:repType to resolve to a primitive type. This adds some complication to 
the check (and makes the check different from prefixLengthType), but allows 
these tests and support to remain unchanged. 
# Enforce the restriction that repType cannot resolve to a primitive type, even 
for input/outputTypeCalc. We modify the existing tests to add new simple types 
that are used as the repType, making the tests in line with the proposed 
restriction. Note that the regression suite does have a few schemas that use 
inputTypeCalc and outputTypeCalc, but none of them have a repType that resolves 
to a primitive type, so this restriction shouldn't break any existing schemas.
# Remove inputTypeCalc/outputTypeCalc completely, including their 
implementation and tests. These have been deprecated and planned for removal, 
so maybe now is the time to do it. However, there are still some schemas in the 
regression suite (including some relatively new schemas) that still use 
input/outputTypeCalc. I'm also not sure if we actually output a deprecation 
warning when these are used, so users might surprised by their removal. Though, 
this feature is an extension in the dfdlx namespace and isn't a widely known 
feature, so maybe we have some leeway in making this backward incompatible 
change.

> Poor handling when dfdlx:repType is a built-in xsd type
> -------------------------------------------------------
>
>                 Key: DAFFODIL-2211
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2211
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Front End
>    Affects Versions: 2.4.0
>            Reporter: Brandon Sloane
>            Assignee: Steve Lawrence
>            Priority: Major
>         Attachments: TestCSV.scala, b.dfdl.xsd, c.dfdl.xsd, csv.tdml, 
> csvDetailed.dfdl.xsd, simpleCSVDetailed.csv, simpleCSVDetailed.xml
>
>
> Attached are two cases, both of which contain:
> {quote}<xs:simpleType name="SomeEnumType" dfdlx:repType="xs:unsignedByte">
>  <xs:restriction base="xs:unsignedShort">
>  <xs:enumeration value="55" dfdlx:repValues="0" />
>  <xs:enumeration value="56" dfdlx:repValues="1" />
>  <xs:enumeration value="57" dfdlx:repValues="2" />
>  </xs:restriction>
> </xs:simpleType>
> {quote}
> In some cases this could potentially make sense (eg. when the document format 
> is such that unsignedByte is automatically 8 bits), but we probably want to 
> disallow this entirely.
> In b.dfdl.xsd, the entire document is using representation='text'. This fails 
> with a somewhat reasonable error:
> {quote}[error] Schema Definition Error: Type UnsignedShort with 
> dfdl:representation='text' cannot have dfdl:lengthKind='implicit'
> Schema context: element reference tns:a Location line 1 in 
> file:/home/bsloane/Documents/incubator-daffodil/test/test/b.dfdl.xsd
> [error] Schema Definition Error: Type UnsignedShort cannot have 
> lengthKind='implicit' when representation='text'
> Schema context: element reference tns:a Location line 1 in 
> file:/home/bsloane/Documents/incubator-daffodil/test/test/b.dfdl.xsd
> {quote}
> in c.dfdl.xsd, the document is useing representation='binary', and fails with 
> an unhandled exception:
> {quote}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>    An unexpected exception occurred. This is a bug!   
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>  Please report this bug and help us fix it:
>   https://daffodil.apache.org/community/#issue-tracker
>  Please include the following exception, the command you ran, and any input, 
> schema, or tdml files used that led to this bug.
> java.util.NoSuchElementException: None.get at 
> scala.None$.get(Option.scala:349) at scala.None$.get(Option.scala:347) at 
> org.apache.daffodil.grammar.primitives.TypeValueCalc.repTypeUnparser$lzycompute(PrimitivesExpressions.scala:264)
>  at 
> org.apache.daffodil.grammar.primitives.TypeValueCalc.repTypeUnparser(PrimitivesExpressions.scala:264)
>  at 
> org.apache.daffodil.grammar.primitives.TypeValueCalc.unparser$lzycompute(PrimitivesExpressions.scala:276)
>  at 
> org.apache.daffodil.grammar.primitives.TypeValueCalc.unparser(PrimitivesExpressions.scala:272)
>  at org.apache.daffodil.grammar.Gram.maybeUnparser(GrammarTerm.scala:146) at 
> org.apache.daffodil.grammar.primitives.ElementCombinatorBase.eRepTypeUnparser$lzycompute(ElementCombinator.scala:421)
>  at 
> org.apache.daffodil.grammar.primitives.ElementCombinatorBase.eRepTypeUnparser(ElementCombinator.scala:421)
>  at 
> org.apache.daffodil.grammar.primitives.ElementParseAndUnspecifiedLength.unparser$lzycompute(ElementCombinator.scala:332)
>  at 
> org.apache.daffodil.grammar.primitives.ElementParseAndUnspecifiedLength.unparser(ElementCombinator.scala:327)
>  at 
> org.apache.daffodil.grammar.primitives.ElementCombinator.unparser$lzycompute(ElementCombinator.scala:143)
>  at 
> org.apache.daffodil.grammar.primitives.ElementCombinator.unparser(ElementCombinator.scala:119)
>  at org.apache.daffodil.grammar.Prod.unparser$lzycompute(Production.scala:92) 
> at org.apache.daffodil.grammar.Prod.unparser(Production.scala:84) at 
> org.apache.daffodil.grammar.Prod.unparser$lzycompute(Production.scala:92) at 
> org.apache.daffodil.grammar.Prod.unparser(Production.scala:84) at 
> org.apache.daffodil.compiler.ProcessorFactory.$anonfun$unparser$1(Compiler.scala:106)
>  at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.liftedTree1$1(OOLAG.scala:549) 
> at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.valueAsAny$lzycompute(OOLAG.scala:547)
>  at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.valueAsAny(OOLAG.scala:544) at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValue.value$lzycompute(OOLAG.scala:594) 
> at org.apache.daffodil.oolag.OOLAG$OOLAGValue.value(OOLAG.scala:594) at 
> org.apache.daffodil.compiler.ProcessorFactory.unparser$lzycompute(Compiler.scala:105)
>  at 
> org.apache.daffodil.compiler.ProcessorFactory.unparser(Compiler.scala:105) at 
> org.apache.daffodil.compiler.ProcessorFactory.$anonfun$new$4(Compiler.scala:127)
>  at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.liftedTree1$1(OOLAG.scala:549) 
> at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.valueAsAny$lzycompute(OOLAG.scala:547)
>  at 
> org.apache.daffodil.oolag.OOLAG$OOLAGValueBase.valueAsAny(OOLAG.scala:544) at 
> org.apache.daffodil.oolag.OOLAG$OOLAGHost.$anonfun$checkErrors$2(OOLAG.scala:286)
>  at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12) at 
> org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60) at 
> org.apache.daffodil.oolag.OOLAG$OOLAGHost.checkErrors(OOLAG.scala:286) at 
> org.apache.daffodil.oolag.OOLAG$OOLAGHost.checkErrors$(OOLAG.scala:277) at 
> org.apache.daffodil.dsom.SchemaComponentImpl.checkErrors(SchemaComponent.scala:38)
>  at org.apache.daffodil.oolag.OOLAG$OOLAGHost.isError(OOLAG.scala:345) at 
> org.apache.daffodil.oolag.OOLAG$OOLAGHost.isError$(OOLAG.scala:344) at 
> org.apache.daffodil.compiler.ProcessorFactory.super$isError(Compiler.scala:141)
>  at 
> org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$3(Compiler.scala:141)
>  at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12) at 
> org.apache.daffodil.oolag.OOLAG$.keepGoing(OOLAG.scala:60) at 
> org.apache.daffodil.compiler.ProcessorFactory.$anonfun$isError$1(Compiler.scala:132)
>  at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12) at 
> scala.util.DynamicVariable.withValue(DynamicVariable.scala:58) at 
> org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>  at org.apache.daffodil.compiler.ProcessorFactory.isError(Compiler.scala:132) 
> at org.apache.daffodil.compiler.Compiler.compileSource(Compiler.scala:359) at 
> org.apache.daffodil.Main$.$anonfun$createProcessorFromSchema$1(Main.scala:704)
>  at org.apache.daffodil.util.Timer$.getTimeResult(Timer.scala:76) at 
> org.apache.daffodil.util.Timer$.getResult(Timer.scala:35) at 
> org.apache.daffodil.Main$.createProcessorFromSchema(Main.scala:703) at 
> org.apache.daffodil.Main$.run(Main.scala:816) at 
> org.apache.daffodil.Main$.main(Main.scala:1351) at 
> org.apache.daffodil.Main.main(Main.scala)
> {quote}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to