Subject: Re: specific XSL file for certain pages instead of
To: None <>
From: Hiroki Sato <>
List: netbsd-docs
Date: 03/21/2005 13:42:22
Content-Type: Multipart/Mixed;
Content-Transfer-Encoding: 7bit

Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Klaus Heinz <> wrote
  in <>:

k> Klaus Heinz wrote:
k> > Patch is appended to this message.
k> Update. The generated files are now added to GENDOCS, so "make" or "make
k> clean" should work as well.

 I made and attached a patch to add the functionality in a slightly
 different way:

  - in Makefile, we can use "XMLDOCS= docid:xslt:xml:target"
    where xslt is the stylesheet, xml is the source xml file,
    and target is the target filename.  If some of the parameters
    are not specified, the default ones (<docid>.{xsl,xml,html}) are used.
    {TARGET,XSLT,XML,SRCS,PARAMS,XSLTPROCOPTS}.<docid> are also available.

  - For xslt in the quadruplet described above, "docbook" and
    "docbook-website" keyword can be used for convenience.
    The necessary dependencies are also added (and we can add
    new keywords, of course).

  - Use XML catalog to resolve filenames of XSLT stylesheet.
    This patch temporarily breaks the ${DOCLANG} hack, but
    it will be fixed by adding catalog.xml in the the localized

 Considering we use an XSLT stylesheet commonly for several
 XML files such as pages in the Ports/ directory, I think
 variable definitions in Makefile in each directory should
 be small and in one location and as much as possible
 to make maintenance easy.

| Hiroki SATO

Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="multiple_stylesheet.diff"

Index: share/mk/
RCS file: /cvsroot/htdocs/share/mk/,v
retrieving revision 1.30
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$ -I\$Id:.*\$ -I\$hrs:.*\$ -r1.30
--- share/mk/	15 Mar 2005 22:55:17 -0000	1.30
+++ share/mk/	21 Mar 2005 04:41:56 -0000
@@ -24,14 +24,6 @@
 LOCALBASE?=	/usr/pkg
-.if defined(PKG_SYSCONFDIR.xmlcatmgr)
-XML_CATALOG_FILES=	${PKG_SYSCONFDIR.xmlcatmgr}/xml/catalog
-.elif defined(PKG_SYSCONFBASE)
-XML_CATALOG_FILES=	${LOCALBASE}/etc/xml/catalog
 DESTDIR?=	${HOME}/public_html
