# this file is a -*- makefile -*- snippet
-# targets in this file are used to build and upload the DocBook 5
+# targets in this file are used to build and upload the namespaced
# version of the DocBook Project XSL Stylesheets
# $Id$
debug:
-freshmeat5:
+freshmeat-ns:
ifeq ($(SFRELID),)
@echo "You must specify the sourceforge release identifier in SFRELID"
exit 1
else
- $(XSLT) VERSION VERSION $(TMP)/fm-docbook5-$(DISTRO) sf-relid=$(SFRELID)
- grep -v "<?xml" $(TMP)/fm-docbook5-$(DISTRO) | freshmeat-submit $(FMGO)
+ $(XSLT) VERSION VERSION $(TMP)/fm-docbook-$(DISTRO)-ns sf-relid=$(SFRELID)
+ grep -v "<?xml" $(TMP)/fm-docbook-$(DISTRO)-ns | freshmeat-submit $(FMGO)
endif
-zip5: zip
+zip-ns: zip
rm -rf $(TMP)/docbook-$(DISTRO)-$(ZIPVER)
- rm -rf $(TMP)/docbook5-$(DISTRO)-$(ZIPVER)
- $(RM) $(TMP)/docbook5-$(DISTRO)-$(ZIPVER).tar.gz
- $(RM) $(TMP)/docbook5-$(DISTRO)-$(ZIPVER).tar.bz2
- $(RM) $(TMP)/docbook5-$(DISTRO)-$(ZIPVER).zip
+ rm -rf $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER)
+ $(RM) $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER).tar.gz
+ $(RM) $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER).tar.bz2
+ $(RM) $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER).zip
(cd $(TMP) && \
unzip $(TMP)/docbook-$(DISTRO)-$(ZIPVER).zip && \
- $(DOCBOOK_SVN)/releasetools/makedb5xsl \
+ $(DOCBOOK_SVN)/releasetools/makexslns \
docbook-$(DISTRO)-$(ZIPVER) \
- docbook5-$(DISTRO)-$(ZIPVER));
+ docbook-$(DISTRO)-ns--$(ZIPVER));
# change branch info
- sed -i "s/^\(.*\)<fm:Branch>XSL Stylesheets<\/fm:Branch>$$/\1<fm:Branch>v5 XSL Stylesheets<\/fm:Branch>/" \
- $(TMP)/docbook5-$(DISTRO)-$(ZIPVER)/VERSION
+ sed -i "s/^\(.*\)<fm:Branch>XSL Stylesheets<\/fm:Branch>$$/\1<fm:Branch>XSL NS Stylesheets<\/fm:Branch>/" \
+ $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER)/VERSION
# change distro name
- sed -i "s/^\(.*\)<xsl:param name=\"DistroName\">docbook-xsl<\/xsl:param>$$/\1<xsl:param name=\"DistroName\">docbook5-xsl<\/xsl:param>/" \
- $(TMP)/docbook5-$(DISTRO)-$(ZIPVER)/VERSION
+ sed -i "s/^\(.*\)<xsl:param name=\"DistroName\">docbook-xsl<\/xsl:param>$$/\1<xsl:param name=\"DistroName\">docbook-xsl-ns<\/xsl:param>/" \
+ $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER)/VERSION
# repair perms
- chmod 755 $(TMP)/docbook5-$(DISTRO)-$(ZIPVER)/fo/pdf2index
- chmod 755 $(TMP)/docbook5-$(DISTRO)-$(ZIPVER)/install.sh
+ chmod 755 $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER)/fo/pdf2index
+ chmod 755 $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER)/install.sh
# gzip/bzip/zip it
- umask 022; cd $(TMP) && $(TAR) cf$(TARFLAGS) - docbook5-$(DISTRO)-$(ZIPVER) \
- | gzip > docbook5-$(DISTRO)-$(ZIPVER).tar.gz
- umask 022; cd $(TMP) && $(TAR) cf$(TARFLAGS) - docbook5-$(DISTRO)-$(ZIPVER) \
- | bzip2 > docbook5-$(DISTRO)-$(ZIPVER).tar.bz2
- umask 022; cd $(TMP) && $(ZIP) $(ZIPFLAGS) docbook5-$(DISTRO)-$(ZIPVER).zip \
- docbook5-$(DISTRO)-$(ZIPVER)
-
-install5: zip5 install
- -$(FTP) $(FTP_OPTS) "mput -O $(SF_UPLOAD_DIR) $(TMP)/docbook5-$(DISTRO)-$(ZIPVER).*; quit" $(SF_UPLOAD_HOST)
+ umask 022; cd $(TMP) && $(TAR) cf$(TARFLAGS) - docbook-$(DISTRO)-ns-$(ZIPVER) \
+ | gzip > docbook-$(DISTRO)-ns-$(ZIPVER).tar.gz
+ umask 022; cd $(TMP) && $(TAR) cf$(TARFLAGS) - docbook-$(DISTRO)-ns-$(ZIPVER) \
+ | bzip2 > docbook-$(DISTRO)-ns-$(ZIPVER).tar.bz2
+ umask 022; cd $(TMP) && $(ZIP) $(ZIPFLAGS) docbook-$(DISTRO)-ns-$(ZIPVER).zip \
+ docbook-$(DISTRO)-ns-$(ZIPVER)
+
+install-ns: zip-ns install
+ -$(FTP) $(FTP_OPTS) "mput -O $(SF_UPLOAD_DIR) $(TMP)/docbook-$(DISTRO)-ns-$(ZIPVER).*; quit" $(SF_UPLOAD_HOST)
-DocBook 5 XSL stylesheets
+DocBook XSL NS (namespaced) Stylesheets
===========================================
Bob Stayton
bobs@sagehill.net
-This package contains a release of XSL stylesheets
-for processing DocBook 5 documents. The stylesheets are
-the same as the concurrent stylesheet release except that
-the templates match on elements in the DocBook namespace.
+This package contains a release of XSL stylesheets for
+processing namespaced DocBook documents (DocBook 5 or
+later). The stylesheets are the same as the concurrent
+stylesheet release except that the templates match on
+elements in the DocBook namespace.
-Note, the stylesheets in these directories have
-not yet been converted to use the DocBook 5 namespace:
+Note, the stylesheets in the directories listed below
+have not yet been converted to use the DocBook
+namespace:
slides
website
Background
-------------
DocBook 5 differs from preceding versions of DocBook because
-its elements are in a namespace "http://docbook.org/ns/docbook".
+its elements are in a namespace, "http://docbook.org/ns/docbook".
Because the elements are in a namespace, the regular
DocBook XSL templates do not match on the elements.
In XSLT, a match attribute must explicitly specify
the namespace prefix to match an element in that namespace
(the default namespace does not apply to pattern matches).
-The regular stylesheets are able to process DocBook 5
-documents now, because they preprocess a DB5 document to
-remove the namespace. When the regular stylesheet
-detects that the root element is in the namespace, it
-processes the document with mode="stripNS" to copy all
-the nodes to a variable, but without the DocBook namespace.
+The non-namspaced DocBook XSL stylesheets (created
+originally for processing DocBook 4 and earlier documents,
+before DocBook was put into a namespace for the DocBook 5
+release) are able to process a namespaced DocBook document
+by preprocessing the document to strip the namespace.
+
+When the non-namspaced stylesheet detects that the root
+element of a document is in the DocBook namespace, it
+processes the document with mode="stripNS" to copy all the
+nodes to a variable, but without the DocBook namespace.
Then it converts the variable to a nodeset, and processes
the nodeset with the regular templates.
The alternative approach is to create a set of templates
-that match on the native namespace of DocBook 5 documents.
-These stylesheets do that.
+that match on the native namespace of DocBook 5 and
+later documents. These stylesheets do that.
These stylesheets completely mimic the behavior of the
existing stylesheets. These are not XSLT 2.0 stylesheets,
How to use these stylesheets
--------------------------------
-A DocBook 5 document has the DocBook namespace declaration
-in the root element, along with the version attribute:
+DocBook 5 and later documents hav the DocBook namespace
+declaration in the root element, along with the version
+attribute:
<book xslns="http://docbook.org/ns/docbook" version="5.0">
-You can process a DocBook 5 document with these stylesheets
-using any XSLT processor, including xsltproc, Saxon 6 or 8,
-and Xalan. Use these stylesheets as you would a stylesheet
-from the regular distribution (except for slides, website,
-and roundtrip).
+You can process a namespaced DocBook document with these
+stylesheets using any XSLT processor, including xsltproc,
+Saxon 6 or 8, and Xalan. Use these stylesheets as you would
+a stylesheet from the regular distribution (except for
+slides, website, and roundtrip).
If you happen to process a DocBook document whose root element
is without the namespace declaration, the stylesheet
does not fail. Rather, it detects that the document
does not have the namespace, and preprocesses it to add the
namespace declaration to all elements in the document.
+
In a manner similar to stripNS, it copies the elements
to a variable while adding the namespace, converts the
variable to a nodeset, and then processes the nodeset with
These are new stylesheets and need thorough testing.
Please report any problems to the docbook-apps
mailing list or the SourceForge bug tracker.
-
s|(xmlns:xsl\s*=\s*"http://www.w3.org/1999/XSL/Transform"(?!>))(\s*\n?)(\s*)|$1$2$3xmlns:d="http://docbook.org/ns/docbook"\n$3|s;
# Convert stripNS to addNS
- s|href="../common/stripns.xsl"|href="../common/db5.xsl"|sg;
+ s|href="../common/stripns.xsl"|href="../common/addns.xsl"|sg;
s|(\s*\n*)(\s*)(<xslo?:when)\s+test\s*=\s*"[^"]*?self::db:[^"]*?">.*?(</xslo?:when>)|$1$2$3 test="namespace-uri\(\*\[1\]\) != 'http://docbook.org/ns/docbook'">\n$2 <xsl:variable name="doc.title">\n$2 <xsl:call-template name="get.doc.title"/>\n$2 </xsl:variable>\n$2 <xsl:call-template name="log.message">\n$2 <xsl:with-param name="level">Note</xsl:with-param>\n$2 <xsl:with-param name="source" select="\$doc.title"/>\n$2 <xsl:with-param name="context-desc">\n$2 <xsl:text>namesp. add</xsl:text>\n$2 </xsl:with-param>\n$2 <xsl:with-param name="message">\n$2 <xsl:text>added namespace before processing</xsl:text>\n$2 </xsl:with-param>\n$2 </xsl:call-template>\n$2 <xsl:variable name="addns">\n$2 <xsl:apply-templates mode="addNS"/>\n$2 </xsl:variable>\n$2 <xsl:apply-templates select="exsl:node-set\(\$addns\)"/>\n$2$4|sg;
#
sub addFiles {
my $miscdir = dirname $0;
- $miscdir .= '/db5files';
+ $miscdir .= '/xslnsfiles';
print STDOUT "miscdir is $miscdir" . "\n";
- copy("$miscdir/db5.xsl", "$destdir/common");
+ copy("$miscdir/addns.xsl", "$destdir/common");
copy("$miscdir/README", "$destdir/README");
copy("$miscdir/manpages.table.xsl", "$destdir/manpages/table.xsl");
copy("$miscdir/titlepage.xsl", "$destdir/template/titlepage.xsl");
# delete these obsolete files.
- # Replace stripns.xsl with db5.xsl in profiling module
+ # Replace stripns.xsl with addns.xsl in profiling module
&nsfilter("$srcdir/profiling/profile.xsl", "$destdir/profiling/profile.xsl");
}