summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul W. Frields <stickster@gmail.com>2006-02-17 03:36:48 +0000
committerPaul W. Frields <stickster@gmail.com>2006-02-17 03:36:48 +0000
commit6ce39645dfef3d8559cd742f79144add0cb3e47a (patch)
treeeac4f1fcdd5e06e51ec70d787b0d5b563f586411
parenta5c58343d1098d5993ffe8e890e70eb2f52d5e59 (diff)
downloadfedora-doc-utils-6ce39645dfef3d8559cd742f79144add0cb3e47a.tar.gz
fedora-doc-utils-6ce39645dfef3d8559cd742f79144add0cb3e47a.tar.xz
fedora-doc-utils-6ce39645dfef3d8559cd742f79144add0cb3e47a.zip
Add "text" alias for "txt" for bad typists and lexihounds. Also strip
annoying revhistory and index elements from plain text builds. There are very few instances where we will be providing txt builds -- e.g. release notes -- so this doesn't seem like a loss. If it is, XSLT is cheap.
-rw-r--r--Makefile.common23
-rw-r--r--packaging/strip-for-txt.xsl79
2 files changed, 95 insertions, 7 deletions
diff --git a/Makefile.common b/Makefile.common
index 0b77f2b..d1432fe 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -84,6 +84,9 @@ endif
ifeq "${XMLTOTXTPOSTOPT}" ""
XMLTOTXTPOSTOPT =-p '-no-numbering -no-references'
endif
+ifeq "${XMLLINTOPT}" ""
+XMLLINTOPT =--xinclude --postvalid --noent
+endif
#########################################################################
#########################################################################
@@ -98,6 +101,7 @@ XMLTO =xmlto
XSLTPROC=xsltproc
XMLFORMAT=xmlformat
XMLFOPTS=-f $(FDPDIR)/docs-common/bin/xmlformat-fdp.conf
+XMLLINT =xmllint
XML2PO =xml2po
PO2XML =po2xml
MSGMERGE=msgmerge
@@ -158,7 +162,7 @@ $(foreach L,${LANGUAGES},$(eval $(call XMLFILES_template,${L})))
TARGETS=all clean distclean fdp-info html html-nochunks pdf po showvars \
tarball rpm rpm-common noarch srpm package-prep package-post \
- src-tarball txt
+ src-tarball txt text
# FIXME: add the .PHONY attribute where the actual target is defined
@@ -286,11 +290,16 @@ pdf:: $(foreach LANG,${LANGUAGES},pdf-$(LANG))
define TXT_template
-.PHONY: txt-${1}
+.PHONY: txt-${1} text-${1}
-txt-$(1) ${DOCBASE}-$(1).txt:: ${XMLFILES-${1}} ${1}/fdp-info.xml
- ${XMLTO} ${XMLTOTXTPOSTOPT} txt $(1)/$(DOCBASE).xml
- mv $(DOCBASE).txt $(DOCBASE)-$(1).txt
+txt-$(1) text-$(1) ${DOCBASE}-$(1).txt:: ${XMLFILES-${1}} ${1}/fdp-info.xml
+ ${XMLLINT} ${XMLLINTOPT} $(1)/$(DOCBASE).xml > $(1)/$(DOCBASE).lint.xml
+ ${XSLTPROC} $(FDPDIR)/docs-common/packaging/strip-for-txt.xsl \
+ $(1)/$(DOCBASE).lint.xml > $(1)/$(DOCBASE).stripped.xml
+ rm $(1)/$(DOCBASE).lint.xml
+ ${XMLTO} ${XMLTOTXTPOSTOPT} txt $(1)/$(DOCBASE).stripped.xml
+ mv $(DOCBASE).stripped.txt $(DOCBASE)-$(1).txt
+ rm $(1)/$(DOCBASE).stripped.xml
distclean::
${RM} ${DOCBASE}-${1}.txt
@@ -298,9 +307,9 @@ endef
$(foreach L,${LANGUAGES},$(eval $(call TXT_template,${L})))
-.PHONY: txt
+.PHONY: txt text
-txt:: $(foreach LANG,${LANGUAGES},txt-$(LANG))
+txt text:: $(foreach LANG,${LANGUAGES},txt-$(LANG))
#
#########################################################################
diff --git a/packaging/strip-for-txt.xsl b/packaging/strip-for-txt.xsl
new file mode 100644
index 0000000..5691b76
--- /dev/null
+++ b/packaging/strip-for-txt.xsl
@@ -0,0 +1,79 @@
+<!-- Strip <revhistory> element from DocBook -->
+<!-- Note this XSLT upgrades your DocBook to the V4.4 DTD! -->
+<xsl:stylesheet version="1.0" xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output encoding="UTF-8" indent="no" method="xml"
+ omit-xml-declaration="no" standalone="no" version="1.0"
+ doctype-public="-//OASIS//DTD DocBook XML V4.4//EN"
+ doctype-system="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" />
+
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="/book">
+ <xsl:element name="book">
+ <xsl:for-each select="*">
+ <xsl:choose>
+ <xsl:when test="self::bookinfo">
+ <xsl:call-template name="bookinfo"/>
+ </xsl:when>
+ <xsl:when test="self::index">
+ <xsl:text/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="/article">
+ <xsl:element name="article">
+ <xsl:for-each select="*">
+ <xsl:choose>
+ <xsl:when test="self::articleinfo">
+ <xsl:call-template name="articleinfo"/>
+ </xsl:when>
+ <xsl:when test="self::index">
+ <xsl:text/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template name="bookinfo">
+ <xsl:element name="bookinfo">
+ <xsl:for-each select="*">
+ <xsl:choose>
+ <xsl:when test="self::revhistory">
+ <xsl:text/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template name="articleinfo">
+ <xsl:element name="articleinfo">
+ <xsl:for-each select="*">
+ <xsl:choose>
+ <xsl:when test="self::revhistory">
+ <xsl:text/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+</xsl:stylesheet>