Subject: Re: specific XSL file for certain pages instead of netbsd-website.xsl for everything
To: None <netbsd-docs@NetBSD.org>
From: Klaus Heinz <k.heinz.maer.fuenf@onlinehome.de>
List: netbsd-docs
Date: 03/20/2005 23:54:17
--9zSXsLTf0vkW971A
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Jan Schaumann wrote:

> We may want to consider knitting the necessary magic to support
> non-standard XSL files into the infrastructure, so we can just specify,
> say

I have tried to add a facility for this, similar to subst,mk in pkgsrc.
Patch is appended to this message.

ciao
     Klaus

--9zSXsLTf0vkW971A
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="web.site.mk.diff"

Index: web.site.mk
===================================================================
RCS file: /cvsroot/htdocs/share/mk/web.site.mk,v
retrieving revision 1.30
diff -u -r1.30 web.site.mk
--- web.site.mk	15 Mar 2005 22:55:17 -0000	1.30
+++ web.site.mk	20 Mar 2005 22:50:09 -0000
@@ -137,6 +137,44 @@
 	@${ECHO} "[html2txt] ${.IMPSRC} -> ${.TARGET}"
 	@${HTML2TXT} ${HTML2TXTOPTS} ${.IMPSRC} > ${.TARGET}
 
+###### Enable non-default stylesheets for transformation of XML documents 
+#
+# DOCSXSL_TARGETS:		list of documents which will be generated by a
+#				non-default stylesheet 
+# DOCSXSL_SRC.${target}:	the XML source file for a single $target
+# DOCSXSL_STYLESHEET.${target}:	path to the stylesheet for $target
+# DOCSXSL_XMLDEPS.${target}:	additional prerequisites for $target.
+#				DOCSXSL_SRC.${target} and
+#				DOCSXSL_STYLESHEET.${target} are automatically
+#				added to this list.
+#
+# Example:
+# DOCSXSL_TARGETS=		news.html
+# DOCSXSL_SRC.news.html=	news.xml
+# DOCSXSL_STYLESHEET.news.html=	${WEB_PREFIX}/share/xsl/newspage.xsl
+# DOCSXSL_XMLDEPS.news.html=	${WEB_PREFIX}/share/xsl/months-${DOCLANG}.xsl
+#
+.if defined(DOCSXSL_TARGETS) && !empty(DOCSXSL_TARGETS)
+_DOCSXSL_TARGETS=	${DOCSXSL_TARGETS}
+.  for _target in ${_DOCSXSL_TARGETS}
+.    if !defined(DOCSXSL_SRC.${_target}) || empty(DOCSXSL_SRC.${_target})
+${_target}:
+	@${ECHO} "No XML source file specified for ${_target}"
+.    elif !defined(DOCSXSL_STYLESHEET.${_target}) || empty(DOCSXSL_STYLESHEET.${_target})
+${_target}:
+	@${ECHO} "No stylesheet specified for ${_target}"
+.    else
+# the XML source file and the stylesheet are prerequisites
+DOCSXSL_XMLDEPS.${_target}+=	${DOCSXSL_SRC.${_target}}	\
+				${DOCSXSL_STYLESHEET.${_target}}
+
+${_target}: ${DOCSXSL_XMLDEPS.${_target}}
+	@${ECHO} "[xsltproc] '${DOCSXSL_SRC.${_target}}' -> ${.TARGET}"
+	@(ulimit -d 500001 && ${XSLTPROC} -o ${.TARGET} ${DOCSXSL_STYLESHEET.${_target}} ${DOCSXSL_SRC.${_target}})
+.    endif
+.  endfor
+.endif
+
 ###
 # file.list --> file.html
 #

--9zSXsLTf0vkW971A--