282
| Does
XPath have operators for checking a value is in a range? (Steve)
12/5: Investigate whether equivalent to DFDL4S 'in' operator exists. 23/6: Mike has found an XPath 'intersect' operator. Handles the enumeration case well, but not as convenient for ranges as DFDL4S's 'in' operator. 11/8: Looked back at the motivating example from DFDL4S. Agreed that DFDL functions to do the equivalent of 'in' and 'inrange' would be useful if nothing can be re-used from XPath. Steve to write up a proposal taking into account different data types. ... 22/9: Proposal sent by Steve for new functions dfdl:checkValues(), dfdl:checkRangeInclusive(), dfdl:checkRangeExclusive(). Discussed whether both range functions needed, and whether they should be allowed for float and double. Mike noted that dfdl:checkConstraints() and simple types could be used instead of all three functions if values were static. Follow-up with DFDL4S team to see if they had thought of that. 3/11: DFDL4S not happy with usability of dfdl:checkConstraints type, but ok with the intersection operator. Next step is to see what the DFDL4S schema would look like if rewritten to use dfdl:checkConstraints and intersection. 5/1/16: Agreed that dfdl:checkConstraints() is not ideal as it requires creation of union simple types. Steve to go back to his proposal from 22/9/15 and rework to include use of the intersect operator. 16/2: No progress 1/3: Discussed with ESA team. Steve to rework his proposal from 22/9/15. |
Reworked proposal:
a) Add XPath 2.0 'intersect' and "except"
operators to the list of supported operators.
Updated Table 57 as follows:
DFDL Expression | ::= | "{" Expr "}" |
Expr | ::= | ExprSingle |
ExprSingle | ::= | IfExpr | OrExpr |
IfExpr | ::= | "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle |
OrExpr | ::= | AndExpr ( "or" AndExpr )* |
AndExpr | ::= | ComparisonExpr ( "and" ComparisonExpr )* |
ComparisonExpr | ::= | AdditiveExpr ( (ValueComp) AdditiveExpr)? |
AdditiveExpr | ::= | MultiplicativeExpr ( ("+" | "-") MultiplicativeExpr )* |
MultiplicativeExpr | ::= | IntersectExceptExpr ( ("*" | "div" | "idiv" | "mod") IntersectExceptExpr )* |
IntersectExceptExpr | ::= | UnaryExpr ( ("intersect" | "except") UnaryExpr )* |
UnaryExpr | ::= | ("-" | "+")* ValueExpr |
ValueExpr | ::= | PathExpr |
ValueComp | ::= | "eq" | "ne" | "lt" | "le" | "gt" | "ge" |
PathExpr | ::= | ("/"
RelativePathExpr?) | RelativePathExpr | FilterExpr |
RelativePathExpr | ::= | StepExpr (("/") StepExpr)* |
StepExpr | ::= | AxisStep |
AxisStep | ::= | (ReverseStep | ForwardStep) Predicate? |
ForwardStep | ::= | (ForwardAxis NodeTest) | AbbrevForwardStep |
ForwardAxis | ::= | ("child"
"::") | ("self" "::") |
AbbrevForwardStep | ::= | NodeTest | ContextItemExpr |
ReverseStep | ::= | (ReverseAxis NodeTest) | AbbrevReverseStep |
ReverseAxis | ::= | ("parent"
"::") |
AbbrevReverseStep | ::= | ".." |
NodeTest | ::= | NameTest |
NameTest | ::= | QName |
FilterExpr | ::= | PrimaryExpr Predicate? |
Predicate | ::= | "[" Expr "]" |
PrimaryExpr | ::= | Literal | VarRef | ParenthesizedExpr | ContextItemExpr | FunctionCall |
Literal | ::= | NumericLiteral | StringLiteral |
NumericLiteral | ::= | IntegerLiteral | DecimalLiteral | DoubleLiteral |
VarRef | ::= | "$" VarName |
VarName | ::= | QName |
ParenthesizedExpr | ::= | "(" Expr ")" |
ContextItemExpr | ::= | "." |
FunctionCall | ::= | QName "(" (ExprSingle ("," ExprSingle)*)? ")" |
dfdl:checkRangeInclusive($node, $val1, $val2) | Returns
boolean true if the specified node value is in the range given by $val1
and $val2, inclusive.
The type of $val1 and $val2 must be compatible with the type of $node, and must be a derivative of xs:decimal, xs:float or xs:double. It is a schema definition error if the $node argument is a complex element. |
dfdl:checkRangeExclusive($node, $val1, $val2) | Returns
boolean true if the specified node value is in the range given by $val1
and $val2, exclusive.
The type of $val1 and $val2 must be compatible with the type of $node, and must be a derivative of xs:decimal, xs:float or xs:double. It is a schema definition error if the $node argument is a complex element. |
dfdl:checkValues($node, $val1, $val2, ...) | Returns
boolean true if the specified node value matches any of the values provided
by $val1 etc.
The type of $val1 etc must be compatible with the type of $node. It is a schema definition error if the $node argument is a complex element. The number of value arguments is implementation-defined. |
dfdl:checkRangeInclusive($node, $val1, $val2) | Returns
boolean true if the specified node value is in the range given by $val1
and $val2, inclusive.
The type of $val1 and $val2 must be compatible with the type of $node, and must be a derivative of xs:decimal. It is a schema definition error if the $node argument is a complex element. |
dfdl:checkRangeExclusive($node, $val1, $val2) | Returns
boolean true if the specified node value is in the range given by $val1
and $val2, exclusive.
The type of $val1 and $val2 must be compatible with the type of $node, and must be a derivative of xs:decimal. It is a schema definition error if the $node argument is a complex element. |
Regards
Steve Hanson
Architect, IBM
DFDL
Co-Chair, OGF
DFDL Working Group
IBM SWG, Hursley, UK
smh@uk.ibm.com
tel:+44-1962-815848
From: Steve
Hanson/UK/IBM
To: DFDL-WG
<dfdl-wg@ogf.org>
Date: 11/08/2015
16:28
Subject: Fw:
[DFDL]: First Release of DFDL4S Parser Library