svn commit: r41205 - in projects/xml-tools/share: mk xml

Gabor Kovesdan gabor at FreeBSD.org
Thu Mar 14 10:25:24 UTC 2013


Author: gabor
Date: Thu Mar 14 10:25:23 2013
New Revision: 41205
URL: http://svnweb.freebsd.org/changeset/doc/41205

Log:
  - 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

Added:
  projects/xml-tools/share/xml/freebsd.sch   (contents, props changed)
Modified:
  projects/xml-tools/share/mk/doc.docbook.mk

Modified: projects/xml-tools/share/mk/doc.docbook.mk
==============================================================================
--- projects/xml-tools/share/mk/doc.docbook.mk	Thu Mar 14 09:19:23 2013	(r41204)
+++ projects/xml-tools/share/mk/doc.docbook.mk	Thu Mar 14 10:25:23 2013	(r41205)
@@ -85,8 +85,12 @@ XSLXHTMLCHUNK?=	${DOC_PREFIX}/${LANGCODE
 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
 
 # ------------------------------------------------------------------------
 #

Added: projects/xml-tools/share/xml/freebsd.sch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/xml-tools/share/xml/freebsd.sch	Thu Mar 14 10:25:23 2013	(r41205)
@@ -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>


More information about the svn-doc-projects mailing list