Exemple #1
0
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))
Exemple #2
0
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))
Exemple #3
0
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))
Exemple #4
0
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))
Exemple #5
0
    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')
Exemple #6
0
    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: