Skip to content

Commit 298163a

Browse files
committed
docs/docs/manual, Meson config: Check if xmllint can be used
1 parent f993cc8 commit 298163a

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ EXTRA_DIST = \
5050
meson_options.txt \
5151
sigc++config.h.meson \
5252
MSVC_NMake/meson.build \
53+
docs/docs/manual/can_use_xmllint.xml \
5354
docs/docs/manual/meson.build \
5455
docs/docs/reference/meson.build \
5556
examples/meson.build \

docs/docs/manual/can_use_xmllint.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<book xmlns="http://docbook.org/ns/docbook"
3+
version="5.0" xml:id="index" xml:lang="en">
4+
5+
<title>xmllint test</title>
6+
7+
<chapter xml:id="chapter-introduction">
8+
<title>Introduction</title>
9+
<para>
10+
This is a short DocBook V5.0 document. It can be used for testing if the installed
11+
version of xmllint or a similar program can validate a DocBook V5.0 document.
12+
</para>
13+
</chapter>
14+
15+
</book>

docs/docs/manual/meson.build

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ if not build_documentation
2424
subdir_done()
2525
endif
2626

27+
# Check if xmllint can be used.
28+
if xmllint.found()
29+
can_parse_and_validate = run_command(
30+
python3, tutorial_custom_cmd, 'xmllint',
31+
validate,
32+
meson.current_source_dir() / 'can_use_xmllint.xml',
33+
meson.current_build_dir() / 'can_use_xmllint.stamp',
34+
).returncode() == 0
35+
if not can_parse_and_validate
36+
# The DocBook V5.0 package is called docbook5-xml in Ubuntu,
37+
# docbook5-schemas in Fedora. It may have other names in other distros.
38+
warning('Can\'t validate XML file.\n' +
39+
'xmllint does not support Relax NG schemas and DocBook V5.0.\n' +
40+
'DocBook V5.0 support may require docbook5-xml, docbook5-schemas or a similar package.'
41+
)
42+
endif
43+
endif
44+
2745
doc_dist_dir = 'untracked' / 'docs' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT
2846

2947
sigc_manual_xml = 'libsigc_manual.xml'

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ endif
288288
validate = get_option('validation') and can_parse_and_validate
289289
explain_val = ''
290290
if get_option('validation') and not validate
291-
explain_val = ' (requires xmllint)'
291+
explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)'
292292
endif
293293

294294
build_pdf = build_pdf_by_default and can_build_pdf

tools/tutorial-custom-cmd.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ def xmllint():
6565
stamp_file_path = sys.argv[4]
6666

6767
relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng'
68+
# schematron_schema = 'http://docbook.org/xml/5.0/sch/docbook.sch'
69+
70+
# Validation against the Schematron schema does not work on Ubuntu 21.04:
71+
# file:///usr/share/xml/docbook/schema/schematron/5.0/docbook.sch:6: element rule:
72+
# Schemas parser error : Failed to compile context expression db:firstterm[@linkend]
73+
# .....
74+
# Schematron schema http://docbook.org/xml/5.0/sch/docbook.sch failed to compile
6875

6976
cmd = [
7077
'xmllint',
@@ -73,7 +80,10 @@ def xmllint():
7380
'--xinclude',
7481
]
7582
if validate == 'true':
76-
cmd += ['--relaxng', relax_ng_schema]
83+
cmd += [
84+
'--relaxng', relax_ng_schema,
85+
#'--schematron', schematron_schema,
86+
]
7787
cmd += [input_xml_file]
7888
result = subprocess.run(cmd)
7989
if result.returncode:

0 commit comments

Comments
 (0)