The argument can also be a long, unsignedLong, or any subtype thereof, and in that case a xs:hexBinary value containing a number of hex digits is produced.
Returns the timezone component, if any, of $arg as an xs:string.
Returns the timezone component, if any, of $arg as an xs:string. The $arg is of type xs:dateTime, xs:date, or xs:time.
If $arg has a timezone component, then the result is a string in the format of an ISO Time zone designator. Interpreted as an offset from UTC, its value may range from +14:00 to -14:00 hours, both inclusive. The UTC time zone is represented as "+00:00". If the $arg has no timezone component, then "" (empty string) is returned.
expression evaluation side-effects this state block.
expression evaluation side-effects this state block.
For DPath expressions, all infoset content must be obtained via methods on this object so that if used in a forward referencing expression the expression can block until the information becomes available.
Move down to an occurrence of an array element.
Down to a non-array element.
Down to a non-array element. Can be optional or scalar.
Modes for expression evaluation.
Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName
Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName
If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.
This function is called when 0 arguments are provided. We treat this as if the argument passed was "." to denote self.
Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision.
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision.
If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.
This particular function expects a single argument which is a Numeric. $precision is assumed 0.
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision.
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision.
If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.
This particular function expects a two arguments: $arg and $precision.
Parsing always uses this mode, for everything except discriminators.
Parsing always uses this mode, for everything except discriminators.
Unparsing never uses this mode for anything.
In this mode, evaluation is simple. If a child doesn't exist but is needed to be traversed, an exception is thrown. If a value doesn't exist an exception is thrown. fn:exists and fn:count return the answers immediately based on the current state of the infoset object.
In this mode, if an infoset node or value that is needed for evaluation is not found, then it is a Runtime Schema Definition Error, i.e., a fatal error.
Base for unparse-time expression evaluation that can have forward reference.
Base for unparse-time expression evaluation that can have forward reference. There are only two such cases, which is dfdl:outputValueCalc, and dfdl:setVariable expressions (which variables are in-turn used by dfdl:outputValueCalc.
We need to have a data structure that lets us represent a type, and its relationship (conversion, subtyping) to other types.
We need to have a data structure that lets us represent a type, and its relationship (conversion, subtyping) to other types.
This is what TypeNodes are for. They are linked into a graph that can answer questions about how two types are related. It can find the least general supertype, or most general subtype of two types.
Division with rounding for decimals
Division with rounding for decimals
About the rounding.
Without rounding specified here, you can get an java arithmetic exception Specifically:
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
What's questionable here, is to what number of fraction digits it will round. That can be specified also as an argument to divide(), but we have no information here (or anywhere really) about what precision is desired. So we're omitting that and just saying "round it".
Really, there's no rounding scale/precision until we're ready to represent the number in a string. In this case we're not. We're in the middle of an expression, just happen to have two BigDecimal operands, and we're dividing them, which should produce a BigDecimal result.
DFDL expressions are supposed to be consistent with XPath, so we look there for suggestions. The XPath spec https://www.w3.org/TR/xpath-functions-3/#op.numeric says it is implementation defined.
For xs:decimal values, let N be the number of digits of precision supported by the implementation, and let M (M <= N) be the minimum limit on the number of digits required for conformance (18 digits for XSD 1.0, 16 digits for XSD 1.1). Then for addition, subtraction, and multiplication operations, the returned result should be accurate to N digits of precision, and for division and modulus operations, the returned result should be accurate to at least M digits of precision. The actual precision is ·implementation-defined·. If the number of digits in the mathematical result exceeds the number of digits that the implementation retains for that operation, the result is truncated or rounded in an ·implementation-defined· manner
In our case, the implementation does what the JVM and java libraries do when divide() is called with two arguments the second of which specifies to round half-up.
Returns $arg if it contains exactly one item.
Returns $arg if it contains exactly one item. Otherwise, raises an error
Summary: Computes the effective boolean value of the sequence $arg.
Summary: Computes the effective boolean value of the sequence $arg.
If $arg is the empty sequence, fn:boolean returns false.
If $arg is a sequence whose first item is a node, fn:boolean returns true.
If $arg is a singleton value of type xs:boolean or a derived from xs:boolean, fn:boolean returns $arg.
If $arg is a singleton value of type xs:string or a type derived from xs:string, xs:anyURI or a type derived from xs:anyURI or xs:untypedAtomic, fn:boolean returns false if the operand value has zero length; otherwise it returns true.
If $arg is a singleton value of any numeric type or a type derived from a numeric type, fn:boolean returns false if the operand value is NaN or is numerically equal to zero; otherwise it returns true.
In all other cases, fn:boolean raises a type error [err:FORG0006].
A NodeInfo.Kind describes what kind of result we want from the expression.
A NodeInfo.Kind describes what kind of result we want from the expression. E.g., a + b we want numbers from both a and b expressions. In /a/b we want a "complex" node from the expression a, and a value from the expression b. But fn:exists(../a/b) we need complex node a so that we can test if b exists. In case of a[b] for b we need a value, but furthermore an array index, so 1..n.
Functions motivate some of the options here. e.g., fn:nilled( exp ) is the test for a nilled value. There we want an expression to something that is nillable.
This same Kind is also used to describe the inherent value (bottom up) of an expression. So a literal "foo" is of string kind, whereas 5.0 is Numeric
The nested objects here allow one to write NodeInfo.Kind (type of any of these enums) NodeInfo.Number.Kind (type of just the number variants) NodeInfo.Value.Kind (type of just the value variants) The enums themselves are just NodeInfo.Decimal (for example)
Note that you can talk about types using type node objects: E.g., NodeInfo.Number. But you can also use Scala typing to ask whether a particular type object is a subtype of another: e.g.
val x = NodeInfo.String val aa = NodeInfo.AnyAtomic x.isSubTypeOf(aa) // true. Ordinary way to check. Navigates our data structure. x.isInstanceOf[NodeInfo.AnyAtomic.Kind] // true. Uses scala type checkingSo each NodeInfo object has a corresponding class (named with .Kind suffix) which is actually a super-type (in Scala sense) of the enums for the types beneath.
The primary advantage of the latter is that this is a big bunch of sealed traits/classes, so if you have a match-case analysis by type, scala's compiler can tell you if your match-case exhausts all possibilities and warn you if it does not.
Used when evaluating discriminators, which only occurs during parsing.
Used when evaluating discriminators, which only occurs during parsing.
In this mode, if a failure occurs in that an infoset node or value is not found then it is a Processing error.
Moves to above the root element so that an absolute path that begins with the name of the root element will descend into the root element.
Unparsing uses this mode for outputValueCalc, variables, and length expressions, when it wants to actually suspend a co-routine that can be resumed.
Unparsing uses this mode for outputValueCalc, variables, and length expressions, when it wants to actually suspend a co-routine that can be resumed.
In this mode, we must be running on a co-routine which can be blocked.
In this mode, evaluation can suspend waiting for a child node to be added/appended, or for a value to be set.
fn:count can block if the array isn't final yet. fn:exists can block if the array or element isn't final yet.
Once the situation leading to the suspension changes, evaluation is retried.
Unparsing uses this mode for evaluation to determine whether or not something will block.
Unparsing uses this mode for evaluation to determine whether or not something will block.
In this mode, we are running on the main co-routine, so we can't actually block.
However, unlike ParserNonBlocking mode, in this mode fn:count of a non-final array will error, indicating to the caller that the expression would have blocked waiting for that array to be finalized. Similarly fn:exists can error, as can many other things. Anything that would have blocked in UnparserBlocking mode will instead error.
The argument can also be a long, unsignedLong, or any subtype thereof, and in that case a xs:hexBinary value containing a number of hex digits is produced. The ordering and number of the digits correspond to a binary big-endian twos- complement implementation of the type of the argument. Digits 0-9, A-F are used. The number of digits produced depends on the type of $arg, being 2, 4, 8 or 16. If $arg is a literal number then the type is the smallest signed type (long, int, short, byte) that can contain the value. If a literal number is not able to be represented by a long, it is a schema definition error.
• dfdl:hexBinary(xs:short(208)) is the hexBinary value "00D0". • dfdl:hexBinary(208) is the hexBinary value "D0". • dfdl:hexBinary(-2084) is the hexBinary value "F7DC".