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/23/2005 21:11:02
----Security_Multipart0(Wed_Mar_23_21_11_02_2005_206)--
Content-Type: Multipart/Mixed;
boundary="--Next_Part(Wed_Mar_23_21_11_02_2005_737)--"
Content-Transfer-Encoding: 7bit
----Next_Part(Wed_Mar_23_21_11_02_2005_737)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
Klaus Heinz <k.heinz.maer.fuenf@onlinehome.de> wrote
in <20050321231854.GA454@silence.homedns.org>:
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 doc.docbook.mk
and web.site.mk 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> ^^^^^^^^^^^^
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 web.site.mk.
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
----Next_Part(Wed_Mar_23_21_11_02_2005_737)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="web.site.mk.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 23 Mar 2005 11:51:41 -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,155 @@
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
+# `xsl' - <id>.xsl
+#
+# XSLT.DEFAULT:
+# 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_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
+
+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,:.*$,,}
.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}= ${XSLT.DEFAULT}
+.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}} == xsl
+XSLT.${_ID}= ${_ID}.xsl
+.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
+
+# backward compatibility
+
+XSLFILE?= ${WEB_PREFIX}/share/xsl/netbsd-webpage-${DOCLANG}.xsl
+XMLDEPS+= ${AUTOLAYOUTFILE}
+XMLDEPS+= ${XSLFILE}
+XMLDEPS+= ${WEB_PREFIX}/share/xsl/webpage.xsl
+XMLDEPS+= ${WEB_PREFIX}/share/xsl/global.xsl
#
# Install dirs derived from the above.
#
+
DOCINSTALLDIR= ${DESTDIR}${WEBBASE}/${WEBDIR}
CGIINSTALLDIR= ${DESTDIR}${WEBBASE}/${CGIDIR}
@@ -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})
.html.txt:
@${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}
.endif
-${WEB_PREFIX}/autolayout.xml: ${WEB_PREFIX}/layout.xml
+${AUTOLAYOUTFILE}: ${LAYOUTFILE}
.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 "../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
+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'"
update:
cd ../; ${MAKE} update; cd Changes;
----Next_Part(Wed_Mar_23_21_11_02_2005_737)----
----Security_Multipart0(Wed_Mar_23_21_11_02_2005_206)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)
iD8DBQBCQVzWTyzT2CeTzy0RApTuAJ4141g8W5YPr51YErlmpnW3C+M48wCdEOa1
G/gT4+DPRrxAZWVN8z+Eq30=
=nOJF
-----END PGP SIGNATURE-----
----Security_Multipart0(Wed_Mar_23_21_11_02_2005_206)----