From 0a9ee763b22c146727d14a50da0c5bbc82e70435 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 27 Sep 2021 10:30:58 +0200 Subject: docs/manual, Meson config: Check if xmllint can be used --- Makefile.am | 1 + docs/manual/can_use_xmllint.xml | 15 +++++++++++++++ docs/manual/meson.build | 18 ++++++++++++++++++ meson.build | 2 +- tools/tutorial-custom-cmd.py | 12 +++++++++++- 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 docs/manual/can_use_xmllint.xml diff --git a/Makefile.am b/Makefile.am index 9a6f4a8..0d9e4e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,6 +45,7 @@ EXTRA_DIST = \ meson_options.txt \ sigc++config.h.meson \ MSVC_NMake/meson.build \ + docs/manual/can_use_xmllint.xml \ docs/manual/meson.build \ docs/reference/meson.build \ examples/meson.build \ diff --git a/docs/manual/can_use_xmllint.xml b/docs/manual/can_use_xmllint.xml new file mode 100644 index 0000000..8ff1b0d --- /dev/null +++ b/docs/manual/can_use_xmllint.xml @@ -0,0 +1,15 @@ + + + +xmllint test + + +Introduction + + This is a short DocBook V5.0 document. It can be used for testing if the installed + version of xmllint or a similar program can validate a DocBook V5.0 document. + + + + diff --git a/docs/manual/meson.build b/docs/manual/meson.build index bc98af9..d2f97b9 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -24,6 +24,24 @@ if not build_documentation subdir_done() endif +# Check if xmllint can be used. +if xmllint.found() + can_parse_and_validate = run_command( + python3, tutorial_custom_cmd, 'xmllint', + validate, + meson.current_source_dir() / 'can_use_xmllint.xml', + meson.current_build_dir() / 'can_use_xmllint.stamp', + ).returncode() == 0 + if not can_parse_and_validate + # The DocBook V5.0 package is called docbook5-xml in Ubuntu, + # docbook5-schemas in Fedora. It may have other names in other distros. + warning('Can\'t validate XML file.\n' + + 'xmllint does not support Relax NG schemas and DocBook V5.0.\n' + + 'DocBook V5.0 support may require docbook5-xml, docbook5-schemas or a similar package.' + ) + endif +endif + install_data('..' / 'index.html', install_dir: install_docdir) install_data('..' / 'images' / 'libsigc_logo.gif', '..' / 'images' / 'top.gif', diff --git a/meson.build b/meson.build index bc8d264..2c8b829 100644 --- a/meson.build +++ b/meson.build @@ -291,7 +291,7 @@ endif validate = get_option('validation') and can_parse_and_validate explain_val = '' if get_option('validation') and not validate - explain_val = ' (requires xmllint)' + explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)' endif build_pdf = build_pdf_by_default and can_build_pdf diff --git a/tools/tutorial-custom-cmd.py b/tools/tutorial-custom-cmd.py index 50b6a5b..c102968 100755 --- a/tools/tutorial-custom-cmd.py +++ b/tools/tutorial-custom-cmd.py @@ -65,6 +65,13 @@ def xmllint(): stamp_file_path = sys.argv[4] relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng' + # schematron_schema = 'http://docbook.org/xml/5.0/sch/docbook.sch' + + # Validation against the Schematron schema does not work on Ubuntu 21.04: + # file:///usr/share/xml/docbook/schema/schematron/5.0/docbook.sch:6: element rule: + # Schemas parser error : Failed to compile context expression db:firstterm[@linkend] + # ..... + # Schematron schema http://docbook.org/xml/5.0/sch/docbook.sch failed to compile cmd = [ 'xmllint', @@ -73,7 +80,10 @@ def xmllint(): '--xinclude', ] if validate == 'true': - cmd += ['--relaxng', relax_ng_schema] + cmd += [ + '--relaxng', relax_ng_schema, + #'--schematron', schematron_schema, + ] cmd += [input_xml_file] result = subprocess.run(cmd) if result.returncode: -- cgit v1.2.1