Changes

Jump to: navigation, search

Addon:Lxml Gramplet

4,254 bytes added, 02:45, 22 March 2022
Example Screenshot results
{{Third-party plugin}}
{{man warn|[[Lxml_GrampletAddon:Lxml Gramplet#Installation|Manual installation and Prerequisites required]]|You can get a copy of from the Addon repository:
https://github.com/gramps-project/addons-source/tree/master/lxml
[[File:Lxml-Gramplet-detached-addon-51.png|right|thumb|450px|lxml Gramplet addon detached from Dashboard]]
[[File:Etree-Gramplet-detached-addon-51.png|right|thumb|450px|etree Gramplet addon detached from Dashboard]]
[[File:Lxml-Gramplet-is-it-a-gramps-51.png|right|thumb|450px|lxml Gramplet addon - "Is it a .gramps? " - warning message]][[File:Lxml-Gramplet-XSD-validation-lxml-warning-51.png|right|thumb|450px|lxml Gramplet addon - "XSD validation (lxml)" - warning message]]{{man label|[[Lxml_GrampletAddon:Lxml Gramplet#Lxml_Grampletlxml_Gramplet|lxml Gramplet]]}} is an experimental [[Gramplets|gramplet]] working under [[Gramps_Glossary#posix|POSIX]] platform(s), which reads, writes (''not the original one; safe read only state''), transforms content of our [[Gramps XML]] file on the fly without an import into our database (Gramps session).
Includes the {{man label|[[Lxml_GrampletAddon:Lxml Gramplet#etree_Gramplet|etree Gramplet]]}} for testing the ''Python ElementTree module''(etree) with Gramps XML.
Add these addons to the Gramps Dashboard.
Load a saved Gramps XML backup ( *.gramps ) and select the {{man button|Run}} buttonAs these addons are standalone, you do not need an open family tree/database to use them.
Currently, this addon quickly explores multiple waysLoad a saved Gramps XML backup ( *. Feel free to modify for your own usegramps ) file and select the {{man button|Run}} button.
For '''testing only''', by design these [https://docsIf the Gramps XML backup ( *.pythongramps )file is not valid you will get an "Is it a .org/3/library/xml.html#xml-vulnerabilities actions are not for productiongramps?" [file]warning message otherwise the file is copied and the lxml Gramplet attempts XSD validation (lxml) before continuing.
* lxml Gramplet - Gramplet for testing lxml and XSLT
Currently, this addon quickly explores multiple ways. Feel free to modify for your own use.
 
For '''testing only''', by design these [https://docs.python.org/3/library/xml.html#xml-vulnerabilities actions are not for production].
====Goals====
====Goals====
Includes the {{man label|[[Lxml_GrampletAddon:Lxml Gramplet#etree_Gramplet|etree Gramplet]]}} for testing the ''Python ElementTree module''(etree) with Gramps XML. 
== Installation ==
=== Prerequisites ===
==== lxml Gramplet ====Before this the lxml Gramplet can be used you will need the following prerequisites installed:
* [http://lxml.de/ lxml] is a Pythonic binding for the C libraries [http://xmlsoft.org/ libxml2]
Both are known for good speed performances by using C-level ([http://www.cython.org/ Cython]).
==== etree Gramplet ==== No extra prerequisites are required. ==Gramps XML file format===* The [[Gramps XML]] file format is robust and well [[Gramps XML#Gramps_XML_Resources|documented]].
==Example Screenshot results==
[[File:lxml_output.png|600px|thumb|left|Dynamic output]]
<br clear="all"/>{{-}}
* Local output without stylesheet
[[File:lxml_no_stylesheet.png|600px|thumb|left|Dynamic output without stylesheet]]
<br clear="all"/>{{-}}
* View via the Gramps [[Addon:HtmlView|HTML view]] addon
[[File:lxml_gramps.png|600px|thumb|left|Within Gramps]]
<br clear="all"/>{{-}}
* Pseudo dynamic code generation (xml + xslt = html file)
[[File:lxml_dynamic_code.png|600px|thumb|left|Dynamic code geneartiongeneration]]
<br clear="all"/>{{-}}
* Action on surname (sort, remove duplicated)
[[File:lxml_slist.png|600px|thumb|left|Sorted surnames list]]
<br clear="all"/>{{-}}
* Action on place title (sort, enable cross search on place fields)
[[File:lxml_plist.png|600px|thumb|left|Sorted places list]]
<br clear="all"/>{{-}}
* Hardcoded list written in python and translated by Gramps into our locale (if translation exists)
* Gtk3
GTK+3 provides an [httphttps://gitdocs.gnomegtk.org/browsegtk3/gtk+broadway.html GDK Broadway /log/?h=broadway HTML backend] that allows GTK applications to run natively within an HTML5 web navigator.
See [http://people.gnome.org/%7Ealexl/broadway-screencast.ogg sample1], [http://youtu.be/AO-qca9ddqg sample2], [http://www.youtube.com/watch?v=hhMFD3ZCrIc sample3].
=Issues=
* Help buttons does for both Gramplets doe not go to this page.==lxml Gramplet==
* With the "lxml Gramplet" if you don't load a valid file or just press run without selecting a file you get an error message popup that states "Is it a .gramps ?" and "Cannot copy "D:\filepath\...\test.gramps" then the "Error Report wizard is shown with the error message "110858: ERROR:lxmlGramplet.py line 284:Cannot copy the file"
* With the "lxml Gramplet" loading a *.gramps file causes:
<pre>
201660: ERROR: grampsapp.py: line 174: Unhandled exception
Traceback (most recent call last):
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\lxmlGramplet.py", line 295, in ReadXML
self.xsd(xsd, filename)
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\lxmlGramplet.py", line 540, in xsd
tree = etree.parse(filename)
File "src/lxml/etree.pyx", line 3444, in lxml.etree.parse (src/lxml/etree.c:83170)
File "src/lxml/parser.pxi", line 1834, in lxml.etree._parseDocument (src/lxml/etree.c:120742)
File "src/lxml/parser.pxi", line 1860, in lxml.etree._parseDocumentFromURL (src/lxml/etree.c:121089)
File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDocFromFile (src/lxml/etree.c:119997)
File "src/lxml/parser.pxi", line 1161, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/etree.c:114546)
File "src/lxml/parser.pxi", line 598, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/etree.c:107723)
File "src/lxml/parser.pxi", line 709, in lxml.etree._handleParseResult (src/lxml/etree.c:109432)
File "src/lxml/parser.pxi", line 638, in lxml.etree._raiseParseError (src/lxml/etree.c:108286)
File "file:/D:/PortableApps/GrampsPortable/Data/settings/gramps/gramps51/plugins/lxml/test.xml", line 1
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\lxmlGramplet.py", line 239, in run
self.ReadXML(entry)
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\lxmlGramplet.py", line 299, in ReadXML
LOG.debug(self.xsd(xsd, filename))
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\lxmlGramplet.py", line 540, in xsd
tree = etree.parse(filename)
File "src/lxml/etree.pyx", line 3444, in lxml.etree.parse (src/lxml/etree.c:83170)
File "src/lxml/parser.pxi", line 1834, in lxml.etree._parseDocument (src/lxml/etree.c:120742)
File "src/lxml/parser.pxi", line 1860, in lxml.etree._parseDocumentFromURL (src/lxml/etree.c:121089)
File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDocFromFile (src/lxml/etree.c:119997)
File "src/lxml/parser.pxi", line 1161, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/etree.c:114546)
File "src/lxml/parser.pxi", line 598, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/etree.c:107723)
File "src/lxml/parser.pxi", line 709, in lxml.etree._handleParseResult (src/lxml/etree.c:109432)
File "src/lxml/parser.pxi", line 638, in lxml.etree._raiseParseError (src/lxml/etree.c:108286)
File "file:/D:/PortableApps/GrampsPortable/Data/settings/gramps/gramps51/plugins/lxml/test.xml", line 1
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
</pre>
==etree Gramplet==
* with etree gramplet loading a *.gramps file causes:
<pre>65808: ERROR: grampsapp.py: line 174: Unhandled exception
Traceback (most recent call last):
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\etreeGramplet.py", line 223, in run
self.ReadXML(entry)
File "D:\PortableApps\GrampsPortable\Data\settings\gramps\gramps51\plugins\lxml\etreeGramplet.py", line 265, in ReadXML
tree = ElementTree.parse(filename)
File "AIO/xml/etree/ElementTree.py", line 1196, in parse
File "AIO/xml/etree/ElementTree.py", line 597, in parse
File "<string>", line None
xml.etree.ElementTree.ParseError: no element found: line 1, column 0</pre>
[[Category:Plugins]]
[[Category:Developers/General]]
[[Category:Gramplets]]
1,969
edits

Navigation menu