Subject: Re: specific XSL file for certain pages instead of
To: None <k.heinz.maer.fuenf@onlinehome.de>
From: Hiroki Sato <hrs@NetBSD.org>
List: netbsd-docs
Date: 03/21/2005 13:42:22
----Security_Multipart0(Mon_Mar_21_13_42_22_2005_632)--
Content-Type: Multipart/Mixed;
boundary="--Next_Part(Mon_Mar_21_13_42_22_2005_892)--"
Content-Transfer-Encoding: 7bit
----Next_Part(Mon_Mar_21_13_42_22_2005_892)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
Klaus Heinz <k.heinz.maer.fuenf@onlinehome.de> wrote
in <20050321005638.GF454@silence.homedns.org>:
k> Klaus Heinz wrote:
k> > Patch is appended to this message.
k>
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
directories.
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
----Next_Part(Mon_Mar_21_13_42_22_2005_892)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="multiple_stylesheet.diff"
Index: share/mk/web.site.mk
===================================================================
RCS file: /cvsroot/htdocs/share/mk/web.site.mk,v
retrieving revision 1.30
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$ -I\$Id:.*\$ -I\$hrs:.*\$ -r1.30 web.site.mk
--- share/mk/web.site.mk 15 Mar 2005 22:55:17 -0000 1.30
+++ share/mk/web.site.mk 21 Mar 2005 04:41:56 -0000
@@ -24,14 +24,6 @@
LOCALBASE?= /usr/pkg
PREFIX?= ${LOCALBASE}
-.if defined(PKG_SYSCONFDIR.xmlcatmgr)
-XML_CATALOG_FILES= ${PKG_SYSCONFDIR.xmlcatmgr}/xml/catalog
-.elif defined(PKG_SYSCONFBASE)
-XML_CATALOG_FILES= ${PKG_SYSCONFBASE}/xml/catalog
-.else
-XML_CATALOG_FILES= ${LOCALBASE}/etc/xml/catalog
-.endif
-
WEBDIR?= ${.CURDIR:T}
CGIDIR?= ${.CURDIR:T}
DESTDIR?= ${HOME}/public_html
@@ -74,35 +66,136 @@
LIST2HTMLOPTS+= -c ${LISTCOLLECTION}
.endif
-# Our customization files.
-.if exists(${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl)
-XSLFILE?= ${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl
-.else
-XSLFILE?= ${WEB_PREFIX}/share/xsl/netbsd-webpage.xsl
-.endif
-LAYOUTFILE= ${WEB_PREFIX}/autolayout.xml
-XMLDEPS+= ${XSLFILE} ${LAYOUTFILE}
-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_ENV+= SGML_CATALOG_FILES=
-XSLTPROC_ENV+= XML_CATALOG_FILES=${XML_CATALOG_FILES}
-XSLTPROC_ARGS+= --xinclude
-XSLTPROC_ARGS+= --stringparam LOCALBASE ${LOCALBASE}
-XSLTPROC_ARGS+= --stringparam WEB_PREFIX ${WEB_PREFIX}
-XSLTPROC_ARGS+= --stringparam autolayout-file ${LAYOUTFILE}
+XSLTPROC_ENV+= XML_CATALOG_FILES="${XML_CATALOG_FILES}"
+
+XSLTPROCOPTS= ${XSLTPROC_ARGS}
+XSLTPROCOPTS+= --xinclude
+XSLTPROCOPTS+= --stringparam LOCALBASE ${LOCALBASE}
+XSLTPROCOPTS+= --stringparam WEB_PREFIX ${WEB_PREFIX}
.if !empty(XML_CATALOG_FILES)
-XSLTPROC_ARGS+= --nonet --catalogs
+XSLTPROCOPTS+= --nonet --catalogs
+.endif
+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,:.*$,,}
.endif
-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
+.endif
+.if !defined(XML.${_ID}) || empty(XML.${_ID})
+XML.${_ID}= ${_ID}.xml
+.endif
+.if !defined(TARGET.${_ID}) || empty(TARGET.${_ID})
+TARGET.${_ID}= ${_ID}.html
+.endif
+
+XSLTPROCOPTS.${_ID}?= ${XSLTPROCOPTS}
+GENDOCS+= ${TARGET.${_ID}}
+CLEANFILES+= ${TARGET.${_ID}}
+
+.if ${XSLT.${_ID}} == docbook
+XSLT.${_ID}= http://www.NetBSD.org/XML/htdocs/lang/share/xsl/netbsd.xsl
+DEPENDS.${_ID}+= ${WEB_PREFIX}/share/xsl/netbsd.xsl
+.elif ${XSLT.${_ID}} == docbook-website
+XSLT.${_ID}= http://www.NetBSD.org/XML/htdocs/lang/share/xsl/webpage.xsl
+DEPENDS.${_ID}+= ${AUTOLAYOUTFILE}
+DEPENDS.${_ID}+= ${WEB_PREFIX}/share/xsl/webpage.xsl
+XSLTPROCOPTS.${_ID}+= --stringparam autolayout-file ${AUTOLAYOUTFILE}
+.elif ${XSLT.${_ID}:Mhttp\://*} != ""
+DEPENDS.${_ID}+= ${XSLT.${_ID}}
+.endif
+DEPENDS.${_ID}+= ${WEB_PREFIX}/share/xsl/global.xsl
+DEPENDS.${_ID}+= ${WEB_PREFIX}/share/xsl/portpage.xsl
+
+.for S in ${SRCS.${_ID}}
+DEPEDNS.${_ID}+= ${S}
+.endfor
+${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}} )
+.else
+ @( ulimit -d 500000 && ${XSLTPROC} ${XSLTPROCOPTS.${_ID}} \
+ -o ${.TARGET} ${PARAMS.${_ID}} \
+ ${XSLT.${_ID}} ${XML.${_ID}} )
+.endif
+#. if !defined(NO_TIDY)
+# -${TIDY} ${TIDYOPTS} ${.TARGET}
+#. endif
+.endfor
+.endfor
+
+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
+.else
+XML_CATALOG_FILES+= file://${LOCALBASE}/etc/xml/catalog
+.endif
+
+# for docbook-website DTD
+
+AUTOLAYOUTFILE?=${WEB_PREFIX}/autolayout.xml
+LAYOUTFILE?= ${WEB_PREFIX}/layout.xml
#
# Install dirs derived from the above.
#
+
DOCINSTALLDIR= ${DESTDIR}${WEBBASE}/${WEBDIR}
CGIINSTALLDIR= ${DESTDIR}${WEBBASE}/${CGIDIR}
@@ -129,9 +222,9 @@
GENDOCS+= ${DOCS:M*.xml:S/.xml$/.html/g}
ORPHANS:= ${ORPHANS:N*.xml}
-.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})
.html.txt:
@${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}
.endif
-${WEB_PREFIX}/autolayout.xml: ${WEB_PREFIX}/layout.xml
+${AUTOLAYOUTFILE}: ${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 "../Makefile.inc"
.endif
-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'"
update:
cd ../; ${MAKE} update; cd Changes;
----Next_Part(Mon_Mar_21_13_42_22_2005_892)----
----Security_Multipart0(Mon_Mar_21_13_42_22_2005_632)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)
iD8DBQBCPlCuTyzT2CeTzy0RAsPlAKCgsgUHYMy41K2APTpaI3OtD9kLGQCdF5P1
OvE/er/kj9gP+cdvVcEU2og=
=B/qv
-----END PGP SIGNATURE-----
----Security_Multipart0(Mon_Mar_21_13_42_22_2005_632)----