def variable_element(tagname, namespaces, attributes): # required `name` attribute try: name = attributes[None, 'name'] except KeyError: raise XUpdateError(XUpdateError.MISSING_REQUIRED_ATTRIBUTE, element=tagname, attribute='name') else: if not isqname(name): raise XUpdateError(XUpdateError.INVALID_QNAME_ATTR, attribute='name', value=name) prefix, name = splitqname(name) if prefix: try: namespace = namespaces[prefix] except KeyError: raise XUpdateError(XUpdateError.UNDEFINED_PREFIX, prefix=prefix) else: namespace = None name = (namespace, name) # optional `select` attribute if (None, 'select') in attributes: select = attributes[None, 'select'] try: select = parse_expression(select) except XPathError, error: raise XUpdateError(XUpdateError.SYNTAX_ERROR, expression=select, text=str(error))
def value_of_element(tagname, namespaces, attributes): # required `select` attribute try: select = attributes[None, 'select'] except KeyError: raise XUpdateError(XUpdateError.MISSING_REQUIRED_ATTRIBUTE, element=tagname, attribute='select') else: try: select = parse_expression(select) except XPathError, error: raise XUpdateError(XUpdateError.SYNTAX_ERROR, expression=select, text=str(error))
try: select = attributes[None, 'select'] except KeyError: raise XUpdateError(XUpdateError.MISSING_REQUIRED_ATTRIBUTE, element=tagname, attribute='select') else: try: select = parse_expression(select) except XPathError, error: raise XUpdateError(XUpdateError.SYNTAX_ERROR, expression=select, text=str(error)) # optional `child` attribute if (None, 'child') in attributes: child = attributes[None, 'child'] try: child = parse_expression(child) except XPathError, error: raise XUpdateError(XUpdateError.SYNTAX_ERROR, expression=child, text=str(error)) else: child = None return commands.append_command(namespaces, select, child) @autodispatch('update', _char_template_model) def update_element(tagname, namespaces, attributes): # required `select` attribute try: select = attributes[None, 'select'] except KeyError: raise XUpdateError(XUpdateError.MISSING_REQUIRED_ATTRIBUTE, element=tagname, attribute='select')
except KeyError: raise XUpdateError(XUpdateError.MISSING_REQUIRED_ATTRIBUTE, element=tagname, attribute='select') else: try: select = parse_expression(select) except XPathError, error: raise XUpdateError(XUpdateError.SYNTAX_ERROR, expression=select, text=str(error)) # optional `child` attribute if (None, 'child') in attributes: child = attributes[None, 'child'] try: child = parse_expression(child) except XPathError, error: raise XUpdateError(XUpdateError.SYNTAX_ERROR, expression=child, text=str(error)) else: child = None return commands.append_command(namespaces, select, child) @autodispatch('update', _char_template_model) def update_element(tagname, namespaces, attributes): # required `select` attribute try: select = attributes[None, 'select'] except KeyError: