Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
97906568
Commit
97906568
authored
9 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Fix docstring formatting
parent
3f57958e
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!181
Release 0.9.0
,
!174
XML Converter
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/__init__.py
+1
-1
1 addition, 1 deletion
src/caoscrawler/__init__.py
src/caoscrawler/xml_converter.py
+24
-18
24 additions, 18 deletions
src/caoscrawler/xml_converter.py
with
25 additions
and
19 deletions
src/caoscrawler/__init__.py
+
1
−
1
View file @
97906568
from
.
import
converters
,
utils
from
.
import
converters
,
utils
,
xml_converter
try
:
from
.conv_impl.spss
import
SPSSConverter
except
ImportError
as
err
:
...
...
This diff is collapsed.
Click to expand it.
src/caoscrawler/xml_converter.py
+
24
−
18
View file @
97906568
...
...
@@ -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.
N
amespac
es
-----
-----
N
ot
es
-----
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment