OSGeo / grass-addons

GRASS GIS Addons Repository
https://grass.osgeo.org/grass-stable/manuals/addons/
GNU General Public License v2.0
103 stars 154 forks source link

[Bug] wx.metadata XML templates fail with xmllint #625

Open wenzeslaus opened 3 years ago

wenzeslaus commented 3 years ago

Name of the addon

wx.metadata

Describe the bug

xmllint reports various errors on the XML templates used by wx.metadata.

To Reproduce

xmllint src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml
xmllint src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml

Expected behavior XML files pass linting by xmllint or the templates are not stored as XML files if they can't be validated as XMLs (ideally suggest a different linter in that case).

Screenshots

From the XML check in Super-Linter:

File:[./src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml]
ERROR! Found errors in [xmllint] linter!
ERROR:[./src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml:12: parser error : attributes construct error
t/ML_gmxCodelists.xml#LanguageCode" codeListValue="{{ md.languagecode }}{# tag="
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml:12: parser error : Couldn't find end of Start Tag LanguageCode line 12
t/ML_gmxCodelists.xml#LanguageCode" codeListValue="{{ md.languagecode }}{# tag="
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml:12: parser error : Opening and ending tag mismatch: language line 7 and LanguageCode
, group = "Metadata",multiline=False #}">{{ md.languagecode }}</gmd:LanguageCode
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml:13: parser error : Opening and ending tag mismatch: MD_Metadata line 7 and language
    </gmd:language>
                   ^
./src/gui/wxpython/wx.metadata/profiles/inspireProfile.xml:14: parser error : Extra content at the end of the document
    <gmd:hierarchyLevel>
    ^]
---------------------------
File:[./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml]
ERROR! Found errors in [xmllint] linter!
ERROR:[./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:27: parser error : attributes construct error
rces/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="{{ co.role }}{# tag="
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:27: parser error : Couldn't find end of Start Tag CI_RoleCode line 27
rces/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="{{ co.role }}{# tag="
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:27: parser error : Opening and ending tag mismatch: role line 11 and CI_RoleCode
",database="role"  #}" codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:28: parser error : Opening and ending tag mismatch: CI_ResponsibleParty line 11 and role
            </gmd:role>
                       ^
./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:29: parser error : Opening and ending tag mismatch: contact line 11 and CI_ResponsibleParty
        </gmd:CI_ResponsibleParty>
                                  ^
./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:30: parser error : Opening and ending tag mismatch: MD_Metadata line 11 and contact
    </gmd:contact>
                  ^
./src/gui/wxpython/wx.metadata/profiles/basicProfile.xml:31: parser error : Extra content at the end of the document
  {% endfor -%}
  ^]
---------------------------
File:[./src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml]
ERROR! Found errors in [xmllint] linter!
ERROR:[./src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml:13: parser error : attributes construct error
t/ML_gmxCodelists.xml#LanguageCode" codeListValue="{{ md.languagecode }}{# tag="
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml:13: parser error : Couldn't find end of Start Tag LanguageCode line 13
t/ML_gmxCodelists.xml#LanguageCode" codeListValue="{{ md.languagecode }}{# tag="
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml:13: parser error : Opening and ending tag mismatch: language line 8 and LanguageCode
, group = "Metadata",multiline=False #}">{{ md.languagecode }}</gmd:LanguageCode
                                                                               ^
./src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml:14: parser error : Opening and ending tag mismatch: MD_Metadata line 8 and language
    </gmd:language>
                   ^
./src/gui/wxpython/wx.metadata/profiles/temporalProfile.xml:15: parser error : Extra content at the end of the document
    <gmd:hierarchyLevel>
    ^]
---------------------------

Additional context Super-Linter check in CI introduced in #618.

ItsAdityaKSingh commented 2 years ago

Hey @wenzeslaus. I would like to work on this issue. But I would need some guidance.

wenzeslaus commented 2 years ago

Welcome @ItsAdityaKSingh! This basically needs either 1) different linter (correctness checker) of XML than xmllint, 2) some configuration settings for xmllint which Super-Linter will accept, or 3) change extension of the files so it is clear to xmllint that it is a template, not are ready-to-use XML.

The third option seems like the simplest to me and perhaps the most correct. It would be nice to have some linting (checking) for the XML template as well if possible.

In any case, to address this, you need to check XML validation in Super-Linter, xmllint, and what would be appropriate file extension for these XML templates, then do what seems to be most right, and open a pull request with your reasoning for the change. It is a simple problem and likely a simple change, so you don't have to go overboard with the analysis.

The change should include VALIDATE_XML: true on the line 31 of .github/workflows/super-linter.yml. This will enable the XML check and the check should pass (you will see if it does once you open a PR and the check runs).

ItsAdityaKSingh commented 2 years ago

Thanks a lot @wenzeslaus for the great insight into this issue. I am grateful to you for doing so but I realise I will need a more basic idea about how things are working in this project. Could you guide me in a direction for doing so, so I could learn and come back to addressing issues such as these with ease. What requirements would I need to complete to be able to? Thanks in advance!

wenzeslaus commented 2 years ago

This issue does not require you to compile or test GRASS GIS locally, so you can leave all that for later. You just need to focus on making the change

Get Git on your computer. Learn how to use it with GitHub. (Plenty of guides online, so just pick what suits you. Official GitHub documentation is pretty good.) Get the source code of this repo. Make the change. A rough guide is here:

A rough outline is here, but it is meant for command line and larger contributions.

https://github.com/OSGeo/grass-addons/blob/grass8/CONTRIBUTING.md

If Git locally is a too big issue to start with, you can try your luck with using the GitHub web interface only. You can do all file edits and renames there as well. In that case, this would be the starting point:

https://github.com/OSGeo/grass-addons/tree/grass8/src/gui/wxpython/wx.metadata/profiles

Hit Edit (the pen icon). Make the change. Go down to Commit changes. It will ask you to create a fork, branch, pull request; you want to do all that (it will do it for you). Then you need to get to some Open pull request (or perhaps submit) button. At that point, the PR will appear in this repo and the right people will be notified. (Again, see GitHub documentation or some blog post for details.)

ItsAdityaKSingh commented 2 years ago

I am comfortable with using Git and Github both online and offline. I wanted to learn more about this project and it's codebase. Regarding that, I would need a guidance to start working on issues!

wenzeslaus commented 2 years ago

This is pretty independent on anything else in the project - hence the good first issue label :-). You are welcome to read Contribute: Development on the website. There are no specific instructions for XMLs since they are not really that prominent in the project, so submitting guidelines focus on other things, but they do contain general notes. In general, most contributors are using this project or know how to, but for this issue it is not needed. However, you can run one of the example notebooks in Binder (you may need to wait some time for it to build the image).