Пример #1
0
def launch(*args, **kwargs):
    import pprint
    from amara.xpath.util import simplify
    source = args[0]
    expr = args[1]
    import amara
    doc = amara.parse(source)
    result = doc.xml_select(expr.decode('utf-8'))
    pprint.pprint(simplify(result))
    return
Пример #2
0
def launch(*args, **kwargs):
    import pprint
    from amara.xpath.util import simplify
    source = args[0]
    expr = args[1]
    import amara
    doc = amara.parse(source)
    result = doc.xml_select(expr.decode('utf-8'))
    pprint.pprint(simplify(result))
    return
Пример #3
0
def akara_xpath(body, ctype, **params):
    '''
    select - XPath expression to be evaluated against the document
    tidy - 'yes' to tidy HTML, or 'no'

    Sample request:
    curl --request POST --data-binary "@foo.xml" --header "Content-Type: application/xml" "http://localhost:8880/akara.xpath?select=/html/head/title&tidy=yes"
    '''
    if params.get("tidy") == 'yes':
        doc = html.parse(body)
    else:
        doc = amara.parse(body)
    result = simplify(doc.xml_select(params['select'].decode('utf-8')))
    return str(result)
Пример #4
0
Файл: xslt.py Проект: dpla/akara
def akara_xpath(body, ctype, **params):
    '''
    select - XPath expression to be evaluated against the document
    tidy - 'yes' to tidy HTML, or 'no'

    Sample request:
    curl --request POST --data-binary "@foo.xml" --header "Content-Type: application/xml" "http://localhost:8880/akara.xpath?select=/html/head/title&tidy=yes"
    '''
    if params.get("tidy") == 'yes':
        doc = html.parse(body)
    else:
        doc = amara.parse(body)
    result = simplify(doc.xml_select(params['select'].decode('utf-8')))
    return str(result)