FormInterpretationAlgorithm implements FormItemVisitor { public GrammarDocument processGrammar(final Grammar grammar) throws UnsupportedFormatError, NoresourceError, BadFetchError, SemanticError { final GrammarProcessor processor = context.getGrammarProcessor(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("preprocessing grammar " + grammar + "..."); } final Locale language = interpreter.getLanguage(); return processor.process(context, null, grammar, language); } FormInterpretationAlgorithm(final VoiceXmlInterpreterContext ctx,
            final VoiceXmlInterpreter ip, final Dialog currentDialog); Dialog getDialog(); VoiceXmlInterpreterContext getVoiceXmlInterpreterContext(); TagStrategyExecutor getTagStrategyExecutor(); void initialize(final Profile prof,
            final Map<String, Object> parameters); FormItem getFormItem(final String name); Collection<FormItem> getFormItems(); FormItem getFormItem(); void mainLoop(); void setJustFilled(final InputItem input); boolean isJustFilled(final InputItem input); boolean isQueuingPrompts(); GrammarDocument processGrammar(final Grammar grammar); void visitBlockFormItem(final BlockFormItem block); void visitFieldFormItem(final InputItem field); void visitInitialFormItem(final InitialFormItem initial); void visitObjectFormItem(final ObjectFormItem object); void visitRecordFormItem(final RecordFormItem record); void visitSubdialogFormItem(final SubdialogFormItem subdialog); void visitTransferFormItem(final TransferFormItem transfer); void setReprompt(final boolean on); String getLocalProperty(final String name); void setLocalProperty(final String name, final String value);  }
@Test public void testProcessGrammar() throws Exception, JVoiceXMLEvent { final VoiceXmlDocument doc = new VoiceXmlDocument(); final Vxml vxml = doc.getVxml(); final Form form = vxml.appendChild(Form.class); final Grammar grammar = form.appendChild(Grammar.class); grammar.setVersion("1.0"); grammar.setType(GrammarType.SRGS_XML); final Rule rule = grammar.appendChild(Rule.class); final OneOf oneof = rule.appendChild(OneOf.class); final Item item1 = oneof.appendChild(Item.class); item1.addText("visa"); final Item item2 = oneof.appendChild(Item.class); item2.addText("mastercard"); final Item item3 = oneof.appendChild(Item.class); item3.addText("american express"); final Dialog executableForm = new ExecutablePlainForm(); executableForm.setNode(form); final FormInterpretationAlgorithm fia = new FormInterpretationAlgorithm( context, interpreter, executableForm); final GrammarDocument processed = fia.processGrammar(grammar); Assert.assertEquals(grammar.toString(), processed.getDocument() .toString()); }