XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
97
SOM Expressions That Include Periods and Dashes
An XFA name may include the dash and/or period characters (“XFA
Names” on page 70),
which have dual
meanings in SOM expressions, especially when such expressions are interpreted by a script interpreter,
such as FormCalc and ECMAScript. Whether such special characters can be included in a SOM expression
depends on whether the expression is expected to be a SOM only or may be either a SOM or a script.
Example 3.4
Object names that include periods and dashes
<template>
<subform>
<subform name="Toys">
<field name="My-toy"/>
<field name="My.childs-toy/>
</subform>
</subform>
</template>
SOM only
A SOM-only expression is used as the argument for the
resolveNode()
function or method or as the
value of a bind element.
Dash. The dash character is interpreted as part of the field name, rather than as an operator. This is true
for both FormCalc and ECMAScript.
<script>
xfa.resolveNode("form..My-toy") // ’-’ included with XFA name
</script>
Period. One or more escape characters must be used to distinguish a period used in a name from a
period used as an object separator.
<script>
// FormCalc environment
xfa.resolveNode("form..My\.childs-toy")
</script>
or
<script contentType="application/x-javascript">
// ECMAScript environment
xfa.resolveNode("form..My\\.childs-toy").rawValue
</script>
ECMAScript strips one of the escape characters before passing the remaining string to the SOM
resolver, but FormCalc does not.
Without the
rawValue
property in the ECMAScript expression, the object
My.childs-toy
would be
returned rather than the value of the object, as explained in
“Using SOM Expressions in ECMAScript” on
page 98
Mixed SOM/script context
A mixed SOM/script context exists when the expression can be interpreted as a SOM expression or as a
script expression. Whether the escape sequence
’\’
can be used to prevent the script environment from
handling dashes and periods is application dependent. If it is not supported, the
resolveNode()
method/function may be used, as described in
“SOM only” on page 97.
Home Index Bookmark Pages
Pages: Home Index All Pages