one-or-more

Returns a sequence if it contains one or more items, otherwise errors

Description

The fn:one-or-more function returns $arg if it contains one or more items. Otherwise, the error FORG0004 is raised. This function is useful when static typing is in effect, to avoid apparent static type errors.

Parameters

Description

arg:item()

the sequence that must have at least one item

Examples

XPath

Results

one-or-more( () )

Error FORG0004

one-or-more('a')

a

one-or-more( ('a', 'b') )

('a', 'b')

In a generator

Copy the snippet below and paste it in Freemapper, under a language node inside the generators element. Each line of the pattern prints the result of one example; to see them, run mi generate <project> <language> example-one-or-more. The examples that raise an error are left out, because an error stops the generation.

[e] example-one-or-more
    [e] start
        [e] match
            [v] /
        [e] body
            [e] write-pattern
                [v] examples
    [e] patterns
        [e] examples
            [v] E02: {{ one-or-more('a') }}
            [v] E03: {{ one-or-more( ('a', 'b') ) }}

See Also