Skip to content

Commit b49f738

Browse files
committed
docs/manual, Meson config: Check if xmllint can be used
1 parent 3ddf3ae commit b49f738

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
@@ -30,6 +30,7 @@ EXTRA_DIST = \
3030
meson_options.txt \
3131
libxml++config.h.meson \
3232
MSVC_NMake/libxml++/meson.build \
33+
docs/manual/can_use_xmllint.xml \
3334
docs/manual/insert_example_code.py \
3435
docs/manual/meson.build \
3536
docs/reference/meson.build \

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/manual/meson.build

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

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

3048
# Create a DocBook XML file with the examples' source code included.

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ endif
365365
validate = get_option('validation') and can_parse_and_validate
366366
explain_val = ''
367367
if get_option('validation') and not validate
368-
explain_val = ' (requires xmllint)'
368+
explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)'
369369
endif
370370

371371
build_pdf = build_pdf_by_default and can_build_pdf

tools/build_scripts/tutorial-custom-cmd.py

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

7777
relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng'
78+
# schematron_schema = 'http://docbook.org/xml/5.0/sch/docbook.sch'
79+
80+
# Validation against the Schematron schema does not work on Ubuntu 21.04:
81+
# file:///usr/share/xml/docbook/schema/schematron/5.0/docbook.sch:6: element rule:
82+
# Schemas parser error : Failed to compile context expression db:firstterm[@linkend]
83+
# .....
84+
# Schematron schema http://docbook.org/xml/5.0/sch/docbook.sch failed to compile
7885

7986
cmd = [
8087
'xmllint',
@@ -83,7 +90,10 @@ def xmllint():
8390
'--xinclude',
8491
]
8592
if validate == 'true':
86-
cmd += ['--relaxng', relax_ng_schema]
93+
cmd += [
94+
'--relaxng', relax_ng_schema,
95+
#'--schematron', schematron_schema,
96+
]
8797
cmd += [input_xml_file]
8898
result = subprocess.run(cmd)
8999
if result.returncode:

0 commit comments

Comments
 (0)