一个没有样板文件的XML转换框架。
inxs的Python项目详细描述
inxs–一个用于xml转换的python框架,没有样板文件。
inxs是不可分割的。
inxs不是xslt。
inxs是isc许可的。
inxs在这里有完整的文档:https://inxs.readthedocs.io/en/latest/
一瞥
defextract_person(node:TagNode):returnnode.attributes['username'],first(node.css_select("name")).full_textdefappend_person(previous_result,result:TagNode):result.append_child(result.new_tag_node("name",attributes={"username":previous_result[0]},children=[previous_result[1]]))transformation=Transformation(Rule('person',(extract_person,append_person)),result_object='context.result',context={'result':new_tag_node('root')})# that's four lines less LOC than the XSLT implementation
defgenerate_skeleton(context):context.html=new_tag_node("html",namespace='http://www.w3.org/1999/xhtml',children=(tag("head",tag("title","Testing XML Example")),tag("body",(tag("h1","Persons"),tag("ul"))),))defextract_person(node:TagNode,persons):persons.append((first(node.css_select("name")).full_text,first(node.css_select("family-name")).full_text))deflist_persons(previous_result,html:TagNode):first(html.css_select("html|body html|ul")).append_child(*(html.new_tag_node("li",children=[f'{x[1]}, {x[0]}'])forxinprevious_result))transformation=Transformation(generate_skeleton,Rule('person',extract_person),lib.sort('persons',itemgetter(1)),list_persons,result_object='context.html',context={'persons':[]})# that's four lines more LOC than the XSLT implementation
Here您可以找到inxs的源存储库和问题跟踪程序。
历史记录
0.2b1(2019-06-23)
- 重构为基于delb而不是lxml
- 从处理程序函数的可用符号中删除了:
- tree
- xpath_evaluator(改用root.xpath)
- 已重命名处理程序函数的可用符号:
- element->;node
- 在核心中重命名为
- SkipToNextElement->;SkipToNextNode
- 已从库中删除:
- drop_siblings
- extract_text
- has_tail
- init_elementmaker
- merge
- replace_text
- sub
- 在库中重命名为
- make_element->;make_node
- remove_element->;remove_node
- remove_elements->;remove_nodes
- sorter->;sort
- strip_attributes->;remove_attributes
- strip_namespace->;remove_namespace
函数和方法的各种参数已相应地重命名。
0.1b1(2017-06-25)
- new:允许任何规则在每次转换时都必须匹配的定义 common_rule_conditions。
- 小的改进和修正。
0.1b0(2017-06-19)
- 第一个测试版。
0.1a0(2017-05-02)
- pypi上的第一个版本。