({{, (RefLink[CompoundElement, paclet:ref/CompoundElement])[{(Subscript[spec, 1]),(Subscript[spec, 2]),…}] 
represents a form or interpreter specification for a list of fields or inputs that gives a list of results.}, {, (RefLink[CompoundElement, paclet:ref/CompoundElement])[\[LeftAssociation](Subscript[key, 1])->(Subscript[spec, 1]),(Subscript[key, 2])->(Subscript[spec, 2]),…\[RightAssociation]]
represents a form or interpreter specification that gives an association of results.}})

OpenersNotesSection(Spacer1)Details

In the context of (RefLink[Interpreter, paclet:ref/Interpreter]), (Subscript[spec, i]) can be any specification used for (RefLink[Interpreter, paclet:ref/Interpreter]), including (RefLink[CompoundElement, paclet:ref/CompoundElement]) or (RefLink[RepeatingElement, paclet:ref/RepeatingElement]).

In the context of (RefLink[FormObject, paclet:ref/FormObject]) and (RefLink[FormFunction, paclet:ref/FormFunction]), (Subscript[spec, i]) can be any specification used for forms, including the full association, but only simple structures can be visualized as a table of fields.

(RefLink[Interpreter, paclet:ref/Interpreter])[CompoundElement[{(Subscript[form, 1]),(Subscript[form, 2]),…}][{(Subscript[input, 1]),(Subscript[input, 2]),…}] is effectively equivalent to {(RefLink[Interpreter, paclet:ref/Interpreter])[(Subscript[form, 1])][(Subscript[input, 1])],(RefLink[Interpreter, paclet:ref/Interpreter])[(Subscript[form, 2])][(Subscript[input, 2])],…}.

In (RefLink[Interpreter, paclet:ref/Interpreter])[CompoundElement[{(Subscript[form, 1]),(Subscript[form, 2]),…}][{(Subscript[input, 1]),(Subscript[input, 2]),…}], the list of (Subscript[input, i]) must be the same length as the list of (Subscript[form, i]). If it is not, a (RefLink[Failure, paclet:ref/Failure]) object is generated.

The result from (RefLink[Interpreter, paclet:ref/Interpreter])[CompoundElement[<|(Subscript[key, 1])->(Subscript[spec, 1]),…|>][input] is an association that contains elements for each of the (Subscript[key, i]). If input is a list, each successive (Subscript[key, i]) is used in order. If input is an association, any (Subscript[key, i]) missing from it is returned as a missing element, and any value associated with a key that is not one of the (Subscript[key, i]) is dropped.

Any of the (Subscript[spec, i]) can themselves be (RefLink[CompoundElement, paclet:ref/CompoundElement]) or (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) objects.

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Use (RefLink[CompoundElement, paclet:ref/CompoundElement]) to combine (RefLink[Interpreter, paclet:ref/Interpreter]) calls of any kind:

Interpreter[CompoundElement[{"GivenName",{"home","office","mobile"},"PhoneNumber"}]][{{"Alice","home", "+44 020 1234 5678"},{"Bob","mobile", "+1 (202) 456-1111"}}]

Use (RefLink[CompoundElement, paclet:ref/CompoundElement]) to speed up (RefLink[Interpreter, paclet:ref/Interpreter]) by grouping calls that require connectivity to the Wolfram Cloud:

Interpreter[CompoundElement[{"City", "Country", "Integer"}]][{"rome", "italy", "4"}]

(RefLink[CompoundElement, paclet:ref/CompoundElement]) will fail on data that does not have the correct shape:

Interpreter[CompoundElement[{"Integer", "ComplexNumber"}]][{"2"}]

Use in a form to create a row of fields:

CloudDeploy[FormFunction["name" -> CompoundElement[{"first" ->"String","last"-> "String"}]]]

The result will be a nested association:

OpenersExampleSection2(Spacer1)Applications  (2)

Interpret data that has a complex structure:

Interpreter[CompoundElement[<|"location" -> CompoundElement[{"City", "USState"}], "singer" -> "MusicAct", "song" -> "MusicWork"|>]][<|"location" -> {"memphis", "tennessee"}, "singer" -> "elvis", "song" -> "hound dog"|>]

Use an association input to coerce the data to the right shape:

Interpreter[CompoundElement[<|"x" -> "Real", "y" -> "Real"|>]][{"12.4", "-5"}]

Interpreter[CompoundElement[<|"x" -> "Real", "y" -> "Real"|>]][<|"y" ->"12.4", "x" -> "-5"|>]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

Use (RefLink[CompoundElement, paclet:ref/CompoundElement]) with (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) to interpret even more complicated structures:

Interpreter[CompoundElement[<|"numbers" -> RepeatingElement["Integer"], "fruit" -> RepeatingElement[{"apple" -> "pomme", "orange" -> "orange", "grapefruit" -> "pamplemousse"}]|>]][<|"numbers" -> {"1","14", "-4"},"fruit" -> {"apple" , "pomme", "grapefruit"}|>]

Use with (RefLink[RepeatingElement, paclet:ref/RepeatingElement]) in the context of (RefLink[FormFunction, paclet:ref/FormFunction]) to generate a table of fields:

CloudDeploy[FormFunction["names" -> RepeatingElement[CompoundElement[<|"first"-> "String", "last" -> "String"|>]]]]

Use (RefLink[CompoundElement, paclet:ref/CompoundElement]) in conjunction with (RefLink[Alternatives, paclet:ref/Alternatives]) to interpret data that can have different shapes:

Interpreter[CompoundElement[{"City", "USState"}]|"City"]["bangkok"]

Interpreter[CompoundElement[{"City", "USState"}]][{"trenton","indonesia"| "NJ"}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Interpreter, paclet:ref/Interpreter])  ▪  (RefLink[DelimitedSequence, paclet:ref/DelimitedSequence])  ▪  (RefLink[RepeatingElement, paclet:ref/RepeatingElement])  ▪  (RefLink[List, paclet:ref/List])  ▪  (RefLink[Association, paclet:ref/Association])  ▪  (RefLink[FormFunction, paclet:ref/FormFunction])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Setting Up Input Interpreters, paclet:guide/InterpretingStrings])}, {▪(RefLinkPlain[Form Structure & Layout, paclet:guide/FormStructureAndLayout])}, {▪(RefLinkPlain[Free-Form & External Input, paclet:guide/FreeFormAndExternalInput])}, {▪(RefLinkPlain[Creating Form Interfaces & Apps, paclet:guide/CreatingFormsAndApps])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/36-creating-websites-and-apps.html])(WebLink[: Creating Websites and Apps, https://www.wolfram.com/language/elementary-introduction/36-creating-websites-and-apps.html])}})}})