Skip to content
Snippets Groups Projects
Commit 97906568 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

DOC: Fix docstring formatting

parent 3f57958e
Branches
Tags
2 merge requests!181Release 0.9.0,!174XML Converter
from . import converters, utils
from . import converters, utils, xml_converter
try:
from .conv_impl.spss import SPSSConverter
except ImportError as err:
......
......@@ -48,9 +48,10 @@ from .converters import SimpleFileConverter, ConverterValidationError, Converter
class XMLFileConverter(SimpleFileConverter):
"""
Convert XML files. See https://gitlab.indiscale.com/caosdb/src/caosdb-crawler/-/issues/145
"""Convert XML files. See
https://gitlab.indiscale.com/caosdb/src/caosdb-crawler/-/issues/145
for the current suggestion for the specification.
"""
def create_children(self, generalStore: GeneralStore, element: StructureElement):
......@@ -72,33 +73,38 @@ class XMLFileConverter(SimpleFileConverter):
class XMLTagConverter(Converter):
def create_children(self, generalStore: GeneralStore, element: StructureElement):
"""
Children that are generated by this function are the result of the xpath query given in
the yaml property "xpath". Its default (when not given) is "child::*", so the direct children
of the current xml node.
The xpath expression must be designed in a way that it returns xml tags (and no attributes or texts).
That means, that the axis "attribute::" and the function "text()" must not be used.
"""Children that are generated by this function are the
result of the xpath query given in the yaml property
``xpath``. Its default (when not given) is ``child::*``, so the
direct children of the current xml node. The xpath expression
must be designed in a way that it returns xml tags (and no
attributes or texts). That means, that the axis ``attribute::``
and the function ``text()`` must not be used.
The following yaml properties can be used to generate other
types of nodes (text nodes and attribute nodes) as subtree
structure elements:
The following yaml properties can be used to generate other types of nodes (text nodes and attribute nodes)
as subtree structure elements:
::
# _*_ marks the default:
attribs_as_children: true # true / _false_
text_as_children: true # true / _false_
tags_as_children: true # _true_ / false
# _*_ marks the default:
attribs_as_children: true # true / _false_
text_as_children: true # true / _false_
tags_as_children: true # _true_ / false
The default is to generate the tags matched by the xpath expression only.
- When text_as_children is set to true, text nodes will be generated that contain the text
contained in the matched tags.
- When attribs_as_children is set to true, attribute nodes will be generated from the attributes
of the matched tags.
Namespaces
----------
Notes
-----
The default is to take the namespace map from the current node and use it in xpath queries.
Because default namespaces cannot be handled by xpath, it is possible to remap the default namespace
using the key "default_namespace".
The key "nsmap" can be used to define additional nsmap entries.
using the key ``default_namespace``.
The key ``nsmap`` can be used to define additional nsmap entries.
"""
if not isinstance(element, XMLTagElement):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment