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

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


Klaus Heinz <> wrote
  in <>:

k> Do we really need this short form docid:xslt:xml:target? So far, we have
k> only very few files which need non-default values for
k> {XSLT,XML,TARGET}.<docid> and I would prefer to use the variables for
k> clarity.

 I believe it is needed.  We do not use non-default values so far
 because a .xml file generates a .html file almost throughout the htdoc
 tree, but this restricts more flexible conversion such as sharing
 "what's new" entries in the multiple html files and/or generating
 various formats (html, rss, ..) from a .xml file.

 Also, I would like to merge the XML->HTML part of
 and into one mk file to simplify the structure.  The
 flexibility is greatly helpful for it, too.

k> If I understand your changes correctly we will need a flag day where we
k> convert all Makefiles (about 98 right now) from DOCS syntax to XMLDOCS?

 The XMLDOCS and DOCS can coexist.  Since my patch is a prototype written
 a while ago, some more work might be needed for keeping backward
 compatibility.  I think eventually XMLDOCS should be used for all
 .xml file conversion, but DOCS can also be used for "a .xml file to
 a .html file" conversion with docbook-website DTD for the time being.

k> > +DEPENDS.${_ID}+=	${WEB_PREFIX}/share/xsl/portpage.xsl
k>                                                 ^^^^^^^^^^^^
k> Should every document depend on portpage.xsl when mainly (only?)
k> htdocs/Ports/<port>/index.xml use the elements from that stylesheet? 

 Probably no.  This part is cut&paste'd from the current

 The revised patch is attached.  It allows use of DOCS and XMLDOCS
 at a time and XSLT.DEFAULT which specifies the default XSLT stylesheet
 used for entries without the stylesheet (`docbook-website' by default).
 An example of changes to each Makefile is also attached.
 Any comments are welcome.  Thanks.

| Hiroki SATO

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

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/	23 Mar 2005 11:51:41 -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,155 @@
-# 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
+#    `xsl'             - <id>.xsl
+#   The default filename or keyword of XSLT stylesheet.
+#   When XSLT.<id> and one in the quadruplet are not specified,
+#   this value is used.
+# 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
+XSLT.DEFAULT?=	docbook-website
+.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})
+.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}} == xsl
+XSLT.${_ID}=	${_ID}.xsl
+.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
+# backward compatibility
+XSLFILE?=	${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl
+XMLDEPS+=	${WEB_PREFIX}/share/xsl/webpage.xsl
+XMLDEPS+=	${WEB_PREFIX}/share/xsl/global.xsl
 # Install dirs derived from the above.
@@ -131,7 +243,7 @@
 .xml.html: ${XMLDEPS}
 	@${ECHO} "[xsltproc] ${.IMPSRC} -> ${.TARGET}"
-	@(ulimit -d 500000 && ${XSLTPROC} -o ${.TARGET} ${XSLFILE} ${.IMPSRC})
+	@(ulimit -d 500000 && ${XSLTPROC} ${XSLTPROCOPTS} --stringparam autolayout-file ${AUTOLAYOUTFILE} -o ${.TARGET} ${XSLFILE} ${.IMPSRC})
 	@${ECHO} "[html2txt] ${.IMPSRC} -> ${.TARGET}"
@@ -167,12 +279,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	23 Mar 2005 11:54:08 -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
+XMLDOCS+=	rss
+XMLDOCS+=	000804
+XMLDOCS+=	1998
+XMLDOCS+=	1999
+XMLDOCS+=	2000
+XMLDOCS+=	2001
+XMLDOCS+=	2002
+XMLDOCS+=	2003
+XMLDOCS+=	2004.xml
-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)