Difference between revisions of "Customize reports with XML tool"
JohnRSibert (talk | contribs) (Initial commit of How To for managing xml) |
m (Move Category tag to bottom) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
---- | ---- | ||
+ | {{Languages|Customize_reports_with_XML_tool}} | ||
+ | {{man warn|1=🚧 Work In Progress|2=This wikipage is an outline from a template being roughed in. Please don't edit '''''just yet'''''. Instead, contribute suggestions on the Discussion page. <br /><br />This page is not planned be linked to a public page until about 2 weeks after 26 March 2021. <br /><br />If this notice remains after that date, please feel welcome to remove this notice and consider the content 'fair game' for unlimited editing.}} | ||
+ | Families often have complicated structures, especially for Twenty-first century blended families. Generating reports that include the various relatives will yield a more complete picture of the family. | ||
− | + | This article offers a less manual method to configure a Report's options as an alternative to the Gramps report interface. | |
+ | == Family Lines Graph == | ||
− | + | Creating a [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_5#Family_Lines_Graph|Family Lines Graph]] often involves carefully selecting multiple people to include, this is a slow process that recursively loads the Select Person dialog. | |
− | |||
− | |||
− | |||
− | + | Gramps stores these selections in a file named <code>report_options.xml</code> in the <code>~/.gramps</code> [[Gramps_{{man version}}_Wiki_Manual_-_User_Directory|User directory]]. The report options are '''overwritten''' every time a graphical report is created. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | It is possible to edit this file manually with a text editor, but that is a tedious and error-prone procedure. | |
− | |||
− | |||
+ | ==Create a Bash script== | ||
+ | The following [https://wikipedia.org/wiki/Bash_(Unix_shell) bash] script will take care of the process for Linux users. It includes backing up the current file and saving the list of Person IDs in a file that can be reused. | ||
− | |||
− | |||
<pre> | <pre> | ||
− | |||
− | |||
− | |||
− | |||
− | + | #!/bin/bash | |
− | + | if [ $# -lt 1 ];then | |
− | + | echo "Utility to replace list of People of Interest in Gramps Family Lines Graph." | |
+ | echo "The file 'report_options.xml' is overwritten after making a backup." | ||
+ | echo "The current list of People of Interest is saved for possible reuse" | ||
+ | echo "Usage: "$0" current_pid [new_pid]" | ||
+ | echo " current_pid is the file name in which to save current pid list" | ||
+ | echo " Optional. If present, new_pid is the name of the file containing" | ||
+ | echo " the new pid list" | ||
+ | echo " eg " $0" bigfamily.pid three_gen.pid" | ||
+ | exit 1 | ||
+ | fi | ||
− | + | gramps_home=~/.gramps/ | |
− | + | #echo "gramps_home = "$gramps_home | |
+ | opts=$gramps_home"report_options.xml" | ||
+ | #echo "opts = "$opts | ||
+ | bak=$opts".bak" | ||
+ | #echo "bak = "$bak | ||
− | + | echo "Backing up "$opts " to " $bak | |
− | + | cp -irp $opts $bak | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | echo "Saving current pid list to "$gramps_home$1 | |
− | + | lxprintf -e 'module[@name="familylines_graph"]/option[@name="gidlist"]'\ | |
− | + | "%s\n" @value $opts > $gramps_home$1 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | echo "Replacing pids in "$opts | |
− | + | echo " with the contents of "$gramps_home$2 | |
− | |||
− | |||
− | |||
− | + | # replacing the xml in situ does not seem to work correctly | |
− | + | # instead send it to a temporary file and copy | |
− | + | lxreplace -q \ | |
+ | 'module[@name="familylines_graph"]/option[@name="gidlist"]' \ | ||
+ | -@ '"value"' "'`cat $gramps_home$2`'" \ | ||
+ | ~/.gramps/report_options.xml > /tmp/temp.xml | ||
− | + | cp -fv /tmp/temp.xml $opts 2>>/dev/null | |
+ | echo "Updated "$opts | ||
− | + | </pre> | |
+ | ==Using the script== | ||
+ | Copy the this code into a file, or get the most [https://github.com/johnrsibert/Grampsish/blob/main/fix_fl_people.sh recent version] of the script from [https://github.com/ github], and save it to a directory on your [http://www.linfo.org/path_env_var.html PATH]. | ||
− | + | You will also need the [https://www.ltg.ed.ac.uk/software/ltxml2/ LTXML2 Toolkit] from the Language Technology Group at Edinburgh University. | |
− | + | ==See also== | |
− | + | * 18 Mar 2021 [https://sourceforge.net/p/gramps/mailman/gramps-users/thread/3fdb89de-f1c0-ead9-5080-c02706f4ffe9%40silmaril.ie/#msg37243313 Family Lines Graph] message thread in the [https://sourceforge.net/p/gramps/mailman/gramps-users/ Gramps-users maillist archive] | |
− | + | [[Category:How do I...]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [https:// |
Latest revision as of 14:49, 28 March 2021
Families often have complicated structures, especially for Twenty-first century blended families. Generating reports that include the various relatives will yield a more complete picture of the family.
This article offers a less manual method to configure a Report's options as an alternative to the Gramps report interface.
Family Lines Graph
Creating a Family Lines Graph often involves carefully selecting multiple people to include, this is a slow process that recursively loads the Select Person dialog.
Gramps stores these selections in a file named report_options.xml
in the ~/.gramps
User directory. The report options are overwritten every time a graphical report is created.
It is possible to edit this file manually with a text editor, but that is a tedious and error-prone procedure.
Create a Bash script
The following bash script will take care of the process for Linux users. It includes backing up the current file and saving the list of Person IDs in a file that can be reused.
#!/bin/bash if [ $# -lt 1 ];then echo "Utility to replace list of People of Interest in Gramps Family Lines Graph." echo "The file 'report_options.xml' is overwritten after making a backup." echo "The current list of People of Interest is saved for possible reuse" echo "Usage: "$0" current_pid [new_pid]" echo " current_pid is the file name in which to save current pid list" echo " Optional. If present, new_pid is the name of the file containing" echo " the new pid list" echo " eg " $0" bigfamily.pid three_gen.pid" exit 1 fi gramps_home=~/.gramps/ #echo "gramps_home = "$gramps_home opts=$gramps_home"report_options.xml" #echo "opts = "$opts bak=$opts".bak" #echo "bak = "$bak echo "Backing up "$opts " to " $bak cp -irp $opts $bak echo "Saving current pid list to "$gramps_home$1 lxprintf -e 'module[@name="familylines_graph"]/option[@name="gidlist"]'\ "%s\n" @value $opts > $gramps_home$1 echo "Replacing pids in "$opts echo " with the contents of "$gramps_home$2 # replacing the xml in situ does not seem to work correctly # instead send it to a temporary file and copy lxreplace -q \ 'module[@name="familylines_graph"]/option[@name="gidlist"]' \ -@ '"value"' "'`cat $gramps_home$2`'" \ ~/.gramps/report_options.xml > /tmp/temp.xml cp -fv /tmp/temp.xml $opts 2>>/dev/null echo "Updated "$opts
Using the script
Copy the this code into a file, or get the most recent version of the script from github, and save it to a directory on your PATH.
You will also need the LTXML2 Toolkit from the Language Technology Group at Edinburgh University.
See also
- 18 Mar 2021 Family Lines Graph message thread in the Gramps-users maillist archive