@@ -74,35 +66,136 @@
-# Our customization files.
-.if exists(${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl)
-XSLFILE?=	${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl
-XSLFILE?=	${WEB_PREFIX}/share/xsl/netbsd-webpage.xsl
-LAYOUTFILE=	${WEB_PREFIX}/autolayout.xml
-XMLDEPS+=	${WEB_PREFIX}/share/xsl/global.xsl
-XMLDEPS+=	${WEB_PREFIX}/share/xsl/webpage.xsl
-XMLDEPS+=	${WEB_PREFIX}/share/xsl/portpage.xsl
-XMLDEPS+=	${WEB_PREFIX}/share/xsl/netbsd.xsl
+# ---
+# .xml -> .html rendering rule
+# The following variables are available:
+# XMLDOCS: (ex. XMLDOCS= doc1 doc2 doc3)
+#   Target document identifier, which is usually the same as the
+#   base part of the filenames.  {XSLT,XML,TARGET}.<id> described below
+#   can be specified in a short form like the following:
+#   "docid:stylesheet:xml:target".
+# TARGET.<id>: (ex. TARGET.doc1= doc1.html)
+#   The target filename.  This is optional and <id>.html is defined
+#   by default.
+# XSLT.<id>: (ex. XSLT.doc1= doc1.xsl)
+#   Filename of the XSLT stylesheet.  This is optional and <id>.xsl is
+#   defined by default.  The following keywords are interpreted specially:
+#    `docbook'         - Norm Walsh's DocBook stylesheet
+#    `docbook-website' - Norm Walsh's Website stylesheet
+# XML.<id>: (ex. XML.doc1= doc1.xml data.xml)
+#   Filename of the XML document.  This is optional and /dev/null is
+#   defined by default.
+# SRCS.<id>: (ex. SRCS.doc1= includes.xsl)
+#   Depencencies.
+# PARAMS.<id>: (ex. PARAMS.doc1= --params "foo" "'textproc/foo'")
+#   Parameters passed to xsltproc(1).
+# XSLTPROCOPTS.<id>: (ex. XSLTPROCOPTS.doc1= --nonet)
+#   Parameters passed to xsltproc(1).
-# Definitions for the XSLT processor. They heavily depend on xsltproc, so
-# making them tunable is not a good idea.
-XSLTPROC_ARGS+=	--xinclude
-XSLTPROC_ARGS+=	--stringparam autolayout-file ${LAYOUTFILE}
+XSLTPROCOPTS+=	--xinclude
 .if !empty(XML_CATALOG_FILES)
-XSLTPROC_ARGS+= --nonet --catalogs
+XSLTPROCOPTS+= --nonet --catalogs
+XSLTPROC=	env ${XSLTPROC_ENV} ${PREFIX}/bin/xsltproc
+.for D in ${XMLDOCS}
+# parse "docid:xslt:xml:target".
+__ID=		${D:C,:.*$,,}
+.if "${D:M*\:*}" != ""
+XSLT.${__ID}=	${D:C,^[^:]*,,:M*\:*:C,^:,,:C,:.*$,,}
+XML.${__ID}=	${D:C,^[^:]*,,:M*\:*:C,^:,,:C,^[^:]*,,:M*\:*:C,^:,,:C,:.*$,,}
+TARGET.${__ID}=	${D:C,^[^:]*,,:M*\:*:C,^:,,:C,^[^:]*,,:M*\:*:C,^:,,:C,^[^:]*,,:M*\:*:C,^:,,:C,:.*$,,}
-XSLTPROC=       env ${XSLTPROC_ENV} ${PREFIX}/bin/xsltproc ${XSLTPROC_ARGS}
+# Use default value if parameter not specified.
+# XXX: use .for twice to completely resolve variable reference.
+#      ${_ID} cannot be used from outside of this .for loop.
+.for _ID in ${__ID}
+.if !defined(XSLT.${_ID}) || empty(XSLT.${_ID})
+XSLT.${_ID}=	${_ID}.xsl
+.if !defined(XML.${_ID}) || empty(XML.${_ID})
+XML.${_ID}=	${_ID}.xml
+.if !defined(TARGET.${_ID}) || empty(TARGET.${_ID})
+TARGET.${_ID}=	${_ID}.html
+GENDOCS+=       ${TARGET.${_ID}}
+.if ${XSLT.${_ID}} == docbook
+DEPENDS.${_ID}+=	${WEB_PREFIX}/share/xsl/netbsd.xsl
+.elif ${XSLT.${_ID}} == docbook-website
+DEPENDS.${_ID}+=	${WEB_PREFIX}/share/xsl/webpage.xsl
+XSLTPROCOPTS.${_ID}+=	--stringparam autolayout-file ${AUTOLAYOUTFILE}
+.elif ${XSLT.${_ID}:Mhttp\://*} != ""
+DEPENDS.${_ID}+=	${XSLT.${_ID}}
+DEPENDS.${_ID}+=	${WEB_PREFIX}/share/xsl/global.xsl
+DEPENDS.${_ID}+=	${WEB_PREFIX}/share/xsl/portpage.xsl
+.for S in ${SRCS.${_ID}}
+DEPEDNS.${_ID}+=	${S}
+${TARGET.${_ID}}: ${XML_INCLUDES} ${XML.${_ID}} ${DEPENDS.${_ID}}
+	@${ECHO} "[xsltproc] ${XML.${_ID}} -> ${.TARGET}"
+.if defined(DEBUG)
+	( ulimit -d 500000 && ${XSLTPROC} ${XSLTPROCOPTS.${_ID}} \
+		-o ${.TARGET} ${PARAMS.${_ID}} \
+		${XSLT.${_ID}} ${XML.${_ID}} )
+	@( ulimit -d 500000 && ${XSLTPROC} ${XSLTPROCOPTS.${_ID}} \
+		-o ${.TARGET} ${PARAMS.${_ID}} \
+		${XSLT.${_ID}} ${XML.${_ID}} )
+#. if !defined(NO_TIDY)
+#. endif
+XML_CATALOG_FILES=	file://${WEB_PREFIX}/${DOCLANG}/share/xml/catalog.xml \
+			file://${WEB_PREFIX}/share/xml/catalog.xml \
+			file://${WEB_PREFIX}/share/xml/catalog-common.xml
+.if defined(PKG_SYSCONFDIR.xmlcatmgr)
+XML_CATALOG_FILES+=	file://${PKG_SYSCONFDIR.xmlcatmgr}/xml/catalog
+.elif defined(PKG_SYSCONFBASE)
+XML_CATALOG_FILES+=	file://${PKG_SYSCONFBASE}/xml/catalog
+XML_CATALOG_FILES+=	file://${LOCALBASE}/etc/xml/catalog
+# for docbook-website DTD
+LAYOUTFILE?=	${WEB_PREFIX}/layout.xml
 # Install dirs derived from the above.
@@ -129,9 +222,9 @@
 GENDOCS+=	${DOCS:M*.xml:S/.xml$/.html/g}
-.xml.html: ${XMLDEPS}
-	@${ECHO} "[xsltproc] ${.IMPSRC} -> ${.TARGET}"
-	@(ulimit -d 500000 && ${XSLTPROC} -o ${.TARGET} ${XSLFILE} ${.IMPSRC})
+#.xml.html: ${XMLDEPS}
+#	@${ECHO} "[xsltproc] ${.IMPSRC} -> ${.TARGET}"
+#	@(ulimit -d 500000 && ${XSLTPROC} -o ${.TARGET} ${XSLFILE} ${.IMPSRC})
 	@${ECHO} "[html2txt] ${.IMPSRC} -> ${.TARGET}"
@@ -167,12 +260,12 @@
 # Make sure autolayout.xml is up-to-date first
-pre-all: ${WEB_PREFIX}/autolayout.xml ${WEB_PREFIX}/gallery/sites.xml 
+pre-all: ${AUTOLAYOUTFILE} ${WEB_PREFIX}/gallery/sites.xml 
 .if ${WEB_PREFIX} == "."
-autolayout.xml: ${WEB_PREFIX}/layout.xml
+autolayout.xml: ${LAYOUTFILE}
-${WEB_PREFIX}/autolayout.xml: ${WEB_PREFIX}/layout.xml
 .if ${WEB_PREFIX} == "."
 	@(cd gallery && ${MAKE} sites.xml)
 	@${ECHO} "[xsltproc] layout.xml -> autolayout.xml"
Index: Changes/Makefile
RCS file: /cvsroot/htdocs/Changes/Makefile,v
retrieving revision 1.16
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$ -I\$Id:.*\$ -I\$hrs:.*\$ -r1.16 Makefile
--- Changes/Makefile	8 Jan 2005 19:15:02 -0000	1.16
+++ Changes/Makefile	21 Mar 2005 04:04:04 -0000
@@ -7,20 +7,20 @@
 .include "../"
-DOCS+=		000804.xml
-DOCS+=		rss.xml
-DOCS+=		1998.xml
-DOCS+=		1999.xml
-DOCS+=		2000.xml
-DOCS+=		2001.xml
-DOCS+=		2002.xml
-DOCS+=		2003.xml
-DOCS+=		2004.xml
-DOCS+=		index.xml
+XMLDOCS+=	index:docbook-website
+XMLDOCS+=	rss:docbook-website
+XMLDOCS+=	000804:docbook-website
+XMLDOCS+=	1998:docbook-website
+XMLDOCS+=	1999:docbook-website
+XMLDOCS+=	2000:docbook-website
+XMLDOCS+=	2001:docbook-website
+XMLDOCS+=	2002:docbook-website
+XMLDOCS+=	2003:docbook-website
+XMLDOCS+=	2004:docbook-website
-all:	index.html
-	cd ..; ${MAKE} index; cd Changes;
-	@echo "NEWS regen complete - time to 'make commit'"
+#all:	index.html
+#	cd ..; ${MAKE} index; cd Changes;
+#	@echo "NEWS regen complete - time to 'make commit'"
 	cd ../; ${MAKE} update; cd Changes;


Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

Version: GnuPG v1.4.0 (FreeBSD)