Example #1
0
GrammarInfo::GrammarInfo(VXIrecGrammar * g,
                         const vxistring & id,
                         const VXMLElement & elem)
  : element(elem), recgrammar(g), scope(GRS_NONE), docID(id), enabled(false)
{
  // (1) Determine the grammar scope.
  
  // (1.1) Obtain default from position in the tree.
  VXMLElement par = elem;
  while (par != 0) {
    VXMLElementType name = par.GetName();
    if (name == NODE_INITIAL || name == NODE_FIELD ||
        name == NODE_RECORD  || name == NODE_TRANSFER)
      { scope = GRS_FIELD;  break; }
    else if (name == NODE_FORM || name == NODE_MENU)
      { scope = GRS_DIALOG; break; }
    else if (name == NODE_VXML)
      { scope = GRS_DOC;    break; }
    par = par.GetParent();
  }

  // (1.2) if scope explicitly specified in grammar or parent, override!
  vxistring str;
  elem.GetAttribute(ATTRIBUTE_SCOPE, str);
  if (str.empty() && par != 0) {
    par.GetAttribute(ATTRIBUTE_SCOPE, str);
  }
  if (!str.empty()) {
    if (str == L"dialog")        scope = GRS_DIALOG;
    else if (str == L"document") scope = GRS_DOC;
  }

  // (2) Do remaining initialization.
  _Initialize(elem);
}
Example #2
0
void GrammarInfo::_Initialize(const VXMLElement & elem)
{
  if (elem == 0) return;

  VXMLElementType name = elem.GetName();
  if (name == NODE_FIELD || name == NODE_INITIAL || name == NODE_TRANSFER)
    elem.GetAttribute(ATTRIBUTE__ITEMNAME, field);
  else if (name == NODE_FORM || name == NODE_MENU) {
    elem.GetAttribute(ATTRIBUTE__ITEMNAME, dialog);
    return;
  }

  _Initialize(elem.GetParent());
}