You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "mbeckerle (via GitHub)" <gi...@apache.org> on 2023/02/24 21:25:53 UTC
[GitHub] [daffodil] mbeckerle commented on a diff in pull request #973: Ignore errors from path expressions that are not descendants of the distinguished root
mbeckerle commented on code in PR #973:
URL: https://github.com/apache/daffodil/pull/973#discussion_r1117656694
##########
daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions_unused_path_no_context.dfdl.xsd:
##########
@@ -28,20 +28,119 @@
</xs:appinfo>
</xs:annotation>
+
<xs:element name="e1" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="1" />
- <xs:group name="unused_group">
+ <xs:group name="unused_group_1">
<xs:sequence>
<xs:element name="value1" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
<xs:sequence dfdl:terminator="{ ./value1 }" />
</xs:sequence>
</xs:group>
- <xs:complexType name="unused_complex_type">
+ <xs:complexType name="unused_complex_type_1">
<xs:sequence>
<xs:element name="value2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
<xs:sequence dfdl:terminator="{ ./value2 }"/>
</xs:sequence>
</xs:complexType>
+
+ <xs:group name="unused_group_2">
+ <xs:sequence>
+ <xs:sequence dfdl:terminator="{ ./value3 }" />
+ </xs:sequence>
+ </xs:group>
+
+ <xs:complexType name="unused_complex_type_2">
+ <xs:sequence>
+ <xs:sequence dfdl:terminator="{ ./value4 }"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="unused_element_2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:sequence dfdl:terminator="{ ./value5 }"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+
+ <xs:group name="unused_group_3">
+ <xs:sequence>
+ <xs:element name="unused" type="xs:string" dfdl:terminator="{ ../value6 }" />
+ </xs:sequence>
+ </xs:group>
+
+ <xs:complexType name="unused_complex_type_3">
+ <xs:sequence>
+ <xs:element name="unused" type="xs:string" dfdl:terminator="{ ../value7 }" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="unused_element_3">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="unused" type="xs:string" dfdl:terminator="{ ../../value8 }" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+
+ <xs:element name="unused_element_4">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="value9" type="xs:string" />
+ <xs:element name="nest1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="nest2" type="xs:string" dfdl:terminator="{ ../../value9 }" />
Review Comment:
Is this line producing a warning? I see a `<warning>value9</warning>` above.
I don't think this should produce a warning. The ../.. walks up to nest1 then unused_element_4, but not past.
unused_element_4 is an element. Had it been a type or group then yes, I can see a warning being ok. But it's an element. So why should this warn?
##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala:
##########
@@ -868,11 +868,25 @@ sealed abstract class StepExpression(val step: String, val pred: Option[Predicat
extends Expression {
def relPathErr() = {
- val err = new RelativePathPastRootError(
- this.schemaFileLocation,
- "Relative path '%s' past root element.",
- this.wholeExpressionText,
- )
+ // This path expression cannot be compiled because we went past the root. This normally
+ // should be an SDE with a RelativePathPastRootError. However, if we don't have any element
+ // compile infos or the current root is not the distinguished root that Daffodil is
+ // compiling, it means this expression is used on a term that is not a descendent of the
+ // distinguish root. The expression might make sense if a different distinguished root were
Review Comment:
typo: shoudl be "// distinguished root"
##########
daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions_unused_path_no_context.dfdl.xsd:
##########
@@ -28,20 +28,119 @@
</xs:appinfo>
</xs:annotation>
+
<xs:element name="e1" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="1" />
- <xs:group name="unused_group">
+ <xs:group name="unused_group_1">
<xs:sequence>
<xs:element name="value1" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
<xs:sequence dfdl:terminator="{ ./value1 }" />
Review Comment:
So, this is a bit odd. The . in ./value1 refers to "some parent element" because this is inside a group.
But we don't care what element that is.
I'm ok with this issuing a warning, I think, so long as existing schemas don't pour out tons of such warnings.
But this is the borderline case where it would be nice if there was a way to avoid the warning in this case.
I can see how the expression compiler can't cope with this though. It wants that Up step to refer to an element that has DPathCompileInfo. There is no such.
So this is a corner case where we definitely cannot compile the expression, but we may not want to issue a warning.
I'd say let's merge this in, and try it out and if we get too many such warnings deal with it then.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org