Open prjemian opened 2 years ago
I'm running into this same issue with 0.3.0
and python 3.8.13
.
Is there a workaround that you would suggest for validating an NXDL XML file?
Thanks for the bump on this. The documentation has a big TODO marking and this basic suggestion:
user@host ~ $ xmllint --noout --schema nxdl.xsd base_classes/NXentry.nxdl.xml
base_classes/NXentry.nxdl.xml validates
This works if your working directory is the root of the NeXus definitions repository, so the files nxdl.xsd
and nxdlTypes.xsd
are in the local directory, as well as the subdrectories: applications
, base_classes
, contributed_definitions
Once this is re-implemented in punx, then punx will find those files and sub-directories for you. Internally, punx will call the library used by xmllint
for this same analysis.
Here's a view of that directory on my local development workstation:
(base) prjemian@zap:~/.../prjemian/punx$ ls ../../NeXus/definitions/
applications contributed_definitions jenkins_build manual package utils
base_classes COPYING legacy_docs nxdlTypes.xsd README.md www
build dev_tools LGPL.txt NXDL_VERSION requirements.txt
CHANGES.rst impatient-guide Makefile nxdl.xsd setup.cfg
Here's how it should work (but fails now):
!!! WARNING: this program is not ready for distribution.
Traceback (most recent call last):
File "/home/prjemian/micromamba/envs/bluesky_2022_3/bin/punx", line 33, in <module>
sys.exit(load_entry_point('punx', 'console_scripts', 'punx')())
File "/home/prjemian/Documents/projects/prjemian/punx/punx/main.py", line 441, in main
args.func(args)
File "/home/prjemian/Documents/projects/prjemian/punx/punx/main.py", line 198, in func_validate
result = validate.validate_xml(args.infile)
AttributeError: module 'punx.validate' has no attribute 'validate_xml'
The code exists (from a previous revision), but has been parked out of distribution since the last refactoring. It will be coming back:
(bluesky_2022_3) prjemian@zap:~/.../prjemian/punx$ git grep validate_xml
punx/ignore_now/main.py: result = validate.validate_xml(args.infile)
punx/ignore_now/nxdlstructure.py: validate.validate_xml(nxdl_file_name)
punx/ignore_now/validate.py: ~validate_xml
punx/ignore_now/validate.py:def validate_xml(xml_file_name):
punx/main.py: result = validate.validate_xml(args.infile)
punx/nxdl_manager.py:def validate_xml_tree(xml_tree):
punx/nxdl_manager.py: validate_xml_tree(lxml_tree)
punx/reserved_code.txt:# validate_xml_tree(self.lxml_tree)
punx/tests/test_nxdl_manager.py: nxdl_manager.validate_xml_tree(tree)
punx/tests/test_nxdl_manager.py: # nxdl_manager.validate_xml_tree(tree)
tests/ignore_now/validate_test.py_: def test_validate_xml___with_invalid_xml_file(self):
tests/ignore_now/validate_test.py_: punx.validate.validate_xml, self.test_file)
tests/ignore_now/validate_test.py_: def test_validate_xml___with_invalid_NXDL_file(self):
tests/ignore_now/validate_test.py_: punx.validate.validate_xml,
Aha, this looks straightforward. Will give it a try with xmllint
.
Thanks for pointing this out. :)
It is an expected feature of punx that it be able to validate NXDL files. Today, this failed:
Noting this version: