|
|||||
|
|||||
Prerequisite Concepts | Related Syntax | ||||
Merging data |
It is sometimes necessary to merge two data sources. Earlier versions of OmniMark, however, only allowed for one active source at a time (with certain limited exceptions). With OmniMark 8 you can have multiple active sources at a time by passing multiple string source
arguments to a function.
The following function, for example, merges a list of employee names with their employee numbers.
define string source function join-employee-data value string source employee-names & value string source employee-numbers as output "<employees>" repeat scan employee-names match any ++ => employee-name ("%n" | value-end) local string employee-number set employee-number to (employee-numbers take any ++ ("%n" | value-end)) take [\"%n"]* output "<employee>" || "<name>" || employee-name || "</name>" || "<number>" || employee-number || "</number>" || "</employee>" again output "</employees>%n"
This string source function
join-employee-data
combines the two string sources employee-names
and employee-numbers
and produces a single string of XML data. The join-employee-data function
can then be used as a source for an XML parse:
process local string employee-names initial { "Tom%nDick%nHarry" } local string employee-numbers initial { "0001%n0002%n0003%n" } do xml-parse scan join-employee-data employee-names and employee-numbers output "%c" done element "employees" output "EMPLOYEES%n=========%n" || "%n" || "%c" element "employee" output "%c%n" element "name" output " NAME: %c%n" element "number" output " NUMBER: %c%n"
Prerequisite Concepts Creating plug and play filters Linking Chains of Streaming Filters Modules |
Related Syntax define string sink function define string source function |
Copyright © Stilo International plc, 1988-2008.