Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5d93ce2

Browse files
committed
doc: Check DocBook XML validity during the build
Building the documentation with XSLT does not check the DTD, like a DSSSL build would. One can often get away with having invalid XML, but the stylesheets might then create incorrect output, as they are not designed to handle that. Therefore, check the validity of the XML against the DTD, using xmllint, during the build. Add xmllint detection to configure, and add some documentation. xmllint comes with libxml2, which is already in use, but it might be in a separate package, such as libxml2-utils on Debian. Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr>
1 parent f43afbc commit 5d93ce2

File tree

5 files changed

+68
-2
lines changed

5 files changed

+68
-2
lines changed

configure

+43
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ vpath_build
630630
PROVE
631631
OSX
632632
XSLTPROC
633+
XMLLINT
633634
DBTOEPUB
634635
COLLATEINDEX
635636
DOCBOOKSTYLE
@@ -14654,6 +14655,48 @@ fi
1465414655
test -n "$DBTOEPUB" && break
1465514656
done
1465614657

14658+
for ac_prog in xmllint
14659+
do
14660+
# Extract the first word of "$ac_prog", so it can be a program name with args.
14661+
set dummy $ac_prog; ac_word=$2
14662+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
14663+
$as_echo_n "checking for $ac_word... " >&6; }
14664+
if ${ac_cv_prog_XMLLINT+:} false; then :
14665+
$as_echo_n "(cached) " >&6
14666+
else
14667+
if test -n "$XMLLINT"; then
14668+
ac_cv_prog_XMLLINT="$XMLLINT" # Let the user override the test.
14669+
else
14670+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14671+
for as_dir in $PATH
14672+
do
14673+
IFS=$as_save_IFS
14674+
test -z "$as_dir" && as_dir=.
14675+
for ac_exec_ext in '' $ac_executable_extensions; do
14676+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
14677+
ac_cv_prog_XMLLINT="$ac_prog"
14678+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
14679+
break 2
14680+
fi
14681+
done
14682+
done
14683+
IFS=$as_save_IFS
14684+
14685+
fi
14686+
fi
14687+
XMLLINT=$ac_cv_prog_XMLLINT
14688+
if test -n "$XMLLINT"; then
14689+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $XMLLINT" >&5
14690+
$as_echo "$XMLLINT" >&6; }
14691+
else
14692+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14693+
$as_echo "no" >&6; }
14694+
fi
14695+
14696+
14697+
test -n "$XMLLINT" && break
14698+
done
14699+
1465714700
for ac_prog in xsltproc
1465814701
do
1465914702
# Extract the first word of "$ac_prog", so it can be a program name with args.

configure.in

+1
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,7 @@ PGAC_CHECK_DOCBOOK(4.2)
18691869
PGAC_PATH_DOCBOOK_STYLESHEETS
18701870
PGAC_PATH_COLLATEINDEX
18711871
AC_CHECK_PROGS(DBTOEPUB, dbtoepub)
1872+
AC_CHECK_PROGS(XMLLINT, xmllint)
18721873
AC_CHECK_PROGS(XSLTPROC, xsltproc)
18731874
AC_CHECK_PROGS(OSX, [osx sgml2xml sx])
18741875

doc/src/sgml/Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ ifndef OSX
4444
OSX = $(missing) osx
4545
endif
4646

47+
ifndef XMLLINT
48+
XMLLINT = $(missing) xmllint
49+
endif
50+
4751
ifndef XSLTPROC
4852
XSLTPROC = $(missing) xsltproc
4953
endif
@@ -78,6 +82,7 @@ override SPFLAGS += -wall -wno-unused-param -wno-empty -wfully-tagged
7882
man distprep-man: man-stamp
7983

8084
man-stamp: stylesheet-man.xsl postgres.xml
85+
$(XMLLINT) --noout --valid postgres.xml
8186
$(XSLTPROC) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $^
8287
touch $@
8388

@@ -254,11 +259,13 @@ endif
254259
xslthtml: xslthtml-stamp
255260

256261
xslthtml-stamp: stylesheet.xsl postgres.xml
262+
$(XMLLINT) --noout --valid postgres.xml
257263
$(XSLTPROC) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_FLAGS) $^
258264
cp $(srcdir)/stylesheet.css html/
259265
touch $@
260266

261267
htmlhelp: stylesheet-hh.xsl postgres.xml
268+
$(XMLLINT) --noout --valid postgres.xml
262269
$(XSLTPROC) $(XSLTPROCFLAGS) $^
263270

264271
%-A4.fo.tmp: stylesheet-fo.xsl %.xml
@@ -268,7 +275,6 @@ htmlhelp: stylesheet-hh.xsl postgres.xml
268275
$(XSLTPROC) $(XSLTPROCFLAGS) --stringparam paper.type USletter -o $@ $^
269276

270277
FOP = fop
271-
XMLLINT = xmllint
272278

273279
# reformat FO output so that locations of errors are easier to find
274280
%.fo: %.fo.tmp
@@ -281,6 +287,7 @@ XMLLINT = xmllint
281287

282288
epub: postgres.epub
283289
postgres.epub: postgres.xml
290+
$(XMLLINT) --noout --valid $<
284291
$(DBTOEPUB) $<
285292

286293

doc/src/sgml/docguide.sgml

+15-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@
148148
</listitem>
149149
</varlistentry>
150150

151+
<varlistentry>
152+
<term><ulink url="http://xmlsoft.org/">Libxml2</ulink> for <command>xmllint</command></term>
153+
<listitem>
154+
<para>
155+
This library and the <command>xmllint</command> tool it contains are
156+
used for processing XML. Many developers will already
157+
have <application>Libxml2</application> installed, because it is also
158+
used when building the PostgreSQL code. Note, however,
159+
that <command>xmllint</command> might need to be installed from a
160+
separate subpackage.
161+
</para>
162+
</listitem>
163+
</varlistentry>
164+
151165
<varlistentry>
152166
<term><ulink url="http://xmlsoft.org/XSLT/">Libxslt</ulink> for <command>xsltproc</command></term>
153167
<listitem>
@@ -255,7 +269,7 @@ yum install docbook-dtds docbook-style-dsssl docbook-style-xsl libxslt openjade
255269
available for <productname>Debian GNU/Linux</productname>.
256270
To install, simply use:
257271
<programlisting>
258-
apt-get install docbook docbook-dsssl docbook-xsl openjade1.3 opensp xsltproc
272+
apt-get install docbook docbook-dsssl docbook-xsl libxml2-utils openjade1.3 opensp xsltproc
259273
</programlisting>
260274
</para>
261275
</sect2>

src/Makefile.global.in

+1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ DOCBOOKSTYLE = @DOCBOOKSTYLE@
353353
JADE = @JADE@
354354
NSGMLS = @NSGMLS@
355355
OSX = @OSX@
356+
XMLLINT = @XMLLINT@
356357
XSLTPROC = @XSLTPROC@
357358

358359
# Code coverage

0 commit comments

Comments
 (0)