- Add support for Schematron validation
- Add a simple Schematron file that validates file references - Silence the output of validation so that the result be more readable
This commit is contained in:
parent
eb47c46865
commit
44368e5859
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/projects/xml-tools/; revision=41205
2 changed files with 48 additions and 3 deletions
|
@ -85,8 +85,12 @@ XSLXHTMLCHUNK?= ${DOC_PREFIX}/${LANGCODE}/share/xsl/freebsd-xhtml-chunk.xsl
|
|||
XSLEPUB?= ${DOC_PREFIX}/${LANGCODE}/share/xsl/freebsd-epub.xsl
|
||||
XSLFO?= ${DOC_PREFIX}/${LANGCODE}/share/xsl/freebsd-fo.xsl
|
||||
|
||||
XSLSCH?= /usr/local/share/xsl/iso-schematron/xslt1/iso_schematron_skeleton_for_xslt1.xsl
|
||||
|
||||
IMAGES_LIB?=
|
||||
|
||||
SCHEMATRONS?= ${DOC_PREFIX}/share/xml/freebsd.sch
|
||||
|
||||
.if exists(${PREFIX}/bin/jade) && !defined(OPENJADE)
|
||||
JADECATALOG?= ${PREFIX}/share/sgml/jade/catalog
|
||||
.else
|
||||
|
@ -332,6 +336,15 @@ NO_RTF= yes
|
|||
.endif
|
||||
.endfor
|
||||
|
||||
.if defined(SCHEMATRONS)
|
||||
.for sch in ${SCHEMATRONS}
|
||||
schxslts+= ${sch}.xsl
|
||||
|
||||
${sch}.xsl: ${sch}
|
||||
${XSLTPROC} ${XSLSCH} ${.ALLSRC} > ${.TARGET}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
# Parsed XML -------------------------------------------------------
|
||||
|
||||
${DOC}.parsed.xml: ${SRCS}
|
||||
|
@ -341,6 +354,7 @@ ${DOC}.parsed.xml: ${SRCS}
|
|||
.else
|
||||
${ECHO_CMD} '<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V4.5-Based Extension//EN" "../../../share/xml/freebsd45.dtd">' >> ${.TARGET}
|
||||
.endif
|
||||
@${ECHO} "==> Basic validation"
|
||||
${XMLLINT} --nonet --noent --valid --xinclude --dropdtd ${MASTERDOC} | \
|
||||
${GREP} -v '^<?xml version=.*?>' >> ${.TARGET}
|
||||
|
||||
|
@ -547,9 +561,29 @@ ${DOC}.${_curformat}:
|
|||
# having to convert it to any other formats
|
||||
#
|
||||
|
||||
lint validate: ${SRCS}
|
||||
${XMLLINT} --nonet --noout --noent --valid ${MASTERDOC}
|
||||
@${RM} -rf ${CLEANFILES} ${CLEANDIRS}
|
||||
#
|
||||
# XXX: There is duplicated code below. In general, we want to see what
|
||||
# is actually run but when validation is executed, it is better to
|
||||
# silence the command invocation so that only error messages appear.
|
||||
#
|
||||
|
||||
lint validate: ${SRCS} ${schxslts}
|
||||
@${GREP} '^<?xml version=.*?>' ${DOC}.xml > ${DOC}.parsed.xml
|
||||
.if ${DOC} == "book"
|
||||
@${ECHO_CMD} '<!DOCTYPE book PUBLIC "-//FreeBSD//DTD DocBook XML V4.5-Based Extension//EN" "../../../share/xml/freebsd45.dtd">' >> ${DOC}.parsed.xml
|
||||
.else
|
||||
@${ECHO_CMD} '<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V4.5-Based Extension//EN" "../../../share/xml/freebsd45.dtd">' >> ${DOC}.parsed.xml
|
||||
.endif
|
||||
@${ECHO} "==> Basic validation"
|
||||
@${XMLLINT} --nonet --noent --valid --xinclude --dropdtd ${MASTERDOC} | \
|
||||
${GREP} -v '^<?xml version=.*?>' >>${DOC}.parsed.xml
|
||||
.if defined(schxslts)
|
||||
@${ECHO} "==> Validating with Schematron constraints"
|
||||
.for sch in ${schxslts}
|
||||
@${XSLTPROC} ${sch} ${DOC}.parsed.xml
|
||||
.endfor
|
||||
.endif
|
||||
@${RM} -rf ${CLEANFILES} ${CLEANDIRS} ${DOC}.parsed.xml
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
|
|
11
share/xml/freebsd.sch
Normal file
11
share/xml/freebsd.sch
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<!-- $FreeBSD$ -->
|
||||
|
||||
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
|
||||
<pattern name="Check file reference validity">
|
||||
<rule context="//*/@fileref">
|
||||
<assert test="contains(., '.')">File reference does not have an extension.</assert>
|
||||
</rule>
|
||||
</pattern>
|
||||
</schema>
|
Loading…
Reference in a new issue