From: Norman Walsh Date: Mon, 2 Apr 2001 13:03:45 +0000 (+0000) Subject: Initial checkin X-Git-Tag: release/1.79.1~6^2~6656 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7700f42fbe8e86a957e01234f138cbaece958a3b;p=docbook-dsssl Initial checkin --- diff --git a/xsl/BUGS b/xsl/BUGS new file mode 100644 index 000000000..5723ffd37 --- /dev/null +++ b/xsl/BUGS @@ -0,0 +1,6 @@ +The fo stylesheet is probably not in perfect sync with the html stylesheet + +Using Equations w/o titles results in incorrectly numbered + equations with titles. Use InformalEquation instead. + +The 'char' alignment in tables is not supported diff --git a/xsl/Makefile b/xsl/Makefile new file mode 100644 index 000000000..691f428df --- /dev/null +++ b/xsl/Makefile @@ -0,0 +1,30 @@ +DIFFVER= + +.PHONY : distrib clean doc + +all: + cd html; make + cd fo; make + cd extensions; make + cvs -n update + +doc: + cd docsrc; make + cd doc; make + +distrib: all doc + dbin/cvs2log -w +ifeq ($(DIFFVER),) + dbin/mergechangelogs > WhatsNew +else + dbin/mergechangelogs -v $(DIFFVER) > WhatsNew +endif + +newversion: + dbin/nextversion + make DIFFVER=$(DIFFVER) distrib + +clean: + cd doc; make clean + cd test; make clean + diff --git a/xsl/README.CVS b/xsl/README.CVS new file mode 100644 index 000000000..db102fe0a --- /dev/null +++ b/xsl/README.CVS @@ -0,0 +1,77 @@ +README.CVS for the DocBook XSL Stylesheets at cvs.docbook.sourceforge.net + +These are XSL stylesheets for the DocBook XML DTD. (They would also +work for the DocBook DTD, modulo certain namecase problems and the +fact that there aren't any XSL implementations that work with SGML +source documents.) + +CVS Manifest +------------ + +README.CVS this file +TODO planned features not yet implemented (may be incomplete :-) +BUGS known problems (may also be incomplete :-) +VERSION the current version number (note that this is an XSL stylesheet, + included by both fo/docbook.xsl and html/docbook.xsl) +common/ contains code common to both stylesheets +docsrc/ source files for the stylesheet documentation +extensions/ Java extension functions +fo/ stylesheets that produce XSL FO result trees +html/ stylesheets that produce HTML result trees +images/ images used by the stylesheets +lib/ contains schema-independent functions +xhtml/ stylesheets that produce XHTML result trees + +Installation +------------ + +*** NOTE: The CVS tree *IS NOT COMPLETE*. In order to run the stylesheets +directly from the CVS tree, you must checkout several additional trees +and run some build scripts. This README will be updated to describe how +sometime real soon now. + +Copyright +--------- + +Copyright (C) 1999, 2000, 2001 Norman Walsh + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the ``Software''), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization +from the individuals in question. + +Any stylesheet derived from this Software that is publically +distributed will be identified with a different name and the +version strings in any derived Software will be changed so that +no possibility of confusion between the derived package and this +Software will exist. + +Warranty +-------- + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER +CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Contacting the Author +--------------------- + +These stylesheets are maintained by Norman Walsh, . diff --git a/xsl/TODO b/xsl/TODO new file mode 100644 index 000000000..526aca8bf --- /dev/null +++ b/xsl/TODO @@ -0,0 +1,4 @@ +Documentation +Continued lists +Bibliography support needs improvement + diff --git a/xsl/VERSION b/xsl/VERSION new file mode 100644 index 000000000..ac146e1c1 --- /dev/null +++ b/xsl/VERSION @@ -0,0 +1,6 @@ + + +1.35 + + diff --git a/xsl/common/common.xsl b/xsl/common/common.xsl new file mode 100644 index 000000000..55bf6f337 --- /dev/null +++ b/xsl/common/common.xsl @@ -0,0 +1,919 @@ + + + + + + + + +$Id$ + +Walsh +Norman +19992000 +Norman Walsh + + +Common Template Reference + + +
Introduction + +This is technical reference documentation for the DocBook XSL +Stylesheets; it documents (some of) the parameters, templates, and +other elements of the stylesheets. + +This is not intended to be user documentation. +It is provided for developers writing customization layers for the +stylesheets, and for anyone who's interested in how it +works. + +Although I am trying to be thorough, this documentation is known +to be incomplete. Don't forget to read the source, too :-) +
+
+ +
+ + + + + + + + + + + +Tests if a given node is a component-level element + + +This template returns '1' if the specified node is a component +(Chapter, Appendix, etc.), and '0' otherwise. + + + + +node + +The node which is to be tested. + + + + + + +This template returns '1' if the specified node is a component +(Chapter, Appendix, etc.), and '0' otherwise. + + + + + + + 1 + 0 + + + + + + +Tests if a given node is a section-level element + + +This template returns '1' if the specified node is a section +(Section, Sect1, Sect2, etc.), and '0' otherwise. + + + + +node + +The node which is to be tested. + + + + + + +This template returns '1' if the specified node is a section +(Section, Sect1, Sect2, etc.), and '0' otherwise. + + + + + + + 1 + 0 + + + + + + +Returns the hierarchical level of a section. + + +This template calculates the hierarchical level of a section. +Hierarchically, components are top level, so a +sect1 is at level 2, sect3 is +at level 3, etc. + +Recursive sections are calculated down to the sixth level. + + + + +node + +The section node for which the level should be calculated. +Defaults to the context node. + + + + + + +The section level, 2, 3, etc. + + + + + + + + 2 + 3 + 4 + 5 + 6 + + + 6 + 5 + 4 + 3 + 2 + + + + + 3 + 4 + 5 + 6 + 6 + + + 6 + 5 + 4 + 3 + + + 2 + + + 2 + + + + +Returns the hierarchical level of a QandASet. + + +This template calculates the hierarchical level of a QandASet. + + + + +The level, 1, 2, etc. + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[ +] +{ +} + + +[ +] +... + + + | +4pi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Selects an appropriate media object from a list + + +This template examines a list of media objects (usually the +children of a mediaobject or inlinemediaobject) and processes +the "right" object. + +This template relies on a template named "is.acceptable.mediaobject" +to determine if a given object is an acceptable graphic. The semantics +of media objects is that the first acceptable graphic should be used. + + +If no acceptable object is located, nothing happens. + + + + +olist + +The node list of potential objects to examine. + + + + + + +Calls <xsl:apply-templates> on the selected object. + + + + + + 1 + + + + + + + + + 0 + + + + 1 + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Returns '1' if the specified media object is recognized. + + +This template examines a media object and returns '1' if the +object is recognized as a graphic. + + + + +object + +The media object to consider. + + + + + + +0 or 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + 0 + + + + + + 1 + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + . + + + + + + + + + + + + + + + + +Warn users about references to non-unique IDs + +If passed an ID in linkend, +check.id.unique prints +a warning message to the user if either the ID does not exist or +the ID is not unique. + + + + + + + + + + + + Error: no ID for constraint linkend: + + . + + + + + + + Warning: multiple "IDs" for constraint linkend: + + . + + + + + + +Warn users about incorrectly typed references + +If passed an ID in linkend, +check.idref.targets makes sure that the element +pointed to by the link is one of the elements listed in +element-list and warns the user otherwise. + + + + + + + + + + + + + + Error: linkend ( + + ) points to " + + " not (one of): + + + + + + + + + +
+ diff --git a/xsl/common/gentext.xsl b/xsl/common/gentext.xsl new file mode 100644 index 000000000..847032eff --- /dev/null +++ b/xsl/common/gentext.xsl @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + object.xref.markup: + + : + + + + + + + + + + + + + + + object.xref.markup: + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/common/l10n.xml b/xsl/common/l10n.xml new file mode 100644 index 000000000..a7ef90e90 --- /dev/null +++ b/xsl/common/l10n.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> + +&ca; +&cs; +&da; +&de; +⪙ +&en; +&es; +&et; +&fi; +&fr; +&hu; +&id; +⁢ +&ja; +&ko; +&nl; +&no; +&pl; +&pt; +&pt_br; +&ro; +&ru; +&sk; +&sl; +&sv; +&zh_cn; +&zh_tw; + diff --git a/xsl/common/l10n.xsl b/xsl/common/l10n.xsl new file mode 100644 index 000000000..23138ab36 --- /dev/null +++ b/xsl/common/l10n.xsl @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _ + + + + + + + + + + + + + + + + + + + + + + + + + No " + + " cross reference text for " + + " exists and no default specified. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No " + + " localization of " + + " exists; using "en". + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editedby + + + + + + by + + + + + bullet + + + + + + + + + + + + No " + + " localization of dingbat + + exists; using "en". + + + + + + + + + + + + + startquote + + + + + + endquote + + + + + + nestedstartquote + + + + + + nestedendquote + + + + + + nav-prev + + + + + + nav-next + + + + + + nav-home + + + + + + nav-up + + + + + + + + + + + + + + + + + No " + + " localization exists. + + + + + + + + No context named " + + " exists in the " + + " localization. + + + + + + + + No template named " + + " exists in the context named " + + " in the " + + " localization. + + + + + + + + diff --git a/xsl/common/labels.xsl b/xsl/common/labels.xsl new file mode 100644 index 000000000..e1b8c6e8d --- /dev/null +++ b/xsl/common/labels.xsl @@ -0,0 +1,510 @@ + + + + + + + +Provides access to element labels + +Processing an element in the +label.markup mode produces the +element label. +Trailing punctuation is not added to the label. + + + + + + + + . + + + + + Request for label of unexpected element: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + label.markup: this can't happen! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Returns true if $section should be labelled + +Returns true if the specified section should be labelled. +By default, this template simply returns $section.autolabel, but +custom stylesheets may override it to get more selective behavior. + + + + + + diff --git a/xsl/common/subtitles.xsl b/xsl/common/subtitles.xsl new file mode 100644 index 000000000..7c7f2cbce --- /dev/null +++ b/xsl/common/subtitles.xsl @@ -0,0 +1,120 @@ + + + + + + + +Provides access to element subtitles + +Processing an element in the +subtitle.markup mode produces the +subtitle of the element. + + + + + + + Request for subtitle of unexpected element: + + + ???SUBTITLE??? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/common/titles.xsl b/xsl/common/titles.xsl new file mode 100644 index 000000000..4af1cc3a9 --- /dev/null +++ b/xsl/common/titles.xsl @@ -0,0 +1,292 @@ + + + + + + + +Provides access to element titles + +Processing an element in the +title.markup mode produces the +title of the element. This does not include the label. + + + + + + + + + + + + + + + + + + + Request for title of unexpected element: + + + ???TITLE??? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + REFENTRY WITHOUT TITLE??? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Note + Important + Caution + Warning + Tip + + + + + + + + + + + diff --git a/xsl/docsrc/Makefile b/xsl/docsrc/Makefile new file mode 100644 index 000000000..51a77edf0 --- /dev/null +++ b/xsl/docsrc/Makefile @@ -0,0 +1,6 @@ +all: + cd common; make + cd lib; make + cd html; make + cd fo; make + cd template; make diff --git a/xsl/docsrc/common/.cvsignore b/xsl/docsrc/common/.cvsignore new file mode 100644 index 000000000..6722cd96e --- /dev/null +++ b/xsl/docsrc/common/.cvsignore @@ -0,0 +1 @@ +*.xml diff --git a/xsl/docsrc/common/Makefile b/xsl/docsrc/common/Makefile new file mode 100644 index 000000000..c91756b93 --- /dev/null +++ b/xsl/docsrc/common/Makefile @@ -0,0 +1,10 @@ +JSTYLE=../../docsrc/xsl2jref.xsl +VPATH=../../common + +XMLFILES = common.xml + +all: $(XMLFILES) + +%.xml : %.xsl $(JSTYLE) ../../docsrc/legalnotice.xml + saxon -6 $< $(JSTYLE) /dev/null output-file=$@ + xnsgmls -E 5 -sv -c /share/doctypes/catalog $@ diff --git a/xsl/docsrc/copyright.xml b/xsl/docsrc/copyright.xml new file mode 100644 index 000000000..8fac2ef5a --- /dev/null +++ b/xsl/docsrc/copyright.xml @@ -0,0 +1,30 @@ + + +Copyright + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the Software), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other dealings in +this Software without prior written authorization from the individuals +in question. + +Any stylesheet derived from this Software that is publically +distributed will be identified with a different name and the version +strings in any derived Software will be changed so that no possibility +of confusion between the derived package and this Software will +exist. + diff --git a/xsl/docsrc/documentation.xml b/xsl/docsrc/documentation.xml new file mode 100644 index 000000000..ef46dd837 --- /dev/null +++ b/xsl/docsrc/documentation.xml @@ -0,0 +1,51 @@ + + + + + +]> + + +DocBook XSL Stylesheet Documentation + + + +Walsh +Norman +Stayton +Bob + + +199920002001 +Norman Walsh + + + +Preface + +This is the beginnings of documentation for the DocBook XSL +Stylesheets. + + + +&publishing.xml; +&extensions.xml; + + +Reference Documentation + +Reference documentation is also available: + + + + + + + +&templates.xml; + + diff --git a/xsl/docsrc/extensions.xml b/xsl/docsrc/extensions.xml new file mode 100644 index 000000000..5122effc7 --- /dev/null +++ b/xsl/docsrc/extensions.xml @@ -0,0 +1,96 @@ + +Saxon Extensions + + +Beginning with release 1.25, the DocBook XSL Stylesheets include +a set of Java extensions for Saxon. + +These extensions enable callouts, numbered program listings, and +the direct inclusion of text: + + + + + + + + + + + + +@rem = '--*-Perl-*-- +@echo off +perl.exe %_batchname %$ +goto endofperl +@rem '; + +# Compress mail... + +require 'n:/home/nwalsh/lib/cygnus.pl'; +require 'timelocal.pl'; +use Cwd; + +select (STDERR); $| = 1; +select (STDOUT); $| = 1; + +@DIRS = ("/home/nwalsh/Mail"); +while (@DIRS) { + $dir = shift @DIRS; + opendir (DIR, $dir); + while ($fname = readdir(DIR)) { + $file = "$dir/$fname"; + next if ! -d $file; + next if $fname =~ /^\.\.?$/; + + print "$file\n"; + push (@DIRS, $file); + &compress ($file); + } +} + +exit; + + +The prologue handles embedding a Perl script in a DOS batch file. + + +The goto statement, interpreted by the DOS batch +file interpreter, skips over the body of the Perl script. + + +The require statement sources in external program +fragments. + + +The use statement is similar, but has additional +utility. It is a Perl5 function. (Note that this callout area specifies +both a line and a column.) + + +This is a user subroutine call. + + + + +
Installation + +The extensions are included in the distribution in +extensions/nwalsh.jar. Just make sure that jar +file is in your CLASSPATH when you run Saxon. + +
+ +
Using the Extensions + +For compatibility with other processors, the extensions are disabled +by default. To enable the extensions, turn on +$saxon.extensions, for example by passing +saxon.extensions=1 to Saxon. + +For more control over the specific extensions, see +. +
+ +
diff --git a/xsl/docsrc/fo/.cvsignore b/xsl/docsrc/fo/.cvsignore new file mode 100644 index 000000000..6722cd96e --- /dev/null +++ b/xsl/docsrc/fo/.cvsignore @@ -0,0 +1 @@ +*.xml diff --git a/xsl/docsrc/fo/Makefile b/xsl/docsrc/fo/Makefile new file mode 100644 index 000000000..2b38ace57 --- /dev/null +++ b/xsl/docsrc/fo/Makefile @@ -0,0 +1,9 @@ +JSTYLE=../../docsrc/xsl2jref.xsl +VPATH=../../fo + +XMLFILES = param.xml table.xml + +all: $(XMLFILES) + +%.xml : %.xsl $(JSTYLE) + saxon -6 $< $(JSTYLE) - output-file=$@ diff --git a/xsl/docsrc/html/.cvsignore b/xsl/docsrc/html/.cvsignore new file mode 100644 index 000000000..6722cd96e --- /dev/null +++ b/xsl/docsrc/html/.cvsignore @@ -0,0 +1 @@ +*.xml diff --git a/xsl/docsrc/html/Makefile b/xsl/docsrc/html/Makefile new file mode 100644 index 000000000..f8304a7f0 --- /dev/null +++ b/xsl/docsrc/html/Makefile @@ -0,0 +1,9 @@ +JSTYLE=../../docsrc/xsl2jref.xsl +VPATH=../../html + +XMLFILES = param.xml ebnf.xml + +all: $(XMLFILES) + +%.xml : %.xsl $(JSTYLE) + saxon -6 $< $(JSTYLE) /dev/null output-file=$@ diff --git a/xsl/docsrc/jrefhtml.xsl b/xsl/docsrc/jrefhtml.xsl new file mode 100644 index 000000000..b176fcabb --- /dev/null +++ b/xsl/docsrc/jrefhtml.xsl @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + + + + + +
+
+ + +
+ + + + + + + Author + + +
+
+ + +
+ + + + + + + Version + + +
+
+ + +
+ + + + + + + Parameters + + +
+
+ + +
+ + + + + + + Returns + + +
+
+ + +
+ + + + + + + Exceptions + + +
+
+ + +
+ + + + + + + See + + +
+
+ + +
+ + + + + + + Since + + +
+
+ + +
+ + + + + + + Serial + + +
+
+ + +
+ + + + + + + Deprecated + + +
+
+ + + +
diff --git a/xsl/docsrc/legalnotice.xml b/xsl/docsrc/legalnotice.xml new file mode 100644 index 000000000..06bb66943 --- /dev/null +++ b/xsl/docsrc/legalnotice.xml @@ -0,0 +1,37 @@ +Copyright Statement + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation files +(the Software), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other dealings in +this Software without prior written authorization from the individuals +in question. + +Any stylesheet derived from this Software that is publically +distributed will be identified with a different name and the version +strings in any derived Software will be changed so that no possibility +of confusion between the derived package and this Software will +exist. + + +Warranty +THE SOFTWARE IS PROVIDED AS IS, +WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY +OTHER CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT +OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/xsl/docsrc/lib/.cvsignore b/xsl/docsrc/lib/.cvsignore new file mode 100644 index 000000000..6722cd96e --- /dev/null +++ b/xsl/docsrc/lib/.cvsignore @@ -0,0 +1 @@ +*.xml diff --git a/xsl/docsrc/lib/Makefile b/xsl/docsrc/lib/Makefile new file mode 100644 index 000000000..e4c522c90 --- /dev/null +++ b/xsl/docsrc/lib/Makefile @@ -0,0 +1,9 @@ +JSTYLE=../../docsrc/xsl2jref.xsl +VPATH=../../lib + +XMLFILES = lib.xml + +all: $(XMLFILES) + +%.xml : %.xsl $(JSTYLE) + saxon -6 $< $(JSTYLE) /dev/null output-file=$@ diff --git a/xsl/docsrc/publishing.xml b/xsl/docsrc/publishing.xml new file mode 100644 index 000000000..977db4565 --- /dev/null +++ b/xsl/docsrc/publishing.xml @@ -0,0 +1,1019 @@ + + + +$Id$ + +Stayton +Bob +2000Bob Stayton + + +DocBook XSL + + + Using XSL tools to publish DocBook + documents + There is a growing list of tools to process DocBook + documents using XSL stylesheets. Each tool implements parts + or all of the XSL standard, which actually has several + components: + + + Extensible Stylesheet Language (XSL) + + A language for expressing stylesheets written + in XML. It includes the formatting object language, but + refers to separate documents for the transformation + language and the path language. + + + + XSL Transformation (XSLT) + + The part of XSL for transforming XML documents + into other XML documents, HTML, or text. It can be used to + rearrange the content and generate new content. + + + + XML Path Language (XPath) + + A language for addressing parts of an XML + document. It is used to find the parts of your document to + apply different styles to. All XSL processors use this + component. + + + +To publish HTML from your XML documents, you just + need an XSLT engine. To get to print, you need an XSLT + engine to produce formatting objects (FO), which then must + be processed with a formatting object processor to produce + PostScript or PDF output. +James Clark's XT was the first useful XSLT engine, + and it is still in wide use. It is written in Java, so it + runs on many platforms, and it is free ( + http://www.jclark.com). + XT comes with James Clark's nonvalidating parser XP, but + you can substitute a different Java parser. Here is a + simple example of using XT from the Unix command line to + produce HTML: You'll need to alter your + CLASSPATH environment variable to + include the path to where you put the + .jar files from the XT + distribution. +CLASSPATH=xt.jar:xp.jar:sax.jar +export CLASSPATH +java com.jclark.xsl.sax.Driver filename.xml docbook/html/docbook.xsl > output.html +If you replace the HTML stylesheet with a + formatting object stylesheet, XT will produce a formatting + object file. Then you can convert that to PDF using FOP, a + formatting object processor available for free from the + Apache XML Project ( + http://xml.apache.org). + Here is an example of that two stage processing: +CLASSPATH=xt.jar:xp.jar:sax.jar:fop.jar +export CLASSPATH +java com.jclark.xsl.sax.Driver filename.xml docbook/fo/docbook.xsl > output.fo +java org.apache.fop.apps.CommandLine output.fo output.pdf +As of this writing, some other XSLT processors to + choose from include: + + + 4XSLT, written in Python, from FourThought LLC ( + http://www.fourthought.com) + + +Sablotron, written in C++, from Ginger Alliance ( + + http://www.gingerall.com) + + +Saxon, written in Java, from Michael Kay ( + http://users.iclway.co.uk/mhkay/saxon) + + +Xalan, written in Java, from the Apache XML + Project ( + http://xml.apache.org) + + +XML::XSLT,written in Perl, from Geert Josten and + Egon Willighagen ( + http://www.cpan.org) + + +For print output, these additional tools are available for processing formatting objects: +XEP (written in Java) from + RenderX ( + http://www.renderx.com).PassiveTeX from Sebastian Rahtz (http://users.ox.ac.uk/~rahtz/passivetex/). + +A brief introduction to XSL +XSL is both a transformation language and a + formatting language. The XSLT transformation part lets you + scan through a document's structure and rearrange its + content any way you like. You can write out the content + using a different set of XML tags, and generate text as + needed. For example, you can scan through a document to + locate all headings and then insert a generated table of + contents at the beginning of the document, at the same time + writing out the content marked up as HTML. XSL is also a + rich formatting language, letting you apply typesetting + controls to all components of your output. With a good + formatting backend, it is capable of producing high quality + printed pages. +An XSL stylesheet is written using XML syntax, and is + itself a well-formed XML document. That makes the basic + syntax familiar, and enables an XML processor to check for + basic syntax errors. The stylesheet instructions use + special element names, which typically begin with + xsl: to distinguish them from any XML + tags you want to appear in the output. The XSL namespace is + identified at the top of the stylesheet file. As with other + XML, any XSL elements that are not empty will require a + closing tag. And some XSL elements have specific attributes + that control their behavior. It helps to keep a good XSL + reference book handy. +Here is an example of a simple XSL stylesheet applied + to a simple XML file to generate HTML output. + +Simple XML file +<?xml version="1.0"?> +<document> +<title>Using a mouse</title> +<para>It's easy to use a mouse. Just roll it +around and click the buttons.</para> +</document> + + +Simple XSL stylesheet +<?xml version='1.0'?> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> +<xsl:output method="html"/> + +<xsl:template match="document"> + <HTML><HEAD><TITLE> + <xsl:value-of select="./title"/> + </TITLE> + </HEAD> + <BODY> + <xsl:apply-templates/> + </BODY> + </HTML> +</xsl:template> + +<xsl:template match="title"> + <H1><xsl:apply-templates/></H1> +</xsl:template> + +<xsl:template match="para"> + <P><xsl:apply-templates/></P> +</xsl:template> + +</xsl:stylesheet> + + + +HTML output +<HTML> +<HEAD> +<TITLE>Using a mouse</TITLE> +</HEAD> +<BODY> +<H1>Using a mouse</H1> +<P>It's easy to use a mouse. Just roll it +around and click the buttons.</P> +</BODY> +</HTML> + + + + +XSL processing model +XSL is a template language, not a procedural +language. That means a stylesheet specifies a sample of the +output, not a sequence of programming steps to generate it. +A stylesheet consists of a mixture of output samples with +instructions of what to put in each sample. Each bit of +output sample and instructions is called +a template. +In general, you write a template for each element +type in your document. That lets you concentrate on +handling just one element at a time, and keeps a stylesheet +modular. The power of XSL comes from processing the +templates recursively. That is, each template handles the +processing of its own element, and then calls other +templates to process its children, and so on. Since an XML +document is always a single root element at the top level +that contains all of the nested descendent elements, the +XSL templates also start at the top and work their way down +through the hierarchy of elements. +Take the +DocBook <para> paragraph element as +an example. To convert this to HTML, you want to wrap the +paragraph content with the HTML +tags <p> and </p>. +But a DocBook <para> can contain +any number of in-line DocBook elements marking up the text. +Fortunately, you can let other templates take care of those +elements, so your XSL template +for <para> can be quite +simple: +<xsl:template match="para"> + <p> + <xsl:apply-templates/> + </p> +</xsl:template> + +The <xsl:template> element +starts a new template, and +its match attribute indicates where to +apply the template, in this case to +any <para> elements. The template +says to output a literal <p> string +and then execute +the <xsl:apply-templates/> instruction. +This tells the XSL processor to look among all the +templates in the stylesheet for any that should be applied +to the content of the paragraph. If each template in the +stylesheet includes +an <xsl:apply-templates/> instruction, +then all descendents will eventually be processed. When it +is through recursively applying templates to the paragraph +content, it outputs the </p> closing +tag. + +Context is important +Since you aren't writing a linear procedure to +process your document, the context of where and how to +apply each modular template is important. +The match attribute +of <xsl:template> provides that +context for most templates. There is an entire expression +language, XPath, for identifying what parts of your +document should be handled by each template. The simplest +context is just an element name, as in the example above. +But you can also specify elements as children of other +elements, elements with certain attribute values, the first +or last elements in a sequence, and so on. Here is how the +DocBook <formalpara> element is +handled: +<xsl:template match="formalpara"> + <p> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="formalpara/title"> + <b><xsl:apply-templates/></b> + <xsl:text> </xsl:text> +</xsl:template> + +<xsl:template match="formalpara/para"> + <xsl:apply-templates/> +</xsl:template> + +There are three templates defined, one for +the <formalpara> element itself, + and one for each of its children elements. The match attribute +value formalpara/title in the second +template is an XPath expression indicating +a <title> element that is an +immediate child of +a <formalpara> element. This +distinguishes such titles from +other <title> elements used in +DocBook. XPath expressions are the key to controlling how +your templates are applied. +In general, the XSL processor has internal rules that +apply templates that are more specific before templates +that are less specific. That lets you control the details, +but also provides a fallback mechanism to a less specific +template when you don't supply the full context for every +combination of elements. This feature is illustrated by the +third template, for formalpara/para. By +including this template, the stylesheet processes a <para> within <formalpara> in +a special way, in this case by not outputting the HTML <p> tags already output by its parent. If this template had not been included, then the processor would have fallen back to the template +specified by match="para" described +above, which would have output a second set of <p> tags. +You can also control template context with +XSL modes, which are used extensively +in the DocBook stylesheets. Modes let you process the same +input more than once in different ways. +A mode attribute in +an <xsl:template> definition adds a +specific mode name to that template. When the same mode +name is used +in <xsl:apply-templates/>, it acts +as a filter to narrow the selection of templates to only +those selected by +the match expression and that +have that mode name. This lets you define two different +templates for the same element match that are applied under +different contexts. For example, there are two templates +defined for +DocBook <listitem> elements: +<xsl:template match="listitem"> + <li><xsl:apply-templates/></li> +</xsl:template> + +<xsl:template match="listitem" mode="xref"> + <xsl:number format="1"/> +</xsl:template> + +The first template is for the normal list item +context where you want to output the +HTML <li> tags. The second template +is called with <xsl:apply-templates +select="$target" mode="xref"/> in the context +of processing <xref> elements. In +this case the select attribute locates +the ID of the specific list item and +the mode attribute selects the second +template, whose effect is to output its item number when it +is in an ordered list. Because there are many such special +needs when +processing <xref> elements, it is +convenient to define a mode name xref to +handle them all. Keep in mind that mode settings +do not automatically get passed down to +other templates +through <xsl:apply-templates/>. + + +Programming features +Although XSL is template-driven, it also has some +features of traditional programming languages. Here are +some examples from the DocBook stylesheets. +Assign a value to a variable: +<xsl:variable name="refelem" select="name($target)"/> + +If statement: +<xsl:if test="$show.comments"> + <i><xsl:call-template name="inline.charseq"/></i> +</xsl:if> + +Case statement: +<xsl:choose> + <xsl:when test="@columns"> + <xsl:value-of select="@columns"/> + </xsl:when> + <xsl:otherwise>1</xsl:otherwise> +</xsl:choose> + +Call a template by name like a subroutine, passing parameter values and accepting a return value: +<xsl:call-template name="xref.xreflabel"> + <xsl:with-param name="target" select="$target"/> +</xsl:call-template> + +However, you can't always use these constructs as you +do in other programming languages. Variables in particular +have very different behavior. + +Using variables and parameters +XSL provides two elements that let you assign a value +to a +name: <xsl:variable> and <xsl:param>. +These share the same name space and syntax for assigning +names and values. Both can be referred to using +the $name syntax. The main difference +between these two elements is that a param's value acts as +a default value that can be overridden when a template is +called using +a <xsl:with-param> element as in the +last example above. +Here are two examples from DocBook: +<xsl:param name="cols">1</xsl:param> +<xsl:variable name="segnum" select="position()"/> + +In both elements, the name of the parameter or +variable is specified with +the name attribute. So the name of +the param here +is cols and the name of +the variable is segnum. +The value of either can be supplied in two ways. The value +of the first example is the text node "1" and is supplied +as the content of the element. The value of the second +example is supplied as the result of the expression in +its select attribute, and the element +itself has no content. +The feature of XSL variables that is odd to new users +is that once you assign a value to a variable, you cannot +assign a new value within the same scope. Doing so will +generate an error. So variables are not used as dynamic +storage bins they way they are in other languages. They +hold a fixed value within their scope of application, and +then disappear when the scope is exited. This feature is a +result of the design of XSL, which is template-driven and +not procedural. This means there is no definite order of +processing, so you can't rely on the values of changing +variables. To use variables in XSL, you need to understand +how their scope is defined. +Variables defined outside of all templates are +considered global variables, and they are readable within +all templates. The value of a global variable is fixed, and +its global value can't be altered from within any template. +However, a template can create a local variable of the same +name and give it a different value. That local value +remains in effect only within the scope of the local +variable. +Variables defined within a template remain in effect +only within their permitted scope, which is defined as all +following siblings and their descendants. To understand +such a scope, you have to remember that XSL instructions +are true XML elements that are embedded in an XML family +hierarchy of XSL elements, often referred to as parents, +children, siblings, ancestors and descendants. Taking the +family analogy a step further, think of a variable +assignment as a piece of advice that you are allowed to +give to certain family members. You can give your advice +only to your younger siblings (those that follow you) and +their descendents. Your older siblings won't listen, +neither will your parents or any of your ancestors. To +stretch the analogy a bit, it is an error to try to give +different advice under the same name to the same group of +listeners (in other words, to redefine the variable). Keep +in mind that this family is not the elements of your +document, but just the XSL instructions in your stylesheet. +To help you keep track of such scopes in hand-written +stylesheets, it helps to indent nested XSL elements. Here +is an edited snippet from the DocBook stylesheet +file pi.xsl that illustrates different +scopes for two variables: + + 1 <xsl:template name="dbhtml-attribute"> + 2 ... + 3 <xsl:choose> + 4 <xsl:when test="$count>count($pis)"> + 5 <!-- not found --> + 6 </xsl:when> + 7 <xsl:otherwise> + 8 <xsl:variable name="pi"> + 9 <xsl:value-of select="$pis[$count]"/> +10 </xsl:variable> +11 <xsl:choose> +12 <xsl:when test="contains($pi,concat($attribute, '='))"> +13 <xsl:variable name="rest" select="substring-after($pi,concat($attribute,'='))"/> +14 <xsl:variable name="quote" select="substring($rest,1,1)"/> +15 <xsl:value-of select="substring-before(substring($rest,2),$quote)"/> +16 </xsl:when> +17 <xsl:otherwise> +18 ... +19 </xsl:otherwise> +20 </xsl:choose> +21 </xsl:otherwise> +22 </xsl:choose> +23 </xsl:template> + + +The scope of the variable pi begins +on line 8 where it is defined in this template, and ends on +line 20 when its last sibling ends.Technically, the scope extends to the end tag of the parent of the <xsl:variable> element. That is effectively the last sibling. The scope of the +variable rest begins on line 13 and ends +on line 15. Fortunately, line 15 outputs an expression +using the value before it goes out of scope. +What happens when +an <xsl:apply-templates/> element +is used within the scope of a local variable? Do the +templates that are applied to the document children get the +variable? The answer is no. The templates that are applied +are not actually within the scope of the variable. They +exist elsewhere in the stylesheet and are not following +siblings or their descendants. +To pass a value to another template, you pass a +parameter using +the <xsl:with-param> element. This +parameter passing is usually done with calls to a specific +named template +using <xsl:call-template>, although +it works +with <xsl:apply-templates> too. +That's because the called template must be expecting the +parameter by defining it using +a <xsl:param> element with the same +parameter name. Any passed parameters whose names are not +defined in the called template are ignored. +Here is an example of parameter passing +from docbook.xsl: +<xsl:call-template name="head.content"> + <xsl:with-param name="node" select="$doc"/> +</xsl:call-template> + +Here a template +named head.content is being called and +passed a parameter named node whose +content is the value of the $doc variable +in the current context. The top of that template looks like +this: +<xsl:template name="head.content"> + <xsl:param name="node" select="."/> + +The template is expecting the parameter because it +has a <xsl:param> defined with the +same name. The value in this definition is the default +value. This would be the parameter value used in the +template if the template was called without passing that +parameter. + + + +Generating HTML output. +You generate HTML from your DocBook XML files by +applying the HTML version of the stylesheets. This is done +by using the HTML driver +file docbook/html/docbook.xsl as your +stylesheet. That is the master stylesheet file that +uses <xsl:include> to pull in the +component files it needs to assemble a complete stylesheet +for producing HTML. +The way the DocBook stylesheet generates HTML is to +apply templates that output a mix of text content and HTML +elements. Starting at the top level in the main +file docbook.xsl: +<xsl:template match="/"> + <xsl:variable name="doc" select="*[1]"/> + <html> + <head> + <xsl:call-template name="head.content"> + <xsl:with-param name="node" select="$doc"/> + </xsl:call-template> + </head> + <body> + <xsl:apply-templates/> + </body> + </html> +</xsl:template> + +This template matches the root element of your input +document, and starts the process of recursively applying +templates. It first defines a variable +named doc and then outputs two literal +HTML elements <html> and <head>. +Then it calls a named +template head.content to process the +content of the HTML <head>, closes +the <head> and starts +the <body>. There it +uses <xsl:apply-templates/> to +recursively process the entire input document. Then it just +closes out the HTML file. +Simple HTML elements can generated as literal +elements as shown here. But if the HTML being output +depends on the context, you need something more powerful to +select the element name and possibly add attributes and +their values. Here is a fragment +from sections.xsl that shows how a +heading tag is generated using +the <xsl:element> and <xsl:attribute> elements: + + 1 <xsl:element name="h{$level}"> + 2 <xsl:attribute name="class">title</xsl:attribute> + 3 <xsl:if test="$level<3"> + 4 <xsl:attribute name="style">clear: all</xsl:attribute> + 5 </xsl:if> + 6 <a> + 7 <xsl:attribute name="name"> + 8 <xsl:call-template name="object.id"/> + 9 </xsl:attribute> +10 <b><xsl:copy-of select="$title"/></b> +11 </a> +12 </xsl:element> + +This whole example is generating a single HTML +heading element. Line 1 begins the HTML element definition +by identifying the name of the element. In this case, the +name is an expression that includes the +variable $level passed as a parameter to +this template. Thus a single template can +generate <h1>, <h2>, +etc. depending on the context in which it is called. Line 2 +defines a class="title" attribute that is +added to this element. Lines 3 to 5 add +a style="clear all" attribute, but only +if the heading level is less than 3. Line 6 opens +an <a> anchor element. Although this +looks like a literal output string, it is actually modified +by lines 7 to 9 that insert +the name attribute into +the <a> element. This illustrates +that XSL is managing output elements as active element +nodes, not just text strings. Line 10 outputs the text of +the heading title, also passed as a parameter to the +template, enclosed in HTML boldface tags. Line 11 closes +the anchor tag with the +literal </a> syntax, while line 12 +closes the heading tag by closing the element definition. +Since the actual element name is a variable, it couldn't +use the literal syntax. +As you follow the sequence of nested templates +processing elements, you might be wondering how the +ordinary text of your input document gets to the output. In +the file docbook.xsl you will find +this template that handles any text not processed by any +other template: +<xsl:template match="text()"> + <xsl:value-of select="."/> +</xsl:template> + +This template's body consists of the "value" of the text node, +which is just its text. In general, all XSL processors have +some built-in templates to handle any content for which +your stylesheet doesn't supply a matching template. This +template serves the same function but appears explicitly in +the stylesheet. + + +Generating formatting objects. +You generate formatting objects from your DocBook XML +files by applying the fo version of the stylesheets. This +is done by using the fo driver +file docbook/fo/docbook.xsl as your +stylesheet. That is the master stylesheet file that +uses <xsl:include> to pull in the +component files it needs to assemble a complete stylesheet +for producing formatting objects. Generating a formatting +objects file is only half the process of producing typeset +output. You also need a formatting object processor such as +the Apache XML Project's FOP as described in an earlier +section. +The DocBook fo stylesheet works in a similar manner +to the HTML stylesheet. Instead of outputting HTML tags, it +outputs text marked up +with <fo:something> tags. +For example, to indicate that some text should be kept +in-line and typeset with a monospace font, it might look +like this: +<fo:inline-sequence font-family="monospace">/usr/man</fo:inline-sequence> +The templates +in docbook/fo/inline.xsl that produce +this output for a +DocBook <filename> element look +like this: +<xsl:template match="filename"> + <xsl:call-template name="inline.monoseq"/> +</xsl:template> + +<xsl:template name="inline.monoseq"> + <xsl:param name="content"> + <xsl:apply-templates/> + </xsl:param> + <fo:inline-sequence font-family="monospace"> + <xsl:copy-of select="$content"/> + </fo:inline-sequence> +</xsl:template> + +There are dozens of fo tags and attributes specified +in the XSL standard. It is beyond the scope of this +document to cover how all of them are used in the DocBook +stylesheets. Fortunately, this is only an intermediate +format that you probably won't have to deal with very much +directly unless you are writing your own +stylesheets. + + + +Customizing DocBook XSL stylesheets +The DocBook XSL stylesheets are written in a modular +fashion. Each of the HTML and FO stylesheets starts with a +driver file that assembles a collection of component files +into a complete stylesheet. This modular design puts similar things together into smaller files that are easier to write and maintain than one big stylesheet. The modular stylesheet files +are distributed among four directories: + + +common/ + +contains code common to both stylesheets, including localization data + + + +fo/ + +a stylesheet that produces XSL FO result trees + + + +html/ + +a stylesheet that produces HTML/XHTML result trees + + + +lib/ + +contains schema-independent functions + + + + + +The driver files for each of HTML and FO stylesheets +are html/docbook.xsl and fo/docbook.xsl, +respectively. A driver file consists mostly of a bunch +of <xsl:include> instructions to +pull in the component templates, and then defines some +top-level templates. For example: +<xsl:include href="../VERSION"/> +<xsl:include href="../lib/lib.xsl"/> +<xsl:include href="../common/l10n.xsl"/> +<xsl:include href="../common/common.xsl"/> +<xsl:include href="autotoc.xsl"/> +<xsl:include href="lists.xsl"/> +<xsl:include href="callout.xsl"/> +... +<xsl:include href="param.xsl"/> +<xsl:include href="pi.xsl"/> + +The first four modules are shared with the FO +stylesheet and are referenced using relative pathnames to +the common directories. Then the long list of component +stylesheets starts. Pathnames in include statements are +always taken to be relative to the including file. Each +included file must be a valid XSL stylesheet, which means +its root element must +be <xsl:stylesheet>. + +Stylesheet inclusion vs. importing +XSL actually provides two inclusion +mechanisms: <xsl:include> and <xsl:import>. +Of the two, <xsl:include> is +the simpler. It treats the included content as if it were +actually typed into the file at that point, and doesn't +give it any more or less precedence relative to the +surrounding text. It is best used when assembling +dissimilar templates that don't overlap what they match. +The DocBook driver files use this instruction to assemble a +set of modules into a stylesheet. +In contrast, <xsl:import> lets +you manage the precedence of templates and variables. It is +the preferred mode of customizing another stylesheet because +it lets you override definitions in the distributed +stylesheet with your own, without altering the distribution +files at all. You simply import the whole stylesheet and +add whatever changes you want. +The precedence rules for import are detailed and +rigorously defined in the XSL standard. The basic rule is +that any templates and variables in the importing +stylesheet have precedence over equivalent templates and +variables in the imported stylesheet. Think of the imported stylesheet elements as a fallback collection, to be used only if a match is not found in the current stylesheet. You can customize the templates you want to change in your stylesheet file, and let the imported stylesheet handle the rest. + +Customizing a DocBook XSL stylesheet is the opposite +of customizing a DocBook DTD. When you customize a DocBook +DTD, the rules of XML and SGML dictate that +the first of any duplicate declarations +wins. Any subsequent declarations of the same element or +entity are ignored. The architecture of the DTD provides +slots for inserting your own custom declarations early +enough in the DTD for them to override the standard +declarations. In contrast, customizing an XSL stylesheet is +simpler because your definitions have precedence over imported ones. + +You can carry modularization to deeper levels because +module files can also include or import other modules. +You'll need to be careful to maintain the precedence that +you want as the modules get rolled up into a complete +stylesheet. + + +Customizing +with <literal><xsl:import></literal> +There is currently one example of customizing +with <xsl:import> in the HTML +version of the DocBook stylesheets. +The xtchunk.xsl stylesheet modifies the +HTML processing to output many smaller HTML files rather +than a single large file per input document. It uses XSL +extensions defined only in the XSL +processor XT. In the driver +file xtchunk.xsl, the first instruction +is <xsl:import +href="docbook.xsl"/>. That instruction imports +the original driver file, which in turn uses +many <xsl:include> instructions to +include all the modules. That single import instruction +gives the new stylesheet the complete set of DocBook +templates to start with. +After the +import, xtchunk.xsl redefines some of +the templates and adds some new ones. Here is one example +of a redefined template: +Original template in autotoc.xsl +<xsl:template name="href.target"> + <xsl:param name="object" select="."/> + <xsl:text>#</xsl:text> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$object"/> + </xsl:call-template> +</xsl:template> + +New template in xtchunk.xsl +<xsl:template name="href.target"> + <xsl:param name="object" select="."/> + <xsl:variable name="ischunk"> + <xsl:call-template name="chunk"> + <xsl:with-param name="node" select="$object"/> + </xsl:call-template> + </xsl:variable> + + <xsl:apply-templates mode="chunk-filename" select="$object"/> + + <xsl:if test="$ischunk='0'"> + <xsl:text>#</xsl:text> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$object"/> + </xsl:call-template> + </xsl:if> +</xsl:template> + +The new template handles the more complex processing +of HREFs when the output is split into many HTML files. +Where the old template could simply +output #object.id, +the new one outputs filename#object.id. + + +Setting stylesheet variables +You may not have to define any new templates, +however. The DocBook stylesheets are parameterized using +XSL variables rather than hard-coded values for many of the +formatting features. Since +the <xsl:import> mechanism also +lets you redefine global variables, this gives you an easy +way to customize many features of the DocBook +stylesheets. Over time, more features will be parameterized to permit customization. If you find hardcoded values in the stylesheets that would be useful to customize, please let the maintainer know. +Near the end of the list of includes in the main +DocBook driver file is the +instruction <xsl:include +href="param.xsl"/>. +The param.xsl file is the most +important module for customizing a DocBook XSL stylesheet. +This module contains no templates, only definitions of +stylesheet variables. Since these variables are defined +outside of any template, they are global variables and +apply to the entire stylesheet. By redefining these +variables in an importing stylesheet, you can change the +behavior of the stylesheet. +To create a customized DocBook stylesheet, you simply +create a new stylesheet file such +as mystyle.xsl that imports the standard +stylesheet and adds your own new variable definitions. Here +is an example of a complete custom stylesheet that changes +the depth of sections listed in the table of contents from +two to three: +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0' + xmlns="http://www.w3.org/TR/xhtml1/transitional" + exclude-result-prefixes="#default"> + +<xsl:import href="docbook.xsl"/> + +<xsl:variable name="toc.section.depth">3</xsl:variable> +<!-- Add other variable definitions here --> + +</xsl:stylesheet> + +Following the opening stylesheet element are the +import instruction and one variable definition. The +variable toc.section.depth was defined +in param.xsl with value "2", and here +it is defined as "3". Since the importing stylesheet takes +precedence, this new value is used. Thus documents +processed with mystyle.xsl instead +of docbook.xsl will have three levels +of sections in the tables of contents, and all other +processing will be the same. +Use the list of variables +in param.xsl as your guide for creating +a custom stylesheet. If the changes you want are controlled +by a variable there, then customizing is easy. + + + +Writing your own templates +If the changes you want are more extensive than what +is supported by variables, you can write new templates. You +can put your new templates directly in your importing +stylesheet, or you can modularize your importing stylesheet +as well. You can write your own stylesheet module +containing a collection of templates for processing lists, +for example, and put them in a file +named mylists.xsl. Then your importing +stylesheet can pull in your list templates with +a <xsl:include +href="mylists.xsl"/> instruction. Since your +included template definitions appear after the main import +instruction, your templates will take precedence. +You'll need to make sure your new templates are +compatible with the remaining modules, which means: + + +Any named templates should use the same name so +calling templates in other modules can find them. + + +Your template set should process the same elements +matched by templates in the original module, to ensure +complete coverage. + + +Include the same set +of <xsl:param> elements in each +template to interface properly with any calling templates, +although you can set different values for your +parameters. + + +Any templates that are used like subroutines to +return a value should return the same data type. + + + + +Writing your own driver +Another approach to customizing the stylesheets is to +write your own driver file. Instead of +using <xsl:import +href="docbook.xsl"/>, you copy that file to a +new name and rewrite any of +the <xsl:include/> instructions to +assemble a custom collection of stylesheet modules. One +reason to do this is to speed up processing by reducing the +size of the stylesheet. If you are using a customized +DocBook DTD that omits many elements you never use, you +might be able to omit those modules of the +stylesheet. + + +Localization +The DocBook stylesheets include features for +localizing generated text, that is, printing any generated +text in a language other than the default English. In +general, the stylesheets will switch to the language +identified by a lang attribute when +processing elements in your documents. If your documents +use the lang attribute, then you don't +need to customize the stylesheets at all for +localization. +As far as the stylesheets go, +a lang attribute is inherited by the +descendents of a document element. The stylesheet searches +for a lang attribute using this XPath +expression: +<xsl:variable name="lang-attr" + select="($target/ancestor-or-self::*/@lang + |$target/ancestor-or-self::*/@xml:lang)[last()]"/> + +This locates the attribute on the current element or +its most recent ancestor. Thus +a lang attribute is in effect for an +element and all of its descendents, unless it is reset in +one of those descendents. If you define it in only your +document root element, then it applies to the whole +document: +<?xml version="1.0"?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN" "docbook.dtd"> +<book lang="fr"> +... +</book> +When text is being generated, the stylesheet checks +the most recent lang attribute and looks +up the generated text strings for that language in a +localization XML file. These are located in +the common directory of the +stylesheets, one file per language. Here is the top of the +file fr.xml: +<localization language="fr"> + +<gentext key="abstract" text="R&#x00E9;sum&#x00E9;"/> +<gentext key="answer" text="R:"/> +<gentext key="appendix" text="Annexe"/> +<gentext key="article" text="Article"/> +<gentext key="bibliography" text="Bibliographie"/> +... + +The stylesheet templates use the gentext key names, +and then the stylesheet looks up the associated text value +when the document is processed with that lang setting. The +file l10n.xml (note +the .xml suffix) lists the filenames of +all the supported languages. +You can also create a custom stylesheet that sets the +language. That might be useful if your documents don't make +appropriate use of the lang attribute. +The module l10n.xsl defines two global +variables that can be overridden with an importing +stylesheet as described above. Here are their default +definitions: +<xsl:variable name="l10n.gentext.language"></xsl:variable> +<xsl:variable name="l10n.gentext.default.language">en</xsl:variable> + +The first one sets the language for all elements, +regardless of an element's lang attribute +value. The second just sets a default language for any +elements that haven't got a lang setting +of their own (or their ancestors). + + + diff --git a/xsl/docsrc/reference.xml b/xsl/docsrc/reference.xml new file mode 100644 index 000000000..ce742bc11 --- /dev/null +++ b/xsl/docsrc/reference.xml @@ -0,0 +1,66 @@ + + + + + + + +]> + + +DocBook XSL Stylesheet Reference Documentation + +$Id$ + +Walsh +Norman +19992000 +Norman Walsh + + + +Preface + +This constitutes only the most rudimentary beginnings of +documentation for these stylesheets. + +At present, the only documentation available is the set +of references generated from the stylesheet sources: + + + + + + + + + + + + + + + + +The reference to the template system is also available, +but at this point it's probably even less useful than the preceding +references. + + + + + + + + + diff --git a/xsl/docsrc/template-example.xml b/xsl/docsrc/template-example.xml new file mode 100644 index 000000000..abb3dbd1e --- /dev/null +++ b/xsl/docsrc/template-example.xml @@ -0,0 +1,12 @@ + + + + + + <author/> + <edition/> + </t:titlepage-content> +</t:titlepage> +</t:templates> diff --git a/xsl/docsrc/template-example.xsl b/xsl/docsrc/template-example.xsl new file mode 100644 index 000000000..b4bd9d6e2 --- /dev/null +++ b/xsl/docsrc/template-example.xsl @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + +<!-- This stylesheet was created by titlepage.xsl; do not edit it by hand. --> + +<xsl:import href="/path/to/html/docbook.xsl"/> + +<xsl:template name="article.titlepage.recto"><xsl:apply-templates mode="article.titlepage.recto.mode" select="(articleinfo/title|artheader/title|title)[1]|articleinfo/author|artheader/author|articleinfo/edition|artheader/edition"/> +</xsl:template> + +<xsl:template name="article.titlepage"> + <div class="titlepage"> + <xsl:call-template name="article.titlepage.before.recto"/> + <xsl:call-template name="article.titlepage.recto"/> + <xsl:call-template name="article.titlepage.before.verso"/> + <xsl:call-template name="article.titlepage.verso"/> + <xsl:call-template name="article.titlepage.separator"/> + </div> +</xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff --git a/xsl/docsrc/template/.cvsignore b/xsl/docsrc/template/.cvsignore new file mode 100644 index 000000000..6722cd96e --- /dev/null +++ b/xsl/docsrc/template/.cvsignore @@ -0,0 +1 @@ +*.xml diff --git a/xsl/docsrc/template/Makefile b/xsl/docsrc/template/Makefile new file mode 100644 index 000000000..30b891eb6 --- /dev/null +++ b/xsl/docsrc/template/Makefile @@ -0,0 +1,10 @@ +JSTYLE=../../docsrc/xsl2jref.xsl +VPATH=../../template + +XMLFILES = titlepage.xml + +all: $(XMLFILES) + +%.xml : %.xsl $(JSTYLE) + saxon -6 $< $(JSTYLE) /dev/null output-file=$@ + xnsgmls -E 5 -sv -c /share/doctypes/catalog $@ diff --git a/xsl/docsrc/templates.xml b/xsl/docsrc/templates.xml new file mode 100644 index 000000000..2e936370a --- /dev/null +++ b/xsl/docsrc/templates.xml @@ -0,0 +1,104 @@ +<chapter> +<chapterinfo> +<releaseinfo role="meta"> +$Id$ +</releaseinfo> +<author><surname>Walsh</surname> +<firstname>Norman</firstname></author> +<copyright><year>2000</year><holder>Norman Walsh</holder> +</copyright> +</chapterinfo> +<title>The Template System + +Some parts of the DocBook XSL Stylesheets are actually generated +using XSL Stylesheets. In particular, the formatting of title pages +is generated using a special template system. The same template system +will eventually allow you to easily customize bibliography entries and +perhaps other parts of the system as well. + +FIXME: there needs to be more introductory/explanatory text +here! + +
Changing the Article Title Page + +In order to demonstrate how this system works, let's consider +how we can use it to change the format of article title pages. + +By default, the stylesheets print the following elements on the +article title page, in this order: +title +subtitle +corpauthor +authorgroup +author +releaseinfo +copyright +legalnotice +pubdate +revision +revhistory +abstract +. Suppose we want to put only the +title, author, and +edition elements on the title page, in the order +that they appear in the articleinfo. + + +The hard (and wrong!) way to do it would be to +edit titlepage.templates.xsl and make the changes +by hand. + +The easy and right way is to construct a template document that +describes the order and sequence of elements that you want: + + + + + + + <author/> + <edition/> + </t:titlepage-content> +</t:titlepage> +</t:templates> +]]></screen> + +<para>Then process this document with the +<filename>template/titlepage.xsl</filename> stylesheet. This will +produce the following somewhat cryptic stylesheet:</para> + +<screen><![CDATA[ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + +<!-- This stylesheet was created by titlepage.xsl; do not edit it by hand. --> + +<xsl:import href="/path/to/html/docbook.xsl"/> + +<xsl:template name="article.titlepage.recto"><xsl:apply-templates mode="article.titlepage.recto.mode" select="(articleinfo/title|artheader/title|title)[1]|articleinfo/author|artheader/author|articleinfo/edition|artheader/edition"/> +</xsl:template> + +<xsl:template name="article.titlepage"> + <div class="titlepage"> + <xsl:call-template name="article.titlepage.before.recto"/> + <xsl:call-template name="article.titlepage.recto"/> + <xsl:call-template name="article.titlepage.before.verso"/> + <xsl:call-template name="article.titlepage.verso"/> + <xsl:call-template name="article.titlepage.separator"/> + </div> +</xsl:template> + +</xsl:stylesheet> +]]></screen> + +<para>Despite its cryptic appearance, it has the desired result. +If you want to change <emphasis>how</emphasis> the titlepage elements +are formatted (as opposed to which ones are formatted), you have to +write your own customization layer that overrides the template for +the element in question in the <quote>titlepage.mode</quote> mode.</para> +</section> + +</chapter> diff --git a/xsl/docsrc/warranty.xml b/xsl/docsrc/warranty.xml new file mode 100644 index 000000000..534b8f90e --- /dev/null +++ b/xsl/docsrc/warranty.xml @@ -0,0 +1,14 @@ +<?xml version='1.0'?> +<!DOCTYPE legalnotice + PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" + "http://www.oasis-open.org/xml/4.1.2/docbookx.dtd"> +<legalnotice><title>Warranty +THE SOFTWARE IS PROVIDED AS IS, +WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY +OTHER CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT +OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/xsl/docsrc/xsl2jref.xsl b/xsl/docsrc/xsl2jref.xsl new file mode 100644 index 000000000..7fe10463a --- /dev/null +++ b/xsl/docsrc/xsl2jref.xsl @@ -0,0 +1,356 @@ + + "> +]> + + + + + + + + + + + + + + + + + + + + You must set the output-file parameter! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &RE; + + + + + &RE; + + + + + + + + + + + + + + + + + &RE; + + + + + + + + + + + + + + + =" + + " + + + + + + + + < + + + + + / + > + + + > + + </ + + > + + + + + + <!-- + + --> + + + + <? + + + + ?> + + + + + + + + + + + + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + + + &RE; + + &RE; + + + &RE; + + + + + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + + + &RE; + + &RE; + + + &RE; + + + + + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + &RE; + + + + &RE; + + &RE; + + + &RE; + + + + + + + &RE; + + &RE; + + &RE; + + + + (in + + mode) + + + &RE; + + &RE; + + &RE; + + &RE; + + + + + + + + + + + &RE; + + &RE; + + + &RE; + + + + + + + + mode + + + + + + + + + + + + mode + + + + + + + + + + + + + + &RE; + + + + + + + + + < + + + + + / + > + + + > + + &RE; + ... + &RE; + </ + + > + + + + + + + diff --git a/xsl/extensions/.cvsignore b/xsl/extensions/.cvsignore new file mode 100644 index 000000000..2c22042b6 --- /dev/null +++ b/xsl/extensions/.cvsignore @@ -0,0 +1,3 @@ +doc +*.jar + diff --git a/xsl/extensions/Makefile b/xsl/extensions/Makefile new file mode 100644 index 000000000..9d1b7220c --- /dev/null +++ b/xsl/extensions/Makefile @@ -0,0 +1,27 @@ +.PHONY: doc saxon551 saxon6 saxon61 xalan2 + +all: saxon551 saxon6 saxon61 xalan2 + +saxon551: + cd saxon551/.classes && make + +saxon6: + cd saxon6/.classes && make + +saxon61: + cd saxon61/.classes && make + +xalan2: + cd xalan2/.classes && make + +jars: saxon551 saxon6 saxon61 xalan2 + cd saxon551/.classes && make jar + cd saxon6/.classes && make jar + cd saxon61/.classes && make jar + cd xalan2/.classes && make jar + +clean: + cd saxon551/.classes && make clean + cd saxon6/.classes && make clean + cd saxon61/.classes && make clean + cd xalan2/.classes && make clean diff --git a/xsl/extensions/prj.el b/xsl/extensions/prj.el new file mode 100644 index 000000000..2174d3e36 --- /dev/null +++ b/xsl/extensions/prj.el @@ -0,0 +1,216 @@ + + + + + + + + +(jde-set-project-name "xalan") +(jde-set-variables + '(jde-gen-session-bean-template (quote ("(jde-import-insert-imports-into-buffer (list \"javax.ejb.*\" +\"java.rmi.RemoteException\"))" "(jde-wiz-update-implements-clause \"SessionBean\")" "'> \"public void ejbActivate() throws RemoteException {\"'>'n \"}\"'>'n +'>'n" "'> \"public void ejbPassivate() throws RemoteException {\"'>'n \"}\"'>'n +'>'n" "'> \"public void ejbRemove() throws RemoteException {\"'>'n \"}\"'>'n '>'n" "'> \"public void setSessionContext(SessionContext ctx) throws +RemoteException {\"" "'>'n \"}\"'>'n '>'n" "'> \"public void unsetSessionContext() throws RemoteException {\"'>'n +\"}\"'>'n '>'n'>"))) + '(jde-gen-beep (quote ("(end-of-line) '&" "\"Toolkit.getDefaultToolkit().beep();\"'>'n'>"))) + '(jde-which-method-format (quote ("[" jde-which-method-current "]"))) + '(jde-run-classic-mode-vm nil) + '(jde-javadoc-gen-nodeprecatedlist nil) + '(jde-which-method-max-length 20) + '(jde-imenu-include-classdef t) + '(jde-javadoc-gen-link-online nil) + '(jde-gen-code-templates (quote (("Get Set Pair" . jde-gen-get-set) ("toString method" . jde-gen-to-string-method) ("Action Listener" . jde-gen-action-listener) ("Window Listener" . jde-gen-window-listener) ("Mouse Listener" . jde-gen-mouse-listener) ("Mouse Motion Listener" . jde-gen-mouse-motion-listener) ("Inner Class" . jde-gen-inner-class) ("println" . jde-gen-println) ("beep" . jde-gen-beep) ("property change support" . jde-gen-property-change-support) ("EJB Entity Bean" . jde-gen-entity-bean) ("EJB Session Bean" . jde-gen-session-bean)))) + '(jde-gen-cflow-else (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"else\")" "'(l '> \"else \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of else\"'>'n'>)" ")"))) + '(jde-make-args "") + '(jde-javadoc-gen-destination-directory "JavaDoc") + '(jde-mode-line-format (quote ("-" mode-line-mule-info mode-line-modified mode-line-frame-identification mode-line-buffer-identification " " global-mode-string " %[(" mode-name mode-line-process minor-mode-alist "%n" ")%]--" (line-number-mode "L%l--") (column-number-mode "C%c--") (-3 . "%p") (jde-which-method-mode ("--" jde-which-method-format "--")) "-%-"))) + '(jde-mode-abbreviations (quote (("ab" . "abstract") ("bo" . "boolean") ("br" . "break") ("by" . "byte") ("byv" . "byvalue") ("cas" . "cast") ("ca" . "catch") ("ch" . "char") ("cl" . "class") ("co" . "const") ("con" . "continue") ("de" . "default") ("dou" . "double") ("el" . "else") ("ex" . "extends") ("fa" . "false") ("fi" . "final") ("fin" . "finally") ("fl" . "float") ("fo" . "for") ("fu" . "future") ("ge" . "generic") ("go" . "goto") ("impl" . "implements") ("impo" . "import") ("ins" . "instanceof") ("in" . "int") ("inte" . "interface") ("lo" . "long") ("na" . "native") ("ne" . "new") ("nu" . "null") ("pa" . "package") ("pri" . "private") ("pro" . "protected") ("pu" . "public") ("re" . "return") ("sh" . "short") ("st" . "static") ("su" . "super") ("sw" . "switch") ("sy" . "synchronized") ("th" . "this") ("thr" . "throw") ("throw" . "throws") ("tra" . "transient") ("tr" . "true") ("vo" . "void") ("vol" . "volatile") ("wh" . "while")))) + '(jde-imenu-enable t) + '(jde-compile-option-verbose nil) + '(jde-db-option-heap-size (quote ((1 . "megabytes") (16 . "megabytes")))) + '(jde-bug-debugger-host-address "localhost" t) + '(jde-make-working-directory "") + '(jde-bug-breakpoint-marker-colors (quote ("red" . "yellow"))) + '(jde-javadoc-gen-use nil) + '(jde-gen-buffer-boilerplate nil) + '(jde-bug-raise-frame-p t) + '(jde-db-option-application-args (quote ("-IN" "/share/xsl/docbook/test/exttest.xml" "-XSL " "/share/xsl/docbook/test/exttest.xsl")) t) + '(jde-javadoc-gen-nonavbar nil) + '(jde-javadoc-gen-nohelp nil) + '(jde-bug-vm-includes-jpda-p nil) + '(jde-gen-jfc-app-buffer-template (quote ("(funcall jde-gen-boilerplate-function) '>'n" "\"import java.awt.Dimension;\" '>'n" "\"import java.awt.Graphics;\" '>'n" "\"import java.awt.Graphics2D;\" '>'n" "\"import java.awt.Color;\" '>'n" "\"import java.awt.geom.Ellipse2D;\" '>'n" "\"import java.awt.event.WindowAdapter;\" '>'n" "\"import java.awt.event.WindowEvent;\" '>'n" "\"import javax.swing.JFrame;\" '>'n" "\"import javax.swing.JPanel;\" '>'n" "\"import javax.swing.JScrollPane;\" '>'n" "\"import javax.swing.JMenuBar;\" '>'n" "\"import javax.swing.JMenu;\" '>'n" "\"import java.awt.event.ActionEvent;\" '>'n" "\"import javax.swing.AbstractAction;\" '>'n '>'n" "\"/**\" '>'n" "\" * \"" "(file-name-nondirectory buffer-file-name) '>'n" "\" *\" '>'n" "\" *\" '>'n" "\" * Created: \" (current-time-string) '>'n" "\" *\" '>'n" "\" * @author \"'>'n" "\" * @version\" '>'n" "\" */\" '>'n" "'>'n" "\"public class \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\" extends JFrame\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"class Canvas extends JPanel\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"public Canvas () \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"setSize(getPreferredSize());\" '>'n" "\"Canvas.this.setBackground(Color.white);\" '>'n" "\"}\"'>'n '>'n" "\"public Dimension getPreferredSize() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"return new Dimension(600, 600);\" '>'n" "\"}\"'>'n '>'n" "\"public void paintComponent(Graphics g) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"super.paintComponent(g);\" '>'n" "\"Graphics2D g2d = (Graphics2D) g;\" '>'n" "\"Ellipse2D circle = new Ellipse2D.Double(0d, 0d, 100d, 100d);\" '>'n" "\"g2d.setColor(Color.red);\" '>'n" "\"g2d.translate(10, 10);\" '>'n" "\"g2d.draw(circle);\" '>'n" "\"g2d.fill(circle);\" '>'n" "\"}\"'>'n " "\"}\"'>'n '>'n" "\"public \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\"()\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"super(\\\"\" (P \"Enter app title: \") \"\\\");\" '>'n" "\"setSize(300, 300);\" '>'n" "\"addWindowListener(new WindowAdapter() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"public void windowClosing(WindowEvent e) {System.exit(0);}\" '>'n" "\"public void windowOpened(WindowEvent e) {}\" '>'n" "\"});\"'>'n" "\"setJMenuBar(createMenu());\" '>'n" "\"getContentPane().add(new JScrollPane(new Canvas()));\" '>'n" "\"}\"'>'n" "'>'n" "\"public static void main(String[] args) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\" f = new \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\"();\" '>'n" "\"f.show();\" '>'n" "\"}\"'>'n '>'n" "\"protected JMenuBar createMenu() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"JMenuBar mb = new JMenuBar();\" '>'n" "\"JMenu menu = new JMenu(\\\"File\\\");\" '>'n" "\"menu.add(new AbstractAction(\\\"Exit\\\") \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"public void actionPerformed(ActionEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"System.exit(0);\" '>'n" "\"}\" '>'n" "\"});\" '>'n" "\"mb.add(menu);\" '>'n" "\"return mb;\" '>'n" "\"}\"'>'n " "\"} // \"'>" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "'>'n"))) + '(jde-bug-key-bindings (quote (("[? ? ?]" . jde-bug-step-over) ("[? ? ?]" . jde-bug-step-into) ("[? ? ?]" . jde-bug-step-into-all) ("[? ? ?]" . jde-bug-step-out) ("[? ? ?]" . jde-bug-continue) ("[? ? ?]" . jde-bug-toggle-breakpoint)))) + '(jde-compile-finish-hook (quote (jde-compile-finish-refresh-speedbar jde-compile-finish-flush-completion-cache))) + '(jde-compile-option-nowarn nil) + '(jde-setnu-mode-threshold 20000) + '(jde-run-java-vm-w "javaw") + '(jde-compile-option-encoding nil) + '(jde-run-option-java-profile (quote (nil . "./java.prof"))) + '(jde-bug-jpda-directory "/usr/local/jdk1.2.2" t) + '(jde-read-compile-args nil) + '(jde-run-java-vm "java") + '(jde-db-option-verbose (quote (nil nil nil))) + '(jde-which-method-class-min-length 4) + '(jde-db-read-app-args nil) + '(jde-javadoc-gen-nodeprecated nil) + '(jde-run-option-heap-profile (quote (nil "./java.hprof" 5 20 "Allocation objects"))) + '(jde-gen-println (quote ("(end-of-line) '&" "\"System.out.println(\" (P \"Print out: \") \");\" '>'n'>"))) + '(jde-enable-abbrev-mode nil) + '(jde-auto-parse-max-buffer-size 50000) + '(jde-gen-cflow-main (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"main\")" "'(l '> \"public static void main (String[] args) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of main ()\"'>'n'>)" ")"))) + '(jde-javadoc-exception-tag-template "\"* @exception \" type \" if an error occurs\"") + '(jde-global-classpath nil t) + '(jde-gen-window-listener-template (quote ("(end-of-line) '& (P \"Window name: \")" "\".addWindowListener(new WindowAdapter() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"public void windowActivated(WindowEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"" "'>'n \"public void windowClosed(WindowEvent e)\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n \"}\"" "'>'n \"public void windowClosing(WindowEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n \"System.exit(0);\" '>'n \"}\"" "'>'n \"public void windowDeactivated(WindowEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n \"}\"" "'>'n \"public void windowDeiconified(WindowEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n \"}\"" "'>'n \"public void windowIconified(WindowEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n \"}\"" "'>'n \"public void windowOpened(WindowEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n \"}\"" "'>'n \"});\" '>'n'>"))) + '(jde-run-working-directory "/share/xsl/docbook/extensions" t) + '(jde-gen-property-change-support (quote ("(end-of-line) '&" "\"protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);\" '>'n '>'n" "\"/**\" '>'n" "\"* Adds a PropertyChangeListener to the listener list.\" '>'n" "\"* The listener is registered for all properties.\" '>'n" "\"*\" '>'n" "\"* @param listener The PropertyChangeListener to be added\" '>'n" "\"*/\" '>'n" "\"public void addPropertyChangeListener(PropertyChangeListener listener) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"pcs.addPropertyChangeListener(listener);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n" "\"* Removes a PropertyChangeListener from the listener list.\" '>'n" "\"* This removes a PropertyChangeListener that was registered for all properties.\" '>'n" "\"*\" '>'n " "\"* @param listener The PropertyChangeListener to be removed\" '>'n" "\"*/\" '>'n" "\"public void removePropertyChangeListener(PropertyChangeListener listener) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>\"pcs.removePropertyChangeListener(listener);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Adds a PropertyChangeListener for a specific property.\" '>'n" "\"* The listener will be invoked only when a call on firePropertyChange\" '>'n" "\"* names that specific property.\" '>'n" "\"*\" '>'n \"* @param propertyName The name of the property to listen on\" '>'n" "\"* @param listener The PropertyChangeListener to be added\" '>'n \"*/\" '>'n" "\"public void addPropertyChangeListener(String propertyName,\" '>'n" "\"PropertyChangeListener listener) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"pcs.addPropertyChangeListener(propertyName, listener);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Removes a PropertyChangeListener for a specific property.\" '>'n" "\"*\" '>'n \"* @param propertyName The name of the property that was listened on\" '>'n" "\"* @param listener The PropertyChangeListener to be removed\" '>'n \"*/\" '>'n" "\"public void removePropertyChangeListener(String propertyName,\" '>'n" "\"PropertyChangeListener listener) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"pcs.removePropertyChangeListener(propertyName, listener);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Reports a bound property update to any registered listeners. \" '>'n" "\"* No event is fired if old and new are equal and non-null.\" '>'n" "\"*\" '>'n \"* @param propertyName The programmatic name of the property that was changed\" '>'n" "\"* @param oldValue The old value of the property\" '>'n" "\"* @param newValue The new value of the property.\" '>'n \"*/\" '>'n" "\"public void firePropertyChange(String propertyName, Object oldValue, Object newValue) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"pcs.firePropertyChange(propertyName, oldValue, newValue);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Reports a bound property update to any registered listeners. \" '>'n" "\"* No event is fired if old and new are equal and non-null.\" '>'n" "\"* This is merely a convenience wrapper around the more general\" '>'n" "\"* firePropertyChange method that takes Object values.\" '>'n" "\"* No event is fired if old and new are equal and non-null.\" '>'n" "\"*\" '>'n \"* @param propertyName The programmatic name of the property that was changed\" '>'n" "\"* @param oldValue The old value of the property\" '>'n" "\"* @param newValue The new value of the property.\" '>'n \"*/\" '>'n" "\"public void firePropertyChange(String propertyName, int oldValue, int newValue) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"pcs.firePropertyChange(propertyName, oldValue, newValue);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Reports a bound property update to any registered listeners. \" '>'n" "\"* No event is fired if old and new are equal and non-null.\" '>'n" "\"* This is merely a convenience wrapper around the more general\" '>'n" "\"* firePropertyChange method that takes Object values.\" '>'n" "\"* No event is fired if old and new are equal and non-null.\" '>'n" "\"*\" '>'n \"* @param propertyName The programmatic name of the property that was changed\" '>'n" "\"* @param oldValue The old value of the property\" '>'n" "\"* @param newValue The new value of the property.\" '>'n \"*/\" '>'n" "\"public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"pcs.firePropertyChange(propertyName, oldValue, newValue);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Fires an existing PropertyChangeEvent to any registered listeners.\" '>'n" "\"* No event is fired if the given event's old and new values are equal and non-null. \" '>'n" "\"*\" '>'n \"* @param evt The PropertyChangeEvent object.\" '>'n\"*/\" '>'n" "\"public void firePropertyChange(PropertyChangeEvent evt) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"pcs.firePropertyChange(evt);\" '>'n \"}\" '>'n '>'n" "\"/**\" '>'n\"* Checks if there are any listeners for a specific property.\" '>'n" "\"*\" '>'n \"* @param evt The PropertyChangeEvent object.\" '>'n" "\"* @return trueif there are one or more listeners for the given property\" '>'n" "\"*/\" '>'n" "\"public boolean hasListeners(String propertyName) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'> \"return pcs.hasListeners(propertyName);\" '>'n \"}\" '>'n '>'n'>"))) + '(jde-javadoc-describe-interface-template "\"* Describe interface \" (jde-javadoc-code name) \" here.\"") + '(jde-imenu-include-signature t) + '(jde-db-marker-regexp "^.*: thread=.*, \\(\\(.*[.]\\)*\\)\\([^$]*\\)\\($.*\\)*[.].+(), line=\\([0-9]*\\),") + '(jde-gen-mouse-motion-listener-template (quote ("(end-of-line) '& (P \"Component name: \")" "\".addMouseMotionListener(new MouseMotionAdapter() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>" "'>'n \"public void mouseDragged(MouseEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>" "'>'n \"public void mouseMoved(MouseEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>" "'>'n \"});\"'>'n'>"))) + '(jde-key-bindings (quote (("[? ? ?]" . jde-run-menu-run-applet) ("[? ? ?]" . jde-build) ("[? ? ?]" . jde-compile) ("[? ? ?]" . jde-debug) ("[? ? ?]" . jde-wiz-implement-interface) ("[? ? ?j]" . jde-javadoc-generate-javadoc-template) ("[? ? ? ]" . bsh) ("[? ? ? ]" . jde-gen-println) ("[? ? ?]" . jde-browse-jdk-doc) ("[? ? ?]" . jde-save-project) ("[? ? ?]" . jde-wiz-update-class-list) ("[? ? ?]" . jde-run) ("[? ? ?]" . speedbar-frame-mode) ("[? ? ?]" . jde-db-menu-debug-applet) ("[? ? ?]" . jde-help-symbol) ("[? ? ?]" . jde-show-class-source) ("[? ? ?]" . jde-import-find-and-import) ("[(control c) (control v) (control ?.)]" . jde-complete-at-point-menu) ("[(control c) (control v) ?.]" . jde-complete-at-point)))) + '(jde-gen-cflow-for-i (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"fori\")" "'(l '> \"for (int \" (p \"variable: \" var) \" = 0; \"" "(s var)" "\" < \"(p \"upper bound: \" ub)\"; \" (s var) \"++) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of for (int \" (s var) \" = 0; \"" "(s var) \" < \" (s ub) \"; \" (s var) \"++)\"'>'n'>)" ")"))) + '(jde-run-option-classpath (quote ("/share/xsl/docbook/extensions/xalan2/.classes" "/projects/apache/xml-xalan/java/build/classes" "/projects/apache/xml-xalan/java/bin/bsf.jar" "/projects/apache/xml-xalan/java/bin/xerces.jar" "/projects/sun/resolver/.classes" "/projects/apache/xml-xerces/java/build/classes" "/home/ndw/java")) t) + '(jde-javadoc-gen-detail-switch (quote ("-protected"))) + '(jde-bug-sio-connect-delay 1) + '(jde-javadoc-param-tag-template "\"* @param \" name \" \" (jde-javadoc-a type) + \" \" (jde-javadoc-code type) \" value\"") + '(jde-compile-option-verbose-path nil) + '(jde-javadoc-display-doc t) + '(jde-imenu-modifier-abbrev-alist (quote (("public" . 43) ("protected" . 177) ("private" . 172) ("static" . 2215) ("transient" . 35) ("volatile" . 126) ("abstract" . 170) ("final" . 182) ("native" . 36) ("synchronized" . 64) ("strictfp" . 37)))) + '(jde-db-debugger (quote ("JDEbug" "/usr/local/jdk1.2.2/lib/i386" . "Executable")) t) + '(jde-jdk-doc-url "http://www.javasoft.com/products/jdk/1.1/docs/index.html") + '(jde-gen-cflow-enable t) + '(jde-compiler "javac") + '(jde-javadoc-gen-verbose nil) + '(jde-javadoc-describe-method-template "\"* Describe \" (jde-javadoc-code name) \" method here.\"") + '(jde-gen-class-buffer-template (quote ("(funcall jde-gen-boilerplate-function) '>'n" "\"/**\" '>'n" "\" * \"" "(file-name-nondirectory buffer-file-name) '>'n" "\" *\" '>'n" "\" *\" '>'n" "\" * Created: \" (current-time-string) '>'n" "\" *\" '>'n" "\" * @author \"'>'n" "\" * @version\" '>'n" "\" */\" '>'n'" "'>'n" "\"public class \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\" \" (jde-gen-get-super-class)" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"public \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\" ()\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'p'n" "\"}\">" "'>'n" "\"}\">" "\"// \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "'>'n"))) + '(jde-javadoc-checker-level (quote protected)) + '(jde-appletviewer-option-vm-args nil) + '(jde-run-executable-args nil) + '(jde-db-option-garbage-collection (quote (t t))) + '(jde-javadoc-gen-stylesheetfile "") + '(jde-use-font-lock t) + '(jde-compile-option-bootclasspath nil) + '(jde-make-program "make") + '(jde-javadoc-gen-group nil) + '(jde-javadoc-gen-link-offline nil) + '(jde-entering-java-buffer-hook (quote (jde-reload-project-file jde-which-method-update-on-entering-buffer))) + '(jde-javadoc-gen-doc-title "") + '(jde-javadoc-gen-header "") + '(jde-run-option-vm-args nil) + '(jde-javadoc-gen-window-title "") + '(jde-compile-option-directory "" t) + '(jde-imenu-create-index-function (quote semantic-create-imenu-index)) + '(jde-gen-console-buffer-template (quote ("(funcall jde-gen-boilerplate-function) '>'n" "\"/**\" '>'n" "\" * \"" "(file-name-nondirectory buffer-file-name) '>'n" "\" *\" '>'n" "\" *\" '>'n" "\" * Created: \" (current-time-string) '>'n" "\" *\" '>'n" "\" * @author \"'>'n" "\" * @version\" '>'n" "\" */\" '>'n" "'>'n" "\"public class \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"public \"" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "\" ()\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'n" "\"}\"'>'n" "'>'n" "\"public static void main(String[] args)\"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "'>'p'n" "\"}\"'>'n" "\"} // \"'>" "(file-name-sans-extension (file-name-nondirectory buffer-file-name))" "'>'n"))) + '(jde-read-make-args nil) + '(jde-javadoc-gen-noindex nil) + '(jde-gen-mouse-listener-template (quote ("(end-of-line) '& (P \"Component name: \")" "\".addMouseListener(new MouseAdapter() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'> " "'>'n \"public void mouseClicked(MouseEvent e) \" " "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\" '>" "'>'n \"public void mouseEntered(MouseEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\" '>" "'>'n \"public void mouseExited(MouseEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>" "'>'n \"public void mousePressed(MouseEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\" '>" "'>'n \"public void mouseReleased(MouseEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>" "'>'n \"});\"'>'n'>"))) + '(jde-run-option-application-args (quote ("-IN" "test.xml" "-XSL" "test.xsl")) t) + '(jde-bug-vm-executable (quote ("java"))) + '(jde-db-set-initial-breakpoint t) + '(jde-bug-debugger-command-timeout 10) + '(jde-db-option-stack-size (quote ((128 . "kilobytes") (400 . "kilobytes")))) + '(jde-db-option-properties nil t) + '(jde-db-source-directories (quote ("/share/xsl/docbook/extensions/xalan2/" "/projects/apache/xml-xalan/java/src/" "/projects/apache/xml-xerces/java/build/src/" "/projects/sun/resolver/" "/home/ndw/java/")) t) + '(jde-run-read-app-args nil) + '(jde-gen-to-string-method-template (quote ("(end-of-line) '&" "\"public String toString() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n'>"))) + '(jde-quote-classpath t) + '(jde-bug-window-message nil) + '(jde-build-use-make nil) + '(jde-javadoc-author-tag-template "\"* @author \" user-full-name \"\"") + '(jde-javadoc-describe-field-template "\"* Describe \" (jde-javadoc-field-type modifiers) + \" \" (jde-javadoc-code name) \" here.\"") + '(jde-javadoc-gen-link-URL nil) + '(jde-compile-option-classpath (quote ("/share/xsl/docbook/extensions/xalan2/.classes" "/projects/apache/xml-xalan/java/build/classes" "/projects/apache/xml-xalan/java/bin/bsf.jar" "/projects/apache/xml-xalan/java/bin/xerces.jar" "/projects/sun/resolver/.classes" "/projects/apache/xml-xerces/java/build/classes" "/home/ndw/java")) t) + '(jde-bug-jdk-directory "/usr/local/jdk1.2.2" t) + '(jde-gen-boilerplate-function (quote jde-gen-create-buffer-boilerplate)) + '(jde-gen-entity-bean-template (quote ("(jde-import-insert-imports-into-buffer (list \"javax.ejb.*\" +\"java.rmi.RemoteException\"))" "'> \"public void ejbActivate() throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n" "'> \"public void ejbPassivate() throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n" "'> \"public void ejbLoad() throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n" "'> \"public void ejbStore() throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n" "'> \"public void ejbRemove() throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n" "'> \"public void setEntityContext(EntityContext ctx) throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n" "'> \"public void unsetEntityContext() throws RemoteException \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n '>'n'>"))) + '(jde-javadoc-describe-constructor-template "\"* Creates a new \" (jde-javadoc-code name) \" instance.\"") + '(jde-bug-server-shmem-name (quote (t . "JDEbug"))) + '(jde-db-startup-commands nil) + '(jde-javadoc-gen-docletpath nil) + '(jde-javadoc-gen-split-index nil) + '(jde-compile-option-deprecation nil t) + '(jde-import-group-of-rules (quote (("^javax?\\.")))) + '(jde-which-method-mode t) + '(jde-gen-k&r t) + '(jde-javadoc-gen-bottom "") + '(jde-javadoc-gen-footer "") + '(jde-db-option-classpath (quote ("/share/xsl/docbook/extensions/xalan2/.classes" "/projects/apache/xml-xalan/java/build/classes" "/projects/apache/xml-xalan/java/bin/bsf.jar" "/projects/apache/xml-xalan/java/bin/xerces.jar" "/projects/sun/resolver/.classes" "/projects/apache/xml-xerces/java/build/classes" "/home/ndw/java")) t) + '(jde-gen-cflow-for (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"for\")" "'(l '> \"for (\" (p \"for-clause: \" clause) \") \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of for (\" (s clause) \")\"'>'n'>)" ")"))) + '(jde-run-mode-hook nil) + '(jde-db-option-verify (quote (nil t))) + '(jde-compile-option-extdirs nil) + '(jde-imenu-sort nil) + '(jde-gen-get-set-var-template (quote ("(end-of-line) '&" "(P \"Variable type: \" type) \" \"" "(P \"Variable name: \" name) \";\" '>'n '>'n" "\"/**\" '>'n" "\"* Get the value of \" (s name) \".\" '>'n" "\"* @return value of \" (s name) \".\" '>'n" "\"*/\" '>'n" "'>'\"public \" (s type)" "(if (string= \"boolean\" (jde-gen-lookup-named 'type) ) " "\" is\" " "\" get\" ) " "(jde-gen-init-cap (jde-gen-lookup-named 'name))" "\"() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\" '>'n" "\"return \" (s name) \";\" '>'n \"}\"" "'>'n '>'n" "\"/**\" '>'n" "\"* Set the value of \" (s name) \".\" '>'n" "\"* @param v Value to assign to \" (s name) \".\" '>'n" "\"*/\" '>'n" "'>'\"public void set\" (jde-gen-init-cap (jde-gen-lookup-named 'name))" "\"(\" (s type) \" v) \" " "(if jde-gen-k&r " "()" "'>'n)" "\"{\" '>'n" "'>'\"this.\" (s name) \" = v;\" '>'n \"}\" '>'n'>"))) + '(jde-bug-saved-breakpoints nil) + '(jde-compile-option-sourcepath (quote ("/share/xsl/docbook/extensions/xalan2" "/projects/apache/xml-xalan/java/build/src" "/projects/apache/xml-xerces/java/build/src" "/projects/sun/resolver")) t) + '(jde-gen-cflow-if (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"if\")" "'(l '> \"if (\" (p \"if-clause: \" clause) \") \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of if (\" (s clause) \")\"'>'n'>)" ")"))) + '(jde-db-option-java-profile (quote (nil . "./java.prof"))) + '(jde-javadoc-gen-author t) + '(jde-compile-option-depend-switch (quote ("-Xdepend"))) + '(jde-setnu-mode-enable nil) + '(jde-run-applet-doc "") + '(jde-compile-option-vm-args nil) + '(jde-javadoc-gen-overview "") + '(jde-javadoc-gen-notree nil) + '(jde-run-option-garbage-collection (quote (t t))) + '(jde-db-mode-hook nil) + '(jde-javadoc-command-path "javadoc") + '(jde-db-option-heap-profile (quote (nil "./java.hprof" 5 20 "Allocation objects"))) + '(jde-import-group-function (quote jde-import-group-of)) + '(jde-db-read-vm-args nil) + '(jde-bug-debug nil) + '(jde-javadoc-end-block-template nil) + '(jde-javadoc-gen-packages nil) + '(jde-gen-cflow-if-else (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"ife\")" "'(l '> \"if (\" (p \"if-clause: \" clause) \") \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of if (\" (s clause) \")\"'> n" "'> \"else \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of if (\" (s clause) \")else\"'>'n'>)" ")"))) + '(jde-gen-cflow-while (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"while\")" "'(l '> \"while (\" (p \"while-clause: \" clause) \") \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'>'r'n" "\"} // end of while (\" (s clause) \")\"'>'n'>)" ")"))) + '(jde-bug-server-socket (quote (t . "2112"))) + '(jde-imenu-include-modifiers nil) + '(jde-appletviewer-option-encoding "") + '(jde-bug-breakpoint-cursor-colors (quote ("cyan" . "brown"))) + '(jde-compile-option-target (quote ("1.1"))) + '(jde-run-executable "") + '(jde-run-option-heap-size (quote ((1 . "megabytes") (16 . "megabytes")))) + '(jde-gen-cflow-switch (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"switch\")" "'(l '> \"switch (\" (p \"switch-condition: \" clause) \") \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n'" "\"case \" (p \"first value: \") \":\"'>'n'>'p'n" "\"break;\"'>'n'>'p'n" "\"default:\"'>'n'>'p'n" "\"break;\"'>'n" "\"} // end of switch (\" (s clause) \")\"'>'n'>)" ")"))) + '(jde-which-method-abbrev-symbol "~") + '(jde-db-option-vm-args nil) + '(jde-run-application-class "org.apache.xalan.xslt.Process" t) + '(jde-javadoc-gen-doclet "") + '(jde-import-auto-sort nil) + '(jde-run-option-verbose (quote (nil nil nil))) + '(jde-project-file-name "prj.el") + '(jde-compile-option-debug (quote ("selected" (t nil nil))) t) + '(jde-bug-jre-home "") + '(jde-import-sorted-groups nil) + '(jde-run-applet-viewer "") + '(jde-javadoc-return-tag-template "\"* @return \" (jde-javadoc-a type) + \" \" (jde-javadoc-code type) \" value\"") + '(jde-javadoc-gen-version t) + '(jde-javadoc-gen-helpfile "") + '(jde-import-excluded-packages (quote ("bsh.*"))) + '(jde-run-read-vm-args nil) + '(jde-help-docsets nil) + '(jde-gen-inner-class-template (quote ("(end-of-line) '& \"class \" (P \"Class name: \" class)" "(P \"Superclass: \" super t)" "(let ((parent (jde-gen-lookup-named 'super)))" "(if (not (string= parent \"\"))" "(concat \" extends \" parent ))) " "(if jde-gen-k&r " "()" "'>'n)" "\"{\" '>'n" "\"public \" (s class) \"() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n" "\"}\" '>'n'>"))) + '(jde-auto-parse-buffer-interval 180) + '(jde-run-option-verify (quote (nil t))) + '(jde-import-reverse-sort-group nil) + '(jde-compile-option-optimize nil) + '(jde-gen-cflow-case (quote ("(if (jde-parse-comment-or-quoted-p)" "'(l \"case\")" "'(l 'n \"case \" (p \"value: \") \":\"'>'n'>'p'n" "\"break;\"'>'n'>'p)" ")"))) + '(jde-compile-option-depend nil) + '(jde-javadoc-describe-class-template "\"* Describe class \" (jde-javadoc-code name) \" here.\"") + '(jde-javadoc-gen-serialwarn nil) + '(jde-gen-action-listener-template (quote ("'& (P \"Component name: \")" "\".addActionListener(new ActionListener() \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"public void actionPerformed(ActionEvent e) \"" "(if jde-gen-k&r " "()" "'>'n)" "\"{\"'>'n" "\"}\"'>'n \"});\"'>'n'>"))) + '(jde-auto-parse-enable t) + '(jde-compile-option-command-line-args "") + '(jde-gen-buffer-templates (quote (("Class" . jde-gen-class) ("Console" . jde-gen-console) ("Swing App" . jde-gen-jfc-app)))) + '(jde-project-context-switching-enabled-p t) + '(jde-javadoc-gen-args nil) + '(jde-run-option-stack-size (quote ((128 . "kilobytes") (400 . "kilobytes")))) + '(jde-run-option-properties nil t)) + + diff --git a/xsl/extensions/saxon551/.cvsignore b/xsl/extensions/saxon551/.cvsignore new file mode 100644 index 000000000..4d3c216f5 --- /dev/null +++ b/xsl/extensions/saxon551/.cvsignore @@ -0,0 +1 @@ +.classes diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/CVS.java b/xsl/extensions/saxon551/com/nwalsh/saxon/CVS.java new file mode 100644 index 000000000..529546be7 --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/CVS.java @@ -0,0 +1,90 @@ +package com.nwalsh.saxon; + +import java.io.*; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.text.DateFormat; +import java.text.ParseException; + +/** + *

Saxon extension to convert CVS date strings into local time

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension to turn the CVS date strings, which are UTC:

+ * + *
$Date: 2000/11/09 02:34:20 $
+ * + *

into legibly formatted local time:

+ * + *
Wed Nov 08 18:34:20 PST 2000
+ * + *

(I happened to be in California when I wrote this documentation.)

+ + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CVS { + /** + *

Constructor for CVS

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public CVS() { + } + + /** + *

Convert a CVS date string into local time.

+ * + * @param cvsDate The CVS date string. + * + * @return The date, converted to local time and reformatted. + */ + public static String localTime (String cvsDate) { + // A cvsDate has the following form "$Date$" + if (!cvsDate.startsWith("$Date: ")) { + return cvsDate; + } + + String yrS = cvsDate.substring(7,11); + String moS = cvsDate.substring(12,14); + String daS = cvsDate.substring(15,17); + String hrS = cvsDate.substring(18,20); + String miS = cvsDate.substring(21,23); + String seS = cvsDate.substring(24,26); + + TimeZone tz = TimeZone.getTimeZone("GMT+0"); + GregorianCalendar gmtCal = new GregorianCalendar(tz); + + try { + gmtCal.set(Integer.parseInt(yrS), + Integer.parseInt(moS)-1, + Integer.parseInt(daS), + Integer.parseInt(hrS), + Integer.parseInt(miS), + Integer.parseInt(seS)); + } catch (NumberFormatException e) { + // nop + } + + Date d = gmtCal.getTime(); + + return d.toString(); + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/Callout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/Callout.java new file mode 100644 index 000000000..94547b1cc --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/Callout.java @@ -0,0 +1,109 @@ +package com.nwalsh.saxon; + +import com.icl.saxon.om.ElementInfo; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class is just for book keeping in the Verbatim class. + * It stores information about the location of callouts.

+ * + *

Only line/column based callouts are supported. This class + * implements the Comparable interface so that callouts can be sorted. + * Callouts are sorted so that they occur in left-to-right, + * top-to-bottom order based on line/column.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + * */ +public class Callout implements Comparable { + /** The callout number. */ + private int callout = 0; + /** The area ElementInfo item that generated this callout. */ + private ElementInfo area = null; + /** The line on which this callout occurs. */ + private int line = 0; + /** The column in which this callout appears. */ + private int col = 0; + + /** The constructor; initialize the private data structures. */ + public Callout(int callout, ElementInfo area, int line, int col) { + this.callout = callout; + this.area = area; + this.line = line; + this.col = col; + } + + /** + *

The compareTo method compares this Callout with another.

+ * + *

Given two Callouts, A and B, A < B if:

+ * + *
    + *
  1. A.line < B.line, or
  2. + *
  3. A.line = B.line && A.col < B.col, or
  4. + *
  5. A.line = B.line && A.col = B.col && A.callout < B.callout
  6. + *
  7. Otherwise, they're equal.
  8. + *
+ */ + public int compareTo (Object o) { + Callout c = (Callout) o; + + if (line == c.getLine()) { + if (col > c.getColumn()) { + return 1; + } else if (col < c.getColumn()) { + return -1; + } else { + if (callout < c.getCallout()) { + return -1; + } else if (callout > c.getCallout()) { + return 1; + } else { + return 0; + } + } + } else { + if (line > c.getLine()) { + return 1; + } else { + return -1; + } + } + } + + /** Access the Callout's area. */ + public ElementInfo getArea() { + return area; + } + + /** Access the Callout's line. */ + public int getLine() { + return line; + } + + /** Access the Callout's column. */ + public int getColumn() { + return col; + } + + /** Access the Callout's callout number. */ + public int getCallout() { + return callout; + } +} + diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/FormatCallout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatCallout.java new file mode 100644 index 000000000..af3ee567c --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatCallout.java @@ -0,0 +1,107 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.Name; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public abstract class FormatCallout { + protected static final String foURI = "http://www.w3.org/1999/XSL/Format"; + protected static final String xhURI = "http://www.w3.org/1999/xhtml"; + protected boolean foStylesheet = false; + + public FormatCallout(boolean fo) { + foStylesheet = fo; + } + + public String areaLabel(ElementInfo area) { + String label = null; + + if (area.getAttributeList().getValue("label") != null) { + // If this area has a label, use it + label = area.getAttributeList().getValue("label"); + } else { + // Otherwise, if its parent is an areaset and it has a label, use that + ElementInfo parent = (ElementInfo) area.getParentNode(); + if (parent != null + && parent.getLocalName().equalsIgnoreCase("areaset") + && parent.getAttributeList().getValue("label") != null) { + label = parent.getAttributeList().getValue("label"); + } + } + + return label; + } + + public void startSpan(Emitter rtf) + throws SAXException { + // no point in doing this for FO, right? + if (!foStylesheet) { + Name spanName = new Name("span"); + AttributeCollection spanAttr = new AttributeCollection(); + spanAttr.addAttribute(new Name("class"), "CDATA", "co"); + rtf.startElement(spanName, spanAttr); + } + } + + public void endSpan(Emitter rtf) + throws SAXException { + // no point in doing this for FO, right? + if (!foStylesheet) { + Name spanName = new Name("span"); + rtf.endElement(spanName); + } + } + + public void formatTextCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + char chars[] = label.toCharArray(); + + try { + startSpan(rtfEmitter); + rtfEmitter.characters(chars, 0, label.length()); + endSpan(rtfEmitter); + } catch (SAXException e) { + System.out.println("SAX Exception in formatTextCallout"); + } + } + + public abstract void formatCallout(Emitter rtfEmitter, + Callout callout); +} + diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/FormatGraphicCallout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatGraphicCallout.java new file mode 100644 index 000000000..4af78b963 --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatGraphicCallout.java @@ -0,0 +1,89 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.Name; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatGraphicCallout extends FormatCallout { + String graphicsPath = ""; + String graphicsExt = ""; + int graphicsMax = 0; + + public FormatGraphicCallout(String path, String ext, int max, boolean fo) { + super(fo); + graphicsPath = path; + graphicsExt = ext; + graphicsMax = max; + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + try { + if (userLabel == null && num <= graphicsMax) { + Name imgName = null; + AttributeCollection imgAttr = null; + + if (foStylesheet) { + imgName = new Name("fo", + "http://www.w3.org/1999/XSL/Format", + "external-graphic"); + imgAttr = new AttributeCollection(); + imgAttr.addAttribute(new Name("src"), "CDATA", + graphicsPath + num + graphicsExt); + imgAttr.addAttribute(new Name("alt"), "CDATA", label); + } else { + imgName = new Name("img"); + imgAttr = new AttributeCollection(); + imgAttr.addAttribute(new Name("src"), "CDATA", + graphicsPath + num + graphicsExt); + imgAttr.addAttribute(new Name("alt"), "CDATA", label); + } + + startSpan(rtfEmitter); + rtfEmitter.startElement(imgName, imgAttr); + rtfEmitter.endElement(imgName); + endSpan(rtfEmitter); + } else { + formatTextCallout(rtfEmitter, callout); + } + } catch (SAXException e) { + System.out.println("SAX Exception in graphic formatCallout"); + } + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/FormatTextCallout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatTextCallout.java new file mode 100644 index 000000000..e6e19fe0e --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatTextCallout.java @@ -0,0 +1,41 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.output.Emitter; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatTextCallout extends FormatCallout { + public FormatTextCallout(boolean fo) { + super(fo); + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + formatTextCallout(rtfEmitter, callout); + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/FormatUnicodeCallout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatUnicodeCallout.java new file mode 100644 index 000000000..5ebb6ceb0 --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatUnicodeCallout.java @@ -0,0 +1,65 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.Name; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatUnicodeCallout extends FormatCallout { + int unicodeMax = 0; + int unicodeStart = 0; + + public FormatUnicodeCallout(int start, int max, boolean fo) { + super(fo); + unicodeMax = max; + unicodeStart = start; + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String label = areaLabel(area); + + try { + if (label == null && num <= unicodeMax) { + char chars[] = new char[1]; + chars[0] = (char) (unicodeStart + num - 1); + + startSpan(rtfEmitter); + rtfEmitter.characters(chars, 0, 1); + endSpan(rtfEmitter); + } else { + formatTextCallout(rtfEmitter, callout); + } + } catch (SAXException e) { + System.out.println("SAX Exception in graphic formatCallout"); + } + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/Text.java b/xsl/extensions/saxon551/com/nwalsh/saxon/Text.java new file mode 100644 index 000000000..272ad5143 --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/Text.java @@ -0,0 +1,113 @@ +// Text - Saxon extension element for inserting text + +package com.nwalsh.saxon; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.net.URL; +import java.net.MalformedURLException; +import com.icl.saxon.*; +import com.icl.saxon.style.*; +import com.icl.saxon.expr.*; +import com.icl.saxon.output.*; +import org.xml.sax.SAXException; +import org.xml.sax.AttributeList; + +/** + *

Saxon extension element for inserting text + * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension element for inserting text into a result tree.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Text extends StyleElement { + /** + *

Constructor for Text

+ * + *

Does nothing.

+ */ + public Text() { + } + + /** + *

Validate the arguments

+ * + *

The element must have an href attribute.

+ */ + public void prepareAttributes() throws SAXException { + // Get mandatory database attribute + try { + String fnAtt = attributeList.getValue("href"); + if (fnAtt == null) { + reportAbsence("href"); + } + } catch (NoSuchFieldError e) { + // nop, must be Saxon6 parsing this extension element + } + } + + /** Validate that the element occurs in a reasonable place. */ + public void validate() throws SAXException { + checkWithinTemplate(); + } + + /** + *

Insert the text of the file into the result tree

+ * + *

Processing this element inserts the contents of the URL named + * by the href attribute into the result tree as plain text.

+ * + */ + public void process( Context context ) throws SAXException { + Outputter out = context.getOutputter(); + + String hrefAtt = attributeList.getValue("href"); + Expression hrefExpr = AttributeValueTemplate.make(hrefAtt, this); + String href = hrefExpr.evaluateAsString(context); + URL fileURL = null; + + try { + try { + fileURL = new URL(href); + } catch (MalformedURLException e1) { + try { + fileURL = new URL("file:" + href); + } catch (MalformedURLException e2) { + System.out.println("Cannot open " + href); + return; + } + } + + InputStreamReader isr = new InputStreamReader(fileURL.openStream()); + BufferedReader is = new BufferedReader(isr); + + char chars[] = new char[4096]; + int len = 0; + while ((len = is.read(chars)) > 0) { + out.writeContent(chars, 0, len); + } + is.close(); + } catch (Exception e) { + System.out.println("Cannot read " + href); + } + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/TextFactory.java b/xsl/extensions/saxon551/com/nwalsh/saxon/TextFactory.java new file mode 100644 index 000000000..34ef9d9fb --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/TextFactory.java @@ -0,0 +1,64 @@ +// TextFactory - Saxon extension element factory + +package com.nwalsh.saxon; + +import com.icl.saxon.style.ExtensionElementFactory; +import org.xml.sax.SAXException; + +/** + *

Saxon extension element factory + * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension element factory for the Text extension element + * family.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + * @see Text + * + */ +public class TextFactory implements ExtensionElementFactory { + /** + *

Constructor for TextFactory

+ * + *

Does nothing.

+ */ + public TextFactory() { + } + + /** + *

Return the class that implements a particular extension element.

+ * + * @param localname The local name of the extension element. + * + * @return The class that handles that extension element. + * + * @exception SAXException("Unknown Text extension element") + */ + public Class getExtensionClass(String localname) throws SAXException { + if (localname.equals("insertfile")) { + try { + return Class.forName("com.nwalsh.saxon.Text"); + } catch (ClassNotFoundException e) { + throw new SAXException("Failed to load class for Text extension element: " + + localname); + } + } + throw new SAXException("Unknown Text extension element: " + + localname); + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java new file mode 100644 index 000000000..b1ded985d --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java @@ -0,0 +1,979 @@ +// Verbatim.java - Saxon extensions supporting DocBook verbatim environments + +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import com.icl.saxon.expr.*; +import com.icl.saxon.om.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.Context; +import com.icl.saxon.AttributeCollection; +import com.icl.saxon.functions.Extensions; +import com.icl.saxon.tree.*; +import com.nwalsh.saxon.Callout; + +/** + *

Saxon extensions supporting DocBook verbatim environments

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * implementation of two features that would be impractical to + * implement directly in XSLT: line numbering and callouts.

+ * + *

Line Numbering

+ *

The numberLines family of functions takes a result tree + * fragment (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * line numbers.

+ * + *

Callouts

+ *

The insertCallouts family of functions takes an + * areaspec and a result tree fragment + * (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * callouts.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Verbatim { + /** A stack to hold the open elements while walking through a verbatim. */ + private static Stack elementStack = null; + /** A stack to hold the temporarily closed elements. */ + private static Stack tempStack = null; + /** The current line number. */ + private static int lineNumber = 0; + /** The current column number. */ + private static int colNumber = 0; + /** The modulus for line numbering (every 'modulus' line is numbered). */ + private static int modulus = 0; + /** The width (in characters) of line numbers (for padding). */ + private static int width = 0; + /** The separator between the line number and the verbatim text. */ + private static String separator = ""; + /** The (sorted) array of callouts obtained from the areaspec. */ + private static Callout callout[] = null; + /** The number of callouts in the callout array. */ + private static int calloutCount = 0; + /** A pointer used to keep track of our position in the callout array. */ + private static int calloutPos = 0; + /** The default column for callouts. */ + private static int defaultColumn = 60; + /** The callout formatter */ + private static FormatCallout fCallout = null; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Verbatim() { + } + + /** + *

Find the string value of a stylesheet variable or parameter

+ * + *

Returns the string value of varName in the current + * context. Returns the empty string if the variable is + * not defined.

+ * + * @param context The current stylesheet context + * @param varName The name of the variable (without the dollar sign) + * + * @return The string value of the variable + */ + protected static String getVariable(Context context, String varName) { + Value variable = null; + String varString = null; + + try { + variable = Extensions.evaluate(context, "$" + varName); + varString = variable.asString(); + return varString; + } catch (SAXException se) { + System.out.println("Undefined variable: " + varName); + return ""; + } catch (IllegalArgumentException e) { + System.out.println("Undefined variable: " + varName); + return ""; + } + } + + /** + *

Setup the parameters associated with line numbering

+ * + *

This method queries the stylesheet for the variables + * associated with line numbering. It is called automatically before + * lines are numbered. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
linenumbering.everyNth
+ *
Specifies the lines that will be numbered. The first line is + * always numbered. (builtin default: 5).
+ *
linenumbering.width
+ *
Specifies the width of the numbers. If the specified width is too + * narrow for the largest number needed, it will automatically be made + * wider. (builtin default: 3).
+ *
linenumbering.separator
+ *
Specifies the string that separates line numbers from lines + * in the program listing. (builtin default: " ").
+ *
stylesheet.result.type
+ *
Specifies the stylesheet result type. The value is either 'fo' + * (for XSL Formatting Objects) or it isn't. (builtin default: html).
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupLineNumbering(Context context) { + // Hardcoded defaults + modulus = 5; + width = 3; + separator = " "; + + String varString = null; + + // Get the modulus + varString = getVariable(context, "linenumbering.everyNth"); + try { + modulus = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.everyNth is not a number: " + varString); + } + + // Get the width + varString = getVariable(context, "linenumbering.width"); + try { + width = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.width is not a number: " + varString); + } + + // Get the separator + varString = getVariable(context, "linenumbering.separator"); + separator = varString; + } + + /** + *

Number lines in a verbatim environment.

+ * + *

This method adds line numbers to a result tree fragment. Each + * newline that occurs in a text node is assumed to start a new line. + * The first line is always numbered, every subsequent saxonMod line + * is numbered (so if saxonMod=5, lines 1, 5, 10, 15, etc. will be + * numbered. If there are fewer than saxonMod lines in the environment, + * every line is numbered.

+ * + *

Every line number will be right justified in a string saxonWidth + * characters long. If the line number of the last line in the + * environment is too long to fit in the specified width, the width + * is automatically increased to the smallest value that can hold the + * number of the last line. (In other words, if you specify the value 2 + * and attempt to enumerate the lines of an environment that is 100 lines + * long, the value 3 will automatically be used for every line in the + * environment.)

+ * + *

The saxonSep string is inserted between the line + * number and the original program listing. Lines that aren't numbered + * are preceded by a saxonWidth blank string and the separator.

+ * + *

If inline markup extends across line breaks, markup changes are + * required. All the open elements are closed before the line break and + * "reopened" afterwards. The reopened elements will have the same + * attributes as the originals, except that 'name' and 'id' attributes + * are not duplicated.

+ * + * @param saxonRTF The result tree fragment of the verbatim environment. + * + * @return The modified result tree fragment. + */ + public static FragmentValue numberLines (Context context, + FragmentValue saxonRTF) { + + setupLineNumbering(context); + + try { + int numLines = countLineBreaks(saxonRTF.getFirst()) + 1; + + elementStack = new Stack(); + lineNumber = 0; + + double log10numLines = Math.log(numLines) / Math.log(10); + + if (width < log10numLines + 1) { + width = (int) Math.floor(log10numLines + 1); + } + + FragmentValue rtf = new FragmentValue(); + lineNumberFragment(rtf, saxonRTF.getFirst()); + return rtf; + } catch (SAXException e) { + // This "can't" happen. + System.out.println("SAX Exception in numberLines"); + return saxonRTF; + } + } + + /** + *

Count the number of lines in a verbatim environment.

+ * + *

This method walks over the nodes of a FragmentValue and + * returns the number of lines breaks that it contains.

+ * + * @param node The root of the tree walk over. + */ + private static int countLineBreaks(NodeInfo node) { + NodeInfo children[] = null; + int numLines = 0; + + if (node.getNodeType() == NodeInfo.DOCUMENT) { + children = ((DocumentInfo) node).getAllChildNodes(); + } else if (node.getNodeType() == NodeInfo.ELEMENT) { + children = ((ElementInfo) node).getAllChildNodes(); + } else if (node.getNodeType() == NodeInfo.TEXT) { + String text = node.getValue(); + + // Walk through the text node looking for newlines + char chars[] = new char[text.length()]; + int pos = 0; + for (int count = 0; count < text.length(); count++) { + if (text.charAt(count) == '\n') { + numLines++; + } + } + } else { + // nop + } + + if (children != null) { + for (int count = 0; count < children.length; count++) { + numLines += countLineBreaks(children[count]); + } + } + + return numLines; + } + + /** + *

Build a FragmentValue with numbered lines.

+ * + *

This is the method that actually does the work of numbering + * lines in a verbatim environment. It recursively walks through a + * tree of nodes, copying the structure into the rtf. Text nodes + * are examined for new lines and modified as requested by the + * global line numbering parameters.

+ * + *

When called, rtf should be an empty FragmentValue and node + * should be the first child of the result tree fragment that contains + * the existing, formatted verbatim text.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param node The root of the tree to copy. + */ + private static void lineNumberFragment(FragmentValue rtf, + NodeInfo node) { + NodeInfo children[] = null; + boolean skipStack = false; + + try { + if (node.getNodeType() == NodeInfo.DOCUMENT) { + rtf.startDocument(); + children = ((DocumentInfo) node).getAllChildNodes(); + } else if (node.getNodeType() == NodeInfo.ELEMENT) { + rtf.startElement(node.getExpandedName(), + ((ElementInfo) node).getAttributeList()); + + if (elementStack.empty()) { + Name foBlock = new Name("fo", + "http://www.w3.org/1999/XSL/Format", + "block"); + if (foBlock.equals(node.getExpandedName()) + || node.getNodeName().equalsIgnoreCase("pre") + || node.getNodeName().equalsIgnoreCase("div")) { + // Don't push the outer-most wrapping div, pre, or fo:block + skipStack = true; + } + } + + if (!skipStack) { + elementStack.push(node); + } + + children = ((ElementInfo) node).getAllChildNodes(); + } else if (node.getNodeType() == NodeInfo.TEXT) { + String text = node.getValue(); + + if (lineNumber == 0) { + // The first line is always numbered + formatLineNumber(rtf, ++lineNumber); + } + + // Walk through the text node looking for newlines + char chars[] = new char[text.length()]; + int pos = 0; + for (int count = 0; count < text.length(); count++) { + if (text.charAt(count) == '\n') { + // This is the tricky bit; if we find a newline, make sure + // it doesn't occur inside any markup. + + if (pos > 0) { + rtf.characters(chars, 0, pos); + pos = 0; + } + + // Close all the open elements... + closeOpenElements(rtf); + + // Copy the newline to the output + chars[pos++] = text.charAt(count); + rtf.characters(chars, 0, pos); + pos = 0; + + // Add the line number + formatLineNumber(rtf, ++lineNumber); + + // Now "reopen" the elements that we closed... + openClosedElements(rtf); + } else { + chars[pos++] = text.charAt(count); + } + } + + if (pos > 0) { + rtf.characters(chars, 0, pos); + } + } else if (node.getNodeType() == NodeInfo.COMMENT) { + String text = node.getValue(); + + char chars[] = new char[text.length()]; + for (int count = 0; count < text.length(); count++) { + chars[count] = text.charAt(count); + } + rtf.comment(chars, 0, text.length()); + } else if (node.getNodeType() == NodeInfo.PI) { + rtf.processingInstruction(node.getNodeName(), node.getValue()); + } else { + System.out.println("Warning: unexpected node type in lineNumberFragment"); + } + + if (children != null) { + for (int count = 0; count < children.length; count++) { + lineNumberFragment(rtf, children[count]); + } + } + + if (node.getNodeType() == NodeInfo.DOCUMENT) { + rtf.endDocument(); + } else if (node.getNodeType() == NodeInfo.ELEMENT) { + rtf.endElement(node.getExpandedName()); + if (!skipStack) { + elementStack.pop(); + } + } else { + // nop + } + } catch (SAXException e) { + System.out.println("SAX Exception in lineNumberFragment"); + } + } + + /** + *

Add a formatted line number to the result tree fragment.

+ * + *

This method examines the global parameters that control line + * number presentation (modulus, width, and separator) and adds + * the appropriate text to the result tree fragment.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param lineNumber The number of the current line. + */ + private static void formatLineNumber(FragmentValue rtf, + int lineNumber) { + char ch = 160; + String lno = ""; + if (lineNumber == 1 + || (modulus >= 1 && (lineNumber % modulus == 0))) { + lno = "" + lineNumber; + } + + while (lno.length() < width) { + lno = ch + lno; + } + + lno += separator; + + char chars[] = new char[lno.length()]; + for (int count = 0; count < lno.length(); count++) { + chars[count] = lno.charAt(count); + } + + try { + rtf.characters(chars, 0, lno.length()); + } catch (SAXException e) { + System.out.println("SAX Exception in formatLineNumber"); + } + } + + /** + *

Setup the parameters associated with callouts

+ * + *

This method queries the stylesheet for the variables + * associated with line numbering. It is called automatically before + * callouts are processed. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
callout.graphics
+ *
Are we using callout graphics? A value of 0 or "" is false, + * any other value is true. If callout graphics are not used, the + * parameters related to graphis are not queried.
+ *
callout.graphics.path
+ *
Specifies the path to callout graphics.
+ *
callout.graphics.extension
+ *
Specifies the extension ot use for callout graphics.
+ *
callout.graphics.number.limit
+ *
Identifies the largest number that can be represented as a + * graphic. Larger callout numbers will be represented using text.
+ *
callout.defaultcolumn
+ *
Specifies the default column for callout bullets that do not + * specify a column.
+ *
stylesheet.result.type
+ *
Specifies the stylesheet result type. The value is either 'fo' + * (for XSL Formatting Objects) or it isn't. (builtin default: html).
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupCallouts(Context context) { + boolean useGraphics = false; + boolean useUnicode = false; + + int unicodeStart = 48; + int unicodeMax = 0; + + // Hardcoded defaults + defaultColumn = 60; + String graphicsPath = null; + String graphicsExt = null; + int graphicsMax = 0; + boolean foStylesheet = false; + + Value variable = null; + String varString = null; + + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = (varString.equals("fo")); + + // Get the default column + varString = getVariable(context, "callout.defaultcolumn"); + try { + defaultColumn = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.defaultcolumn is not a number: " + + varString); + } + + // Use graphics at all? + varString = getVariable(context, "callout.graphics"); + useGraphics = !(varString.equals("0") || varString.equals("")); + + // Use unicode at all? + varString = getVariable(context, "callout.unicode"); + useUnicode = !(varString.equals("0") || varString.equals("")); + + if (useGraphics) { + // Get the graphics path + varString = getVariable(context, "callout.graphics.path"); + graphicsPath = varString; + + // Get the graphics extension + varString = getVariable(context, "callout.graphics.extension"); + graphicsExt = varString; + + // Get the number limit + varString = getVariable(context, "callout.graphics.number.limit"); + try { + graphicsMax = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.graphics.number.limit is not a number: " + + varString); + graphicsMax = 0; + } + + fCallout = new FormatGraphicCallout(graphicsPath, + graphicsExt, + graphicsMax, + foStylesheet); + } else if (useUnicode) { + // Get the starting character + varString = getVariable(context, "callout.unicode.start.character"); + try { + unicodeStart = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.unicode.start.character is not a number: " + + varString); + unicodeStart = 48; + } + + // Get the number limit + varString = getVariable(context, "callout.unicode.number.limit"); + try { + unicodeMax = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.unicode.number.limit is not a number: " + + varString); + unicodeStart = 0; + } + + fCallout = new FormatUnicodeCallout(unicodeStart, + unicodeMax, + foStylesheet); + } else { + fCallout = new FormatTextCallout(foStylesheet); + } + } + + /** + *

Insert callouts into a verbatim environment.

+ * + *

This method examines the areaset and area elements + * in the supplied areaspec and decorates the supplied + * result tree fragment with appropriate callout markers.

+ * + *

If a label attribute is supplied on an area, + * its content will be used for the label, otherwise the callout + * number will be used. Callouts are + * numbered in document order. All of the areas in an + * areaset get the same number.

+ * + *

If the callout number is not greater than gMax, the + * callout generated will be:

+ * + *
+   * <img src="$gPath/conumber$gExt" alt="conumber">
+   * 
+ * + *

Otherwise, it will be the callout number surrounded by + * parenthesis.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn. Lines will be padded with blanks to reach the + * necessary column, but callouts that are located beyond the last + * line of the verbatim environment will be ignored.

+ * + *

Callouts are inserted before the character at the line/column + * where they are to occur.

+ * + * @param areaspecNodeSet The source node set that contains the areaspec. + * @param saxonRTF The result tree fragment of the verbatim environment. + * @param defaultColumn The column for callouts that specify only a line. + * @param gPath The path to use for callout graphics. + * @param gExt The extension to use for callout graphics. + * @param gMax The largest number that can be represented as a graphic. + * @param useFO Should fo:external-graphics be produced, as opposed to + * HTML imgs. This is bogus, the extension should figure it out, but I + * haven't figured out how to do that yet. + * + * @return The modified result tree fragment. + */ + public static FragmentValue insertCallouts (Context context, + NodeSetIntent areaspecNodeSet, + FragmentValue saxonRTF) { + + setupCallouts(context); + + callout = new Callout[10]; + calloutCount = 0; + calloutPos = 0; + lineNumber = 1; + colNumber = 1; + + // First we walk through the areaspec to calculate the position + // of the callouts + // + // + // + // + // + // + // + // + try { + int pos = 0; + int coNum = 0; + boolean inAreaSet = false; + NodeInfo areaspec = areaspecNodeSet.getFirst(); + NodeInfo children[] = areaspec.getAllChildNodes(); + + for (int count = 0; count < children.length; count++) { + NodeInfo node = children[count]; + if (node.getNodeType() == NodeInfo.ELEMENT) { + if (node.getNodeName().equalsIgnoreCase("areaset")) { + coNum++; + NodeInfo areas[] = node.getAllChildNodes(); + for (int acount = 0; acount < areas.length; acount++) { + NodeInfo area = areas[acount]; + if (area.getNodeType() == NodeInfo.ELEMENT) { + if (area.getNodeName().equalsIgnoreCase("area")) { + addCallout(coNum, area, defaultColumn); + } else { + System.out.println("Unexpected element in areaset: " + + area.getNodeName()); + } + } + } + } else if (node.getNodeName().equalsIgnoreCase("area")) { + coNum++; + addCallout(coNum, node, defaultColumn); + } else { + System.out.println("Unexpected element in areaspec: " + + node.getNodeName()); + } + } + } + + // Now sort them + java.util.Arrays.sort(callout, 0, calloutCount); + + FragmentValue rtf = new FragmentValue(); + calloutFragment(rtf, saxonRTF.getFirst()); + return rtf; + } catch (SAXException e) { + return saxonRTF; + } + } + + /** + *

Build a FragmentValue with callout decorations.

+ * + *

This is the method that actually does the work of adding + * callouts to a verbatim environment. It recursively walks through a + * tree of nodes, copying the structure into the rtf. Text nodes + * are examined for the position of callouts as described by the + * global callout parameters.

+ * + *

When called, rtf should be an empty FragmentValue and node + * should be the first child of the result tree fragment that contains + * the existing, formatted verbatim text.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param node The root of the tree to copy. + */ + private static void calloutFragment(FragmentValue rtf, + NodeInfo node) { + NodeInfo children[] = null; + + try { + if (node.getNodeType() == NodeInfo.DOCUMENT) { + rtf.startDocument(); + children = ((DocumentInfo) node).getAllChildNodes(); + } else if (node.getNodeType() == NodeInfo.ELEMENT) { + rtf.startElement(node.getExpandedName(), + ((ElementInfo) node).getAttributeList()); + children = ((ElementInfo) node).getAllChildNodes(); + elementStack.push(node); + } else if (node.getNodeType() == NodeInfo.TEXT) { + String text = node.getValue(); + + char chars[] = new char[text.length()]; + int pos = 0; + for (int count = 0; count < text.length(); count++) { + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + if (pos > 0) { + rtf.characters(chars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtf, callout[calloutPos]); + calloutPos++; + } + + openClosedElements(rtf); + } + + if (text.charAt(count) == '\n') { + // What if we need to pad this line? + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + + if (pos > 0) { + rtf.characters(chars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + formatPad(rtf, callout[calloutPos].getColumn() - colNumber); + colNumber = callout[calloutPos].getColumn(); + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtf, callout[calloutPos]); + calloutPos++; + } + } + + openClosedElements(rtf); + } + + lineNumber++; + colNumber = 1; + } else { + colNumber++; + } + chars[pos++] = text.charAt(count); + } + + if (pos > 0) { + rtf.characters(chars, 0, pos); + } + } else if (node.getNodeType() == NodeInfo.COMMENT) { + String text = node.getValue(); + char chars[] = new char[text.length()]; + for (int count = 0; count < text.length(); count++) { + chars[count] = text.charAt(count); + } + rtf.comment(chars, 0, text.length()); + } else if (node.getNodeType() == NodeInfo.PI) { + rtf.processingInstruction(node.getNodeName(), node.getValue()); + } else { + System.out.println("Warning: unexpected node type in calloutFragment"); + } + + if (children != null) { + for (int count = 0; count < children.length; count++) { + calloutFragment(rtf, children[count]); + } + } + + if (node.getNodeType() == NodeInfo.DOCUMENT) { + rtf.endDocument(); + } else if (node.getNodeType() == NodeInfo.ELEMENT) { + rtf.endElement(node.getExpandedName()); + elementStack.pop(); + } else { + // nop + } + } catch (SAXException e) { + System.out.println("SAX Exception in calloutFragment"); + } + } + + /** + *

Add a callout to the global callout array

+ * + *

This method examines a callout area and adds it to + * the global callout array if it can be interpreted.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn.

+ * + * @param coNum The callout number. + * @param node The area. + * @param defaultColumn The default column for callouts. + */ + private static void addCallout (int coNum, + NodeInfo node, + int defaultColumn) { + ElementInfo area = (ElementInfo) node; + AttributeCollection attr = area.getAttributeList(); + String units = attr.getValue("units"); + String coords = attr.getValue("coords"); + + if (units != null + && !units.equalsIgnoreCase("linecolumn") + && !units.equalsIgnoreCase("linerange")) { + System.out.println("Only linecolumn and linerange units are supported"); + return; + } + + if (coords == null) { + System.out.println("Coords must be specified"); + return; + } + + // Now let's see if we can interpret the coordinates... + StringTokenizer st = new StringTokenizer(coords); + int tokenCount = 0; + int c1 = 0; + int c2 = 0; + while (st.hasMoreTokens()) { + tokenCount++; + if (tokenCount > 2) { + System.out.println("Unparseable coordinates"); + return; + } + try { + String token = st.nextToken(); + int coord = Integer.parseInt(token); + c2 = coord; + if (tokenCount == 1) { + c1 = coord; + } + } catch (NumberFormatException e) { + System.out.println("Unparseable coordinate"); + return; + } + } + + // Make sure we aren't going to blow past the end of our array + if (calloutCount == callout.length) { + Callout bigger[] = new Callout[calloutCount+10]; + for (int count = 0; count < callout.length; count++) { + bigger[count] = callout[count]; + } + callout = bigger; + } + + // Ok, add the callout + if (tokenCount == 2) { + if (units != null && units.equalsIgnoreCase("linerange")) { + for (int count = c1; count <= c2; count++) { + callout[calloutCount++] = new Callout(coNum, area, + count, defaultColumn); + } + } else { + // assume linecolumn + callout[calloutCount++] = new Callout(coNum, area, c1, c2); + } + } else { + // if there's only one number, assume it's the line + callout[calloutCount++] = new Callout(coNum, area, c1, defaultColumn); + } + } + + /** + *

Add blanks to the result tree fragment.

+ * + *

This method adds numBlanks to the result tree fragment. + * It's used to pad lines when callouts occur after the last existing + * characater in a line.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param numBlanks The number of blanks to add. + */ + private static void formatPad(FragmentValue rtf, + int numBlanks) { + char chars[] = new char[numBlanks]; + for (int count = 0; count < numBlanks; count++) { + chars[count] = ' '; + } + + try { + rtf.characters(chars, 0, numBlanks); + } catch (SAXException e) { + System.out.println("SAX Exception in formatCallout"); + } + } + + private static void closeOpenElements(FragmentValue rtf) + throws SAXException { + String foURI = "http://www.w3.org/1999/XSL/Format"; + String xhURI = "http://www.w3.org/1999/xhtml"; + + // Close all the open elements... + tempStack = new Stack(); + while (!elementStack.empty()) { + ElementInfo elem = (ElementInfo) elementStack.pop(); + Name exName = elem.getExpandedName(); + String localName = elem.getLocalName(); + String ns = exName.getURI(); + + if (ns != null && ns.equals("")) { + ns = null; + } + + // If this is the bottom of the stack and it's an fo:block + // or an HTML pre or div, don't duplicate it... + if (elementStack.empty() + && (((ns != null) + && ns.equals(foURI) + && localName.equals("block")) + || ((ns == null) + && localName.equalsIgnoreCase("pre")) + || ((ns != null) + && ns.equals(xhURI) + && localName.equals("pre")) + || ((ns == null) + && localName.equalsIgnoreCase("div")) + || ((ns != null) + && ns.equals(xhURI) + && localName.equals("div")))) { + elementStack.push(elem); + break; + } else { + rtf.endElement(exName); + tempStack.push(elem); + } + } + } + + private static void openClosedElements(FragmentValue rtf) + throws SAXException { + // Now "reopen" the elements that we closed... + while (!tempStack.empty()) { + ElementInfo elem = (ElementInfo) tempStack.pop(); + AttributeCollection elemAttr = elem.getAttributeList(); + AttributeCollection newAttr = new AttributeCollection(); + for (int acount = 0; acount < elemAttr.getLength(); acount++) { + String name = elemAttr.getName(acount); + + if (name.equalsIgnoreCase("name") + || name.equalsIgnoreCase("id")) { + // skip 'name' and 'id' attributes + } else { + newAttr.addAttribute(elemAttr.getExpandedName(acount), + elemAttr.getType(acount), + elemAttr.getValue(acount)); + } + } + + rtf.startElement(elem.getExpandedName(), newAttr); + elementStack.push(elem); + } + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/package.html b/xsl/extensions/saxon551/com/nwalsh/saxon/package.html new file mode 100644 index 000000000..1253b7340 --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/package.html @@ -0,0 +1,50 @@ + + +Norman Walsh's Saxon Extensions Package + + +

Norman Walsh's Saxon Extensions Package for Saxon 5.*

+ +

This package implements Saxon extensions for XSLT. Future development +of this package will be limited to bug fixes only. The Saxon 6.0 Extension +Package is a practically complete, and much cleaner, reimplementation.

+ +

Copyright (C) 2000 Norman Walsh

+

Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

+ +

The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

+ +

Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the +individuals in question.

+ +

Anything derived from this Software that is publically +distributed will be identified with a different name and the +version strings in any derived Software will be changed so that no +possibility of confusion between the derived package and this +Software will exist.

+ + +
+

Warranty

+

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER +CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.

+
+ + + diff --git a/xsl/extensions/saxon6/.cvsignore b/xsl/extensions/saxon6/.cvsignore new file mode 100644 index 000000000..4d3c216f5 --- /dev/null +++ b/xsl/extensions/saxon6/.cvsignore @@ -0,0 +1 @@ +.classes diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/CVS.java b/xsl/extensions/saxon6/com/nwalsh/saxon/CVS.java new file mode 100644 index 000000000..529546be7 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/CVS.java @@ -0,0 +1,90 @@ +package com.nwalsh.saxon; + +import java.io.*; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.text.DateFormat; +import java.text.ParseException; + +/** + *

Saxon extension to convert CVS date strings into local time

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension to turn the CVS date strings, which are UTC:

+ * + *
$Date: 2000/11/09 02:34:20 $
+ * + *

into legibly formatted local time:

+ * + *
Wed Nov 08 18:34:20 PST 2000
+ * + *

(I happened to be in California when I wrote this documentation.)

+ + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CVS { + /** + *

Constructor for CVS

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public CVS() { + } + + /** + *

Convert a CVS date string into local time.

+ * + * @param cvsDate The CVS date string. + * + * @return The date, converted to local time and reformatted. + */ + public static String localTime (String cvsDate) { + // A cvsDate has the following form "$Date$" + if (!cvsDate.startsWith("$Date: ")) { + return cvsDate; + } + + String yrS = cvsDate.substring(7,11); + String moS = cvsDate.substring(12,14); + String daS = cvsDate.substring(15,17); + String hrS = cvsDate.substring(18,20); + String miS = cvsDate.substring(21,23); + String seS = cvsDate.substring(24,26); + + TimeZone tz = TimeZone.getTimeZone("GMT+0"); + GregorianCalendar gmtCal = new GregorianCalendar(tz); + + try { + gmtCal.set(Integer.parseInt(yrS), + Integer.parseInt(moS)-1, + Integer.parseInt(daS), + Integer.parseInt(hrS), + Integer.parseInt(miS), + Integer.parseInt(seS)); + } catch (NumberFormatException e) { + // nop + } + + Date d = gmtCal.getTime(); + + return d.toString(); + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/Callout.java b/xsl/extensions/saxon6/com/nwalsh/saxon/Callout.java new file mode 100644 index 000000000..f0be0cd4f --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/Callout.java @@ -0,0 +1,91 @@ +package com.nwalsh.saxon; + +import com.icl.saxon.om.*; +import com.icl.saxon.tree.*; + +/** + *

A class for maintaining information about callouts.

+ * + *

To make processing callouts easier, they are parsed out of the + * input structure and stored in a sorted array. (The array is sorted + * according to the order in which the callouts occur.)

+ * + *

This class is just the little record + * that we store in the array for each callout.

+ */ +public class Callout implements Comparable { + /** The callout number. */ + private int callout = 0; + /** The area ElementInfo item that generated this callout. */ + private ElementInfo area = null; + /** The line on which this callout occurs. */ + private int line = 0; + /** The column in which this callout appears. */ + private int col = 0; + + /** The constructor; initialize the private data structures. */ + public Callout(int callout, ElementInfo area, int line, int col) { + this.callout = callout; + this.area = area; + this.line = line; + this.col = col; + } + + /** + *

The compareTo method compares this Callout with another.

+ * + *

Given two Callouts, A and B, A < B if:

+ * + *
    + *
  1. A.line < B.line, or
  2. + *
  3. A.line = B.line && A.col < B.col, or
  4. + *
  5. A.line = B.line && A.col = B.col && A.callout < B.callout
  6. + *
  7. Otherwise, they're equal.
  8. + *
+ */ + public int compareTo (Object o) { + Callout c = (Callout) o; + + if (line == c.getLine()) { + if (col > c.getColumn()) { + return 1; + } else if (col < c.getColumn()) { + return -1; + } else { + if (callout < c.getCallout()) { + return -1; + } else if (callout > c.getCallout()) { + return 1; + } else { + return 0; + } + } + } else { + if (line > c.getLine()) { + return 1; + } else { + return -1; + } + } + } + + /** Access the Callout's area. */ + public ElementInfo getArea() { + return area; + } + + /** Access the Callout's line. */ + public int getLine() { + return line; + } + + /** Access the Callout's column. */ + public int getColumn() { + return col; + } + + /** Access the Callout's callout number. */ + public int getCallout() { + return callout; + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/CalloutEmitter.java b/xsl/extensions/saxon6/com/nwalsh/saxon/CalloutEmitter.java new file mode 100644 index 000000000..01cbfaaf2 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/CalloutEmitter.java @@ -0,0 +1,522 @@ +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import com.icl.saxon.Builder; +import com.icl.saxon.Context; +import com.icl.saxon.expr.*; +import com.icl.saxon.functions.Extensions; +import com.icl.saxon.om.*; +import com.icl.saxon.output.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.tree.*; + +/** + *

Saxon extension to decorate a result tree fragment with callouts.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides the guts of a + * Saxon 6.* + * implementation of callouts for verbatim environments. (It is used + * by the Verbatim class.)

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some verbatim environment. The Verbatim class initializes + * a CalloutEmitter with information about the callouts that should be applied + * to the verbatim environment in question. Then the result tree fragment + * is "replayed" through the CalloutEmitter; the CalloutEmitter builds a + * new result tree fragment from this event stream, decorated with callouts, + * and that is returned.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see Verbatim + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CalloutEmitter extends CopyEmitter { + /** A stack for the preserving information about open elements. */ + protected Stack elementStack = null; + + /** A stack for holding information about temporarily closed elements. */ + protected Stack tempStack = null; + + /** Is the next element absolutely the first element in the fragment? */ + protected boolean firstElement = false; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** The default column for callouts that specify only a line. */ + protected int defaultColumn = 60; + + /** Is the stylesheet currently running an FO stylesheet? */ + protected boolean foStylesheet = false; + + /** The current line number. */ + private static int lineNumber = 0; + + /** The current column number. */ + private static int colNumber = 0; + + /** The (sorted) array of callouts obtained from the areaspec. */ + private static Callout callout[] = null; + + /** The number of callouts in the callout array. */ + private static int calloutCount = 0; + + /** A pointer used to keep track of our position in the callout array. */ + private static int calloutPos = 0; + + /** The FormatCallout object to use for formatting callouts. */ + private static FormatCallout fCallout = null; + + /**

Constructor for the CalloutEmitter.

+ * + * @param namePool The name pool to use for constructing elements and attributes. + * @param defaultColumn The default column for callouts. + * @param foStylesheet Is this an FO stylesheet? + * @param fCallout The callout formatting object + */ + public CalloutEmitter(NamePool namePool, + int defaultColumn, + boolean foStylesheet, + FormatCallout fCallout) { + super(namePool); + elementStack = new Stack(); + firstElement = true; + + this.defaultColumn = defaultColumn; + this.foStylesheet = foStylesheet; + this.fCallout = fCallout; + } + + /** + *

Examine the areaspec and determine the number and position of + * callouts.

+ * + *

The areaspecNodeSet + * is examined and a sorted list of the callouts is constructed.

+ * + *

This data structure is used to augment the result tree fragment + * with callout bullets.

+ * + * @param areaspecNodeSet The source document <areaspec> element. + * + */ + public void setupCallouts (NodeSetIntent areaspecNodeSet) { + callout = new Callout[10]; + calloutCount = 0; + calloutPos = 0; + lineNumber = 1; + colNumber = 1; + + // First we walk through the areaspec to calculate the position + // of the callouts + // + // + // + // + // + // + // + // + try { + int pos = 0; + int coNum = 0; + boolean inAreaSet = false; + NodeInfo areaspec = areaspecNodeSet.getFirst(); + NodeInfo children[] = areaspec.getAllChildNodes(); + + for (int count = 0; count < children.length; count++) { + NodeInfo node = children[count]; + if (node.getNodeType() == NodeInfo.ELEMENT) { + if (node.getNodeName().equalsIgnoreCase("areaset")) { + coNum++; + NodeInfo areas[] = node.getAllChildNodes(); + for (int acount = 0; acount < areas.length; acount++) { + NodeInfo area = areas[acount]; + if (area.getNodeType() == NodeInfo.ELEMENT) { + if (area.getNodeName().equalsIgnoreCase("area")) { + addCallout(coNum, area, defaultColumn); + } else { + System.out.println("Unexpected element in areaset: " + + area.getNodeName()); + } + } + } + } else if (node.getNodeName().equalsIgnoreCase("area")) { + coNum++; + addCallout(coNum, node, defaultColumn); + } else { + System.out.println("Unexpected element in areaspec: " + + node.getNodeName()); + } + } + } + + // Now sort them + java.util.Arrays.sort(callout, 0, calloutCount); + } catch (SAXException e) { + //nop; + } + } + + /** Process characters. */ + public void characters(char[] chars, int start, int len) + throws org.xml.sax.SAXException { + + // If we hit characters, then there's no first element... + firstElement = false; + + if (lineNumber == 0) { + // if there are any text nodes, there's at least one line + lineNumber++; + colNumber = 1; + } + + // Walk through the text node looking for callout positions + char[] newChars = new char[len]; + int pos = 0; + for (int count = start; count < start+len; count++) { + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + if (pos > 0) { + rtf.characters(newChars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtf, callout[calloutPos]); + calloutPos++; + } + + openClosedElements(rtf); + } + + if (chars[count] == '\n') { + // What if we need to pad this line? + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + + if (pos > 0) { + rtf.characters(newChars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + formatPad(callout[calloutPos].getColumn() - colNumber); + colNumber = callout[calloutPos].getColumn(); + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtf, callout[calloutPos]); + calloutPos++; + } + } + + openClosedElements(rtf); + } + + lineNumber++; + colNumber = 1; + } else { + colNumber++; + } + newChars[pos++] = chars[count]; + } + + if (pos > 0) { + rtf.characters(newChars, 0, pos); + } + } + + /** + *

Add blanks to the result tree fragment.

+ * + *

This method adds numBlanks to the result tree fragment. + * It's used to pad lines when callouts occur after the last existing + * characater in a line.

+ * + * @param numBlanks The number of blanks to add. + */ + protected void formatPad(int numBlanks) { + char chars[] = new char[numBlanks]; + for (int count = 0; count < numBlanks; count++) { + chars[count] = ' '; + } + + try { + rtf.characters(chars, 0, numBlanks); + } catch (SAXException e) { + System.out.println("SAX Exception in formatPad"); + } + } + + /** + *

Add a callout to the global callout array

+ * + *

This method examines a callout area and adds it to + * the global callout array if it can be interpreted.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn.

+ * + * @param coNum The callout number. + * @param node The area. + * @param defaultColumn The default column for callouts. + */ + protected void addCallout (int coNum, + NodeInfo node, + int defaultColumn) { + ElementInfo area = (ElementInfo) node; + ExtendedAttributes attr = area.getAttributeList(); + String units = attr.getValue("units"); + String coords = attr.getValue("coords"); + + if (units != null + && !units.equalsIgnoreCase("linecolumn") + && !units.equalsIgnoreCase("linerange")) { + System.out.println("Only linecolumn and linerange units are supported"); + return; + } + + if (coords == null) { + System.out.println("Coords must be specified"); + return; + } + + // Now let's see if we can interpret the coordinates... + StringTokenizer st = new StringTokenizer(coords); + int tokenCount = 0; + int c1 = 0; + int c2 = 0; + while (st.hasMoreTokens()) { + tokenCount++; + if (tokenCount > 2) { + System.out.println("Unparseable coordinates"); + return; + } + try { + String token = st.nextToken(); + int coord = Integer.parseInt(token); + c2 = coord; + if (tokenCount == 1) { + c1 = coord; + } + } catch (NumberFormatException e) { + System.out.println("Unparseable coordinate"); + return; + } + } + + // Make sure we aren't going to blow past the end of our array + if (calloutCount == callout.length) { + Callout bigger[] = new Callout[calloutCount+10]; + for (int count = 0; count < callout.length; count++) { + bigger[count] = callout[count]; + } + callout = bigger; + } + + // Ok, add the callout + if (tokenCount == 2) { + if (units != null && units.equalsIgnoreCase("linerange")) { + for (int count = c1; count <= c2; count++) { + callout[calloutCount++] = new Callout(coNum, area, + count, defaultColumn); + } + } else { + // assume linecolumn + callout[calloutCount++] = new Callout(coNum, area, c1, c2); + } + } else { + // if there's only one number, assume it's the line + callout[calloutCount++] = new Callout(coNum, area, c1, defaultColumn); + } + } + + /** Process end element events. */ + public void endElement(int nameCode) + throws org.xml.sax.SAXException { + if (!elementStack.empty()) { + // if we didn't push the very first element (an fo:block or + // pre or div surrounding the whole block), then the stack will + // be empty when we get to the end of the first element... + elementStack.pop(); + } + rtf.endElement(nameCode); + } + + /** Process start element events. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) + throws org.xml.sax.SAXException { + + if (!skipThisElement(nameCode)) { + StartElementInfo sei = new StartElementInfo(nameCode, attributes, + namespaces, nscount); + elementStack.push(sei); + } + + firstElement = false; + + rtf.startElement(nameCode, attributes, namespaces, nscount); + } + + /** + *

Protect the outer-most block wrapper.

+ * + *

Open elements in the result tree fragment are closed and reopened + * around callouts (so that callouts don't appear inside links or other + * environments). But if the result tree fragment is a single block + * (a div or pre in HTML, an fo:block in FO), that outer-most block is + * treated specially.

+ * + *

This method returns true if the element in question is that + * outermost block.

+ * + * @param nameCode The name code for the element + * + * @return True if the element is the outer-most block, false otherwise. + */ + protected boolean skipThisElement(int nameCode) { + if (firstElement) { + int thisFingerprint = namePool.getFingerprint(nameCode); + int foBlockFingerprint = namePool.getFingerprint(foURI, "block"); + int htmlPreFingerprint = namePool.getFingerprint("", "pre"); + int htmlDivFingerprint = namePool.getFingerprint("", "div"); + + if ((foStylesheet && thisFingerprint == foBlockFingerprint) + || (!foStylesheet && (thisFingerprint == htmlPreFingerprint + || thisFingerprint == htmlDivFingerprint))) { + // Don't push the outer-most wrapping div, pre, or fo:block + return true; + } + } + + return false; + } + + private void closeOpenElements(Emitter rtfEmitter) + throws SAXException { + // Close all the open elements... + tempStack = new Stack(); + while (!elementStack.empty()) { + StartElementInfo elem = (StartElementInfo) elementStack.pop(); + rtfEmitter.endElement(elem.getNameCode()); + tempStack.push(elem); + } + } + + private void openClosedElements(Emitter rtfEmitter) + throws SAXException { + // Now "reopen" the elements that we closed... + while (!tempStack.empty()) { + StartElementInfo elem = (StartElementInfo) tempStack.pop(); + AttributeCollection attr = (AttributeCollection)elem.getAttributes(); + AttributeCollection newAttr = new AttributeCollection(namePool); + + for (int acount = 0; acount < attr.getLength(); acount++) { + String localName = attr.getLocalName(acount); + int nameCode = attr.getNameCode(acount); + String type = attr.getType(acount); + String value = attr.getValue(acount); + String uri = attr.getURI(acount); + String prefix = ""; + + if (localName.indexOf(':') > 0) { + prefix = localName.substring(0, localName.indexOf(':')); + localName = localName.substring(localName.indexOf(':')+1); + } + + if (uri.equals("") + && ((foStylesheet + && localName.equals("id")) + || (!foStylesheet + && (localName.equals("id") + || localName.equals("name"))))) { + // skip this attribute + } else { + newAttr.addAttribute(prefix, uri, localName, type, value); + } + } + + rtfEmitter.startElement(elem.getNameCode(), + newAttr, + elem.getNamespaces(), + elem.getNSCount()); + + elementStack.push(elem); + } + } + + /** + *

A private class for maintaining the information required to call + * the startElement method.

+ * + *

In order to close and reopen elements, information about those + * elements has to be maintained. This class is just the little record + * that we push on the stack to keep track of that info.

+ */ + private class StartElementInfo { + private int _nameCode; + org.xml.sax.Attributes _attributes; + int[] _namespaces; + int _nscount; + + public StartElementInfo(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) { + _nameCode = nameCode; + _attributes = attributes; + _namespaces = namespaces; + _nscount = nscount; + } + + public int getNameCode() { + return _nameCode; + } + + public org.xml.sax.Attributes getAttributes() { + return _attributes; + } + + public int[] getNamespaces() { + return _namespaces; + } + + public int getNSCount() { + return _nscount; + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/ColumnScanEmitter.java b/xsl/extensions/saxon6/com/nwalsh/saxon/ColumnScanEmitter.java new file mode 100644 index 000000000..a206b1def --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/ColumnScanEmitter.java @@ -0,0 +1,179 @@ +package com.nwalsh.saxon; + +import org.xml.sax.*; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; + +/** + *

Saxon extension to scan the column widthsin a result tree fragment.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation to scan the column widths in a result tree + * fragment.

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some colgroup environment. That result tree fragment + * is "replayed" through the ColumnScanEmitter; the ColumnScanEmitter watches + * the cols go by and extracts the column widths that it sees. These + * widths are then made available.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class ColumnScanEmitter implements com.icl.saxon.output.Emitter { + /** The number of columns seen. */ + protected int numColumns = 0; + protected String width[] = new String[5]; + protected NamePool namePool = null; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** Construct a new ColumnScanEmitter. */ + public ColumnScanEmitter(NamePool namePool) { + numColumns = 0; + this.namePool = namePool; + } + + /** Return the number of columns. */ + public int columnCount() { + return numColumns; + } + + /** Return the number of columns. */ + public String[] columnWidths() { + return width; + } + + /** Discarded. */ + public void characters(char[] chars, int start, int len) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void comment(char[] chars, int start, int length) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void endDocument() + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void endElement(int nameCode) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void processingInstruction(java.lang.String name, + java.lang.String data) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setCharacterSet(CharacterSet charset) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setDocumentLocator(org.xml.sax.Locator locator) { + // nop + } + + /** Discarded. */ + public void setEscaping(boolean escaping) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setNamePool(NamePool namePool) { + // nop + } + + /** Discarded. */ + public void setOutputDetails(OutputDetails details) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setUnparsedEntity(java.lang.String name, java.lang.String uri) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setWriter(java.io.Writer writer) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void startDocument() + throws org.xml.sax.SAXException { + // nop + } + + /** Examine for column info. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, int nscount) + throws org.xml.sax.SAXException { + + int thisFingerprint = namePool.getFingerprint(nameCode); + int colFingerprint = namePool.getFingerprint("", "col"); + int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); + + if (thisFingerprint == colFingerprint + || thisFingerprint == foColFingerprint) { + if (numColumns >= width.length) { + String newWidth[] = new String[width.length+10]; + for (int count = 0; count < width.length; count++) { + newWidth[count] = width[count]; + } + width = newWidth; + } + + if (thisFingerprint == colFingerprint) { + if (attributes.getValue("width") == null) { + width[numColumns++] = "1*"; + } else { + width[numColumns++] = attributes.getValue("width"); + } + } else { + if (attributes.getValue("column-width") == null) { + width[numColumns++] = "1*"; + } else { + width[numColumns++] = attributes.getValue("column-width"); + } + } + } + } +} + + diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/ColumnUpdateEmitter.java b/xsl/extensions/saxon6/com/nwalsh/saxon/ColumnUpdateEmitter.java new file mode 100644 index 000000000..a1d479883 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/ColumnUpdateEmitter.java @@ -0,0 +1,95 @@ +package com.nwalsh.saxon; + +import org.xml.sax.*; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; +import com.icl.saxon.tree.AttributeCollection; + +/** + *

Saxon extension to scan the column widthsin a result tree fragment.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation to scan the column widths in a result tree + * fragment.

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some colgroup environment. That result tree fragment + * is "replayed" through the ColumnUpdateEmitter; the ColumnUpdateEmitter watches + * the cols go by and extracts the column widths that it sees. These + * widths are then made available.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class ColumnUpdateEmitter extends CopyEmitter { + /** The number of columns seen. */ + protected int numColumns = 0; + protected String width[] = null; + protected NamePool namePool = null; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** Construct a new ColumnUpdateEmitter. */ + public ColumnUpdateEmitter(NamePool namePool, + String width[]) { + super(namePool); + numColumns = 0; + this.width = width; + this.namePool = namePool; + } + + /** Examine for column info. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, int nscount) + throws org.xml.sax.SAXException { + + int thisFingerprint = namePool.getFingerprint(nameCode); + int colFingerprint = namePool.getFingerprint("", "col"); + int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); + + if (thisFingerprint == colFingerprint) { + AttributeCollection attr = new AttributeCollection(namePool, attributes); + int widthFingerprint = namePool.getFingerprint("", "width"); + + if (attr.getValueByFingerprint(widthFingerprint) == null) { + attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } else { + attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } + attributes = attr; + } else if (thisFingerprint == foColFingerprint) { + AttributeCollection attr = new AttributeCollection(namePool, attributes); + int widthFingerprint = namePool.getFingerprint("", "column-width"); + + if (attr.getValueByFingerprint(widthFingerprint) == null) { + attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } else { + attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } + attributes = attr; + } + + rtf.startElement(nameCode, attributes, namespaces, nscount); + } +} + + diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/CopyEmitter.java b/xsl/extensions/saxon6/com/nwalsh/saxon/CopyEmitter.java new file mode 100644 index 000000000..008fe9957 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/CopyEmitter.java @@ -0,0 +1,165 @@ +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import com.icl.saxon.Builder; +import com.icl.saxon.Context; +import com.icl.saxon.expr.*; +import com.icl.saxon.functions.Extensions; +import com.icl.saxon.om.*; +import com.icl.saxon.output.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.tree.*; + +/** + *

A Saxon 6.0 Emitter that clones its input.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation of an emitter that manufactures a cloned result + * tree fragment.

+ * + *

The purpose of this emitter is to provide something for + * CalloutEmitter and NumberLinesEmitter to extend. + * This emitter simply copies all input to a new result tree fragment.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see CalloutEmitter + * @see NumberLinesEmitter + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CopyEmitter implements com.icl.saxon.output.Emitter { + /** The result tree fragment containing the copied fragment. */ + protected FragmentValue rtf = null; + + /**

The namePool.

+ * + *

Copied from the caller, it should be the runtime name pool.

+ */ + protected NamePool namePool = null; + + /**

Constructor for the CopyEmitter.

+ * + * @param namePool The name pool to use for constructing elements and attributes. + */ + public CopyEmitter(NamePool namePool) { + try { + rtf = new FragmentValue(); + rtf.allowConversion(true); + this.namePool = namePool; + } catch (SAXException e) { + rtf = null; + } + } + + /** + *

Return the result tree fragment constructed by replaying events + * through this emitter.

+ */ + public FragmentValue getResultTreeFragment() { + return rtf; + } + + /** Copy characters. */ + public void characters(char[] chars, int start, int len) + throws org.xml.sax.SAXException { + rtf.characters(chars, start, len); + } + + /** Copy comments. */ + public void comment(char[] chars, int start, int length) + throws org.xml.sax.SAXException { + rtf.comment(chars, start, length); + } + + /** Copy end document events. */ + public void endDocument() + throws org.xml.sax.SAXException { + rtf.endDocument(); + } + + /** Copy end element events. */ + public void endElement(int nameCode) + throws org.xml.sax.SAXException { + rtf.endElement(nameCode); + } + + /** Copy processing instructions. */ + public void processingInstruction(java.lang.String name, + java.lang.String data) + throws org.xml.sax.SAXException { + rtf.processingInstruction(name, data); + } + + /** Copy set character set events. */ + public void setCharacterSet(CharacterSet charset) + throws org.xml.sax.SAXException { + rtf.setCharacterSet(charset); + } + + /** Copy set document locator events. */ + public void setDocumentLocator(org.xml.sax.Locator locator) { + rtf.setDocumentLocator(locator); + } + + /** Copy set escaping events. */ + public void setEscaping(boolean escaping) + throws org.xml.sax.SAXException { + rtf.setEscaping(escaping); + } + + /** Copy set name pool events. */ + public void setNamePool(NamePool namePool) { + rtf.setNamePool(namePool); + } + + /** Copy set output details events. */ + public void setOutputDetails(OutputDetails details) + throws org.xml.sax.SAXException { + rtf.setOutputDetails(details); + } + + /** Copy set unparsed entity events. */ + public void setUnparsedEntity(java.lang.String name, java.lang.String uri) + throws org.xml.sax.SAXException { + rtf.setUnparsedEntity(name, uri); + } + + /** Copy set writer events. */ + public void setWriter(java.io.Writer writer) + throws org.xml.sax.SAXException { + rtf.setWriter(writer); + } + + /** Copy start document events. */ + public void startDocument() + throws org.xml.sax.SAXException { + rtf.startDocument(); + } + + /** Copy start element events. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) + throws org.xml.sax.SAXException { + rtf.startElement(nameCode, attributes, namespaces, nscount); + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/FormatCallout.java b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatCallout.java new file mode 100644 index 000000000..8f76499a7 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatCallout.java @@ -0,0 +1,110 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.tree.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public abstract class FormatCallout { + protected static final String foURI = "http://www.w3.org/1999/XSL/Format"; + protected static final String xhURI = "http://www.w3.org/1999/xhtml"; + protected boolean foStylesheet = false; + protected NamePool namePool = null; + + public FormatCallout(NamePool nPool, boolean fo) { + namePool = nPool; + foStylesheet = fo; + } + + public String areaLabel(ElementInfo area) { + String label = null; + + if (area.getAttributeList().getValue("label") != null) { + // If this area has a label, use it + label = area.getAttributeList().getValue("label"); + } else { + // Otherwise, if its parent is an areaset and it has a label, use that + ElementInfo parent = (ElementInfo) area.getParentNode(); + if (parent != null + && parent.getLocalName().equalsIgnoreCase("areaset") + && parent.getAttributeList().getValue("label") != null) { + label = parent.getAttributeList().getValue("label"); + } + } + + return label; + } + + public void startSpan(Emitter rtf) + throws SAXException { + // no point in doing this for FO, right? + if (!foStylesheet && namePool != null) { + int spanName = namePool.allocate("", "", "span"); + AttributeCollection spanAttr = new AttributeCollection(namePool); + int namespaces[] = new int[1]; + spanAttr.addAttribute("", "", "class", "CDATA", "co"); + rtf.startElement(spanName, spanAttr, namespaces, 0); + } + } + + public void endSpan(Emitter rtf) + throws SAXException { + // no point in doing this for FO, right? + if (!foStylesheet && namePool != null) { + int spanName = namePool.allocate("", "", "span"); + rtf.endElement(spanName); + } + } + + public void formatTextCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + char chars[] = label.toCharArray(); + + try { + startSpan(rtfEmitter); + rtfEmitter.characters(chars, 0, label.length()); + endSpan(rtfEmitter); + } catch (SAXException e) { + System.out.println("SAX Exception in formatTextCallout"); + } + } + + public abstract void formatCallout(Emitter rtfEmitter, + Callout callout); +} + diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/FormatGraphicCallout.java b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatGraphicCallout.java new file mode 100644 index 000000000..c9fabfe73 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatGraphicCallout.java @@ -0,0 +1,87 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.tree.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatGraphicCallout extends FormatCallout { + String graphicsPath = ""; + String graphicsExt = ""; + int graphicsMax = 0; + + public FormatGraphicCallout(NamePool nPool, String path, String ext, int max, boolean fo) { + super(nPool, fo); + graphicsPath = path; + graphicsExt = ext; + graphicsMax = max; + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + try { + if (userLabel == null && num <= graphicsMax) { + int imgName = 0; + AttributeCollection imgAttr = null; + int namespaces[] = new int[1]; + + if (foStylesheet) { + imgName = namePool.allocate("fo", foURI, "external-graphic"); + imgAttr = new AttributeCollection(namePool); + imgAttr.addAttribute("", "", "src", "CDATA", + graphicsPath + num + graphicsExt); + } else { + imgName = namePool.allocate("", "", "img"); + imgAttr = new AttributeCollection(namePool); + imgAttr.addAttribute("", "", "src", "CDATA", + graphicsPath + num + graphicsExt); + imgAttr.addAttribute("", "", "alt", "CDATA", label); + } + + startSpan(rtfEmitter); + rtfEmitter.startElement(imgName, imgAttr, namespaces, 0); + rtfEmitter.endElement(imgName); + endSpan(rtfEmitter); + } else { + formatTextCallout(rtfEmitter, callout); + } + } catch (SAXException e) { + System.out.println("SAX Exception in graphic formatCallout"); + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/FormatTextCallout.java b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatTextCallout.java new file mode 100644 index 000000000..5c2d8c8fd --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatTextCallout.java @@ -0,0 +1,42 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatTextCallout extends FormatCallout { + public FormatTextCallout(NamePool nPool, boolean fo) { + super(nPool, fo); + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + formatTextCallout(rtfEmitter, callout); + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/FormatUnicodeCallout.java b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatUnicodeCallout.java new file mode 100644 index 000000000..137476d78 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatUnicodeCallout.java @@ -0,0 +1,65 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.tree.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatUnicodeCallout extends FormatCallout { + int unicodeMax = 0; + int unicodeStart = 0; + + public FormatUnicodeCallout(NamePool nPool, int start, int max, boolean fo) { + super(nPool, fo); + unicodeMax = max; + unicodeStart = start; + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String label = areaLabel(area); + + try { + if (label == null && num <= unicodeMax) { + char chars[] = new char[1]; + chars[0] = (char) (unicodeStart + num - 1); + + startSpan(rtfEmitter); + rtfEmitter.characters(chars, 0, 1); + endSpan(rtfEmitter); + } else { + formatTextCallout(rtfEmitter, callout); + } + } catch (SAXException e) { + System.out.println("SAX Exception in graphic formatCallout"); + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/LineCountEmitter.java b/xsl/extensions/saxon6/com/nwalsh/saxon/LineCountEmitter.java new file mode 100644 index 000000000..257e3e66b --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/LineCountEmitter.java @@ -0,0 +1,155 @@ +package com.nwalsh.saxon; + +import org.xml.sax.*; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; + +/** + *

Saxon extension to count the lines in a result tree fragment.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation to count the number of lines in a result tree + * fragment.

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some verbatim environment. That result tree fragment + * is "replayed" through the LineCountEmitter; the LineCountEmitter watches + * characters go by and counts the number of line feeds that it sees. + * That number is then returned.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see Verbatim + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class LineCountEmitter implements com.icl.saxon.output.Emitter { + /** The number of lines seen. */ + protected int numLines = 0; + + /** Construct a new LineCountEmitter. */ + public LineCountEmitter() { + numLines = 0; + } + + /** Reset the number of lines. */ + public void reset() { + numLines = 0; + } + + /** Return the number of lines. */ + public int lineCount() { + return numLines; + } + + /** Process characters. */ + public void characters(char[] chars, int start, int len) + throws org.xml.sax.SAXException { + + if (numLines == 0) { + // If there are any characters at all, there's at least one line + numLines++; + } + + for (int count = start; count < start+len; count++) { + if (chars[count] == '\n') { + numLines++; + } + } + } + + /** Discarded. */ + public void comment(char[] chars, int start, int length) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void endDocument() + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void endElement(int nameCode) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void processingInstruction(java.lang.String name, + java.lang.String data) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setCharacterSet(CharacterSet charset) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setDocumentLocator(org.xml.sax.Locator locator) { + // nop + } + + /** Discarded. */ + public void setEscaping(boolean escaping) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setNamePool(NamePool namePool) { + // nop + } + + /** Discarded. */ + public void setOutputDetails(OutputDetails details) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setUnparsedEntity(java.lang.String name, java.lang.String uri) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void setWriter(java.io.Writer writer) + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void startDocument() + throws org.xml.sax.SAXException { + // nop + } + + /** Discarded. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, int nscount) + throws org.xml.sax.SAXException { + // nop + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/NumberLinesEmitter.java b/xsl/extensions/saxon6/com/nwalsh/saxon/NumberLinesEmitter.java new file mode 100644 index 000000000..3d318b86c --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/NumberLinesEmitter.java @@ -0,0 +1,322 @@ +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tree.AttributeCollection; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; + +/** + *

Saxon extension to decorate a result tree fragment with line numbers.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides the guts of a + * Saxon 6.* + * implementation of line numbering for verbatim environments. (It is used + * by the Verbatim class.)

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some verbatim environment. The Verbatim class initializes + * a NumberLinesEmitter with information about what lines should be + * numbered and how. Then the result tree fragment + * is "replayed" through the NumberLinesEmitter; the NumberLinesEmitter + * builds a + * new result tree fragment from this event stream, decorated with line + * numbers, + * and that is returned.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see Verbatim + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class NumberLinesEmitter extends CopyEmitter { + /** A stack for the preserving information about open elements. */ + protected Stack elementStack = null; + + /** The current line number. */ + protected int lineNumber = 0; + + /** Is the next element absolutely the first element in the fragment? */ + protected boolean firstElement = false; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** Every modulus line will be numbered. */ + protected int modulus = 5; + + /** Line numbers are width characters wide. */ + protected int width = 3; + + /** Line numbers are separated from the listing by separator. */ + protected String separator = " "; + + /** Is the stylesheet currently running an FO stylesheet? */ + protected boolean foStylesheet = false; + + /**

Constructor for the NumberLinesEmitter.

+ * + * @param namePool The name pool to use for constructing elements and attributes. + * @param modulus The modulus to use for this listing. + * @param width The width to use for line numbers in this listing. + * @param separator The separator to use for this listing. + * @param foStylesheet Is this an FO stylesheet? + */ + public NumberLinesEmitter(NamePool namePool, + int modulus, + int width, + String separator, + boolean foStylesheet) { + super(namePool); + elementStack = new Stack(); + firstElement = true; + + this.modulus = modulus; + this.width = width; + this.separator = separator; + this.foStylesheet = foStylesheet; + } + + /** Process characters. */ + public void characters(char[] chars, int start, int len) + throws org.xml.sax.SAXException { + + // If we hit characters, then there's no first element... + firstElement = false; + + if (lineNumber == 0) { + // The first line is always numbered + formatLineNumber(++lineNumber); + } + + // Walk through the text node looking for newlines + char[] newChars = new char[len]; + int pos = 0; + for (int count = start; count < start+len; count++) { + if (chars[count] == '\n') { + // This is the tricky bit; if we find a newline, make sure + // it doesn't occur inside any markup. + + if (pos > 0) { + // Output any characters that preceded this newline + rtf.characters(newChars, 0, pos); + pos = 0; + } + + // Close all the open elements... + Stack tempStack = new Stack(); + while (!elementStack.empty()) { + StartElementInfo elem = (StartElementInfo) elementStack.pop(); + rtf.endElement(elem.getNameCode()); + tempStack.push(elem); + } + + // Copy the newline to the output + newChars[pos++] = chars[count]; + rtf.characters(newChars, 0, pos); + pos = 0; + + // Add the line number + formatLineNumber(++lineNumber); + + // Now "reopen" the elements that we closed... + while (!tempStack.empty()) { + StartElementInfo elem = (StartElementInfo) tempStack.pop(); + AttributeCollection attr = (AttributeCollection)elem.getAttributes(); + AttributeCollection newAttr = new AttributeCollection(namePool); + + for (int acount = 0; acount < attr.getLength(); acount++) { + String localName = attr.getLocalName(acount); + int nameCode = attr.getNameCode(acount); + String type = attr.getType(acount); + String value = attr.getValue(acount); + String uri = attr.getURI(acount); + String prefix = ""; + + if (localName.indexOf(':') > 0) { + prefix = localName.substring(0, localName.indexOf(':')); + localName = localName.substring(localName.indexOf(':')+1); + } + + if (uri.equals("") + && ((foStylesheet + && localName.equals("id")) + || (!foStylesheet + && (localName.equals("id") + || localName.equals("name"))))) { + // skip this attribute + } else { + newAttr.addAttribute(prefix, uri, localName, type, value); + } + } + + rtf.startElement(elem.getNameCode(), + newAttr, + elem.getNamespaces(), + elem.getNSCount()); + + elementStack.push(elem); + } + } else { + newChars[pos++] = chars[count]; + } + } + + if (pos > 0) { + rtf.characters(newChars, 0, pos); + pos = 0; + } + } + + /** + *

Add a formatted line number to the result tree fragment.

+ * + * @param lineNumber The number of the current line. + */ + protected void formatLineNumber(int lineNumber) + throws SAXException { + + char ch = 160; //   + + String lno = ""; + if (lineNumber == 1 + || (modulus >= 1 && (lineNumber % modulus == 0))) { + lno = "" + lineNumber; + } + + while (lno.length() < width) { + lno = ch + lno; + } + + lno += separator; + + char chars[] = new char[lno.length()]; + for (int count = 0; count < lno.length(); count++) { + chars[count] = lno.charAt(count); + } + + characters(chars, 0, lno.length()); + } + + /** Process end element events. */ + public void endElement(int nameCode) + throws org.xml.sax.SAXException { + if (!elementStack.empty()) { + // if we didn't push the very first element (an fo:block or + // pre or div surrounding the whole block), then the stack will + // be empty when we get to the end of the first element... + elementStack.pop(); + } + rtf.endElement(nameCode); + } + + /** Process start element events. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) + throws org.xml.sax.SAXException { + + if (!skipThisElement(nameCode)) { + StartElementInfo sei = new StartElementInfo(nameCode, attributes, + namespaces, nscount); + elementStack.push(sei); + } + + firstElement = false; + + rtf.startElement(nameCode, attributes, namespaces, nscount); + } + + /** + *

Protect the outer-most block wrapper.

+ * + *

Open elements in the result tree fragment are closed and reopened + * around callouts (so that callouts don't appear inside links or other + * environments). But if the result tree fragment is a single block + * (a div or pre in HTML, an fo:block in FO), that outer-most block is + * treated specially.

+ * + *

This method returns true if the element in question is that + * outermost block.

+ * + * @param nameCode The name code for the element + * + * @return True if the element is the outer-most block, false otherwise. + */ + protected boolean skipThisElement(int nameCode) { + if (firstElement) { + int foBlockFingerprint = namePool.getFingerprint(foURI, "block"); + int htmlPreFingerprint = namePool.getFingerprint("", "pre"); + int htmlDivFingerprint = namePool.getFingerprint("", "div"); + + if ((foStylesheet && nameCode == foBlockFingerprint) + || (!foStylesheet && (nameCode == htmlPreFingerprint + || nameCode == htmlDivFingerprint))) { + // Don't push the outer-most wrapping div, pre, or fo:block + return true; + } + } + + return false; + } + + /** + *

A private class for maintaining the information required to call + * the startElement method.

+ * + *

In order to close and reopen elements, information about those + * elements has to be maintained. This class is just the little record + * that we push on the stack to keep track of that info.

+ */ + private class StartElementInfo { + private int _nameCode; + org.xml.sax.Attributes _attributes; + int[] _namespaces; + int _nscount; + + public StartElementInfo(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) { + _nameCode = nameCode; + _attributes = attributes; + _namespaces = namespaces; + _nscount = nscount; + } + + public int getNameCode() { + return _nameCode; + } + + public org.xml.sax.Attributes getAttributes() { + return _attributes; + } + + public int[] getNamespaces() { + return _namespaces; + } + + public int getNSCount() { + return _nscount; + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/Table.java b/xsl/extensions/saxon6/com/nwalsh/saxon/Table.java new file mode 100644 index 000000000..6428e8107 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/Table.java @@ -0,0 +1,428 @@ +// Verbatim.java - Saxon extensions supporting DocBook verbatim environments + +package com.nwalsh.saxon; + +import java.util.Hashtable; +import org.xml.sax.*; +import org.w3c.dom.*; +import com.icl.saxon.expr.*; +import com.icl.saxon.om.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.Context; +import com.icl.saxon.tree.*; +import com.icl.saxon.functions.Extensions; +import com.nwalsh.saxon.NumberLinesEmitter; +import com.nwalsh.saxon.CalloutEmitter; + +/** + *

Saxon extensions supporting Tables

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * implementation of some code to adjust CALS Tables to HTML + * Tables.

+ * + *

Column Widths

+ *

The adjustColumnWidths method takes a result tree + * fragment (assumed to contain the colgroup of an HTML Table) + * and returns the result tree fragment with the column widths + * adjusted to HTML terms.

+ * + *

Convert Lengths

+ *

The convertLength method takes a length specification + * of the form 9999.99xx (where "xx" is a unit) and returns that length + * as an integral number of pixels. For convenience, percentage lengths + * are returned unchanged.

+ *

The recognized units are: inches (in), centimeters (cm), + * millimeters (mm), picas (pc, 1pc=12pt), points (pt), and pixels (px). + * A number with no units is assumed to be pixels.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Table { + /** The number of pixels per inch */ + private static int pixelsPerInch = 96; + + /** The nominal table width (6in by default). */ + private static int nominalWidth = 6 * pixelsPerInch; + + /** The default table width (100% by default). */ + private static String tableWidth = "100%"; + + /** Is this an FO stylesheet? */ + private static boolean foStylesheet = false; + + /** The hash used to associate units with a length in pixels. */ + protected static Hashtable unitHash = null; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Table() { + } + + /** Initialize the internal hash table with proper values. */ + protected static void initializeHash() { + unitHash = new Hashtable(); + unitHash.put("in", new Float(pixelsPerInch)); + unitHash.put("cm", new Float(pixelsPerInch / 2.54)); + unitHash.put("mm", new Float(pixelsPerInch / 25.4)); + unitHash.put("pc", new Float((pixelsPerInch / 72) * 12)); + unitHash.put("pt", new Float(pixelsPerInch / 72)); + unitHash.put("px", new Float(1)); + } + + /** Set the pixels-per-inch value. Only positive values are legal. */ + public static void setPixelsPerInch(int value) { + if (value > 0) { + pixelsPerInch = value; + initializeHash(); + } + } + + /** Return the current pixels-per-inch value. */ + public int getPixelsPerInch() { + return pixelsPerInch; + } + + /** + *

Convert a length specification to a number of pixels.

+ * + *

The specified length should be of the form [+/-]999.99xx, + * where xx is a valid unit.

+ */ + public static int convertLength(String length) { + // The format of length should be 999.999xx + int sign = 1; + String digits = ""; + String units = ""; + char lench[] = length.toCharArray(); + float flength = 0; + boolean done = false; + int pos = 0; + float factor = 1; + int pixels = 0; + + if (unitHash == null) { + initializeHash(); + } + + if (lench[pos] == '+' || lench[pos] == '-') { + if (lench[pos] == '-') { + sign = -1; + } + pos++; + } + + while (!done) { + if (pos >= lench.length) { + done = true; + } else { + if ((lench[pos] > '9' || lench[pos] < '0') && lench[pos] != '.') { + done = true; + units = length.substring(pos); + } else { + digits += lench[pos++]; + } + } + } + + try { + flength = Float.parseFloat(digits); + } catch (NumberFormatException e) { + System.out.println(digits + " is not a number; 1 used instead."); + flength = 1; + } + + Float f = null; + + if (!units.equals("")) { + f = (Float) unitHash.get(units); + if (f == null) { + System.out.println(units + " is not a known unit; 1 used instead."); + factor = 1; + } else { + factor = f.floatValue(); + } + } else { + factor = 1; + } + + f = new Float(flength * factor); + + pixels = f.intValue() * sign; + + return pixels; + } + + /** + *

Find the string value of a stylesheet variable or parameter

+ * + *

Returns the string value of varName in the current + * context. Returns the empty string if the variable is + * not defined.

+ * + * @param context The current stylesheet context + * @param varName The name of the variable (without the dollar sign) + * + * @return The string value of the variable + */ + protected static String getVariable(Context context, String varName) + throws SAXException { + Value variable = null; + String varString = null; + + try { + variable = Extensions.evaluate(context, "$" + varName); + varString = variable.asString(); + return varString; + } catch (IllegalArgumentException e) { + System.out.println("Undefined variable: " + varName); + return ""; + } + } + + /** + *

Setup the parameters associated with column width calculations

+ * + *

This method queries the stylesheet for the variables + * associated with table column widths. It is called automatically before + * column widths are adjusted. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
nominal.table.width
+ *
The "normal" width for tables. This must be an absolute length.
+ *
table.width
+ *
The width for tables. This may be either an absolute + * length or a percentage.
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupColumnWidths(Context context) { + // Hardcoded defaults + nominalWidth = 6 * pixelsPerInch; + tableWidth = "100%"; + + String varString = null; + + try { + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = varString.equals("fo"); + + // Get the nominal table width + varString = getVariable(context, "nominal.table.width"); + nominalWidth = convertLength(varString); + + // Get the table width + varString = getVariable(context, "table.width"); + tableWidth = varString; + } catch (SAXException e) { + //nop, can't happen + } + } + + /** + *

Adjust column widths in an HTML table.

+ * + *

The specification of column widths in CALS (a relative width + * plus an optional absolute width) are incompatible with HTML column + * widths. This method adjusts CALS column width specifiers in an + * attempt to produce equivalent HTML specifiers.

+ * + *

In order for this method to work, the CALS width specifications + * should be placed in the "width" attribute of the <col>s within + * a <colgroup>. Then the colgroup result tree fragment is passed + * to this method.

+ * + *

This method makes use of two parameters from the XSL stylesheet + * that calls it: nominal.table.width and + * table.width. The value of nominal.table.width + * must be an absolute distance. The value of table.width + * can be either absolute or relative.

+ * + *

Presented with a mixture of relative and + * absolute lengths, the table width is used to calculate + * appropriate values. If the table.width is relative, + * the nominal width is used for this calculation.

+ * + *

There are three possible combinations of values:

+ * + *
    + *
  1. There are no relative widths; in this case the absolute widths + * are used in the HTML table.
  2. + *
  3. There are no absolute widths; in this case the relative widths + * are used in the HTML table.
  4. + *
  5. There are a mixture of absolute and relative widths: + *
      + *
    1. If the table width is absolute, all widths become absolute.
    2. + *
    3. If the table width is relative, make all the widths absolute + * relative to the nominal table width then turn them all + * back into relative widths.
    4. + *
    + *
  6. + *
+ * + * @param context The stylesheet context; supplied automatically by Saxon + * @param rtf The result tree fragment containing the colgroup. + * + * @return The result tree fragment containing the adjusted colgroup. + * + */ + public static FragmentValue adjustColumnWidths (Context context, + FragmentValue rtf) { + setupColumnWidths(context); + + try { + NamePool namePool = context.getController().getNamePool(); + ColumnScanEmitter csEmitter = new ColumnScanEmitter(namePool); + rtf.replay(csEmitter); + + int numColumns = csEmitter.columnCount(); + String widths[] = csEmitter.columnWidths(); + + float relTotal = 0; + float relParts[] = new float[numColumns]; + + float absTotal = 0; + float absParts[] = new float[numColumns]; + + for (int count = 0; count < numColumns; count++) { + String width = widths[count]; + int pos = width.indexOf("*"); + if (pos >= 0) { + String relPart = width.substring(0, pos); + String absPart = width.substring(pos+1); + + try { + float rel = Float.parseFloat(relPart); + relTotal += rel; + relParts[count] = rel; + } catch (NumberFormatException e) { + System.out.println(relPart + " is not a valid relative unit."); + } + + int pixels = 0; + if (absPart != null && !absPart.equals("")) { + pixels = convertLength(absPart); + } + + absTotal += pixels; + absParts[count] = pixels; + } else { + relParts[count] = 0; + + int pixels = 0; + if (width != null && !width.equals("")) { + pixels = convertLength(width); + } + + absTotal += pixels; + absParts[count] = pixels; + } + } + + // Ok, now we have the relative widths and absolute widths in + // two parallel arrays. + // + // - If there are no relative widths, output the absolute widths + // - If there are no absolute widths, output the relative widths + // - If there are a mixture of relative and absolute widths, + // - If the table width is absolute, turn these all into absolute + // widths. + // - If the table width is relative, turn these all into absolute + // widths in the nominalWidth and then turn them back into + // percentages. + + if (relTotal == 0) { + for (int count = 0; count < numColumns; count++) { + Float f = new Float(absParts[count]); + if (foStylesheet) { + int pixels = f.intValue(); + float inches = (float) pixels / pixelsPerInch; + widths[count] = inches + "in"; + } else { + widths[count] = Integer.toString(f.intValue()); + } + } + } else if (absTotal == 0) { + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / relTotal * 100; + Float f = new Float(rel); + widths[count] = Integer.toString(f.intValue()) + "%"; + } + } else { + int pixelWidth = nominalWidth; + + if (tableWidth.indexOf("%") <= 0) { + pixelWidth = convertLength(tableWidth); + } + + if (pixelWidth <= absTotal) { + System.out.println("Table is wider than table width."); + } else { + pixelWidth -= absTotal; + } + + absTotal = 0; + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / relTotal * pixelWidth; + relParts[count] = rel + absParts[count]; + absTotal += rel + absParts[count]; + } + + if (tableWidth.indexOf("%") <= 0) { + for (int count = 0; count < numColumns; count++) { + Float f = new Float(relParts[count]); + if (foStylesheet) { + int pixels = f.intValue(); + float inches = (float) pixels / pixelsPerInch; + widths[count] = inches + "in"; + } else { + widths[count] = Integer.toString(f.intValue()); + } + } + } else { + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / absTotal * 100; + Float f = new Float(rel); + widths[count] = Integer.toString(f.intValue()) + "%"; + } + } + } + + ColumnUpdateEmitter cuEmitter = new ColumnUpdateEmitter(namePool, + widths); + + rtf.replay(cuEmitter); + return cuEmitter.getResultTreeFragment(); + } catch (SAXException e) { + // This "can't" happen. + System.out.println("SAX Exception in numberLines"); + return rtf; + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/Text.java b/xsl/extensions/saxon6/com/nwalsh/saxon/Text.java new file mode 100644 index 000000000..396465860 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/Text.java @@ -0,0 +1,131 @@ +// Text - Saxon extension element for inserting text + +package com.nwalsh.saxon; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.net.URL; +import java.net.MalformedURLException; +import com.icl.saxon.*; +import com.icl.saxon.style.*; +import com.icl.saxon.expr.*; +import com.icl.saxon.output.*; +import org.xml.sax.SAXException; +import org.xml.sax.AttributeList; + +/** + *

Saxon extension element for inserting text + * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension element for inserting text into a result tree.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Text extends StyleElement { + /** + *

Constructor for Text

+ * + *

Does nothing.

+ */ + public Text() { + } + + /** + *

Is this element an instruction?

+ * + *

Yes, it is.

+ * + * @return true + */ + public boolean isInstruction() { + return true; + } + + /** + *

Can this element contain a template-body?

+ * + *

Yes, it can, but only so that it can contain xsl:fallback.

+ * + * @return true + */ + public boolean mayContainTemplateBody() { + return true; + } + + /** + *

Validate the arguments

+ * + *

The element must have an href attribute.

+ */ + public void prepareAttributes() throws SAXException { + // Get mandatory href attribute + String fnAtt = getAttribute("href"); + if (fnAtt == null) { + reportAbsence("href"); + } + } + + /** Validate that the element occurs in a reasonable place. */ + public void validate() throws SAXException { + checkWithinTemplate(); + } + + /** + *

Insert the text of the file into the result tree

+ * + *

Processing this element inserts the contents of the URL named + * by the href attribute into the result tree as plain text.

+ * + */ + public void process( Context context ) throws SAXException { + Outputter out = context.getOutputter(); + + String hrefAtt = getAttribute("href"); + Expression hrefExpr = makeAttributeValueTemplate(hrefAtt); + String href = hrefExpr.evaluateAsString(context); + URL fileURL = null; + + try { + try { + fileURL = new URL(href); + } catch (MalformedURLException e1) { + try { + fileURL = new URL("file:" + href); + } catch (MalformedURLException e2) { + System.out.println("Cannot open " + href); + return; + } + } + + InputStreamReader isr = new InputStreamReader(fileURL.openStream()); + BufferedReader is = new BufferedReader(isr); + + char chars[] = new char[4096]; + int len = 0; + while ((len = is.read(chars)) > 0) { + out.writeContent(chars, 0, len); + } + is.close(); + } catch (Exception e) { + System.out.println("Cannot read " + href); + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/TextFactory.java b/xsl/extensions/saxon6/com/nwalsh/saxon/TextFactory.java new file mode 100644 index 000000000..34ef9d9fb --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/TextFactory.java @@ -0,0 +1,64 @@ +// TextFactory - Saxon extension element factory + +package com.nwalsh.saxon; + +import com.icl.saxon.style.ExtensionElementFactory; +import org.xml.sax.SAXException; + +/** + *

Saxon extension element factory + * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension element factory for the Text extension element + * family.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + * @see Text + * + */ +public class TextFactory implements ExtensionElementFactory { + /** + *

Constructor for TextFactory

+ * + *

Does nothing.

+ */ + public TextFactory() { + } + + /** + *

Return the class that implements a particular extension element.

+ * + * @param localname The local name of the extension element. + * + * @return The class that handles that extension element. + * + * @exception SAXException("Unknown Text extension element") + */ + public Class getExtensionClass(String localname) throws SAXException { + if (localname.equals("insertfile")) { + try { + return Class.forName("com.nwalsh.saxon.Text"); + } catch (ClassNotFoundException e) { + throw new SAXException("Failed to load class for Text extension element: " + + localname); + } + } + throw new SAXException("Unknown Text extension element: " + + localname); + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java new file mode 100644 index 000000000..6e63dda52 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java @@ -0,0 +1,447 @@ +// Verbatim.java - Saxon extensions supporting DocBook verbatim environments + +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import com.icl.saxon.expr.*; +import com.icl.saxon.om.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.Context; +import com.icl.saxon.tree.*; +import com.icl.saxon.functions.Extensions; +import com.nwalsh.saxon.NumberLinesEmitter; +import com.nwalsh.saxon.CalloutEmitter; + +/** + *

Saxon extensions supporting DocBook verbatim environments

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * implementation of two features that would be impractical to + * implement directly in XSLT: line numbering and callouts.

+ * + *

Line Numbering

+ *

The numberLines method takes a result tree + * fragment (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * line numbers.

+ * + *

Callouts

+ *

The insertCallouts method takes an + * areaspec and a result tree fragment + * (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * callouts.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Verbatim { + /** True if the stylesheet is producing formatting objects */ + private static boolean foStylesheet = false; + /** The modulus for line numbering (every 'modulus' line is numbered). */ + private static int modulus = 0; + /** The width (in characters) of line numbers (for padding). */ + private static int width = 0; + /** The separator between the line number and the verbatim text. */ + private static String separator = ""; + + /** The default column for callouts that have only a line or line range */ + private static int defaultColumn = 60; + + /** The FormatCallout object to use for formatting callouts. */ + private static FormatCallout fCallout = null; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Verbatim() { + } + + /** + *

Find the string value of a stylesheet variable or parameter

+ * + *

Returns the string value of varName in the current + * context. Returns the empty string if the variable is + * not defined.

+ * + * @param context The current stylesheet context + * @param varName The name of the variable (without the dollar sign) + * + * @return The string value of the variable + */ + protected static String getVariable(Context context, String varName) { + Value variable = null; + String varString = null; + + try { + variable = Extensions.evaluate(context, "$" + varName); + varString = variable.asString(); + return varString; + } catch (SAXException e) { + System.out.println("Undefined variable: " + varName); + return ""; + } catch (IllegalArgumentException e) { + System.out.println("Undefined variable: " + varName); + return ""; + } + } + + /** + *

Setup the parameters associated with line numbering

+ * + *

This method queries the stylesheet for the variables + * associated with line numbering. It is called automatically before + * lines are numbered. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
linenumbering.everyNth
+ *
Specifies the lines that will be numbered. The first line is + * always numbered. (builtin default: 5).
+ *
linenumbering.width
+ *
Specifies the width of the numbers. If the specified width is too + * narrow for the largest number needed, it will automatically be made + * wider. (builtin default: 3).
+ *
linenumbering.separator
+ *
Specifies the string that separates line numbers from lines + * in the program listing. (builtin default: " ").
+ *
stylesheet.result.type
+ *
Specifies the stylesheet result type. The value is either 'fo' + * (for XSL Formatting Objects) or it isn't. (builtin default: html).
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupLineNumbering(Context context) { + // Hardcoded defaults + modulus = 5; + width = 3; + separator = " "; + foStylesheet = false; + + String varString = null; + + // Get the modulus + varString = getVariable(context, "linenumbering.everyNth"); + try { + modulus = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.everyNth is not a number: " + varString); + } + + // Get the width + varString = getVariable(context, "linenumbering.width"); + try { + width = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.width is not a number: " + varString); + } + + // Get the separator + varString = getVariable(context, "linenumbering.separator"); + separator = varString; + + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = (varString.equals("fo")); + } + + /** + *

Number lines in a verbatim environment

+ * + *

The extension function expects the following variables to be + * available in the calling context: $linenumbering.everyNth, + * $linenumbering.width, $linenumbering.separator, and + * $stylesheet.result.type.

+ * + *

This method adds line numbers to a result tree fragment. Each + * newline that occurs in a text node is assumed to start a new line. + * The first line is always numbered, every subsequent 'everyNth' line + * is numbered (so if everyNth=5, lines 1, 5, 10, 15, etc. will be + * numbered. If there are fewer than everyNth lines in the environment, + * every line is numbered.

+ * + *

Every line number will be right justified in a string 'width' + * characters long. If the line number of the last line in the + * environment is too long to fit in the specified width, the width + * is automatically increased to the smallest value that can hold the + * number of the last line. (In other words, if you specify the value 2 + * and attempt to enumerate the lines of an environment that is 100 lines + * long, the value 3 will automatically be used for every line in the + * environment.)

+ * + *

The 'separator' string is inserted between the line + * number and the original program listing. Lines that aren't numbered + * are preceded by a 'width' blank string and the separator.

+ * + *

If inline markup extends across line breaks, markup changes are + * required. All the open elements are closed before the line break and + * "reopened" afterwards. The reopened elements will have the same + * attributes as the originals, except that 'name' and 'id' attributes + * are not duplicated if the stylesheet.result.type is "html" and + * 'id' attributes will not be duplicated if the result type is "fo".

+ * + * @param rtf The result tree fragment of the verbatim environment. + * + * @return The modified result tree fragment. + */ + public static FragmentValue numberLines (Context context, + FragmentValue rtf) { + setupLineNumbering(context); + + try { + LineCountEmitter lcEmitter = new LineCountEmitter(); + rtf.replay(lcEmitter); + int numLines = lcEmitter.lineCount(); + + int listingModulus = numLines < modulus ? 1 : modulus; + + double log10numLines = Math.log(numLines) / Math.log(10); + + int listingWidth = width < log10numLines+1 + ? (int) Math.floor(log10numLines + 1) + : width; + + NamePool namePool = context.getController().getNamePool(); + NumberLinesEmitter nlEmitter = new NumberLinesEmitter(namePool, + listingModulus, + listingWidth, + separator, + foStylesheet); + rtf.replay(nlEmitter); + return nlEmitter.getResultTreeFragment(); + } catch (SAXException e) { + // This "can't" happen. + System.out.println("SAX Exception in numberLines"); + return rtf; + } + } + + /** + *

Setup the parameters associated with callouts

+ * + *

This method queries the stylesheet for the variables + * associated with line numbering. It is called automatically before + * callouts are processed. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
callout.graphics
+ *
Are we using callout graphics? A value of 0 or "" is false, + * any other value is true. If callout graphics are not used, the + * parameters related to graphis are not queried.
+ *
callout.graphics.path
+ *
Specifies the path to callout graphics.
+ *
callout.graphics.extension
+ *
Specifies the extension ot use for callout graphics.
+ *
callout.graphics.number.limit
+ *
Identifies the largest number that can be represented as a + * graphic. Larger callout numbers will be represented using text.
+ *
callout.defaultcolumn
+ *
Specifies the default column for callout bullets that do not + * specify a column.
+ *
stylesheet.result.type
+ *
Specifies the stylesheet result type. The value is either 'fo' + * (for XSL Formatting Objects) or it isn't. (builtin default: html).
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupCallouts(Context context) { + NamePool namePool = context.getController().getNamePool(); + + boolean useGraphics = false; + boolean useUnicode = false; + + // Hardcoded defaults + defaultColumn = 60; + foStylesheet = false; + + int unicodeStart = 48; + int unicodeMax = 0; + + String graphicsPath = null; + String graphicsExt = null; + int graphicsMax = 0; + + Value variable = null; + String varString = null; + + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = (varString.equals("fo")); + + // Get the default column + varString = getVariable(context, "callout.defaultcolumn"); + try { + defaultColumn = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.defaultcolumn is not a number: " + + varString); + } + + // Use graphics at all? + varString = getVariable(context, "callout.graphics"); + useGraphics = !(varString.equals("0") || varString.equals("")); + + // Use unicode at all? + varString = getVariable(context, "callout.unicode"); + useUnicode = !(varString.equals("0") || varString.equals("")); + + if (useGraphics) { + // Get the graphics path + varString = getVariable(context, "callout.graphics.path"); + graphicsPath = varString; + + // Get the graphics extension + varString = getVariable(context, "callout.graphics.extension"); + graphicsExt = varString; + + // Get the number limit + varString = getVariable(context, "callout.graphics.number.limit"); + try { + graphicsMax = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.graphics.number.limit is not a number: " + + varString); + graphicsMax = 0; + } + + fCallout = new FormatGraphicCallout(namePool, + graphicsPath, + graphicsExt, + graphicsMax, + foStylesheet); + } else if (useUnicode) { + // Get the starting character + varString = getVariable(context, "callout.unicode.start.character"); + try { + unicodeStart = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.unicode.start.character is not a number: " + + varString); + unicodeStart = 48; + } + + // Get the number limit + varString = getVariable(context, "callout.unicode.number.limit"); + try { + unicodeMax = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.unicode.number.limit is not a number: " + + varString); + unicodeStart = 0; + } + + fCallout = new FormatUnicodeCallout(namePool, + unicodeStart, + unicodeMax, + foStylesheet); + } else { + fCallout = new FormatTextCallout(namePool, foStylesheet); + } + } + + /** + *

Insert text callouts into a verbatim environment.

+ * + *

This method examines the areaset and area elements + * in the supplied areaspec and decorates the supplied + * result tree fragment with appropriate callout markers.

+ * + *

If a label attribute is supplied on an area, + * its content will be used for the label, otherwise the callout + * number will be used, surrounded by parenthesis. Callout numbers may + * also be represented as graphics. Callouts are + * numbered in document order. All of the areas in an + * areaset get the same number.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn. Lines will be padded with blanks to reach the + * necessary column, but callouts that are located beyond the last + * line of the verbatim environment will be ignored.

+ * + *

Callouts are inserted before the character at the line/column + * where they are to occur.

+ * + *

If graphical callouts are used, and the callout number is less + * than or equal to the $callout.graphics.number.limit, the following image + * will be generated for HTML: + * + *

+   * <img src="$callout.graphics.path/999$callout.graphics.ext"
+   *         alt="conumber">
+   * 
+ * + * If the $stylesheet.result.type is 'fo', the following image will + * be generated: + * + *
+   * <fo:external-graphic src="$callout.graphics.path/999$callout.graphics.ext"/>
+   * 
+ * + *

If the callout number exceeds $callout.graphics.number.limit, + * the callout will be the callout number surrounded by + * parenthesis.

+ * + * @param context The stylesheet context. + * @param areaspecNodeSet The source node set that contains the areaspec. + * @param rtf The result tree fragment of the verbatim environment. + * + * @return The modified result tree fragment. + */ + + public static FragmentValue insertCallouts (Context context, + NodeSetIntent areaspecNodeSet, + FragmentValue rtf) { + setupCallouts(context); + + try { + NamePool namePool = context.getController().getNamePool(); + CalloutEmitter cEmitter = new CalloutEmitter(namePool, + defaultColumn, + foStylesheet, + fCallout); + cEmitter.setupCallouts(areaspecNodeSet); + rtf.replay(cEmitter); + return cEmitter.getResultTreeFragment(); + } catch (SAXException e) { + // This "can't" happen. + System.out.println("SAX Exception in insertCallouts"); + return rtf; + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/package.html b/xsl/extensions/saxon6/com/nwalsh/saxon/package.html new file mode 100644 index 000000000..b05a46709 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/package.html @@ -0,0 +1,48 @@ + + +Norman Walsh's Saxon Extensions Package + + +

Norman Walsh's Saxon Extensions Package for Saxon 6.*

+ +

This package implements Saxon extensions for XSLT.

+ +

Copyright (C) 2000 Norman Walsh

+

Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

+ +

The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

+ +

Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the +individuals in question.

+ +

Anything derived from this Software that is publically +distributed will be identified with a different name and the +version strings in any derived Software will be changed so that no +possibility of confusion between the derived package and this +Software will exist.

+ + +
+

Warranty

+

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER +CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.

+
+ + + diff --git a/xsl/extensions/saxon61/.cvsignore b/xsl/extensions/saxon61/.cvsignore new file mode 100644 index 000000000..4d3c216f5 --- /dev/null +++ b/xsl/extensions/saxon61/.cvsignore @@ -0,0 +1 @@ +.classes diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/CVS.java b/xsl/extensions/saxon61/com/nwalsh/saxon/CVS.java new file mode 100644 index 000000000..529546be7 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/CVS.java @@ -0,0 +1,90 @@ +package com.nwalsh.saxon; + +import java.io.*; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.text.DateFormat; +import java.text.ParseException; + +/** + *

Saxon extension to convert CVS date strings into local time

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension to turn the CVS date strings, which are UTC:

+ * + *
$Date: 2000/11/09 02:34:20 $
+ * + *

into legibly formatted local time:

+ * + *
Wed Nov 08 18:34:20 PST 2000
+ * + *

(I happened to be in California when I wrote this documentation.)

+ + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CVS { + /** + *

Constructor for CVS

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public CVS() { + } + + /** + *

Convert a CVS date string into local time.

+ * + * @param cvsDate The CVS date string. + * + * @return The date, converted to local time and reformatted. + */ + public static String localTime (String cvsDate) { + // A cvsDate has the following form "$Date$" + if (!cvsDate.startsWith("$Date: ")) { + return cvsDate; + } + + String yrS = cvsDate.substring(7,11); + String moS = cvsDate.substring(12,14); + String daS = cvsDate.substring(15,17); + String hrS = cvsDate.substring(18,20); + String miS = cvsDate.substring(21,23); + String seS = cvsDate.substring(24,26); + + TimeZone tz = TimeZone.getTimeZone("GMT+0"); + GregorianCalendar gmtCal = new GregorianCalendar(tz); + + try { + gmtCal.set(Integer.parseInt(yrS), + Integer.parseInt(moS)-1, + Integer.parseInt(daS), + Integer.parseInt(hrS), + Integer.parseInt(miS), + Integer.parseInt(seS)); + } catch (NumberFormatException e) { + // nop + } + + Date d = gmtCal.getTime(); + + return d.toString(); + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/Callout.java b/xsl/extensions/saxon61/com/nwalsh/saxon/Callout.java new file mode 100644 index 000000000..f0be0cd4f --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/Callout.java @@ -0,0 +1,91 @@ +package com.nwalsh.saxon; + +import com.icl.saxon.om.*; +import com.icl.saxon.tree.*; + +/** + *

A class for maintaining information about callouts.

+ * + *

To make processing callouts easier, they are parsed out of the + * input structure and stored in a sorted array. (The array is sorted + * according to the order in which the callouts occur.)

+ * + *

This class is just the little record + * that we store in the array for each callout.

+ */ +public class Callout implements Comparable { + /** The callout number. */ + private int callout = 0; + /** The area ElementInfo item that generated this callout. */ + private ElementInfo area = null; + /** The line on which this callout occurs. */ + private int line = 0; + /** The column in which this callout appears. */ + private int col = 0; + + /** The constructor; initialize the private data structures. */ + public Callout(int callout, ElementInfo area, int line, int col) { + this.callout = callout; + this.area = area; + this.line = line; + this.col = col; + } + + /** + *

The compareTo method compares this Callout with another.

+ * + *

Given two Callouts, A and B, A < B if:

+ * + *
    + *
  1. A.line < B.line, or
  2. + *
  3. A.line = B.line && A.col < B.col, or
  4. + *
  5. A.line = B.line && A.col = B.col && A.callout < B.callout
  6. + *
  7. Otherwise, they're equal.
  8. + *
+ */ + public int compareTo (Object o) { + Callout c = (Callout) o; + + if (line == c.getLine()) { + if (col > c.getColumn()) { + return 1; + } else if (col < c.getColumn()) { + return -1; + } else { + if (callout < c.getCallout()) { + return -1; + } else if (callout > c.getCallout()) { + return 1; + } else { + return 0; + } + } + } else { + if (line > c.getLine()) { + return 1; + } else { + return -1; + } + } + } + + /** Access the Callout's area. */ + public ElementInfo getArea() { + return area; + } + + /** Access the Callout's line. */ + public int getLine() { + return line; + } + + /** Access the Callout's column. */ + public int getColumn() { + return col; + } + + /** Access the Callout's callout number. */ + public int getCallout() { + return callout; + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/CalloutEmitter.java b/xsl/extensions/saxon61/com/nwalsh/saxon/CalloutEmitter.java new file mode 100644 index 000000000..693c6e863 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/CalloutEmitter.java @@ -0,0 +1,527 @@ +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.Builder; +import com.icl.saxon.Context; +import com.icl.saxon.expr.*; +import com.icl.saxon.functions.Extensions; +import com.icl.saxon.om.*; +import com.icl.saxon.output.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.tree.*; + +/** + *

Saxon extension to decorate a result tree fragment with callouts.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides the guts of a + * Saxon 6.* + * implementation of callouts for verbatim environments. (It is used + * by the Verbatim class.)

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some verbatim environment. The Verbatim class initializes + * a CalloutEmitter with information about the callouts that should be applied + * to the verbatim environment in question. Then the result tree fragment + * is "replayed" through the CalloutEmitter; the CalloutEmitter builds a + * new result tree fragment from this event stream, decorated with callouts, + * and that is returned.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see Verbatim + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CalloutEmitter extends CopyEmitter { + /** A stack for the preserving information about open elements. */ + protected Stack elementStack = null; + + /** A stack for holding information about temporarily closed elements. */ + protected Stack tempStack = null; + + /** Is the next element absolutely the first element in the fragment? */ + protected boolean firstElement = false; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** The default column for callouts that specify only a line. */ + protected int defaultColumn = 60; + + /** Is the stylesheet currently running an FO stylesheet? */ + protected boolean foStylesheet = false; + + /** The current line number. */ + private static int lineNumber = 0; + + /** The current column number. */ + private static int colNumber = 0; + + /** The (sorted) array of callouts obtained from the areaspec. */ + private static Callout callout[] = null; + + /** The number of callouts in the callout array. */ + private static int calloutCount = 0; + + /** A pointer used to keep track of our position in the callout array. */ + private static int calloutPos = 0; + + /** The FormatCallout object to use for formatting callouts. */ + private static FormatCallout fCallout = null; + + /**

Constructor for the CalloutEmitter.

+ * + * @param namePool The name pool to use for constructing elements and attributes. + * @param graphicsPath The path to callout number graphics. + * @param graphicsExt The extension for callout number graphics. + * @param graphicsMax The largest callout number that can be represented as a graphic. + * @param defaultColumn The default column for callouts. + * @param foStylesheet Is this an FO stylesheet? + */ + public CalloutEmitter(NamePool namePool, + int defaultColumn, + boolean foStylesheet, + FormatCallout fCallout) { + super(namePool); + elementStack = new Stack(); + firstElement = true; + + this.defaultColumn = defaultColumn; + this.foStylesheet = foStylesheet; + this.fCallout = fCallout; + } + + /** + *

Examine the areaspec and determine the number and position of + * callouts.

+ * + *

The areaspecNodeSet + * is examined and a sorted list of the callouts is constructed.

+ * + *

This data structure is used to augment the result tree fragment + * with callout bullets.

+ * + * @param areaspecNodeSet The source document <areaspec> element. + * + */ + public void setupCallouts (NodeSetIntent areaspecNodeSet) { + callout = new Callout[10]; + calloutCount = 0; + calloutPos = 0; + lineNumber = 1; + colNumber = 1; + + // First we walk through the areaspec to calculate the position + // of the callouts + // + // + // + // + // + // + // + // + try { + int pos = 0; + int coNum = 0; + boolean inAreaSet = false; + NodeInfo areaspec = areaspecNodeSet.getFirst(); + NodeInfo children[] = areaspec.getAllChildNodes(); + + for (int count = 0; count < children.length; count++) { + NodeInfo node = children[count]; + if (node.getNodeType() == NodeInfo.ELEMENT) { + if (node.getNodeName().equalsIgnoreCase("areaset")) { + coNum++; + NodeInfo areas[] = node.getAllChildNodes(); + for (int acount = 0; acount < areas.length; acount++) { + NodeInfo area = areas[acount]; + if (area.getNodeType() == NodeInfo.ELEMENT) { + if (area.getNodeName().equalsIgnoreCase("area")) { + addCallout(coNum, area, defaultColumn); + } else { + System.out.println("Unexpected element in areaset: " + + area.getNodeName()); + } + } + } + } else if (node.getNodeName().equalsIgnoreCase("area")) { + coNum++; + addCallout(coNum, node, defaultColumn); + } else { + System.out.println("Unexpected element in areaspec: " + + node.getNodeName()); + } + } + } + + // Now sort them + java.util.Arrays.sort(callout, 0, calloutCount); + } catch (TransformerException e) { + //nop; + } + } + + /** Process characters. */ + public void characters(char[] chars, int start, int len) + throws TransformerException { + + // If we hit characters, then there's no first element... + firstElement = false; + + if (lineNumber == 0) { + // if there are any text nodes, there's at least one line + lineNumber++; + colNumber = 1; + } + + // Walk through the text node looking for callout positions + char[] newChars = new char[len]; + int pos = 0; + for (int count = start; count < start+len; count++) { + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + if (pos > 0) { + rtfEmitter.characters(newChars, 0, pos); + pos = 0; + } + + closeOpenElements(rtfEmitter); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtfEmitter, callout[calloutPos]); + calloutPos++; + } + + openClosedElements(rtfEmitter); + } + + if (chars[count] == '\n') { + // What if we need to pad this line? + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + + if (pos > 0) { + rtfEmitter.characters(newChars, 0, pos); + pos = 0; + } + + closeOpenElements(rtfEmitter); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + formatPad(callout[calloutPos].getColumn() - colNumber); + colNumber = callout[calloutPos].getColumn(); + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtfEmitter, callout[calloutPos]); + calloutPos++; + } + } + + openClosedElements(rtfEmitter); + } + + lineNumber++; + colNumber = 1; + } else { + colNumber++; + } + newChars[pos++] = chars[count]; + } + + if (pos > 0) { + rtfEmitter.characters(newChars, 0, pos); + } + } + + /** + *

Add blanks to the result tree fragment.

+ * + *

This method adds numBlanks to the result tree fragment. + * It's used to pad lines when callouts occur after the last existing + * characater in a line.

+ * + * @param numBlanks The number of blanks to add. + */ + protected void formatPad(int numBlanks) { + char chars[] = new char[numBlanks]; + for (int count = 0; count < numBlanks; count++) { + chars[count] = ' '; + } + + try { + rtfEmitter.characters(chars, 0, numBlanks); + } catch (TransformerException e) { + System.out.println("Transformer Exception in formatPad"); + } + } + + /** + *

Add a callout to the global callout array

+ * + *

This method examines a callout area and adds it to + * the global callout array if it can be interpreted.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn.

+ * + * @param coNum The callout number. + * @param node The area. + * @param defaultColumn The default column for callouts. + */ + protected void addCallout (int coNum, + NodeInfo node, + int defaultColumn) { + + ElementInfo area = (ElementInfo) node; + ExtendedAttributes attr = area.getAttributeList(); + String units = attr.getValue("units"); + String coords = attr.getValue("coords"); + + if (units != null + && !units.equalsIgnoreCase("linecolumn") + && !units.equalsIgnoreCase("linerange")) { + System.out.println("Only linecolumn and linerange units are supported"); + return; + } + + if (coords == null) { + System.out.println("Coords must be specified"); + return; + } + + // Now let's see if we can interpret the coordinates... + StringTokenizer st = new StringTokenizer(coords); + int tokenCount = 0; + int c1 = 0; + int c2 = 0; + while (st.hasMoreTokens()) { + tokenCount++; + if (tokenCount > 2) { + System.out.println("Unparseable coordinates"); + return; + } + try { + String token = st.nextToken(); + int coord = Integer.parseInt(token); + c2 = coord; + if (tokenCount == 1) { + c1 = coord; + } + } catch (NumberFormatException e) { + System.out.println("Unparseable coordinate"); + return; + } + } + + // Make sure we aren't going to blow past the end of our array + if (calloutCount == callout.length) { + Callout bigger[] = new Callout[calloutCount+10]; + for (int count = 0; count < callout.length; count++) { + bigger[count] = callout[count]; + } + callout = bigger; + } + + // Ok, add the callout + if (tokenCount == 2) { + if (units != null && units.equalsIgnoreCase("linerange")) { + for (int count = c1; count <= c2; count++) { + callout[calloutCount++] = new Callout(coNum, area, + count, defaultColumn); + } + } else { + // assume linecolumn + callout[calloutCount++] = new Callout(coNum, area, c1, c2); + } + } else { + // if there's only one number, assume it's the line + callout[calloutCount++] = new Callout(coNum, area, c1, defaultColumn); + } + } + + /** Process end element events. */ + public void endElement(int nameCode) + throws TransformerException { + + if (!elementStack.empty()) { + // if we didn't push the very first element (an fo:block or + // pre or div surrounding the whole block), then the stack will + // be empty when we get to the end of the first element... + elementStack.pop(); + } + rtfEmitter.endElement(nameCode); + } + + /** Process start element events. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) + throws TransformerException { + + if (!skipThisElement(nameCode)) { + StartElementInfo sei = new StartElementInfo(nameCode, attributes, + namespaces, nscount); + elementStack.push(sei); + } + + firstElement = false; + + rtfEmitter.startElement(nameCode, attributes, namespaces, nscount); + } + + /** + *

Protect the outer-most block wrapper.

+ * + *

Open elements in the result tree fragment are closed and reopened + * around callouts (so that callouts don't appear inside links or other + * environments). But if the result tree fragment is a single block + * (a div or pre in HTML, an fo:block in FO), that outer-most block is + * treated specially.

+ * + *

This method returns true if the element in question is that + * outermost block.

+ * + * @param nameCode The name code for the element + * + * @return True if the element is the outer-most block, false otherwise. + */ + protected boolean skipThisElement(int nameCode) { + if (firstElement) { + int thisFingerprint = namePool.getFingerprint(nameCode); + int foBlockFingerprint = namePool.getFingerprint(foURI, "block"); + int htmlPreFingerprint = namePool.getFingerprint("", "pre"); + int htmlDivFingerprint = namePool.getFingerprint("", "div"); + + if ((foStylesheet && thisFingerprint == foBlockFingerprint) + || (!foStylesheet && (thisFingerprint == htmlPreFingerprint + || thisFingerprint == htmlDivFingerprint))) { + // Don't push the outer-most wrapping div, pre, or fo:block + return true; + } + } + + return false; + } + + private void closeOpenElements(Emitter rtfEmitter) + throws TransformerException { + // Close all the open elements... + tempStack = new Stack(); + while (!elementStack.empty()) { + StartElementInfo elem = (StartElementInfo) elementStack.pop(); + rtfEmitter.endElement(elem.getNameCode()); + tempStack.push(elem); + } + } + + private void openClosedElements(Emitter rtfEmitter) + throws TransformerException { + // Now "reopen" the elements that we closed... + while (!tempStack.empty()) { + StartElementInfo elem = (StartElementInfo) tempStack.pop(); + AttributeCollection attr = (AttributeCollection)elem.getAttributes(); + AttributeCollection newAttr = new AttributeCollection(namePool); + + for (int acount = 0; acount < attr.getLength(); acount++) { + String localName = attr.getLocalName(acount); + int nameCode = attr.getNameCode(acount); + String type = attr.getType(acount); + String value = attr.getValue(acount); + String uri = attr.getURI(acount); + String prefix = ""; + + if (localName.indexOf(':') > 0) { + prefix = localName.substring(0, localName.indexOf(':')); + localName = localName.substring(localName.indexOf(':')+1); + } + + if (uri.equals("") + && ((foStylesheet + && localName.equals("id")) + || (!foStylesheet + && (localName.equals("id") + || localName.equals("name"))))) { + // skip this attribute + } else { + newAttr.addAttribute(prefix, uri, localName, type, value); + } + } + + rtfEmitter.startElement(elem.getNameCode(), + newAttr, + elem.getNamespaces(), + elem.getNSCount()); + + elementStack.push(elem); + } + } + + /** + *

A private class for maintaining the information required to call + * the startElement method.

+ * + *

In order to close and reopen elements, information about those + * elements has to be maintained. This class is just the little record + * that we push on the stack to keep track of that info.

+ */ + private class StartElementInfo { + private int _nameCode; + org.xml.sax.Attributes _attributes; + int[] _namespaces; + int _nscount; + + public StartElementInfo(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) { + _nameCode = nameCode; + _attributes = attributes; + _namespaces = namespaces; + _nscount = nscount; + } + + public int getNameCode() { + return _nameCode; + } + + public org.xml.sax.Attributes getAttributes() { + return _attributes; + } + + public int[] getNamespaces() { + return _namespaces; + } + + public int getNSCount() { + return _nscount; + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/ColumnScanEmitter.java b/xsl/extensions/saxon61/com/nwalsh/saxon/ColumnScanEmitter.java new file mode 100644 index 000000000..0b7c3c99a --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/ColumnScanEmitter.java @@ -0,0 +1,167 @@ +package com.nwalsh.saxon; + +import org.xml.sax.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; + +/** + *

Saxon extension to scan the column widthsin a result tree fragment.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation to scan the column widths in a result tree + * fragment.

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some colgroup environment. That result tree fragment + * is "replayed" through the ColumnScanEmitter; the ColumnScanEmitter watches + * the cols go by and extracts the column widths that it sees. These + * widths are then made available.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class ColumnScanEmitter extends com.icl.saxon.output.Emitter { + /** The number of columns seen. */ + protected int numColumns = 0; + protected String width[] = new String[5]; + protected NamePool namePool = null; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** Construct a new ColumnScanEmitter. */ + public ColumnScanEmitter(NamePool namePool) { + numColumns = 0; + this.namePool = namePool; + } + + /** Return the number of columns. */ + public int columnCount() { + return numColumns; + } + + /** Return the number of columns. */ + public String[] columnWidths() { + return width; + } + + /** Discarded. */ + public void characters(char[] chars, int start, int len) + throws TransformerException { + // nop + } + + /** Discarded. */ + public void comment(char[] chars, int start, int length) + throws TransformerException { + // nop + } + + /** Discarded. */ + public void endDocument() + throws TransformerException { + // nop + } + + /** Discarded. */ + public void endElement(int nameCode) + throws TransformerException { + // nop + } + + /** Discarded. */ + public void processingInstruction(java.lang.String name, + java.lang.String data) + throws TransformerException { + // nop + } + + /** Discarded. */ + public void setDocumentLocator(org.xml.sax.Locator locator) { + // nop + } + + /** Discarded. */ + public void setEscaping(boolean escaping) + throws TransformerException { + // nop + } + + /** Discarded. */ + public void setNamePool(NamePool namePool) { + // nop + } + + /** Discarded. */ + public void setUnparsedEntity(java.lang.String name, java.lang.String uri) + throws TransformerException { + // nop + } + + /** Discarded. */ + public void setWriter(java.io.Writer writer) { + // nop + } + + /** Discarded. */ + public void startDocument() + throws TransformerException { + // nop + } + + /** Examine for column info. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, int nscount) + throws TransformerException { + + int thisFingerprint = namePool.getFingerprint(nameCode); + int colFingerprint = namePool.getFingerprint("", "col"); + int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); + + if (thisFingerprint == colFingerprint + || thisFingerprint == foColFingerprint) { + if (numColumns >= width.length) { + String newWidth[] = new String[width.length+10]; + for (int count = 0; count < width.length; count++) { + newWidth[count] = width[count]; + } + width = newWidth; + } + + if (thisFingerprint == colFingerprint) { + if (attributes.getValue("width") == null) { + width[numColumns++] = "1*"; + } else { + width[numColumns++] = attributes.getValue("width"); + } + } else { + if (attributes.getValue("column-width") == null) { + width[numColumns++] = "1*"; + } else { + width[numColumns++] = attributes.getValue("column-width"); + } + } + } + } +} + + diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/ColumnUpdateEmitter.java b/xsl/extensions/saxon61/com/nwalsh/saxon/ColumnUpdateEmitter.java new file mode 100644 index 000000000..99b43c8c1 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/ColumnUpdateEmitter.java @@ -0,0 +1,96 @@ +package com.nwalsh.saxon; + +import org.xml.sax.*; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; +import com.icl.saxon.tree.AttributeCollection; + +/** + *

Saxon extension to scan the column widthsin a result tree fragment.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation to scan the column widths in a result tree + * fragment.

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some colgroup environment. That result tree fragment + * is "replayed" through the ColumnUpdateEmitter; the ColumnUpdateEmitter watches + * the cols go by and extracts the column widths that it sees. These + * widths are then made available.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class ColumnUpdateEmitter extends CopyEmitter { + /** The number of columns seen. */ + protected int numColumns = 0; + protected String width[] = null; + protected NamePool namePool = null; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** Construct a new ColumnUpdateEmitter. */ + public ColumnUpdateEmitter(NamePool namePool, + String width[]) { + super(namePool); + numColumns = 0; + this.width = width; + this.namePool = namePool; + } + + /** Examine for column info. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, int nscount) + throws TransformerException { + + int thisFingerprint = namePool.getFingerprint(nameCode); + int colFingerprint = namePool.getFingerprint("", "col"); + int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); + + if (thisFingerprint == colFingerprint) { + AttributeCollection attr = new AttributeCollection(namePool, attributes); + int widthFingerprint = namePool.getFingerprint("", "width"); + + if (attr.getValueByFingerprint(widthFingerprint) == null) { + attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } else { + attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } + attributes = attr; + } else if (thisFingerprint == foColFingerprint) { + AttributeCollection attr = new AttributeCollection(namePool, attributes); + int widthFingerprint = namePool.getFingerprint("", "column-width"); + + if (attr.getValueByFingerprint(widthFingerprint) == null) { + attr.addAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } else { + attr.setAttribute(widthFingerprint, "CDATA", width[numColumns++]); + } + attributes = attr; + } + + rtfEmitter.startElement(nameCode, attributes, namespaces, nscount); + } +} + + diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/CopyEmitter.java b/xsl/extensions/saxon61/com/nwalsh/saxon/CopyEmitter.java new file mode 100644 index 000000000..ee15c9b65 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/CopyEmitter.java @@ -0,0 +1,150 @@ +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.Builder; +import com.icl.saxon.Context; +import com.icl.saxon.expr.*; +import com.icl.saxon.functions.Extensions; +import com.icl.saxon.om.*; +import com.icl.saxon.output.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.tree.*; + +/** + *

A Saxon 6.0 Emitter that clones its input.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation of an emitter that manufactures a cloned result + * tree fragment.

+ * + *

The purpose of this emitter is to provide something for + * CalloutEmitter and NumberLinesEmitter to extend. + * This emitter simply copies all input to a new result tree fragment.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see CalloutEmitter + * @see NumberLinesEmitter + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CopyEmitter extends com.icl.saxon.output.Emitter { + /** The result tree fragment containing the copied fragment. */ + protected FragmentValue rtf = null; + protected Emitter rtfEmitter = null; + + /**

The namePool.

+ * + *

Copied from the caller, it should be the runtime name pool.

+ */ + protected NamePool namePool = null; + + /**

Constructor for the CopyEmitter.

+ * + * @param namePool The name pool to use for constructing elements and attributes. + */ + public CopyEmitter(NamePool namePool) { + rtf = new FragmentValue(); + rtfEmitter = rtf.getEmitter(); + this.namePool = namePool; + } + + /** + *

Return the result tree fragment constructed by replaying events + * through this emitter.

+ */ + public FragmentValue getResultTreeFragment() { + return rtf; + } + + /** Copy characters. */ + public void characters(char[] chars, int start, int len) + throws TransformerException { + rtfEmitter.characters(chars, start, len); + } + + /** Copy comments. */ + public void comment(char[] chars, int start, int length) + throws TransformerException { + rtfEmitter.comment(chars, start, length); + } + + /** Copy end document events. */ + public void endDocument() + throws TransformerException { + rtfEmitter.endDocument(); + } + + /** Copy end element events. */ + public void endElement(int nameCode) + throws TransformerException { + rtfEmitter.endElement(nameCode); + } + + /** Copy processing instructions. */ + public void processingInstruction(java.lang.String name, + java.lang.String data) + throws TransformerException { + rtfEmitter.processingInstruction(name, data); + } + + /** Copy set document locator events. */ + public void setDocumentLocator(org.xml.sax.Locator locator) { + rtfEmitter.setDocumentLocator(locator); + } + + /** Copy set escaping events. */ + public void setEscaping(boolean escaping) + throws TransformerException { + rtfEmitter.setEscaping(escaping); + } + + /** Copy set name pool events. */ + public void setNamePool(NamePool namePool) { + rtfEmitter.setNamePool(namePool); + } + + /** Copy set unparsed entity events. */ + public void setUnparsedEntity(java.lang.String name, java.lang.String uri) + throws TransformerException { + rtfEmitter.setUnparsedEntity(name, uri); + } + + /** Copy set writer events. */ + public void setWriter(java.io.Writer writer) { + rtfEmitter.setWriter(writer); + } + + /** Copy start document events. */ + public void startDocument() + throws TransformerException { + rtfEmitter.startDocument(); + } + + /** Copy start element events. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) + throws TransformerException { + rtfEmitter.startElement(nameCode, attributes, namespaces, nscount); + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/FormatCallout.java b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatCallout.java new file mode 100644 index 000000000..c8be006ca --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatCallout.java @@ -0,0 +1,112 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import javax.xml.transform.TransformerException; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.tree.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public abstract class FormatCallout { + protected static final String foURI = "http://www.w3.org/1999/XSL/Format"; + protected static final String xhURI = "http://www.w3.org/1999/xhtml"; + protected boolean foStylesheet = false; + protected NamePool namePool = null; + + public FormatCallout(NamePool nPool, boolean fo) { + namePool = nPool; + foStylesheet = fo; + } + + public String areaLabel(ElementInfo area) { + String label = null; + + if (area.getAttributeList().getValue("label") != null) { + // If this area has a label, use it + label = area.getAttributeList().getValue("label"); + } else { + // Otherwise, if its parent is an areaset and it has a label, use that + ElementInfo parent = (ElementInfo) area.getParentNode(); + if (parent != null + && parent.getLocalName().equalsIgnoreCase("areaset") + && parent.getAttributeList().getValue("label") != null) { + label = parent.getAttributeList().getValue("label"); + } + } + + return label; + } + + public void startSpan(Emitter rtf) + throws TransformerException { + // no point in doing this for FO, right? + if (!foStylesheet && namePool != null) { + int spanName = namePool.allocate("", "", "span"); + AttributeCollection spanAttr = new AttributeCollection(namePool); + int namespaces[] = new int[1]; + spanAttr.addAttribute("", "", "class", "CDATA", "co"); + rtf.startElement(spanName, spanAttr, namespaces, 0); + } + } + + public void endSpan(Emitter rtf) + throws TransformerException { + // no point in doing this for FO, right? + if (!foStylesheet && namePool != null) { + int spanName = namePool.allocate("", "", "span"); + rtf.endElement(spanName); + } + } + + public void formatTextCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + char chars[] = label.toCharArray(); + + try { + startSpan(rtfEmitter); + rtfEmitter.characters(chars, 0, label.length()); + endSpan(rtfEmitter); + } catch (TransformerException e) { + System.out.println("Transformer Exception in formatTextCallout"); + } + } + + public abstract void formatCallout(Emitter rtfEmitter, + Callout callout); +} + diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/FormatGraphicCallout.java b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatGraphicCallout.java new file mode 100644 index 000000000..a61590222 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatGraphicCallout.java @@ -0,0 +1,89 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import javax.xml.transform.TransformerException; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.tree.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatGraphicCallout extends FormatCallout { + String graphicsPath = ""; + String graphicsExt = ""; + int graphicsMax = 0; + + public FormatGraphicCallout(NamePool nPool, String path, String ext, int max, boolean fo) { + super(nPool, fo); + graphicsPath = path; + graphicsExt = ext; + graphicsMax = max; + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + try { + if (userLabel == null && num <= graphicsMax) { + int imgName = 0; + AttributeCollection imgAttr = null; + int namespaces[] = new int[1]; + + if (foStylesheet) { + imgName = namePool.allocate("fo", foURI, "external-graphic"); + imgAttr = new AttributeCollection(namePool); + imgAttr.addAttribute("", "", "src", "CDATA", + graphicsPath + num + graphicsExt); + } else { + imgName = namePool.allocate("", "", "img"); + imgAttr = new AttributeCollection(namePool); + imgAttr.addAttribute("", "", "src", "CDATA", + graphicsPath + num + graphicsExt); + imgAttr.addAttribute("", "", "alt", "CDATA", label); + } + + startSpan(rtfEmitter); + rtfEmitter.startElement(imgName, imgAttr, namespaces, 0); + rtfEmitter.endElement(imgName); + endSpan(rtfEmitter); + } else { + formatTextCallout(rtfEmitter, callout); + } + } catch (TransformerException e) { + System.out.println("Transformer Exception in graphic formatCallout"); + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/FormatTextCallout.java b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatTextCallout.java new file mode 100644 index 000000000..0c0c0f7a1 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatTextCallout.java @@ -0,0 +1,44 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import javax.xml.transform.TransformerException; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatTextCallout extends FormatCallout { + public FormatTextCallout(NamePool nPool, boolean fo) { + super(nPool, fo); + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + formatTextCallout(rtfEmitter, callout); + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/FormatUnicodeCallout.java b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatUnicodeCallout.java new file mode 100644 index 000000000..e4fdc0e59 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatUnicodeCallout.java @@ -0,0 +1,68 @@ +package com.nwalsh.saxon; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; + +import javax.xml.transform.TransformerException; + +import com.icl.saxon.om.ElementInfo; +import com.icl.saxon.om.NamePool; +import com.icl.saxon.output.Emitter; +import com.icl.saxon.tree.AttributeCollection; + +import com.nwalsh.saxon.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatUnicodeCallout extends FormatCallout { + int unicodeMax = 0; + int unicodeStart = 0; + + public FormatUnicodeCallout(NamePool nPool, int start, int max, boolean fo) { + super(nPool, fo); + unicodeMax = max; + unicodeStart = start; + } + + public void formatCallout(Emitter rtfEmitter, + Callout callout) { + + ElementInfo area = callout.getArea(); + int num = callout.getCallout(); + String label = areaLabel(area); + + try { + if (label == null && num <= unicodeMax) { + char chars[] = new char[1]; + chars[0] = (char) (unicodeStart + num - 1); + + startSpan(rtfEmitter); + rtfEmitter.characters(chars, 0, 1); + endSpan(rtfEmitter); + } else { + formatTextCallout(rtfEmitter, callout); + } + } catch (TransformerException e) { + System.out.println("Transformer Exception in graphic formatCallout"); + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/LineCountEmitter.java b/xsl/extensions/saxon61/com/nwalsh/saxon/LineCountEmitter.java new file mode 100644 index 000000000..99d7b2d54 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/LineCountEmitter.java @@ -0,0 +1,143 @@ +package com.nwalsh.saxon; + +import org.xml.sax.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; + +/** + *

Saxon extension to count the lines in a result tree fragment.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon 6.* + * implementation to count the number of lines in a result tree + * fragment.

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some verbatim environment. That result tree fragment + * is "replayed" through the LineCountEmitter; the LineCountEmitter watches + * characters go by and counts the number of line feeds that it sees. + * That number is then returned.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see Verbatim + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class LineCountEmitter extends com.icl.saxon.output.Emitter { + /** The number of lines seen. */ + protected int numLines = 0; + + /** Construct a new LineCountEmitter. */ + public LineCountEmitter() { + numLines = 0; + } + + /** Reset the number of lines. */ + public void reset() { + numLines = 0; + } + + /** Return the number of lines. */ + public int lineCount() { + return numLines; + } + + /** Process characters. */ + public void characters(char[] chars, int start, int len) + throws javax.xml.transform.TransformerException { + + if (numLines == 0) { + // If there are any characters at all, there's at least one line + numLines++; + } + + for (int count = start; count < start+len; count++) { + if (chars[count] == '\n') { + numLines++; + } + } + } + + /** Discarded. */ + public void comment(char[] chars, int start, int length) + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void endDocument() + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void endElement(int nameCode) + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void processingInstruction(java.lang.String name, + java.lang.String data) + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void setDocumentLocator(org.xml.sax.Locator locator) { + // nop + } + + /** Discarded. */ + public void setEscaping(boolean escaping) + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void setNamePool(NamePool namePool) { + // nop + } + + /** Discarded. */ + public void setUnparsedEntity(java.lang.String name, java.lang.String uri) + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void setWriter(java.io.Writer writer) { + // nop + } + + /** Discarded. */ + public void startDocument() + throws javax.xml.transform.TransformerException { + // nop + } + + /** Discarded. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, int nscount) + throws javax.xml.transform.TransformerException { + // nop + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/NumberLinesEmitter.java b/xsl/extensions/saxon61/com/nwalsh/saxon/NumberLinesEmitter.java new file mode 100644 index 000000000..f8065e370 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/NumberLinesEmitter.java @@ -0,0 +1,323 @@ +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.output.*; +import com.icl.saxon.om.*; +import com.icl.saxon.tree.AttributeCollection; +import com.icl.saxon.tinytree.TinyBuilder; +import com.icl.saxon.expr.FragmentValue; +import com.icl.saxon.Builder; + +/** + *

Saxon extension to decorate a result tree fragment with line numbers.

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides the guts of a + * Saxon 6.* + * implementation of line numbering for verbatim environments. (It is used + * by the Verbatim class.)

+ * + *

The general design is this: the stylesheets construct a result tree + * fragment for some verbatim environment. The Verbatim class initializes + * a NumberLinesEmitter with information about what lines should be + * numbered and how. Then the result tree fragment + * is "replayed" through the NumberLinesEmitter; the NumberLinesEmitter + * builds a + * new result tree fragment from this event stream, decorated with line + * numbers, + * and that is returned.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @see Verbatim + * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class NumberLinesEmitter extends CopyEmitter { + /** A stack for the preserving information about open elements. */ + protected Stack elementStack = null; + + /** The current line number. */ + protected int lineNumber = 0; + + /** Is the next element absolutely the first element in the fragment? */ + protected boolean firstElement = false; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** Every modulus line will be numbered. */ + protected int modulus = 5; + + /** Line numbers are width characters wide. */ + protected int width = 3; + + /** Line numbers are separated from the listing by separator. */ + protected String separator = " "; + + /** Is the stylesheet currently running an FO stylesheet? */ + protected boolean foStylesheet = false; + + /**

Constructor for the NumberLinesEmitter.

+ * + * @param namePool The name pool to use for constructing elements and attributes. + * @param modulus The modulus to use for this listing. + * @param width The width to use for line numbers in this listing. + * @param separator The separator to use for this listing. + * @param foStylesheet Is this an FO stylesheet? + */ + public NumberLinesEmitter(NamePool namePool, + int modulus, + int width, + String separator, + boolean foStylesheet) { + super(namePool); + elementStack = new Stack(); + firstElement = true; + + this.modulus = modulus; + this.width = width; + this.separator = separator; + this.foStylesheet = foStylesheet; + } + + /** Process characters. */ + public void characters(char[] chars, int start, int len) + throws TransformerException { + + // If we hit characters, then there's no first element... + firstElement = false; + + if (lineNumber == 0) { + // The first line is always numbered + formatLineNumber(++lineNumber); + } + + // Walk through the text node looking for newlines + char[] newChars = new char[len]; + int pos = 0; + for (int count = start; count < start+len; count++) { + if (chars[count] == '\n') { + // This is the tricky bit; if we find a newline, make sure + // it doesn't occur inside any markup. + + if (pos > 0) { + // Output any characters that preceded this newline + rtfEmitter.characters(newChars, 0, pos); + pos = 0; + } + + // Close all the open elements... + Stack tempStack = new Stack(); + while (!elementStack.empty()) { + StartElementInfo elem = (StartElementInfo) elementStack.pop(); + rtfEmitter.endElement(elem.getNameCode()); + tempStack.push(elem); + } + + // Copy the newline to the output + newChars[pos++] = chars[count]; + rtfEmitter.characters(newChars, 0, pos); + pos = 0; + + // Add the line number + formatLineNumber(++lineNumber); + + // Now "reopen" the elements that we closed... + while (!tempStack.empty()) { + StartElementInfo elem = (StartElementInfo) tempStack.pop(); + AttributeCollection attr = (AttributeCollection)elem.getAttributes(); + AttributeCollection newAttr = new AttributeCollection(namePool); + + for (int acount = 0; acount < attr.getLength(); acount++) { + String localName = attr.getLocalName(acount); + int nameCode = attr.getNameCode(acount); + String type = attr.getType(acount); + String value = attr.getValue(acount); + String uri = attr.getURI(acount); + String prefix = ""; + + if (localName.indexOf(':') > 0) { + prefix = localName.substring(0, localName.indexOf(':')); + localName = localName.substring(localName.indexOf(':')+1); + } + + if (uri.equals("") + && ((foStylesheet + && localName.equals("id")) + || (!foStylesheet + && (localName.equals("id") + || localName.equals("name"))))) { + // skip this attribute + } else { + newAttr.addAttribute(prefix, uri, localName, type, value); + } + } + + rtfEmitter.startElement(elem.getNameCode(), + newAttr, + elem.getNamespaces(), + elem.getNSCount()); + + elementStack.push(elem); + } + } else { + newChars[pos++] = chars[count]; + } + } + + if (pos > 0) { + rtfEmitter.characters(newChars, 0, pos); + pos = 0; + } + } + + /** + *

Add a formatted line number to the result tree fragment.

+ * + * @param lineNumber The number of the current line. + */ + protected void formatLineNumber(int lineNumber) + throws TransformerException { + + char ch = 160; //   + + String lno = ""; + if (lineNumber == 1 + || (modulus >= 1 && (lineNumber % modulus == 0))) { + lno = "" + lineNumber; + } + + while (lno.length() < width) { + lno = ch + lno; + } + + lno += separator; + + char chars[] = new char[lno.length()]; + for (int count = 0; count < lno.length(); count++) { + chars[count] = lno.charAt(count); + } + + characters(chars, 0, lno.length()); + } + + /** Process end element events. */ + public void endElement(int nameCode) + throws TransformerException { + if (!elementStack.empty()) { + // if we didn't push the very first element (an fo:block or + // pre or div surrounding the whole block), then the stack will + // be empty when we get to the end of the first element... + elementStack.pop(); + } + rtfEmitter.endElement(nameCode); + } + + /** Process start element events. */ + public void startElement(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) + throws TransformerException { + + if (!skipThisElement(nameCode)) { + StartElementInfo sei = new StartElementInfo(nameCode, attributes, + namespaces, nscount); + elementStack.push(sei); + } + + firstElement = false; + + rtfEmitter.startElement(nameCode, attributes, namespaces, nscount); + } + + /** + *

Protect the outer-most block wrapper.

+ * + *

Open elements in the result tree fragment are closed and reopened + * around callouts (so that callouts don't appear inside links or other + * environments). But if the result tree fragment is a single block + * (a div or pre in HTML, an fo:block in FO), that outer-most block is + * treated specially.

+ * + *

This method returns true if the element in question is that + * outermost block.

+ * + * @param nameCode The name code for the element + * + * @return True if the element is the outer-most block, false otherwise. + */ + protected boolean skipThisElement(int nameCode) { + if (firstElement) { + int foBlockFingerprint = namePool.getFingerprint(foURI, "block"); + int htmlPreFingerprint = namePool.getFingerprint("", "pre"); + int htmlDivFingerprint = namePool.getFingerprint("", "div"); + + if ((foStylesheet && nameCode == foBlockFingerprint) + || (!foStylesheet && (nameCode == htmlPreFingerprint + || nameCode == htmlDivFingerprint))) { + // Don't push the outer-most wrapping div, pre, or fo:block + return true; + } + } + + return false; + } + + /** + *

A private class for maintaining the information required to call + * the startElement method.

+ * + *

In order to close and reopen elements, information about those + * elements has to be maintained. This class is just the little record + * that we push on the stack to keep track of that info.

+ */ + private class StartElementInfo { + private int _nameCode; + org.xml.sax.Attributes _attributes; + int[] _namespaces; + int _nscount; + + public StartElementInfo(int nameCode, + org.xml.sax.Attributes attributes, + int[] namespaces, + int nscount) { + _nameCode = nameCode; + _attributes = attributes; + _namespaces = namespaces; + _nscount = nscount; + } + + public int getNameCode() { + return _nameCode; + } + + public org.xml.sax.Attributes getAttributes() { + return _attributes; + } + + public int[] getNamespaces() { + return _namespaces; + } + + public int getNSCount() { + return _nscount; + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/Table.java b/xsl/extensions/saxon61/com/nwalsh/saxon/Table.java new file mode 100644 index 000000000..8afe55d59 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/Table.java @@ -0,0 +1,428 @@ +// Verbatim.java - Saxon extensions supporting DocBook verbatim environments + +package com.nwalsh.saxon; + +import java.util.Hashtable; +import org.xml.sax.*; +import org.w3c.dom.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.expr.*; +import com.icl.saxon.om.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.Context; +import com.icl.saxon.tree.*; +import com.icl.saxon.functions.Extensions; + +/** + *

Saxon extensions supporting Tables

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * implementation of some code to adjust CALS Tables to HTML + * Tables.

+ * + *

Column Widths

+ *

The adjustColumnWidths method takes a result tree + * fragment (assumed to contain the colgroup of an HTML Table) + * and returns the result tree fragment with the column widths + * adjusted to HTML terms.

+ * + *

Convert Lengths

+ *

The convertLength method takes a length specification + * of the form 9999.99xx (where "xx" is a unit) and returns that length + * as an integral number of pixels. For convenience, percentage lengths + * are returned unchanged.

+ *

The recognized units are: inches (in), centimeters (cm), + * millimeters (mm), picas (pc, 1pc=12pt), points (pt), and pixels (px). + * A number with no units is assumed to be pixels.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Table { + /** The number of pixels per inch */ + private static int pixelsPerInch = 96; + + /** The nominal table width (6in by default). */ + private static int nominalWidth = 6 * pixelsPerInch; + + /** The default table width (100% by default). */ + private static String tableWidth = "100%"; + + /** Is this an FO stylesheet? */ + private static boolean foStylesheet = false; + + /** The hash used to associate units with a length in pixels. */ + protected static Hashtable unitHash = null; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Table() { + } + + /** Initialize the internal hash table with proper values. */ + protected static void initializeHash() { + unitHash = new Hashtable(); + unitHash.put("in", new Float(pixelsPerInch)); + unitHash.put("cm", new Float(pixelsPerInch / 2.54)); + unitHash.put("mm", new Float(pixelsPerInch / 25.4)); + unitHash.put("pc", new Float((pixelsPerInch / 72) * 12)); + unitHash.put("pt", new Float(pixelsPerInch / 72)); + unitHash.put("px", new Float(1)); + } + + /** Set the pixels-per-inch value. Only positive values are legal. */ + public static void setPixelsPerInch(int value) { + if (value > 0) { + pixelsPerInch = value; + initializeHash(); + } + } + + /** Return the current pixels-per-inch value. */ + public int getPixelsPerInch() { + return pixelsPerInch; + } + + /** + *

Convert a length specification to a number of pixels.

+ * + *

The specified length should be of the form [+/-]999.99xx, + * where xx is a valid unit.

+ */ + public static int convertLength(String length) { + // The format of length should be 999.999xx + int sign = 1; + String digits = ""; + String units = ""; + char lench[] = length.toCharArray(); + float flength = 0; + boolean done = false; + int pos = 0; + float factor = 1; + int pixels = 0; + + if (unitHash == null) { + initializeHash(); + } + + if (lench[pos] == '+' || lench[pos] == '-') { + if (lench[pos] == '-') { + sign = -1; + } + pos++; + } + + while (!done) { + if (pos >= lench.length) { + done = true; + } else { + if ((lench[pos] > '9' || lench[pos] < '0') && lench[pos] != '.') { + done = true; + units = length.substring(pos); + } else { + digits += lench[pos++]; + } + } + } + + try { + flength = Float.parseFloat(digits); + } catch (NumberFormatException e) { + System.out.println(digits + " is not a number; 1 used instead."); + flength = 1; + } + + Float f = null; + + if (!units.equals("")) { + f = (Float) unitHash.get(units); + if (f == null) { + System.out.println(units + " is not a known unit; 1 used instead."); + factor = 1; + } else { + factor = f.floatValue(); + } + } else { + factor = 1; + } + + f = new Float(flength * factor); + + pixels = f.intValue() * sign; + + return pixels; + } + + /** + *

Find the string value of a stylesheet variable or parameter

+ * + *

Returns the string value of varName in the current + * context. Returns the empty string if the variable is + * not defined.

+ * + * @param context The current stylesheet context + * @param varName The name of the variable (without the dollar sign) + * + * @return The string value of the variable + */ + protected static String getVariable(Context context, String varName) + throws TransformerException { + Value variable = null; + String varString = null; + + try { + variable = Extensions.evaluate(context, "$" + varName); + varString = variable.asString(); + return varString; + } catch (IllegalArgumentException e) { + System.out.println("Undefined variable: " + varName); + return ""; + } + } + + /** + *

Setup the parameters associated with column width calculations

+ * + *

This method queries the stylesheet for the variables + * associated with table column widths. It is called automatically before + * column widths are adjusted. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
nominal.table.width
+ *
The "normal" width for tables. This must be an absolute length.
+ *
table.width
+ *
The width for tables. This may be either an absolute + * length or a percentage.
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupColumnWidths(Context context) { + // Hardcoded defaults + nominalWidth = 6 * pixelsPerInch; + tableWidth = "100%"; + + String varString = null; + + try { + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = varString.equals("fo"); + + // Get the nominal table width + varString = getVariable(context, "nominal.table.width"); + nominalWidth = convertLength(varString); + + // Get the table width + varString = getVariable(context, "table.width"); + tableWidth = varString; + } catch (TransformerException e) { + //nop, can't happen + } + } + + /** + *

Adjust column widths in an HTML table.

+ * + *

The specification of column widths in CALS (a relative width + * plus an optional absolute width) are incompatible with HTML column + * widths. This method adjusts CALS column width specifiers in an + * attempt to produce equivalent HTML specifiers.

+ * + *

In order for this method to work, the CALS width specifications + * should be placed in the "width" attribute of the <col>s within + * a <colgroup>. Then the colgroup result tree fragment is passed + * to this method.

+ * + *

This method makes use of two parameters from the XSL stylesheet + * that calls it: nominal.table.width and + * table.width. The value of nominal.table.width + * must be an absolute distance. The value of table.width + * can be either absolute or relative.

+ * + *

Presented with a mixture of relative and + * absolute lengths, the table width is used to calculate + * appropriate values. If the table.width is relative, + * the nominal width is used for this calculation.

+ * + *

There are three possible combinations of values:

+ * + *
    + *
  1. There are no relative widths; in this case the absolute widths + * are used in the HTML table.
  2. + *
  3. There are no absolute widths; in this case the relative widths + * are used in the HTML table.
  4. + *
  5. There are a mixture of absolute and relative widths: + *
      + *
    1. If the table width is absolute, all widths become absolute.
    2. + *
    3. If the table width is relative, make all the widths absolute + * relative to the nominal table width then turn them all + * back into relative widths.
    4. + *
    + *
  6. + *
+ * + * @param context The stylesheet context; supplied automatically by Saxon + * @param rtf The result tree fragment containing the colgroup. + * + * @return The result tree fragment containing the adjusted colgroup. + * + */ + public static FragmentValue adjustColumnWidths (Context context, + FragmentValue rtf) { + setupColumnWidths(context); + + try { + NamePool namePool = context.getController().getNamePool(); + + ColumnScanEmitter csEmitter = new ColumnScanEmitter(namePool); + rtf.replay(csEmitter); + + int numColumns = csEmitter.columnCount(); + String widths[] = csEmitter.columnWidths(); + + float relTotal = 0; + float relParts[] = new float[numColumns]; + + float absTotal = 0; + float absParts[] = new float[numColumns]; + + for (int count = 0; count < numColumns; count++) { + String width = widths[count]; + + int pos = width.indexOf("*"); + if (pos >= 0) { + String relPart = width.substring(0, pos); + String absPart = width.substring(pos+1); + + try { + float rel = Float.parseFloat(relPart); + relTotal += rel; + relParts[count] = rel; + } catch (NumberFormatException e) { + System.out.println(relPart + " is not a valid relative unit."); + } + + int pixels = 0; + if (absPart != null && !absPart.equals("")) { + pixels = convertLength(absPart); + } + + absTotal += pixels; + absParts[count] = pixels; + } else { + relParts[count] = 0; + + int pixels = 0; + if (width != null && !width.equals("")) { + pixels = convertLength(width); + } + + absTotal += pixels; + absParts[count] = pixels; + } + } + + // Ok, now we have the relative widths and absolute widths in + // two parallel arrays. + // + // - If there are no relative widths, output the absolute widths + // - If there are no absolute widths, output the relative widths + // - If there are a mixture of relative and absolute widths, + // - If the table width is absolute, turn these all into absolute + // widths. + // - If the table width is relative, turn these all into absolute + // widths in the nominalWidth and then turn them back into + // percentages. + + if (relTotal == 0) { + for (int count = 0; count < numColumns; count++) { + Float f = new Float(absParts[count]); + if (foStylesheet) { + int pixels = f.intValue(); + float inches = (float) pixels / pixelsPerInch; + widths[count] = inches + "in"; + } else { + widths[count] = Integer.toString(f.intValue()); + } + } + } else if (absTotal == 0) { + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / relTotal * 100; + Float f = new Float(rel); + widths[count] = Integer.toString(f.intValue()) + "%"; + } + } else { + int pixelWidth = nominalWidth; + + if (tableWidth.indexOf("%") <= 0) { + pixelWidth = convertLength(tableWidth); + } + + if (pixelWidth <= absTotal) { + System.out.println("Table is wider than table width."); + } else { + pixelWidth -= absTotal; + } + + absTotal = 0; + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / relTotal * pixelWidth; + relParts[count] = rel + absParts[count]; + absTotal += rel + absParts[count]; + } + + if (tableWidth.indexOf("%") <= 0) { + for (int count = 0; count < numColumns; count++) { + Float f = new Float(relParts[count]); + if (foStylesheet) { + int pixels = f.intValue(); + float inches = (float) pixels / pixelsPerInch; + widths[count] = inches + "in"; + } else { + widths[count] = Integer.toString(f.intValue()); + } + } + } else { + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / absTotal * 100; + Float f = new Float(rel); + widths[count] = Integer.toString(f.intValue()) + "%"; + } + } + } + + ColumnUpdateEmitter cuEmitter = new ColumnUpdateEmitter(namePool, + widths); + rtf.replay(cuEmitter); + return cuEmitter.getResultTreeFragment(); + } catch (TransformerException e) { + // This "can't" happen. + System.out.println("Transformer Exception in adjustColumnWidths"); + return rtf; + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/Text.java b/xsl/extensions/saxon61/com/nwalsh/saxon/Text.java new file mode 100644 index 000000000..f5a95d7ff --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/Text.java @@ -0,0 +1,132 @@ +// Text - Saxon extension element for inserting text + +package com.nwalsh.saxon; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.net.URL; +import java.net.MalformedURLException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerConfigurationException; +import com.icl.saxon.*; +import com.icl.saxon.style.*; +import com.icl.saxon.expr.*; +import com.icl.saxon.output.*; +import org.xml.sax.AttributeList; + +/** + *

Saxon extension element for inserting text + * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension element for inserting text into a result tree.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Text extends StyleElement { + /** + *

Constructor for Text

+ * + *

Does nothing.

+ */ + public Text() { + } + + /** + *

Is this element an instruction?

+ * + *

Yes, it is.

+ * + * @return true + */ + public boolean isInstruction() { + return true; + } + + /** + *

Can this element contain a template-body?

+ * + *

Yes, it can, but only so that it can contain xsl:fallback.

+ * + * @return true + */ + public boolean mayContainTemplateBody() { + return true; + } + + /** + *

Validate the arguments

+ * + *

The element must have an href attribute.

+ */ + public void prepareAttributes() throws TransformerConfigurationException { + // Get mandatory href attribute + String fnAtt = getAttribute("href"); + if (fnAtt == null) { + reportAbsence("href"); + } + } + + /** Validate that the element occurs in a reasonable place. */ + public void validate() throws TransformerConfigurationException { + checkWithinTemplate(); + } + + /** + *

Insert the text of the file into the result tree

+ * + *

Processing this element inserts the contents of the URL named + * by the href attribute into the result tree as plain text.

+ * + */ + public void process( Context context ) throws TransformerException { + Outputter out = context.getOutputter(); + + String hrefAtt = getAttribute("href"); + Expression hrefExpr = makeAttributeValueTemplate(hrefAtt); + String href = hrefExpr.evaluateAsString(context); + URL fileURL = null; + + try { + try { + fileURL = new URL(href); + } catch (MalformedURLException e1) { + try { + fileURL = new URL("file:" + href); + } catch (MalformedURLException e2) { + System.out.println("Cannot open " + href); + return; + } + } + + InputStreamReader isr = new InputStreamReader(fileURL.openStream()); + BufferedReader is = new BufferedReader(isr); + + char chars[] = new char[4096]; + int len = 0; + while ((len = is.read(chars)) > 0) { + out.writeContent(chars, 0, len); + } + is.close(); + } catch (Exception e) { + System.out.println("Cannot read " + href); + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/TextFactory.java b/xsl/extensions/saxon61/com/nwalsh/saxon/TextFactory.java new file mode 100644 index 000000000..ccf5001c0 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/TextFactory.java @@ -0,0 +1,67 @@ +// TextFactory - Saxon extension element factory + +package com.nwalsh.saxon; + +import com.icl.saxon.style.ExtensionElementFactory; +import org.xml.sax.SAXException; + +/** + *

Saxon extension element factory + * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension element factory for the Text extension element + * family.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + * @see Text + * + */ +public class TextFactory implements ExtensionElementFactory { + /** + *

Constructor for TextFactory

+ * + *

Does nothing.

+ */ + public TextFactory() { + } + + /** + *

Return the class that implements a particular extension element.

+ * + * @param localname The local name of the extension element. + * + * @return The class that handles that extension element. + * + * @exception SAXException("Unknown Text extension element") + */ + public Class getExtensionClass(String localname) { + if (localname.equals("insertfile")) { + try { + return Class.forName("com.nwalsh.saxon.Text"); + } catch (ClassNotFoundException e) { + return null; + } + } + return null; + } +} + + + + + diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java new file mode 100644 index 000000000..5823d88b7 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java @@ -0,0 +1,458 @@ +// Verbatim.java - Saxon extensions supporting DocBook verbatim environments + +package com.nwalsh.saxon; + +import java.util.Stack; +import java.util.StringTokenizer; +import org.xml.sax.*; +import org.w3c.dom.*; +import javax.xml.transform.TransformerException; +import com.icl.saxon.expr.*; +import com.icl.saxon.om.*; +import com.icl.saxon.pattern.*; +import com.icl.saxon.Context; +import com.icl.saxon.tree.*; +import com.icl.saxon.functions.Extensions; +import com.nwalsh.saxon.NumberLinesEmitter; +import com.nwalsh.saxon.CalloutEmitter; + +/** + *

Saxon extensions supporting DocBook verbatim environments

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * implementation of two features that would be impractical to + * implement directly in XSLT: line numbering and callouts.

+ * + *

Line Numbering

+ *

The numberLines method takes a result tree + * fragment (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * line numbers.

+ * + *

Callouts

+ *

The insertCallouts method takes an + * areaspec and a result tree fragment + * (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * callouts.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Verbatim { + /** True if the stylesheet is producing formatting objects */ + private static boolean foStylesheet = false; + /** The modulus for line numbering (every 'modulus' line is numbered). */ + private static int modulus = 0; + /** The width (in characters) of line numbers (for padding). */ + private static int width = 0; + /** The separator between the line number and the verbatim text. */ + private static String separator = ""; + + /** True if callouts have been setup */ + private static boolean calloutsSetup = false; + /** The default column for callouts that have only a line or line range */ + private static int defaultColumn = 60; + /** The path to use for graphical callout decorations. */ + private static String graphicsPath = null; + /** The extension to use for graphical callout decorations. */ + private static String graphicsExt = null; + /** The largest callout number that can be represented graphically. */ + private static int graphicsMax = 10; + + /** The FormatCallout object to use for formatting callouts. */ + private static FormatCallout fCallout = null; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Verbatim() { + } + + /** + *

Find the string value of a stylesheet variable or parameter

+ * + *

Returns the string value of varName in the current + * context. Returns the empty string if the variable is + * not defined.

+ * + * @param context The current stylesheet context + * @param varName The name of the variable (without the dollar sign) + * + * @return The string value of the variable + */ + protected static String getVariable(Context context, String varName) { + Value variable = null; + String varString = null; + + try { + variable = Extensions.evaluate(context, "$" + varName); + varString = variable.asString(); + return varString; + } catch (TransformerException te) { + System.out.println("Undefined variable: " + varName); + return ""; + } catch (IllegalArgumentException iae) { + System.out.println("Undefined variable: " + varName); + return ""; + } + } + + /** + *

Setup the parameters associated with line numbering

+ * + *

This method queries the stylesheet for the variables + * associated with line numbering. It is called automatically before + * lines are numbered. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
linenumbering.everyNth
+ *
Specifies the lines that will be numbered. The first line is + * always numbered. (builtin default: 5).
+ *
linenumbering.width
+ *
Specifies the width of the numbers. If the specified width is too + * narrow for the largest number needed, it will automatically be made + * wider. (builtin default: 3).
+ *
linenumbering.separator
+ *
Specifies the string that separates line numbers from lines + * in the program listing. (builtin default: " ").
+ *
stylesheet.result.type
+ *
Specifies the stylesheet result type. The value is either 'fo' + * (for XSL Formatting Objects) or it isn't. (builtin default: html).
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupLineNumbering(Context context) { + // Hardcoded defaults + modulus = 5; + width = 3; + separator = " "; + foStylesheet = false; + + String varString = null; + + // Get the modulus + varString = getVariable(context, "linenumbering.everyNth"); + try { + modulus = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.everyNth is not a number: " + varString); + } + + // Get the width + varString = getVariable(context, "linenumbering.width"); + try { + width = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.width is not a number: " + varString); + } + + // Get the separator + varString = getVariable(context, "linenumbering.separator"); + separator = varString; + + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = (varString.equals("fo")); + } + + /** + *

Number lines in a verbatim environment

+ * + *

The extension function expects the following variables to be + * available in the calling context: $linenumbering.everyNth, + * $linenumbering.width, $linenumbering.separator, and + * $stylesheet.result.type.

+ * + *

This method adds line numbers to a result tree fragment. Each + * newline that occurs in a text node is assumed to start a new line. + * The first line is always numbered, every subsequent 'everyNth' line + * is numbered (so if everyNth=5, lines 1, 5, 10, 15, etc. will be + * numbered. If there are fewer than everyNth lines in the environment, + * every line is numbered.

+ * + *

Every line number will be right justified in a string 'width' + * characters long. If the line number of the last line in the + * environment is too long to fit in the specified width, the width + * is automatically increased to the smallest value that can hold the + * number of the last line. (In other words, if you specify the value 2 + * and attempt to enumerate the lines of an environment that is 100 lines + * long, the value 3 will automatically be used for every line in the + * environment.)

+ * + *

The 'separator' string is inserted between the line + * number and the original program listing. Lines that aren't numbered + * are preceded by a 'width' blank string and the separator.

+ * + *

If inline markup extends across line breaks, markup changes are + * required. All the open elements are closed before the line break and + * "reopened" afterwards. The reopened elements will have the same + * attributes as the originals, except that 'name' and 'id' attributes + * are not duplicated if the stylesheet.result.type is "html" and + * 'id' attributes will not be duplicated if the result type is "fo".

+ * + * @param rtf The result tree fragment of the verbatim environment. + * + * @return The modified result tree fragment. + */ + public static FragmentValue numberLines (Context context, + FragmentValue rtf) { + + setupLineNumbering(context); + + try { + LineCountEmitter lcEmitter = new LineCountEmitter(); + rtf.replay(lcEmitter); + int numLines = lcEmitter.lineCount(); + + int listingModulus = numLines < modulus ? 1 : modulus; + + double log10numLines = Math.log(numLines) / Math.log(10); + + int listingWidth = width < log10numLines+1 + ? (int) Math.floor(log10numLines + 1) + : width; + + NamePool namePool = context.getController().getNamePool(); + NumberLinesEmitter nlEmitter = new NumberLinesEmitter(namePool, + listingModulus, + listingWidth, + separator, + foStylesheet); + rtf.replay(nlEmitter); + return nlEmitter.getResultTreeFragment(); + } catch (TransformerException e) { + // This "can't" happen. + System.out.println("Transformer Exception in numberLines"); + return rtf; + } + } + + /** + *

Setup the parameters associated with callouts

+ * + *

This method queries the stylesheet for the variables + * associated with line numbering. It is called automatically before + * callouts are processed. The context is used to retrieve the values, + * this allows templates to redefine these variables.

+ * + *

The following variables are queried. If the variables do not + * exist, builtin defaults will be used (but you may also get a bunch + * of messages from the Java interpreter).

+ * + *
+ *
callout.graphics
+ *
Are we using callout graphics? A value of 0 or "" is false, + * any other value is true. If callout graphics are not used, the + * parameters related to graphis are not queried.
+ *
callout.graphics.path
+ *
Specifies the path to callout graphics.
+ *
callout.graphics.extension
+ *
Specifies the extension ot use for callout graphics.
+ *
callout.graphics.number.limit
+ *
Identifies the largest number that can be represented as a + * graphic. Larger callout numbers will be represented using text.
+ *
callout.defaultcolumn
+ *
Specifies the default column for callout bullets that do not + * specify a column.
+ *
stylesheet.result.type
+ *
Specifies the stylesheet result type. The value is either 'fo' + * (for XSL Formatting Objects) or it isn't. (builtin default: html).
+ *
+ * + * @param context The current stylesheet context + * + */ + private static void setupCallouts(Context context) { + NamePool namePool = context.getController().getNamePool(); + + boolean useGraphics = false; + boolean useUnicode = false; + + int unicodeStart = 49; + int unicodeMax = 0; + + // Hardcoded defaults + defaultColumn = 60; + graphicsPath = null; + graphicsExt = null; + graphicsMax = 0; + foStylesheet = false; + calloutsSetup = true; + + Value variable = null; + String varString = null; + + // Get the stylesheet type + varString = getVariable(context, "stylesheet.result.type"); + foStylesheet = (varString.equals("fo")); + + // Get the default column + varString = getVariable(context, "callout.defaultcolumn"); + try { + defaultColumn = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.defaultcolumn is not a number: " + + varString); + } + + // Use graphics at all? + varString = getVariable(context, "callout.graphics"); + useGraphics = !(varString.equals("0") || varString.equals("")); + + // Use unicode at all? + varString = getVariable(context, "callout.unicode"); + useUnicode = !(varString.equals("0") || varString.equals("")); + + if (useGraphics) { + // Get the graphics path + varString = getVariable(context, "callout.graphics.path"); + graphicsPath = varString; + + // Get the graphics extension + varString = getVariable(context, "callout.graphics.extension"); + graphicsExt = varString; + + // Get the number limit + varString = getVariable(context, "callout.graphics.number.limit"); + try { + graphicsMax = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.graphics.number.limit is not a number: " + + varString); + graphicsMax = 0; + } + + fCallout = new FormatGraphicCallout(namePool, + graphicsPath, + graphicsExt, + graphicsMax, + foStylesheet); + } else if (useUnicode) { + // Get the starting character + varString = getVariable(context, "callout.unicode.start.character"); + try { + unicodeStart = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.unicode.start.character is not a number: " + + varString); + unicodeStart = 48; + } + + // Get the number limit + varString = getVariable(context, "callout.unicode.number.limit"); + try { + unicodeMax = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$callout.unicode.number.limit is not a number: " + + varString); + unicodeStart = 0; + } + + fCallout = new FormatUnicodeCallout(namePool, + unicodeStart, + unicodeMax, + foStylesheet); + } else { + fCallout = new FormatTextCallout(namePool, foStylesheet); + } + } + + /** + *

Insert text callouts into a verbatim environment.

+ * + *

This method examines the areaset and area elements + * in the supplied areaspec and decorates the supplied + * result tree fragment with appropriate callout markers.

+ * + *

If a label attribute is supplied on an area, + * its content will be used for the label, otherwise the callout + * number will be used, surrounded by parenthesis. Callout numbers may + * also be represented as graphics. Callouts are + * numbered in document order. All of the areas in an + * areaset get the same number.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn. Lines will be padded with blanks to reach the + * necessary column, but callouts that are located beyond the last + * line of the verbatim environment will be ignored.

+ * + *

Callouts are inserted before the character at the line/column + * where they are to occur.

+ * + *

If graphical callouts are used, and the callout number is less + * than or equal to the $callout.graphics.number.limit, the following image + * will be generated for HTML: + * + *

+   * <img src="$callout.graphics.path/999$callout.graphics.ext"
+   *         alt="conumber">
+   * 
+ * + * If the $stylesheet.result.type is 'fo', the following image will + * be generated: + * + *
+   * <fo:external-graphic src="$callout.graphics.path/999$callout.graphics.ext"/>
+   * 
+ * + *

If the callout number exceeds $callout.graphics.number.limit, + * the callout will be the callout number surrounded by + * parenthesis.

+ * + * @param context The stylesheet context. + * @param areaspecNodeSet The source node set that contains the areaspec. + * @param rtf The result tree fragment of the verbatim environment. + * + * @return The modified result tree fragment. + */ + + public static FragmentValue insertCallouts (Context context, + NodeSetIntent areaspecNodeSet, + FragmentValue rtf) { + + setupCallouts(context); + + try { + NamePool namePool = context.getController().getNamePool(); + CalloutEmitter cEmitter = new CalloutEmitter(namePool, + defaultColumn, + foStylesheet, + fCallout); + cEmitter.setupCallouts(areaspecNodeSet); + rtf.replay(cEmitter); + return cEmitter.getResultTreeFragment(); + } catch (TransformerException e) { + // This "can't" happen. + System.out.println("Transformer Exception in insertCallouts"); + return rtf; + } + } +} diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/package.html b/xsl/extensions/saxon61/com/nwalsh/saxon/package.html new file mode 100644 index 000000000..b05a46709 --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/package.html @@ -0,0 +1,48 @@ + + +Norman Walsh's Saxon Extensions Package + + +

Norman Walsh's Saxon Extensions Package for Saxon 6.*

+ +

This package implements Saxon extensions for XSLT.

+ +

Copyright (C) 2000 Norman Walsh

+

Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

+ +

The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

+ +

Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the +individuals in question.

+ +

Anything derived from this Software that is publically +distributed will be identified with a different name and the +version strings in any derived Software will be changed so that no +possibility of confusion between the derived package and this +Software will exist.

+ + +
+

Warranty

+

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER +CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.

+
+ + + diff --git a/xsl/extensions/xalan2/.cvsignore b/xsl/extensions/xalan2/.cvsignore new file mode 100644 index 000000000..4d3c216f5 --- /dev/null +++ b/xsl/extensions/xalan2/.cvsignore @@ -0,0 +1 @@ +.classes diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/CVS.java b/xsl/extensions/xalan2/com/nwalsh/xalan/CVS.java new file mode 100644 index 000000000..acf1d057a --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/CVS.java @@ -0,0 +1,90 @@ +package com.nwalsh.xalan; + +import java.io.*; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.text.DateFormat; +import java.text.ParseException; + +/** + *

Saxon extension to convert CVS date strings into local time

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Saxon + * extension to turn the CVS date strings, which are UTC:

+ * + *
$Date: 2000/11/09 02:34:20 $
+ * + *

into legibly formatted local time:

+ * + *
Wed Nov 08 18:34:20 PST 2000
+ * + *

(I happened to be in California when I wrote this documentation.)

+ + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class CVS { + /** + *

Constructor for CVS

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public CVS() { + } + + /** + *

Convert a CVS date string into local time.

+ * + * @param cvsDate The CVS date string. + * + * @return The date, converted to local time and reformatted. + */ + public String localTime (String cvsDate) { + // A cvsDate has the following form "$Date$" + if (!cvsDate.startsWith("$Date: ")) { + return cvsDate; + } + + String yrS = cvsDate.substring(7,11); + String moS = cvsDate.substring(12,14); + String daS = cvsDate.substring(15,17); + String hrS = cvsDate.substring(18,20); + String miS = cvsDate.substring(21,23); + String seS = cvsDate.substring(24,26); + + TimeZone tz = TimeZone.getTimeZone("GMT+0"); + GregorianCalendar gmtCal = new GregorianCalendar(tz); + + try { + gmtCal.set(Integer.parseInt(yrS), + Integer.parseInt(moS)-1, + Integer.parseInt(daS), + Integer.parseInt(hrS), + Integer.parseInt(miS), + Integer.parseInt(seS)); + } catch (NumberFormatException e) { + // nop + } + + Date d = gmtCal.getTime(); + + return d.toString(); + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/Callout.java b/xsl/extensions/xalan2/com/nwalsh/xalan/Callout.java new file mode 100644 index 000000000..920cfc3bf --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/Callout.java @@ -0,0 +1,143 @@ +package com.nwalsh.xalan; + +import org.w3c.dom.*; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class is just for book keeping in the Verbatim class. + * It stores information about the location of callouts.

+ * + *

Only line/column based callouts are supported. This class + * implements the Comparable interface so that callouts can be sorted. + * Callouts are sorted so that they occur in left-to-right, + * top-to-bottom order based on line/column.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + * */ +public class Callout implements Comparable { + /** The callout number. */ + private int callout = 0; + /** The area Element item that generated this callout. */ + private Element area = null; + /** The line on which this callout occurs. */ + private int line = 0; + /** The column in which this callout appears. */ + private int col = 0; + /** The type of callout. */ + private int type = 0; + /** The other type of callout. */ + private String otherType = null; + + public static final int CALS_PAIR = 1; + public static final int LINE_COLUMN = 2; + public static final int LINE_COLUMN_PAIR = 3; + public static final int LINE_RANGE = 4; + public static final int OTHER = 5; + + /** The constructor; initialize the private data structures. */ + public Callout(int callout, Element area, int line, int col, int type) { + this.callout = callout; + this.area = area; + this.line = line; + this.col = col; + this.type = type; + this.otherType = null; + } + + /** The constructor; initialize the private data structures. */ + public Callout(int callout, Element area, int line, int col, String otherType) { + this.callout = callout; + this.area = area; + this.line = line; + this.col = col; + this.type = Callout.OTHER; + this.otherType = otherType; + } + + /** + *

The compareTo method compares this Callout with another.

+ * + *

Given two Callouts, A and B, A < B if:

+ * + *
    + *
  1. A.line < B.line, or
  2. + *
  3. A.line = B.line && A.col < B.col, or
  4. + *
  5. A.line = B.line && A.col = B.col && A.callout < B.callout
  6. + *
  7. Otherwise, they're equal.
  8. + *
+ */ + public int compareTo (Object o) { + Callout c = (Callout) o; + + if (line == c.getLine()) { + if (col > c.getColumn()) { + return 1; + } else if (col < c.getColumn()) { + return -1; + } else { + if (callout < c.getCallout()) { + return -1; + } else if (callout > c.getCallout()) { + return 1; + } else { + return 0; + } + } + } else { + if (line > c.getLine()) { + return 1; + } else { + return -1; + } + } + } + + /** Access the Callout's area. */ + public Element getArea() { + return area; + } + + /** Access the Callout's line. */ + public int getLine() { + return line; + } + + /** Access the Callout's column. */ + public int getColumn() { + return col; + } + + /** Access the Callout's callout number. */ + public int getCallout() { + return callout; + } + + /** Access the Callout's type. */ + public int getType() { + return type; + } + + /** Access the Callout's otherType. */ + public String getOtherType() { + return otherType; + } + + +} + diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/FormatCallout.java b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatCallout.java new file mode 100644 index 000000000..99363b5d1 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatCallout.java @@ -0,0 +1,106 @@ +package com.nwalsh.xalan; + +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; +import org.w3c.dom.*; +import org.apache.xml.utils.DOMBuilder; +import org.apache.xml.utils.AttList; +import com.nwalsh.xalan.Callout; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public abstract class FormatCallout { + protected static final String foURI = "http://www.w3.org/1999/XSL/Format"; + protected static final String xhURI = "http://www.w3.org/1999/xhtml"; + protected boolean stylesheetFO = false; + + public FormatCallout() { + //nop; + } + + public String areaLabel(Element area) { + NamedNodeMap domAttr = area.getAttributes(); + AttList attr = new AttList(domAttr); + String label = null; + + if (attr.getValue("label") != null) { + // If this area has a label, use it + label = attr.getValue("label"); + } else { + // Otherwise, if its parent is an areaset and it has a label, use that + Element parent = (Element) area.getParentNode(); + NamedNodeMap pdomAttr = parent.getAttributes(); + AttList pAttr = new AttList(pdomAttr); + if (parent != null + && parent.getNodeName().equals("areaset") + && pAttr.getValue("label") != null) { + label = pAttr.getValue("label"); + } + } + + return label; + } + + public void startSpan(DOMBuilder rtf) + throws SAXException { + // no point in doing this for FO, right? + if (!stylesheetFO) { + AttributesImpl spanAttr = new AttributesImpl(); + spanAttr.addAttribute("", "class", "class", "CDATA", "co"); + rtf.startElement("", "span", "span", spanAttr); + } + } + + public void endSpan(DOMBuilder rtf) + throws SAXException { + // no point in doing this for FO, right? + if (!stylesheetFO) { + rtf.endElement("", "span", "span"); + } + } + + public void formatTextCallout(DOMBuilder rtf, + Callout callout) { + Element area = callout.getArea(); + int num = callout.getCallout(); + String userLabel = areaLabel(area); + String label = "(" + num + ")"; + + if (userLabel != null) { + label = userLabel; + } + + char chars[] = label.toCharArray(); + + try { + startSpan(rtf); + rtf.characters(chars, 0, label.length()); + endSpan(rtf); + } catch (SAXException e) { + System.out.println("SAX Exception in text formatCallout"); + } + } + + public abstract void formatCallout(DOMBuilder rtf, + Callout callout); +} + diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/FormatGraphicCallout.java b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatGraphicCallout.java new file mode 100644 index 000000000..a4f83bd41 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatGraphicCallout.java @@ -0,0 +1,83 @@ +package com.nwalsh.xalan; + +import org.xml.sax.helpers.AttributesImpl; +import org.xml.sax.SAXException; +import org.w3c.dom.*; +import org.apache.xml.utils.DOMBuilder; +import com.nwalsh.xalan.Callout; +import org.apache.xml.utils.AttList; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatGraphicCallout extends FormatCallout { + String graphicsPath = ""; + String graphicsExt = ""; + int graphicsMax = 0; + + public FormatGraphicCallout(String path, String ext, int max, boolean fo) { + graphicsPath = path; + graphicsExt = ext; + graphicsMax = max; + stylesheetFO = fo; + } + + public void formatCallout(DOMBuilder rtf, + Callout callout) { + Element area = callout.getArea(); + int num = callout.getCallout(); + String label = areaLabel(area); + + try { + if (label == null && num <= graphicsMax) { + AttributesImpl imgAttr = new AttributesImpl(); + String ns = ""; + String prefix = ""; + String imgName = ""; + + if (stylesheetFO) { + ns = foURI; + prefix = "fo:"; // FIXME: this could be a problem... + imgName = "external-graphic"; + imgAttr.addAttribute("", "src", "src", "CDATA", + graphicsPath + num + graphicsExt); + imgAttr.addAttribute("", "alt", "alt", "CDATA", label); + } else { + ns = ""; + prefix = ""; + imgName = "img"; + imgAttr.addAttribute("", "src", "src", "CDATA", + graphicsPath + num + graphicsExt); + imgAttr.addAttribute("", "alt", "alt", "CDATA", label); + } + + startSpan(rtf); + rtf.startElement(ns, imgName, prefix+imgName, imgAttr); + rtf.endElement(ns, imgName, prefix+imgName); + endSpan(rtf); + } else { + formatTextCallout(rtf, callout); + } + } catch (SAXException e) { + System.out.println("SAX Exception in graphics formatCallout"); + } + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/FormatTextCallout.java b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatTextCallout.java new file mode 100644 index 000000000..8cdbef541 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatTextCallout.java @@ -0,0 +1,38 @@ +package com.nwalsh.xalan; + +import org.w3c.dom.*; +import org.apache.xml.utils.DOMBuilder; +import com.nwalsh.xalan.Callout; +import org.apache.xml.utils.AttList; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatTextCallout extends FormatCallout { + public FormatTextCallout(boolean fo) { + stylesheetFO = fo; + } + + public void formatCallout(DOMBuilder rtf, + Callout callout) { + formatTextCallout(rtf, callout); + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/FormatUnicodeCallout.java b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatUnicodeCallout.java new file mode 100644 index 000000000..ef8f352fd --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/FormatUnicodeCallout.java @@ -0,0 +1,61 @@ +package com.nwalsh.xalan; + +import org.xml.sax.SAXException; +import org.w3c.dom.*; +import org.apache.xml.utils.DOMBuilder; +import com.nwalsh.xalan.Callout; +import org.apache.xml.utils.AttList; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @see Verbatim + * + * @version $Id$ + **/ + +public class FormatUnicodeCallout extends FormatCallout { + int unicodeMax = 0; + int unicodeStart = 0; + + public FormatUnicodeCallout(int start, int max, boolean fo) { + unicodeMax = max; + unicodeStart = start; + stylesheetFO = fo; + } + + public void formatCallout(DOMBuilder rtf, + Callout callout) { + Element area = callout.getArea(); + int num = callout.getCallout(); + String label = areaLabel(area); + + try { + if (label == null && num <= unicodeMax) { + char chars[] = new char[1]; + chars[0] = (char) (unicodeStart + num - 1); + + startSpan(rtf); + rtf.characters(chars, 0, 1); + endSpan(rtf); + } else { + formatTextCallout(rtf, callout); + } + } catch (SAXException e) { + System.out.println("SAX Exception in unicode formatCallout"); + } + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/Func.java b/xsl/extensions/xalan2/com/nwalsh/xalan/Func.java new file mode 100644 index 000000000..e03ae6bd2 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/Func.java @@ -0,0 +1,59 @@ +// Func - Xalann extension function test + +package com.nwalsh.xalan; + +import org.xml.sax.SAXException; +import org.xml.sax.AttributeList; +import org.xml.sax.ContentHandler; + +import org.w3c.dom.*; +import org.w3c.dom.traversal.NodeIterator; +import org.apache.xerces.dom.*; + +import org.apache.xpath.objects.XObject; +import org.apache.xpath.objects.XRTreeFrag; +import org.apache.xpath.XPath; +import org.apache.xpath.NodeSet; +import org.apache.xalan.extensions.XSLProcessorContext; +import org.apache.xalan.extensions.ExpressionContext; +import org.apache.xalan.transformer.TransformerImpl; +import org.apache.xalan.templates.StylesheetRoot; +import org.apache.xalan.templates.ElemExtensionCall; +import org.apache.xalan.templates.OutputProperties; +import org.apache.xalan.res.XSLTErrorResources; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.TransformerException; + +public class Func { + public Func() { + } + + public DocumentFragment doSomething(NodeIterator rtf) { + System.out.println("Got here 2: " + rtf); + + DocumentFragment df = (DocumentFragment) rtf.nextNode(); + Element node = (Element) df.getFirstChild(); + + System.out.println("node=" + node); + System.out.println("namesp uri: " + node.getNamespaceURI()); + System.out.println("local name: " + node.getLocalName()); + + return df; + } + + public DocumentFragment doSomething(DocumentFragment rtf) { + System.out.println("Got here: " + rtf); + + return rtf; + /* + Element node = (Element) rtf.getFirstChild(); + + System.out.println("node=" + node); + System.out.println("namesp uri: " + node.getNamespaceURI()); + System.out.println("local name: " + node.getLocalName()); + + return rtf; + */ + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/Params.java b/xsl/extensions/xalan2/com/nwalsh/xalan/Params.java new file mode 100644 index 000000000..6e524274e --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/Params.java @@ -0,0 +1,58 @@ +// Params.java - Read stylesheet parameters in Xalan + +package com.nwalsh.xalan; + +import org.apache.xpath.objects.XObject; +import org.apache.xpath.XPathContext; +import org.apache.xalan.extensions.ExpressionContext; +import org.apache.xml.utils.QName; + +import javax.xml.transform.TransformerException; + +public class Params { + + public static String getString(ExpressionContext context, + String varName) { + try { + XPathContext xpc = (XPathContext) context; + XObject var = xpc.getVariable(new QName(varName)); + if (var != null) { + return var.toString(); + } else { + System.out.println("$" + varName + " is not a defined parameter."); + return ""; + } + } catch (TransformerException te) { + System.out.println("Transformer exception getting value of $" + varName); + return ""; + } + } + + public static int getInt(ExpressionContext context, + String varName) { + String stringValue = getString(context, varName); + if (stringValue != null) { + try { + int value = Integer.parseInt(stringValue); + return value; + } catch (NumberFormatException e) { + System.out.println("$" + varName + " is not an integer."); + } + } + return 0; + } + + public static boolean getBoolean(ExpressionContext context, + String varName) { + String stringValue = getString(context, varName); + if (stringValue != null) { + if (stringValue.equals("0") || stringValue.equals("")) { + return false; + } else { + return true; + } + } else { + return false; + } + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/Table.java b/xsl/extensions/xalan2/com/nwalsh/xalan/Table.java new file mode 100644 index 000000000..02b323138 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/Table.java @@ -0,0 +1,532 @@ +// Verbatim.java - Xalan extensions supporting DocBook verbatim environments + +package com.nwalsh.xalan; + +import java.util.Hashtable; +import org.xml.sax.*; +import org.xml.sax.helpers.AttributesImpl; +import org.w3c.dom.*; +import org.w3c.dom.traversal.NodeIterator; + +import javax.xml.transform.TransformerException; + +import org.apache.xpath.objects.XObject; +import org.apache.xpath.XPathContext; +import org.apache.xalan.extensions.ExpressionContext; +import org.apache.xml.utils.DOMBuilder; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.apache.xml.utils.QName; +import org.apache.xml.utils.AttList; + +/** + *

Xalan extensions supporting Tables

+ * + *

$Id$

+ * + *

Copyright (C) 2000 Norman Walsh.

+ * + *

This class provides a + * Xalan + * implementation of some code to adjust CALS Tables to HTML + * Tables.

+ * + *

Column Widths

+ *

The adjustColumnWidths method takes a result tree + * fragment (assumed to contain the colgroup of an HTML Table) + * and returns the result tree fragment with the column widths + * adjusted to HTML terms.

+ * + *

Convert Lengths

+ *

The convertLength method takes a length specification + * of the form 9999.99xx (where "xx" is a unit) and returns that length + * as an integral number of pixels. For convenience, percentage lengths + * are returned unchanged.

+ *

The recognized units are: inches (in), centimeters (cm), + * millimeters (mm), picas (pc, 1pc=12pt), points (pt), and pixels (px). + * A number with no units is assumed to be pixels.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Table { + /** The number of pixels per inch */ + private static int pixelsPerInch = 96; + + /** The hash used to associate units with a length in pixels. */ + protected static Hashtable unitHash = null; + + /** The FO namespace name. */ + protected static String foURI = "http://www.w3.org/1999/XSL/Format"; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Table() { + } + + /** Initialize the internal hash table with proper values. */ + protected static void initializeHash() { + unitHash = new Hashtable(); + unitHash.put("in", new Float(pixelsPerInch)); + unitHash.put("cm", new Float(pixelsPerInch / 2.54)); + unitHash.put("mm", new Float(pixelsPerInch / 25.4)); + unitHash.put("pc", new Float((pixelsPerInch / 72) * 12)); + unitHash.put("pt", new Float(pixelsPerInch / 72)); + unitHash.put("px", new Float(1)); + } + + /** Set the pixels-per-inch value. Only positive values are legal. */ + public static void setPixelsPerInch(int value) { + if (value > 0) { + pixelsPerInch = value; + initializeHash(); + } + } + + /** Return the current pixels-per-inch value. */ + public int getPixelsPerInch() { + return pixelsPerInch; + } + + /** + *

Convert a length specification to a number of pixels.

+ * + *

The specified length should be of the form [+/-]999.99xx, + * where xx is a valid unit.

+ */ + public static int convertLength(String length) { + // The format of length should be 999.999xx + int sign = 1; + String digits = ""; + String units = ""; + char lench[] = length.toCharArray(); + float flength = 0; + boolean done = false; + int pos = 0; + float factor = 1; + int pixels = 0; + + if (unitHash == null) { + initializeHash(); + } + + if (lench[pos] == '+' || lench[pos] == '-') { + if (lench[pos] == '-') { + sign = -1; + } + pos++; + } + + while (!done) { + if (pos >= lench.length) { + done = true; + } else { + if ((lench[pos] > '9' || lench[pos] < '0') && lench[pos] != '.') { + done = true; + units = length.substring(pos); + } else { + digits += lench[pos++]; + } + } + } + + try { + flength = Float.parseFloat(digits); + } catch (NumberFormatException e) { + System.out.println(digits + " is not a number; 1 used instead."); + flength = 1; + } + + Float f = null; + + if (!units.equals("")) { + f = (Float) unitHash.get(units); + if (f == null) { + System.out.println(units + " is not a known unit; 1 used instead."); + factor = 1; + } else { + factor = f.floatValue(); + } + } else { + factor = 1; + } + + f = new Float(flength * factor); + + pixels = f.intValue() * sign; + + return pixels; + } + + /** + *

Find the string value of a stylesheet variable or parameter

+ * + *

Returns the string value of varName in the current + * context. Returns the empty string if the variable is + * not defined.

+ * + * @param context The current stylesheet context + * @param varName The name of the variable (without the dollar sign) + * + * @return The string value of the variable + */ + private String getStringVariable(ExpressionContext context, + String varName) { + try { + XPathContext xpc = (XPathContext) context; + XObject var = xpc.getVariable(new QName(varName)); + if (var != null) { + return var.toString(); + } else { + System.out.println("$" + varName + " is not a defined parameter."); + return ""; + } + } catch (TransformerException te) { + System.out.println("Transformer exception getting value of $" + varName); + return ""; + } + } + + private int getIntVariable(ExpressionContext context, + String varName) { + String stringValue = getStringVariable(context, varName); + if (stringValue != null) { + try { + int value = Integer.parseInt(stringValue); + return value; + } catch (NumberFormatException e) { + System.out.println("$" + varName + " is not an integer."); + } + } + return 0; + } + + private boolean getBooleanVariable(ExpressionContext context, + String varName) { + String stringValue = getStringVariable(context, varName); + if (stringValue != null) { + if (stringValue.equals("0") || stringValue.equals("")) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + *

Adjust column widths in an HTML table.

+ * + *

The specification of column widths in CALS (a relative width + * plus an optional absolute width) are incompatible with HTML column + * widths. This method adjusts CALS column width specifiers in an + * attempt to produce equivalent HTML specifiers.

+ * + *

In order for this method to work, the CALS width specifications + * should be placed in the "width" attribute of the <col>s within + * a <colgroup>. Then the colgroup result tree fragment is passed + * to this method.

+ * + *

This method makes use of two parameters from the XSL stylesheet + * that calls it: nominal.table.width and + * table.width. The value of nominal.table.width + * must be an absolute distance. The value of table.width + * can be either absolute or relative.

+ * + *

Presented with a mixture of relative and + * absolute lengths, the table width is used to calculate + * appropriate values. If the table.width is relative, + * the nominal width is used for this calculation.

+ * + *

There are three possible combinations of values:

+ * + *
    + *
  1. There are no relative widths; in this case the absolute widths + * are used in the HTML table.
  2. + *
  3. There are no absolute widths; in this case the relative widths + * are used in the HTML table.
  4. + *
  5. There are a mixture of absolute and relative widths: + *
      + *
    1. If the table width is absolute, all widths become absolute.
    2. + *
    3. If the table width is relative, make all the widths absolute + * relative to the nominal table width then turn them all + * back into relative widths.
    4. + *
    + *
  6. + *
+ * + * @param context The stylesheet context; supplied automatically by Xalan + * @param rtf The result tree fragment containing the colgroup. + * + * @return The result tree fragment containing the adjusted colgroup. + * + */ + + public DocumentFragment adjustColumnWidths (ExpressionContext context, + NodeIterator xalanNI) { + + int nominalWidth = convertLength(Params.getString(context, + "nominal.table.width")); + String tableWidth = Params.getString(context, "table.width"); + String styleType = Params.getString(context, "stylesheet.result.type"); + boolean foStylesheet = styleType.equals("fo"); + + DocumentFragment xalanRTF = (DocumentFragment) xalanNI.nextNode(); + Element colgroup = (Element) xalanRTF.getFirstChild(); + + // N.B. ...stree.ElementImpl doesn't implement getElementsByTagName() + + Node firstCol = null; + // If this is an FO tree, there might be no colgroup... + if (colgroup.getLocalName().equals("colgroup")) { + firstCol = colgroup.getFirstChild(); + } else { + firstCol = colgroup; + } + + // Count the number of columns... + Node child = firstCol; + int numColumns = 0; + while (child != null) { + if (child.getNodeType() == Node.ELEMENT_NODE + && (child.getNodeName().equals("col") + || (child.getNamespaceURI().equals(foURI) + && child.getLocalName().equals("table-column")))) { + numColumns++; + } + + child = child.getNextSibling(); + } + + String widths[] = new String[numColumns]; + Element columns[] = new Element[numColumns]; + int colnum = 0; + + child = firstCol; + while (child != null) { + if (child.getNodeType() == Node.ELEMENT_NODE + && (child.getNodeName().equals("col") + || (child.getNamespaceURI().equals(foURI) + && child.getLocalName().equals("table-column")))) { + Element col = (Element) child; + NamedNodeMap domAttr = col.getAttributes(); + AttList attr = new AttList(domAttr); + + columns[colnum] = col; + + if (foStylesheet) { + if (attr.getValue("column-width") == null) { + widths[colnum] = "1*"; + } else { + widths[colnum] = attr.getValue("column-width"); + } + } else { + if (attr.getValue("width") == null) { + widths[colnum] = "1*"; + } else { + widths[colnum] = attr.getValue("width"); + } + } + + colnum++; + } + child = child.getNextSibling(); + } + + float relTotal = 0; + float relParts[] = new float[numColumns]; + + float absTotal = 0; + float absParts[] = new float[numColumns]; + + for (int count = 0; count < numColumns; count++) { + String width = widths[count]; + int pos = width.indexOf("*"); + if (pos >= 0) { + String relPart = width.substring(0, pos); + String absPart = width.substring(pos+1); + + try { + float rel = Float.parseFloat(relPart); + relTotal += rel; + relParts[count] = rel; + } catch (NumberFormatException e) { + System.out.println(relPart + " is not a valid relative unit."); + } + + int pixels = 0; + if (absPart != null && !absPart.equals("")) { + pixels = convertLength(absPart); + } + + absTotal += pixels; + absParts[count] = pixels; + } else { + relParts[count] = 0; + + int pixels = 0; + if (width != null && !width.equals("")) { + pixels = convertLength(width); + } + + absTotal += pixels; + absParts[count] = pixels; + } + } + + // Ok, now we have the relative widths and absolute widths in + // two parallel arrays. + // + // - If there are no relative widths, output the absolute widths + // - If there are no absolute widths, output the relative widths + // - If there are a mixture of relative and absolute widths, + // - If the table width is absolute, turn these all into absolute + // widths. + // - If the table width is relative, turn these all into absolute + // widths in the nominalWidth and then turn them back into + // percentages. + + if (relTotal == 0) { + for (int count = 0; count < numColumns; count++) { + Float f = new Float(absParts[count]); + if (foStylesheet) { + int pixels = f.intValue(); + float inches = (float) pixels / pixelsPerInch; + widths[count] = inches + "in"; + } else { + widths[count] = Integer.toString(f.intValue()); + } + } + } else if (absTotal == 0) { + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / relTotal * 100; + Float f = new Float(rel); + widths[count] = Integer.toString(f.intValue()) + "%"; + } + } else { + int pixelWidth = nominalWidth; + + if (tableWidth.indexOf("%") <= 0) { + pixelWidth = convertLength(tableWidth); + } + + if (pixelWidth <= absTotal) { + System.out.println("Table is wider than table width."); + } else { + pixelWidth -= absTotal; + } + + absTotal = 0; + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / relTotal * pixelWidth; + relParts[count] = rel + absParts[count]; + absTotal += rel + absParts[count]; + } + + if (tableWidth.indexOf("%") <= 0) { + for (int count = 0; count < numColumns; count++) { + Float f = new Float(relParts[count]); + if (foStylesheet) { + int pixels = f.intValue(); + float inches = (float) pixels / pixelsPerInch; + widths[count] = inches + "in"; + } else { + widths[count] = Integer.toString(f.intValue()); + } + } + } else { + for (int count = 0; count < numColumns; count++) { + float rel = relParts[count] / absTotal * 100; + Float f = new Float(rel); + widths[count] = Integer.toString(f.intValue()) + "%"; + } + } + } + + // Now rebuild the colgroup with the right widths + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + System.out.println("PCE!"); + return xalanRTF; + } + Document doc = docBuilder.newDocument(); + DocumentFragment df = doc.createDocumentFragment(); + DOMBuilder rtf = new DOMBuilder(doc, df); + + try { + String ns = colgroup.getNamespaceURI(); + String localName = colgroup.getLocalName(); + String name = colgroup.getTagName(); + NamedNodeMap colgroupDomAttr = colgroup.getAttributes(); + AttList colgroupAttr = new AttList(colgroupDomAttr); + + if (colgroup.getLocalName().equals("colgroup")) { + rtf.startElement(ns, localName, name, colgroupAttr); + } + + for (colnum = 0; colnum < numColumns; colnum++) { + Element col = columns[colnum]; + + NamedNodeMap domAttr = col.getAttributes(); + + AttributesImpl attr = new AttributesImpl(); + for (int acount = 0; acount < domAttr.getLength(); acount++) { + Node a = domAttr.item(acount); + String a_ns = a.getNamespaceURI(); + String a_localName = a.getLocalName(); + + if ((foStylesheet && !a_localName.equals("column-width")) + || !a_localName.equalsIgnoreCase("width")) { + attr.addAttribute(a.getNamespaceURI(), + a.getLocalName(), + a.getNodeName(), + "CDATA", + a.getNodeValue()); + } + } + + if (foStylesheet) { + attr.addAttribute("", "column-width", "column-width", "CDATA", widths[colnum]); + } else { + attr.addAttribute("", "width", "width", "CDATA", widths[colnum]); + } + + rtf.startElement(col.getNamespaceURI(), + col.getLocalName(), + col.getTagName(), + attr); + rtf.endElement(col.getNamespaceURI(), + col.getLocalName(), + col.getTagName()); + } + + if (colgroup.getLocalName().equals("colgroup")) { + rtf.endElement(ns, localName, name); + } + } catch (SAXException se) { + System.out.println("SE!"); + return xalanRTF; + } + + return df; + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/Text.java b/xsl/extensions/xalan2/com/nwalsh/xalan/Text.java new file mode 100644 index 000000000..4ca3234b9 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/Text.java @@ -0,0 +1,128 @@ +// Text - Xalan extension element for inserting text + +package com.nwalsh.xalan; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.net.URL; +import java.net.MalformedURLException; + +import org.xml.sax.SAXException; +import org.xml.sax.AttributeList; +import org.xml.sax.ContentHandler; + +import org.w3c.dom.*; +import org.apache.xerces.dom.*; + +import org.apache.xpath.objects.XObject; +import org.apache.xpath.XPath; +import org.apache.xpath.NodeSet; +import org.apache.xalan.extensions.XSLProcessorContext; +import org.apache.xalan.transformer.TransformerImpl; +import org.apache.xalan.templates.StylesheetRoot; +import org.apache.xalan.templates.ElemExtensionCall; +import org.apache.xalan.templates.OutputProperties; +import org.apache.xalan.res.XSLTErrorResources; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.TransformerException; + +/** + *

Xalan extension element for inserting text + * + *

$Id$

+ * + *

Copyright (C) 2001 Norman Walsh.

+ * + *

This class provides a + * Xalan + * extension element for inserting text into a result tree.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Text { + /** + *

Constructor for Text

+ * + *

Does nothing.

+ */ + public Text() { + } + + public NodeList insertfile(XSLProcessorContext context, + ElemExtensionCall elem) + throws MalformedURLException, + FileNotFoundException, + IOException, + TransformerException { + String href = getFilename(context, elem); + + NodeSet textNodes = new NodeSet(); + Document textDoc = DOMImplementationImpl.getDOMImplementation().createDocument(null, "tmpDoc", null); + + URL fileURL = null; + + try { + try { + fileURL = new URL(href); + } catch (MalformedURLException e1) { + try { + fileURL = new URL("file:" + href); + } catch (MalformedURLException e2) { + System.out.println("Cannot open " + href); + return null; + } + } + + InputStreamReader isr = new InputStreamReader(fileURL.openStream()); + BufferedReader is = new BufferedReader(isr); + + char chars[] = new char[4096]; + int len = 0; + while ((len = is.read(chars)) > 0) { + String s = new String(chars, 0, len); + // Does it matter that this produces multiple, adjacent text + // nodes? I don't think so... + textNodes.addNode(textDoc.createTextNode(s)); + } + is.close(); + } catch (Exception e) { + System.out.println("Cannot read " + href); + } + + return textNodes; + } + + private String getFilename(XSLProcessorContext context, ElemExtensionCall elem) + throws java.net.MalformedURLException, + java.io.FileNotFoundException, + java.io.IOException, + javax.xml.transform.TransformerException { + + String fileName; + + fileName = ((ElemExtensionCall)elem).getAttribute ("href", + context.getContextNode(), + context.getTransformer()); + + if(fileName == null) { + context.getTransformer().getMsgMgr().error(elem, + "No 'href' on text, or not a filename"); + } + + return fileName; + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/Verbatim.java b/xsl/extensions/xalan2/com/nwalsh/xalan/Verbatim.java new file mode 100644 index 000000000..6797add57 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/Verbatim.java @@ -0,0 +1,900 @@ +// Verbatim.java - Xalan extensions supporting DocBook verbatim environments + +package com.nwalsh.xalan; + +import java.util.Stack; +import java.util.StringTokenizer; + +import org.xml.sax.*; +import org.xml.sax.helpers.AttributesImpl; +import org.w3c.dom.*; +import org.w3c.dom.traversal.NodeIterator; +import org.apache.xerces.dom.*; + +import org.apache.xpath.objects.XObject; +import org.apache.xpath.XPath; +import org.apache.xpath.XPathContext; +import org.apache.xpath.NodeSet; +import org.apache.xalan.extensions.XSLProcessorContext; +import org.apache.xalan.extensions.ExpressionContext; +import org.apache.xalan.transformer.TransformerImpl; +import org.apache.xalan.templates.StylesheetRoot; +import org.apache.xalan.templates.ElemExtensionCall; +import org.apache.xalan.templates.OutputProperties; +import org.apache.xalan.res.XSLTErrorResources; +import org.apache.xml.utils.DOMBuilder; +import org.apache.xml.utils.AttList; +import org.apache.xml.utils.QName; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.TransformerException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import com.nwalsh.xalan.Callout; +import com.nwalsh.xalan.Params; + +/** + *

Xalan extensions supporting DocBook verbatim environments

+ * + *

$Id$

+ * + *

Copyright (C) 2001 Norman Walsh.

+ * + *

This class provides a + * Xalan + * implementation of two features that would be impractical to + * implement directly in XSLT: line numbering and callouts.

+ * + *

Line Numbering

+ *

The numberLines family of functions takes a result tree + * fragment (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * line numbers.

+ * + *

Callouts

+ *

The insertCallouts family of functions takes an + * areaspec and a result tree fragment + * (assumed to contain the contents of a formatted verbatim + * element in DocBook: programlisting, screen, address, literallayout, + * or synopsis) and returns a result tree fragment decorated with + * callouts.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @version $Id$ + * + */ +public class Verbatim { + /** A stack to hold the open elements while walking through a RTF. */ + private Stack elementStack = null; + /** A stack to hold the temporarily closed elements. */ + private Stack tempStack = null; + /** The current line number. */ + private int lineNumber = 0; + /** The current column number. */ + private int colNumber = 0; + /** The modulus for line numbering (every 'modulus' line is numbered). */ + private int modulus = 0; + /** The width (in characters) of line numbers (for padding). */ + private int width = 0; + /** The separator between the line number and the verbatim text. */ + private String separator = ""; + /** The (sorted) array of callouts obtained from the areaspec. */ + private Callout callout[] = null; + /** The number of callouts in the callout array. */ + private int calloutCount = 0; + /** A pointer used to keep track of our position in the callout array. */ + private int calloutPos = 0; + /** The path to use for graphical callout decorations. */ + private String graphicsPath = null; + /** The extension to use for graphical callout decorations. */ + private String graphicsExt = null; + /** The largest callout number that can be represented graphically. */ + private int graphicsMax = 10; + /** Should graphic callouts use fo:external-graphics or imgs. */ + private boolean graphicsFO = false; + + private static final String foURI = "http://www.w3.org/1999/XSL/Format"; + private static final String xhURI = "http://www.w3.org/1999/xhtml"; + + /** + *

Constructor for Verbatim

+ * + *

All of the methods are static, so the constructor does nothing.

+ */ + public Verbatim() { + } + + /** + *

Number lines in a verbatim environment.

+ * + *

This method adds line numbers to a result tree fragment. Each + * newline that occurs in a text node is assumed to start a new line. + * The first line is always numbered, every subsequent xalanMod line + * is numbered (so if xalanMod=5, lines 1, 5, 10, 15, etc. will be + * numbered. If there are fewer than xalanMod lines in the environment, + * every line is numbered.

+ * + *

xalanMod is taken from the $linenumbering.everyNth parameter.

+ * + *

Every line number will be right justified in a string xalanWidth + * characters long. If the line number of the last line in the + * environment is too long to fit in the specified width, the width + * is automatically increased to the smallest value that can hold the + * number of the last line. (In other words, if you specify the value 2 + * and attempt to enumerate the lines of an environment that is 100 lines + * long, the value 3 will automatically be used for every line in the + * environment.)

+ * + *

xalanWidth is taken from the $linenumbering.width parameter.

+ * + *

The xalanSep string is inserted between the line + * number and the original program listing. Lines that aren't numbered + * are preceded by a xalanWidth blank string and the separator.

+ * + *

xalanSep is taken from the $linenumbering.separator parameter.

+ * + *

If inline markup extends across line breaks, markup changes are + * required. All the open elements are closed before the line break and + * "reopened" afterwards. The reopened elements will have the same + * attributes as the originals, except that 'name' and 'id' attributes + * are not duplicated.

+ * + * @param xalanRTF The result tree fragment of the verbatim environment. + * + * @return The modified result tree fragment. + */ + public DocumentFragment numberLines (ExpressionContext context, + NodeIterator xalanNI) { + + int xalanMod = Params.getInt(context, "linenumbering.everyNth"); + int xalanWidth = Params.getInt(context, "linenumbering.width"); + String xalanSep = Params.getString(context, "linenumbering.separator"); + + DocumentFragment xalanRTF = (DocumentFragment) xalanNI.nextNode(); + int numLines = countLineBreaks(xalanRTF) + 1; + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + System.out.println("PCE!"); + return xalanRTF; + } + Document doc = docBuilder.newDocument(); + DocumentFragment df = doc.createDocumentFragment(); + DOMBuilder db = new DOMBuilder(doc, df); + + elementStack = new Stack(); + lineNumber = 0; + modulus = numLines < xalanMod ? 1 : xalanMod; + width = xalanWidth; + separator = xalanSep; + + double log10numLines = Math.log(numLines) / Math.log(10); + + if (width < log10numLines + 1) { + width = (int) Math.floor(log10numLines + 1); + } + + lineNumberFragment(db, xalanRTF); + return df; + } + + /** + *

Count the number of lines in a verbatim environment.

+ * + *

This method walks over the nodes of a DocumentFragment and + * returns the number of lines breaks that it contains.

+ * + * @param node The root of the tree walk over. + */ + private int countLineBreaks(Node node) { + int numLines = 0; + + if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE + || node.getNodeType() == Node.ELEMENT_NODE) { + Node child = node.getFirstChild(); + while (child != null) { + numLines += countLineBreaks(child); + child = child.getNextSibling(); + } + } else if (node.getNodeType() == Node.TEXT_NODE) { + String text = node.getNodeValue(); + + // Walk through the text node looking for newlines + int pos = 0; + for (int count = 0; count < text.length(); count++) { + if (text.charAt(count) == '\n') { + numLines++; + } + } + } else { + // nop + } + + return numLines; + } + + /** + *

Build a DocumentFragment with numbered lines.

+ * + *

This is the method that actually does the work of numbering + * lines in a verbatim environment. It recursively walks through a + * tree of nodes, copying the structure into the rtf. Text nodes + * are examined for new lines and modified as requested by the + * global line numbering parameters.

+ * + *

When called, rtf should be an empty DocumentFragment and node + * should be the first child of the result tree fragment that contains + * the existing, formatted verbatim text.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param node The root of the tree to copy. + */ + private void lineNumberFragment(DOMBuilder rtf, + Node node) { + try { + if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE) { + Node child = node.getFirstChild(); + while (child != null) { + lineNumberFragment(rtf, child); + child = child.getNextSibling(); + } + } else if (node.getNodeType() == Node.ELEMENT_NODE) { + String ns = node.getNamespaceURI(); + String localName = node.getLocalName(); + String name = ((Element) node).getTagName(); + NamedNodeMap domAttr = node.getAttributes(); + AttList attr = new AttList(domAttr); + + rtf.startElement(ns, localName, name, attr); + elementStack.push(node); + + Node child = node.getFirstChild(); + while (child != null) { + lineNumberFragment(rtf, child); + child = child.getNextSibling(); + } + } else if (node.getNodeType() == Node.TEXT_NODE) { + String text = node.getNodeValue(); + + if (lineNumber == 0) { + // The first line is always numbered + formatLineNumber(rtf, ++lineNumber); + } + + // Walk through the text node looking for newlines + char chars[] = text.toCharArray(); + int pos = 0; + for (int count = 0; count < text.length(); count++) { + if (text.charAt(count) == '\n') { + // This is the tricky bit; if we find a newline, make sure + // it doesn't occur inside any markup. + + if (pos > 0) { + rtf.characters(chars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + // Copy the newline to the output + chars[pos++] = text.charAt(count); + rtf.characters(chars, 0, pos); + pos = 0; + + // Add the line number + formatLineNumber(rtf, ++lineNumber); + + openClosedElements(rtf); + } else { + chars[pos++] = text.charAt(count); + } + } + + if (pos > 0) { + rtf.characters(chars, 0, pos); + } + } else if (node.getNodeType() == Node.COMMENT_NODE) { + String text = node.getNodeValue(); + char chars[] = text.toCharArray(); + rtf.comment(chars, 0, text.length()); + } else if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { + rtf.processingInstruction(node.getNodeName(), node.getNodeValue()); + } else { + System.out.println("Warning: unexpected node type in lineNumberFragment"); + } + + if (node.getNodeType() == Node.ELEMENT_NODE) { + String ns = node.getNamespaceURI(); + String localName = node.getLocalName(); + String name = ((Element) node).getTagName(); + rtf.endElement(ns, localName, name); + elementStack.pop(); + } + } catch (SAXException e) { + System.out.println("SAX Exception in lineNumberFragment"); + } + } + + /** + *

Add a formatted line number to the result tree fragment.

+ * + *

This method examines the global parameters that control line + * number presentation (modulus, width, and separator) and adds + * the appropriate text to the result tree fragment.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param lineNumber The number of the current line. + */ + private void formatLineNumber(DOMBuilder rtf, + int lineNumber) { + char ch = 160; + String lno = ""; + if (lineNumber == 1 + || (modulus >= 1 && (lineNumber % modulus == 0))) { + lno = "" + lineNumber; + } + + while (lno.length() < width) { + lno = ch + lno; + } + + lno += separator; + + char chars[] = lno.toCharArray(); + try { + rtf.characters(chars, 0, lno.length()); + } catch (SAXException e) { + System.out.println("SAX Exception in formatLineNumber"); + } + } + + /** + *

Insert text callouts into a verbatim environment.

+ * + *

This method examines the areaset and area elements + * in the supplied areaspec and decorates the supplied + * result tree fragment with appropriate callout markers.

+ * + *

If a label attribute is supplied on an area, + * its content will be used for the label, otherwise the callout + * number will be used, surrounded by parenthesis. Callouts are + * numbered in document order. All of the areas in an + * areaset get the same number.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn. Lines will be padded with blanks to reach the + * necessary column, but callouts that are located beyond the last + * line of the verbatim environment will be ignored.

+ * + *

Callouts are inserted before the character at the line/column + * where they are to occur.

+ * + * @param areaspecNodeSet The source node set that contains the areaspec. + * @param xalanRTF The result tree fragment of the verbatim environment. + * @param defaultColumn The column for callouts that specify only a line. + * + * @return The modified result tree fragment. */ + + /** + *

Insert graphical callouts into a verbatim environment.

+ * + *

This method examines the areaset and area elements + * in the supplied areaspec and decorates the supplied + * result tree fragment with appropriate callout markers.

+ * + *

If a label attribute is supplied on an area, + * its content will be used for the label, otherwise the callout + * number will be used. Callouts are + * numbered in document order. All of the areas in an + * areaset get the same number.

+ * + *

If the callout number is not greater than gMax, the + * callout generated will be:

+ * + *
+   * <img src="$gPath/conumber$gExt" alt="conumber">
+   * 
+ * + *

Otherwise, it will be the callout number surrounded by + * parenthesis.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn. Lines will be padded with blanks to reach the + * necessary column, but callouts that are located beyond the last + * line of the verbatim environment will be ignored.

+ * + *

Callouts are inserted before the character at the line/column + * where they are to occur.

+ * + * @param areaspecNodeSet The source node set that contains the areaspec. + * @param xalanRTF The result tree fragment of the verbatim environment. + * @param defaultColumn The column for callouts that specify only a line. + * @param gPath The path to use for callout graphics. + * @param gExt The extension to use for callout graphics. + * @param gMax The largest number that can be represented as a graphic. + * @param useFO Should fo:external-graphics be produced, as opposed to + * HTML imgs. This is bogus, the extension should figure it out, but I + * haven't figured out how to do that yet. + * + * @return The modified result tree fragment. + */ + + public DocumentFragment insertCallouts (ExpressionContext context, + NodeIterator areaspecNodeSet, + NodeIterator xalanNI) { + + String type = Params.getString(context, "stylesheet.result.type"); + boolean useFO = type.equals("fo"); + int defaultColumn = Params.getInt(context, "callout.defaultcolumn"); + + if (Params.getBoolean(context, "callout.graphics")) { + String gPath = Params.getString(context, "callout.graphics.path"); + String gExt = Params.getString(context, "callout.graphics.extension"); + int gMax = Params.getInt(context, "callout.graphics.number.limit"); + return insertGraphicCallouts(areaspecNodeSet, xalanNI, defaultColumn, + gPath, gExt, gMax, useFO); + } else if (Params.getBoolean(context, "callout.unicode")) { + int uStart = Params.getInt(context, "callout.unicode.start.character"); + int uMax = Params.getInt(context, "callout.unicode.number.limit"); + return insertUnicodeCallouts(areaspecNodeSet, xalanNI, defaultColumn, + uStart, uMax, useFO); + } else { + return insertTextCallouts(areaspecNodeSet, xalanNI, defaultColumn, useFO); + } + } + + public DocumentFragment insertGraphicCallouts (NodeIterator areaspecNodeSet, + NodeIterator xalanNI, + int defaultColumn, + String gPath, + String gExt, + int gMax, + boolean useFO) { + FormatGraphicCallout fgc = new FormatGraphicCallout(gPath,gExt,gMax,useFO); + return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, fgc); + } + + public DocumentFragment insertUnicodeCallouts (NodeIterator areaspecNodeSet, + NodeIterator xalanNI, + int defaultColumn, + int uStart, + int uMax, + boolean useFO) { + FormatUnicodeCallout fuc = new FormatUnicodeCallout(uStart, uMax, useFO); + return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, fuc); + } + + public DocumentFragment insertTextCallouts (NodeIterator areaspecNodeSet, + NodeIterator xalanNI, + int defaultColumn, + boolean useFO) { + FormatTextCallout ftc = new FormatTextCallout(useFO); + return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, ftc); + } + + public DocumentFragment insertCallouts (NodeIterator areaspecNodeSet, + NodeIterator xalanNI, + int defaultColumn, + FormatCallout fCallout) { + + DocumentFragment xalanRTF = (DocumentFragment) xalanNI.nextNode(); + + callout = new Callout[10]; + calloutCount = 0; + calloutPos = 0; + lineNumber = 1; + colNumber = 1; + + // First we walk through the areaspec to calculate the position + // of the callouts + // + // + // + // + // + // + // + // + int pos = 0; + int coNum = 0; + boolean inAreaSet = false; + Node node = areaspecNodeSet.nextNode(); + node = node.getFirstChild(); + while (node != null) { + if (node.getNodeType() == Node.ELEMENT_NODE) { + if (node.getNodeName().equals("areaset")) { + coNum++; + Node area = node.getFirstChild(); + while (area != null) { + if (area.getNodeType() == Node.ELEMENT_NODE) { + if (area.getNodeName().equals("area")) { + addCallout(coNum, area, defaultColumn); + } else { + System.out.println("Unexpected element in areaset: " + + area.getNodeName()); + } + } + area = area.getNextSibling(); + } + } else if (node.getNodeName().equalsIgnoreCase("area")) { + coNum++; + addCallout(coNum, node, defaultColumn); + } else { + System.out.println("Unexpected element in areaspec: " + + node.getNodeName()); + } + } + + node = node.getNextSibling(); + } + + // Now sort them + java.util.Arrays.sort(callout, 0, calloutCount); + + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = null; + + try { + docBuilder = docFactory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + System.out.println("PCE 2!"); + return xalanRTF; + } + Document doc = docBuilder.newDocument(); + DocumentFragment df = doc.createDocumentFragment(); + DOMBuilder db = new DOMBuilder(doc, df); + + elementStack = new Stack(); + calloutFragment(db, xalanRTF, fCallout); + return df; + } + + /** + *

Build a FragmentValue with callout decorations.

+ * + *

This is the method that actually does the work of adding + * callouts to a verbatim environment. It recursively walks through a + * tree of nodes, copying the structure into the rtf. Text nodes + * are examined for the position of callouts as described by the + * global callout parameters.

+ * + *

When called, rtf should be an empty FragmentValue and node + * should be the first child of the result tree fragment that contains + * the existing, formatted verbatim text.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param node The root of the tree to copy. + */ + private void calloutFragment(DOMBuilder rtf, + Node node, + FormatCallout fCallout) { + try { + if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE) { + Node child = node.getFirstChild(); + while (child != null) { + calloutFragment(rtf, child, fCallout); + child = child.getNextSibling(); + } + } else if (node.getNodeType() == Node.ELEMENT_NODE) { + String ns = node.getNamespaceURI(); + String localName = node.getLocalName(); + String name = ((Element) node).getTagName(); + NamedNodeMap domAttr = node.getAttributes(); + AttList attr = new AttList(domAttr); + + rtf.startElement(ns, localName, name, attr); + elementStack.push(node); + + Node child = node.getFirstChild(); + while (child != null) { + calloutFragment(rtf, child, fCallout); + child = child.getNextSibling(); + } + } else if (node.getNodeType() == Node.TEXT_NODE) { + String text = node.getNodeValue(); + + char chars[] = text.toCharArray(); + int pos = 0; + for (int count = 0; count < text.length(); count++) { + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + if (pos > 0) { + rtf.characters(chars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtf, callout[calloutPos]); + calloutPos++; + } + + openClosedElements(rtf); + } + + if (text.charAt(count) == '\n') { + // What if we need to pad this line? + if (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + + if (pos > 0) { + rtf.characters(chars, 0, pos); + pos = 0; + } + + closeOpenElements(rtf); + + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() > colNumber) { + formatPad(rtf, callout[calloutPos].getColumn() - colNumber); + colNumber = callout[calloutPos].getColumn(); + while (calloutPos < calloutCount + && callout[calloutPos].getLine() == lineNumber + && callout[calloutPos].getColumn() == colNumber) { + fCallout.formatCallout(rtf, callout[calloutPos]); + calloutPos++; + } + } + + openClosedElements(rtf); + } + + lineNumber++; + colNumber = 1; + } else { + colNumber++; + } + chars[pos++] = text.charAt(count); + } + + if (pos > 0) { + rtf.characters(chars, 0, pos); + } + } else if (node.getNodeType() == Node.COMMENT_NODE) { + String text = node.getNodeValue(); + char chars[] = text.toCharArray(); + rtf.comment(chars, 0, text.length()); + } else if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { + rtf.processingInstruction(node.getNodeName(), node.getNodeValue()); + } else { + System.out.println("Warning: unexpected node type in calloutFragment: " + node.getNodeType() + ": " + node.getNodeName()); + } + + if (node.getNodeType() == Node.ELEMENT_NODE) { + String ns = node.getNamespaceURI(); + String localName = node.getLocalName(); + String name = ((Element) node).getTagName(); + rtf.endElement(ns, localName, name); + elementStack.pop(); + } else { + // nop + } + } catch (SAXException e) { + System.out.println("SAX Exception in calloutFragment"); + } + } + + /** + *

Add a callout to the global callout array

+ * + *

This method examines a callout area and adds it to + * the global callout array if it can be interpreted.

+ * + *

Only the linecolumn and linerange units are + * supported. If no unit is specifed, linecolumn is assumed. + * If only a line is specified, the callout decoration appears in + * the defaultColumn.

+ * + * @param coNum The callout number. + * @param node The area. + * @param defaultColumn The default column for callouts. + */ + private void addCallout (int coNum, + Node node, + int defaultColumn) { + Element area = (Element) node; + + NamedNodeMap domAttr = node.getAttributes(); + AttList attr = new AttList(domAttr); + + String units = attr.getValue("units"); + String otherUnits = attr.getValue("otherunits"); + String coords = attr.getValue("coords"); + int type = 0; + String otherType = null; + + if (units == null || units.equals("linecolumn")) { + type = Callout.LINE_COLUMN; // the default + } else if (units.equals("linerange")) { + type = Callout.LINE_RANGE; + } else if (units.equals("linecolumnpair")) { + type = Callout.LINE_COLUMN_PAIR; + } else if (units.equals("calspair")) { + type = Callout.CALS_PAIR; + } else { + type = Callout.OTHER; + otherType = otherUnits; + } + + if (type != Callout.LINE_COLUMN + && type != Callout.LINE_RANGE) { + System.out.println("Only linecolumn and linerange units are supported"); + return; + } + + if (coords == null) { + System.out.println("Coords must be specified"); + return; + } + + // Now let's see if we can interpret the coordinates... + StringTokenizer st = new StringTokenizer(coords); + int tokenCount = 0; + int c1 = 0; + int c2 = 0; + while (st.hasMoreTokens()) { + tokenCount++; + if (tokenCount > 2) { + System.out.println("Unparseable coordinates"); + return; + } + try { + String token = st.nextToken(); + int coord = Integer.parseInt(token); + c2 = coord; + if (tokenCount == 1) { + c1 = coord; + } + } catch (NumberFormatException e) { + System.out.println("Unparseable coordinate"); + return; + } + } + + // Make sure we aren't going to blow past the end of our array + if (calloutCount == callout.length) { + Callout bigger[] = new Callout[calloutCount+10]; + for (int count = 0; count < callout.length; count++) { + bigger[count] = callout[count]; + } + callout = bigger; + } + + // Ok, add the callout + if (tokenCount == 2) { + if (type == Callout.LINE_RANGE) { + for (int count = c1; count <= c2; count++) { + callout[calloutCount++] = new Callout(coNum, area, + count, defaultColumn, + type); + } + } else { + // assume linecolumn + callout[calloutCount++] = new Callout(coNum, area, c1, c2, type); + } + } else { + // if there's only one number, assume it's the line + callout[calloutCount++] = new Callout(coNum, area, c1, defaultColumn, type); + } + } + + /** + *

Add blanks to the result tree fragment.

+ * + *

This method adds numBlanks to the result tree fragment. + * It's used to pad lines when callouts occur after the last existing + * characater in a line.

+ * + * @param rtf The resulting verbatim environment with numbered lines. + * @param numBlanks The number of blanks to add. + */ + private void formatPad(DOMBuilder rtf, + int numBlanks) { + char chars[] = new char[numBlanks]; + for (int count = 0; count < numBlanks; count++) { + chars[count] = ' '; + } + + try { + rtf.characters(chars, 0, numBlanks); + } catch (SAXException e) { + System.out.println("SAX Exception in formatCallout"); + } + } + + private void closeOpenElements(DOMBuilder rtf) + throws SAXException { + // Close all the open elements... + tempStack = new Stack(); + while (!elementStack.empty()) { + Node elem = (Node) elementStack.pop(); + + String ns = elem.getNamespaceURI(); + String localName = elem.getLocalName(); + String name = ((Element) elem).getTagName(); + + // If this is the bottom of the stack and it's an fo:block + // or an HTML pre or div, don't duplicate it... + if (elementStack.empty() + && (((ns != null) + && ns.equals(foURI) + && localName.equals("block")) + || (((ns == null) + && localName.equalsIgnoreCase("pre")) + || ((ns != null) + && ns.equals(xhURI) + && localName.equals("pre"))) + || (((ns == null) + && localName.equalsIgnoreCase("div")) + || ((ns != null) + && ns.equals(xhURI) + && localName.equals("div"))))) { + elementStack.push(elem); + break; + } else { + rtf.endElement(ns, localName, name); + tempStack.push(elem); + } + } + } + + private void openClosedElements(DOMBuilder rtf) + throws SAXException { + // Now "reopen" the elements that we closed... + while (!tempStack.empty()) { + Node elem = (Node) tempStack.pop(); + + String ns = elem.getNamespaceURI(); + String localName = elem.getLocalName(); + String name = ((Element) elem).getTagName(); + NamedNodeMap domAttr = elem.getAttributes(); + + AttributesImpl attr = new AttributesImpl(); + for (int acount = 0; acount < domAttr.getLength(); acount++) { + Node a = domAttr.item(acount); + + if (((ns == null || ns == "http://www.w3.org/1999/xhtml") + && localName.equalsIgnoreCase("a")) + || (a.getLocalName().equalsIgnoreCase("id"))) { + // skip this attribute + } else { + attr.addAttribute(a.getNamespaceURI(), + a.getLocalName(), + a.getNodeName(), + "CDATA", + a.getNodeValue()); + } + } + + rtf.startElement(ns, localName, name, attr); + elementStack.push(elem); + } + + tempStack = null; + } +} diff --git a/xsl/extensions/xalan2/com/nwalsh/xalan/package.html b/xsl/extensions/xalan2/com/nwalsh/xalan/package.html new file mode 100644 index 000000000..92224fa85 --- /dev/null +++ b/xsl/extensions/xalan2/com/nwalsh/xalan/package.html @@ -0,0 +1,48 @@ + + +Norman Walsh's Xalan Extensions Package + + +

Norman Walsh's Xalan Extensions Package for Xalan2

+ +

This package implements Xalan extensions for XSLT.

+ +

Copyright (C) 2000 Norman Walsh

+

Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

+ +

The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

+ +

Except as contained in this notice, the names of individuals +credited with contribution to this software shall not be used in +advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the +individuals in question.

+ +

Anything derived from this Software that is publically +distributed will be identified with a different name and the +version strings in any derived Software will be changed so that no +possibility of confusion between the derived package and this +Software will exist.

+ + +
+

Warranty

+

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER +CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.

+
+ + + diff --git a/xsl/fo/.cvsignore b/xsl/fo/.cvsignore new file mode 100644 index 000000000..c7dc21b88 --- /dev/null +++ b/xsl/fo/.cvsignore @@ -0,0 +1 @@ +titlepage.templates.xsl diff --git a/xsl/fo/Makefile b/xsl/fo/Makefile new file mode 100644 index 000000000..0afd45c75 --- /dev/null +++ b/xsl/fo/Makefile @@ -0,0 +1,4 @@ +all: titlepage.templates.xsl + +titlepage.templates.xsl: titlepage.templates.xml ../template/titlepage.xsl + saxon $< ../template/titlepage.xsl $@ diff --git a/xsl/fo/admon.xsl b/xsl/fo/admon.xsl new file mode 100644 index 000000000..6280ff8a5 --- /dev/null +++ b/xsl/fo/admon.xsl @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + 36pt + + + + + + + note + warning + caution + tip + important + note + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/autoidx.xsl b/xsl/fo/autoidx.xsl new file mode 100644 index 000000000..29731937f --- /dev/null +++ b/xsl/fo/autoidx.xsl @@ -0,0 +1,332 @@ + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/autotoc.xsl b/xsl/fo/autotoc.xsl new file mode 100644 index 000000000..ac5c526d0 --- /dev/null +++ b/xsl/fo/autotoc.xsl @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + TableofContents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/biblio.xsl b/xsl/fo/biblio.xsl new file mode 100644 index 000000000..df29b566b --- /dev/null +++ b/xsl/fo/biblio.xsl @@ -0,0 +1,961 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [ + + ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ldquo + + + + rdquo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + copyright + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ldquo + + + + rdquo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/block.xsl b/xsl/fo/block.xsl new file mode 100644 index 000000000..5af1132a6 --- /dev/null +++ b/xsl/fo/block.xsl @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/callout.xsl b/xsl/fo/callout.xsl new file mode 100644 index 000000000..6862916f3 --- /dev/null +++ b/xsl/fo/callout.xsl @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to do callouts with + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + red + + + A callout list contains more than 10 callouts; + callout numbering truncated. + + + + + + + + + + + + + + + + diff --git a/xsl/fo/component.xsl b/xsl/fo/component.xsl new file mode 100644 index 000000000..a490fb0a7 --- /dev/null +++ b/xsl/fo/component.xsl @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/division.xsl b/xsl/fo/division.xsl new file mode 100644 index 000000000..610e8b917 --- /dev/null +++ b/xsl/fo/division.xsl @@ -0,0 +1,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/docbook.xsl b/xsl/fo/docbook.xsl new file mode 100644 index 000000000..27eaa17ca --- /dev/null +++ b/xsl/fo/docbook.xsl @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + < + + > + + </ + + > + + + + + + + + + + Making + + pages on + + paper ( + + x + + ) + + + + + + + + + [could not find document title] + + + + + + + + + + + + ID ' + + ' not found in document. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/fo.xsl b/xsl/fo/fo.xsl new file mode 100644 index 000000000..9caa42958 --- /dev/null +++ b/xsl/fo/fo.xsl @@ -0,0 +1,36 @@ + + + + + + + bullet + + o + © + + + ® + (SM) + " + " + ' + ' + -- + - + o + + + + + diff --git a/xsl/fo/footnote.xsl b/xsl/fo/footnote.xsl new file mode 100644 index 000000000..014f34efb --- /dev/null +++ b/xsl/fo/footnote.xsl @@ -0,0 +1,58 @@ + + + + + + + + + [ + + ] + + + + + + + + + + + [ + + ] + + + + + + + + + + + + + + [ + + ] + + + + + diff --git a/xsl/fo/fop.xsl b/xsl/fo/fop.xsl new file mode 100644 index 000000000..9fb64c5ae --- /dev/null +++ b/xsl/fo/fop.xsl @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/formal.xsl b/xsl/fo/formal.xsl new file mode 100644 index 000000000..129ce9e85 --- /dev/null +++ b/xsl/fo/formal.xsl @@ -0,0 +1,133 @@ + + + + + + + + + + + + keep-with-previous.within-column="always"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fixed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fixed + + + + + + + + + + diff --git a/xsl/fo/glossary.xsl b/xsl/fo/glossary.xsl new file mode 100644 index 000000000..bcf35f7fe --- /dev/null +++ b/xsl/fo/glossary.xsl @@ -0,0 +1,292 @@ + + + + + + + +2in +0.25in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/graphics.xsl b/xsl/fo/graphics.xsl new file mode 100644 index 000000000..a19ef6d3d --- /dev/null +++ b/xsl/fo/graphics.xsl @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + file: + + + + + Expected @entityref or @fileref on + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + % + auto + + + + + + + + + + + + auto + + + + + + + + + + + + auto + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to insert files with + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to insert files with + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/index.xsl b/xsl/fo/index.xsl new file mode 100644 index 000000000..f6095712e --- /dev/null +++ b/xsl/fo/index.xsl @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + , + + + + + + + + + + + + + + diff --git a/xsl/fo/info.xsl b/xsl/fo/info.xsl new file mode 100644 index 000000000..bca6ce082 --- /dev/null +++ b/xsl/fo/info.xsl @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/inline.xsl b/xsl/fo/inline.xsl new file mode 100644 index 000000000..939ab8d9a --- /dev/null +++ b/xsl/fo/inline.xsl @@ -0,0 +1,576 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + element + + + + + + + + + + + + + + + + + </ + + > + + + + + + + & + + ; + + + + + + + &# + + ; + + + + + + + % + + ; + + + + + + + <? + + > + + + + + + + < + + > + + + + + + + <!-- + + --> + + + + + + + + + + + + + < + + > + + + + + + + + + + + + - + - + - + + - + + + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + + + + + + + + + + + -> + + + + + + + + + + + + + + + + + + + + + + + + [ + + ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/keywords.xsl b/xsl/fo/keywords.xsl new file mode 100644 index 000000000..2303b35d2 --- /dev/null +++ b/xsl/fo/keywords.xsl @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/xsl/fo/lists.xsl b/xsl/fo/lists.xsl new file mode 100644 index 000000000..4889c72c6 --- /dev/null +++ b/xsl/fo/lists.xsl @@ -0,0 +1,536 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + em + + + + 1in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + 1 + 1 + + 1 + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + 1 + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : ??? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ??? + + + + + + + + diff --git a/xsl/fo/math.xsl b/xsl/fo/math.xsl new file mode 100644 index 000000000..23c0585cd --- /dev/null +++ b/xsl/fo/math.xsl @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/pagesetup.xsl b/xsl/fo/pagesetup.xsl new file mode 100644 index 000000000..54dad59fe --- /dev/null +++ b/xsl/fo/pagesetup.xsl @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + titlepage2 + + twoside2 + + + + + + + + titlepage1 + + twoside1 + + + + + + + + titlepage2 + + oneside2 + + + + + + + + titlepage1 + + oneside1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/param.xsl b/xsl/fo/param.xsl new file mode 100644 index 000000000..9db4d1d16 --- /dev/null +++ b/xsl/fo/param.xsl @@ -0,0 +1,1111 @@ + + + + + + + + +$Id$ + +Walsh +Norman +19992000 +Norman Walsh + + +Formatting Object Parameter Reference + + +
Introduction + +This is technical reference documentation for the DocBook XSL +Stylesheets; it documents (some of) the parameters, templates, and +other elements of the stylesheets. + +This reference describes each of the Formatting Object +Stylesheet parameters. These are the easily +customizable parts of the stylesheet. If you want to specify +an alternate value for one or more of these parameters, you can do so +in a driver stylesheet. + +For example, if you want to turn on automatic section numbering, +you might create a driver stylesheet like this: + + + + + + + +]]> + +Naturally, you have to change the +href attribute on +<xsl:import> +to point to docbook.xsl +on your system. + +This is not intended to be user documentation. +It is provided for developers writing customization layers for the +stylesheets, and for anyone who's interested in how it +works. + +Although I am trying to be thorough, this documentation is known +to be incomplete. Don't forget to read the source, too :-) +
+
+
+ + +docbook.css +text/css + + +kr + + + + +../images/ + + + + + +Extension for admonition graphics + +Sets the extension to use on admonition graphics. + + + + + + + + + + +. + + + + + +Are divisions in QAndASets enumerated? + +If true (non-zero), unlabeled qandadivs will be enumerated. + + + + + + + + +Does enumeration of QandASet components inherit the numeration of parent elements? + +If true (non-zero), numbered QandADiv elements and Questions and Answers inherit +the numeration of the ancestors of the QandASet. + + + + + + + + + +Default extension for graphic filenames + +If a graphic or mediaobject +includes a reference to a filename that does not include an extension, +and the format attribute is +unspecified, the default extension will be used. + + + + + + + bold + 12pt + false + always + + + +Properties of formal object titles + +This attribute set is used to specify the properties of formal +object titles. + + + + + + + 2em + 1.8em + 2.2em + bold + 18pt + 1.5em + 1.3em + 1.8em + false + always + + + +Properties of component titles + +This attribute set is used to specify the properties of component +titles. + + + + + + + 14pt + bold + false + always + + + +Properties of admonition titles + +This attribute set is used to specify the properties of admonition +titles. + + + + + + + 0.5em + 1em + 2em + 0.5em + 1em + 2em + + + + + + + + +Visual properties of hotlinks + +This attribute set is used to specify properties of xrefs + + + + + + + +Turns page numbers in xrefs on and off + +When equal to 1, this parameter triggers generation of page +number citations after xrefs. + + + + + + + 1em + 0.8em + 1.2em + + + +Spacing properties of normal paragraphs + +This attribute set is used to specify the spacing properties +of normal paragraphs. + + + + + + + + 1em + 0.8em + 1.2em + + + +Spacing properties of list blocks + +This attribute set is used to specify the spacing properties +of list blocks. + + + + + + + + 1em + 0.8em + 1.2em + + + +Spacing properties of list items + +This attribute set is used to specify the spacing properties +of list items. + + + + + + + + +Specify the root element to format + +If rootid is specified, it must be the +value of an ID that occurs in the document being formatted. The entire +document will be loaded and parsed, but formatting will begin at the +element identified, rather than at the root. For example, this allows +you to process only chapter 4 of a book. +Because the entire document is available to the processor, automatic +numbering, cross references, and other dependencies are correctly +resolved. + + + + + + + +Use graphics for callouts? + +If non-zero, callouts are presented with graphics (e.g., reverse-video +circled numbers instead of "(1)", "(2)", etc.). +Default graphics are provided in the distribution. + + + + + + + + +First character to use for Unicode callouts + +If non-zero, callouts are presented with Unicode characters +starting with the character specified. Zero indicates that Unicode +callouts should not be used. + + + + + + + + +Use Zapf Dingbats for callouts? + +If non-zero, callouts are presented with Zapf Dingbats. + + + + + + + + +Number of the largest callout graphic + +If callout.graphics +is non-zero, graphics are used to represent +callout numbers. The value of +callout.graphics.number.limit +is +the largest number for which a graphic exists. If the callout number +exceeds this limit, the default presentation "(nnn)" will always +be used. + + + + + + + + +Number of the largest callout graphic + +If callout.graphics +is non-zero, graphics are used to represent +callout numbers. The value of +callout.graphics.number.limit +is +the largest number for which a graphic exists. If the callout number +exceeds this limit, the default presentation "(nnn)" will always +be used. + + + + + + + + +Extension for callout graphics + +Sets the extension to use on callout graphics. + + + + + + + +Path to callout graphics + +Sets the path, probably relative to the directory where the HTML +files are created, to the callout graphics. + + + + + + + + +Number of the largest callout graphic + +If callout.graphics +is non-zero, graphics are used to represent +callout numbers. The value of +callout.graphics.number.limit +is +the largest number for which a graphic exists. If the callout number +exceeds this limit, the default presentation "(nnn)" will always +be used. + + + + + + + + +Enable extensions + +If non-zero, extensions may be used. Each extension is +further controlled by its own parameter. But if +use.extensions is zero, no extensions will +be used. + + + + + + + + +Enable the textinsert extension element + +The textinsert extension element inserts the contents of a +a file into the result tree (as text). + + + + + + + + +Enable the line numbering extension + +If true, verbatim environments (elements that have the +format='linespecific' notation attribute: address, literallayout, +programlisting, screen, synopsis) that specify line numbering will +have, surprise, line numbers. + + + + + + + + +Indicate which lines should be numbered + +If line numbering is enabled, everyNth line will be numbered. + + + + + + + + +Indicates the width of line numbers + +If line numbering is enabled, line numbers will appear right +justified in a field "width" characters wide. + + + + + + + + +Specify a separator between line numbers and lines + +The separator is inserted between line numbers and lines in +the verbatim environment. + + + + + + + + +Enable the callout extension + +The callouts extension processes areaset +elements in ProgramListingCO and other text-based +callout elements. + + + + + + + + +Indicates what column callouts appear in by default + +If a callout does not identify a column (for example, if it uses +the linerange unit), +it will appear in the default column. + + + + + + + + +Enable the table columns extension function + +The table columns extension function adjusts the widths of table +columns in the HTML result to more accurately reflect the specifications +in the CALS table. + + + + + + + + +The (absolute) nominal width of tables + +In order to convert CALS column widths into FO column widths, it +is sometimes necessary to have an absolute table width to use for conversion +of mixed absolute and relative widths. This value must be an absolute +length (not a percentage). + + + + + + + +The default width of tables + +If specified, this value will be used for the WIDTH attribute on +tables that do not specify an alternate width (with the dbhtml processing +instruction). + + + + + + +Select the paper type + +The paper type is a convenient way to specify the paper size. +The list of known paper sizes includes USletter and most of the A, +B, and C sizes. See page.width.portrait, for example. + + + + + + + +Select the page orientation + +In portrait orientation, the short edge is horizontal; in +landscape orientation, it is vertical. + + + + + + + + 8.5in + 1682mm + 1189mm + 841mm + 594mm + 420mm + 297mm + 210mm + 148mm + 105mm + 74mm + 52mm + 37mm + 26mm + 1000mm + 707mm + 500mm + 353mm + 250mm + 176mm + 125mm + 88mm + 62mm + 44mm + 31mm + 917mm + 648mm + 458mm + 324mm + 229mm + 162mm + 114mm + 81mm + 57mm + 40mm + 28mm + 8.5in + + + + +Specify the physical size of the short edge of the page + +The portrait page width is the length of the short +edge of the physical page. + + + + + + + + 210mm + 11in + 8.5in + 2378mm + 1682mm + 1189mm + 841mm + 594mm + 420mm + 297mm + 210mm + 148mm + 105mm + 74mm + 52mm + 37mm + 1414mm + 1000mm + 707mm + 500mm + 353mm + 250mm + 176mm + 125mm + 88mm + 62mm + 44mm + 1297mm + 917mm + 648mm + 458mm + 324mm + 229mm + 162mm + 114mm + 81mm + 57mm + 40mm + 11in + + + + +Specify the physical size of the long edge of the page + +The portrait page height is the length of the long +edge of the physical page. + + + + + + + + + + + + + + + + + +The width of the physical page + +The page width is generally calculated from the +paper.type and +page.orientation. + + + + + + + + + + + + + + + + + +The height of the physical page + +The page height is generally calculated from the +paper.type and +page.orientation. + + + + + + + + +Is the document to be printed double sided? + +Double-sided documents are printed with a slightly wider margin +on the binding edge of the page. + +FIXME: The current set of parameters does not take writing direction +into account. + + + + + + + +Specifies the number of columns of text on the page + +The specified number of columns of text will appear on each page. + + + + + + + + +Specifies the height of the footer. + +The region after extent is the height of the area where footers +are printed. + + + + + + + + +Specifies the height of the header + +The region before extent is the height of the area where headers +are printed. + + + + + +1in + + +The top margin of the page + +The top page margin is the distance from the physical top of the +page to the first line of text (body or header). + + + + + +1in + + +The bottom margin of the page + +The bottom page margin is the distance from the physical bottom of +the page to the last line of text (body or footer). + + + + + + + + 1.25in + 1in + + + + +The inner page margin + +The inner page margin is the distance from binding edge of the +page to the first column of text. In the left-to-right, top-to-bottom writing +direction, this is the left margin of recto pages. +The inner and outer margins are usually the same unless the output +is double-sided. + + + + + + + + 0.75in + 10pc + + + + +The outer page margin + +The outer page margin is the distance from non-binding edge of the +page to the last column of text. In the left-to-right, top-to-bottom writing +direction, this is the right margin of recto pages. +The inner and outer margins are usually the same unless the output +is double-sided. + + + + + +24pt + + +The bottom margin of the body text + +The body bottom margin is the distance from the last line of text +in the page body to the bottom page margin. Note that the page footer, if +any, appears in the space between the body bottom margin and the page +bottom margin. + + + + + +24pt + + +FIXME: + +The body top margin is the distance from the page top margin to +the first line of text +in the page body. Note that the page header, if +any, appears in the space between the page top margin and the body +top margin. + + + + + +Times Roman + + +The default font family for body text + +The body font family is the default font used for text in the page body. + + + + + +Helvetica + + +The default font family for titles + +The title font family is used for titles (chapter, section, figure, +etc.) + + + + + +Courier + + +The default font family for monospace environments + +The monospace font family is used for verbatim environments +(program listings, screens, etc.). + + + + + +Helvetica + + +The default sans-serif font family + +The default sans-serif font family. At the present, this isn't +actually used by the stylesheets. + + + + + +10 + + +Specifies the default point size for body text + +The body font size is specified in two parameters +(body.font.master and body.font.size) +so that math can be performed on the font size by XSLT. + + + + + + + pt + + + +Specifies the default font size for body text + +The body font size is specified in two parameters +(body.font.master and body.font.size) +so that math can be performed on the font size by XSLT. + + + + + + + pt + + + +The font size for footnotes + +The footnote font size is used for...footnotes! + + + + + + +true + + +Specify hyphenation behavior + +If true, words may be hyphenated. Otherwise, they may not. + + + + + +justify + + +Specify the default text alignment + +The default text alignment is used for most body text. + + + + + + + + +Identifies the output format of this stylesheet + +The extension functions need to know if the output format +is HTML ('html') or XSL Formatting Objects ('fo'). This variable answers +that question. Valid settings are 'html' or 'fo'. + + + + + + + +Generate a table of contents for components? + +If non-zero, a table of contents is generated at the beginning +of each component (chapters, appendixes, etc.) + + + + + + + + +Generate a table of contents for divisions? + +If non-zero, a table of contents is generated at the beginning +of each division (sets, books, etc.) + + + + + + + + +Generate a list of titles for Figures? + +If non-zero, a list of titles is generated for Figures. + + + + + + + + +Generate a list of titles for Examples? + +If non-zero, a list of titles is generated for Examples. + + + + + + + + +Generate a list of titles for Equations? + +If non-zero, a list of titles is generated for Equations. + + + + + + + + +Generate a list of titles for Tables? + +If non-zero, a list of titles is generated for Tables. + + + + + + + + +Enable PassiveTeX extensions? + +If non-zero, +PassiveTeX +extensions will be used. At present, this consists of PDF bookmarks +and sorted index terms. + + + + + + + + +Enable FOP extensions? + +If non-zero, +FOP +extensions will be used. At present, this consists of PDF bookmarks. + + + + + + + + +Default units for an unqualified dimension + +If an unqualified dimension is encountered (for example, in a +graphic width), the default-units will be used for the +units. Unqualified dimensions are not allowed in XSL Formatting Objects. + + + + + + + + +
+ diff --git a/xsl/fo/pi.xsl b/xsl/fo/pi.xsl new file mode 100644 index 000000000..72c574ce5 --- /dev/null +++ b/xsl/fo/pi.xsl @@ -0,0 +1,183 @@ + + + + + + + + + + + + + filename + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + filename + + + + + + + + dir + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + No cmdsynopsis elements matched dbcmdlist PI, perhaps it's nested too deep? + + + +
+ + + +
+
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+ + + + + + No funcsynopsis elements matched dbfunclist PI, perhaps it's nested too deep? + + + +
+ + + +
+
+ + + + diff --git a/xsl/fo/qandaset.xsl b/xsl/fo/qandaset.xsl new file mode 100644 index 000000000..412f68211 --- /dev/null +++ b/xsl/fo/qandaset.xsl @@ -0,0 +1,23 @@ + + + + + +number + + + + + + + + diff --git a/xsl/fo/refentry.xsl b/xsl/fo/refentry.xsl new file mode 100644 index 000000000..b1ccdc051 --- /dev/null +++ b/xsl/fo/refentry.xsl @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + em-dash + + + + + + + + + + + + + + : + + + + + + + + + Synopsis (what about the title?) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/sections.xsl b/xsl/fo/sections.xsl new file mode 100644 index 000000000..a544f0891 --- /dev/null +++ b/xsl/fo/sections.xsl @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + end-on-even + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + 18 + 16 + 14 + 12 + 12 + 10 + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/synop.xsl b/xsl/fo/synop.xsl new file mode 100644 index 000000000..4eb9a04bc --- /dev/null +++ b/xsl/fo/synop.xsl @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (void); + + + (); + + + + + + (...); + + + + + + + ( + + + + + + + + + + + , + + + ); + + + + + + + + + + + + + + + , + + + + + + ; + + + + ( + + ) + + + + + diff --git a/xsl/fo/table.xsl b/xsl/fo/table.xsl new file mode 100644 index 000000000..d677e4532 --- /dev/null +++ b/xsl/fo/table.xsl @@ -0,0 +1,711 @@ + + + + + + + + +$Id$ + +Walsh +Norman +19992000 +Norman Walsh + + +Formatting Object Table Reference + + +
Introduction + +This is technical reference documentation for the DocBook XSL +Stylesheets; it documents (some of) the parameters, templates, and +other elements of the stylesheets. + +This is not intended to be user documentation. +It is provided for developers writing customization layers for the +stylesheets, and for anyone who's interested in how it +works. + +Although I am trying to be thorough, this documentation is known +to be incomplete. Don't forget to read the source, too :-) +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to do adjust column widths with + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + 1* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Calculate an XSL FO table column width specification from a +CALS table column width specification. + + +CALS expresses table column widths in the following basic +forms: + + + +99.99units, a fixed length specifier. + + +99.99, a fixed length specifier without any units. + + +99.99*, a relative length specifier. + + +99.99*+99.99units, a combination of both. + + + +The CALS units are points (pt), picas (pi), centimeters (cm), +millimeters (mm), and inches (in). These are the same units as XSL, +except that XSL abbreviates picas "pc" instead of "pi". If a length +specifier has no units, the CALS default unit (pt) is assumed. + +Relative length specifiers are represented in XSL with the +proportional-column-width() function. + +Here are some examples: + + + +"36pt" becomes "36pt" + + +"3pi" becomes "3pc" + + +"36" becomes "36pt" + + +"3*" becomes "proportional-column-width(3)" + + +"3*+2pi" becomes "proportional-column-width(3)+2pc" + + +"1*+2" becomes "proportional-column-width(1)+2pt" + + + + + + +colwidth + +The CALS column width specification. + + + + + + +The XSL column width specification. + + + + + 1* + + + + + + + + + + + proportional-column-width( + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pc + pt + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/xsl/fo/titlepage.templates.xml b/xsl/fo/titlepage.templates.xml new file mode 100644 index 000000000..f479b22bb --- /dev/null +++ b/xsl/fo/titlepage.templates.xml @@ -0,0 +1,877 @@ + + + + + + + + + + + + +]> + + + + + + + + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="set" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + named-template="division.title" + param:node="ancestor-or-self::set[1]" + fo:font-size="&hsize5;" + fo:space-before="&hsize5space;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="book" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + named-template="division.title" + param:node="ancestor-or-self::book[1]" + fo:font-size="&hsize5;" + fo:space-before="&hsize5space;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-size="&hsize4;" + fo:space-before="&hsize4space;" + fo:font-family="{$title.font.family}"/> + <corpauthor fo:font-size="&hsize3;" + fo:keep-with-next="always" + fo:space-before="2in"/> + <authorgroup fo:space-before="2in"/> + <author fo:font-size="&hsize3;" + fo:space-before="&hsize2space;" + fo:keep-with-next="always"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + <title predicate="[1]" + fo:font-size="&hsize2;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <pubdate fo:space-before="1em"/> + <copyright/> + <abstract/> + <legalnotice fo:font-size="8pt"/> + </t:titlepage-content> + + <t:titlepage-separator> + <fo:block break-after="page"/> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + <fo:block break-after="page"/> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="part" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + named-template="division.title" + param:node="ancestor-or-self::part[1]" + fo:font-size="&hsize5;" + fo:space-before="&hsize5space;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-size="&hsize4;" + fo:space-before="&hsize4space;" + fo:font-weight='bold' + fo:font-style='italic' + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="partintro" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:margin-left="-4pc" + fo:space-before="1em" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-size="&hsize2;" + fo:font-weight="bold" + fo:font-style="italic" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="reference" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + named-template="division.title" + param:node="ancestor-or-self::reference[1]" + fo:font-size="&hsize5;" + fo:space-before="&hsize5space;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="dedication" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::dedication[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-family="{$title.font.family}" + fo:font-weight="bold"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="preface" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::preface[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-family="{$title.font.family}" + fo:font-weight="bold"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="chapter" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + named-template="component.title" + param:node="ancestor-or-self::chapter[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:space-before="0.5em" + fo:margin-left="-4pc" + fo:font-style="italic" + fo:font-size="&hsize2;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="appendix" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + named-template="component.title" + param:node="ancestor-or-self::appendix[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="section" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect1" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect2" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect3" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect4" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect5" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="simplesect" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + fo:margin-left="-4pc" + fo:font-family="{$title.font.family}"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="bibliography" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::bibliography[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-family="{$title.font.family}" + fo:font-weight="bold"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="glossary" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::glossary[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-family="{$title.font.family}" + fo:font-weight="bold"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="index" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::index[1]" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-family="{$title.font.family}" + fo:font-weight="bold"/> + <subtitle predicate="[1]" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="table.of.contents" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="gentext" + param:key="'TableofContents'" + fo:space-after="1em" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + + <t:titlepage element="list.of.tables" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="gentext" + param:key="'ListofTables'" + fo:space-after="1em" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + + <t:titlepage element="list.of.figures" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="gentext" + param:key="'ListofFigures'" + fo:space-after="1em" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + + <t:titlepage element="list.of.examples" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="gentext" + param:key="'ListofExamples'" + fo:space-after="1em" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + + <t:titlepage element="list.of.equations" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="gentext" + param:key="'ListofEquations'" + fo:space-after="1em" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + + <t:titlepage element="list.of.unknowns" wrapper="fo:block"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="gentext" + param:key="'ListofUnknown'" + fo:space-after="1em" + fo:margin-left="-4pc" + fo:font-size="&hsize3;" + fo:font-weight="bold" + fo:font-family="{$title.font.family}"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> + </t:titlepage> + +<!-- ==================================================================== --> + +</t:templates> diff --git a/xsl/fo/titlepage.xsl b/xsl/fo/titlepage.xsl new file mode 100644 index 000000000..eeebfd988 --- /dev/null +++ b/xsl/fo/titlepage.xsl @@ -0,0 +1,650 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:attribute-set name="book.titlepage.recto.style"> + <xsl:attribute name="font-family"> + <xsl:value-of select="$title.font.family"/> + </xsl:attribute> + <xsl:attribute name="font-weight">bold</xsl:attribute> + <xsl:attribute name="font-size">12pt</xsl:attribute> + <xsl:attribute name="text-align">center</xsl:attribute> +</xsl:attribute-set> + +<xsl:attribute-set name="book.titlepage.verso.style"> + <xsl:attribute name="font-size">10pt</xsl:attribute> +</xsl:attribute-set> + +<xsl:attribute-set name="article.titlepage.recto.style"/> +<xsl:attribute-set name="article.titlepage.verso.style"/> + +<xsl:attribute-set name="set.titlepage.recto.style"/> +<xsl:attribute-set name="set.titlepage.verso.style"/> + +<xsl:attribute-set name="part.titlepage.recto.style"> + <xsl:attribute name="text-align">center</xsl:attribute> +</xsl:attribute-set> + +<xsl:attribute-set name="part.titlepage.verso.style"/> + +<xsl:attribute-set name="partintro.titlepage.recto.style"/> +<xsl:attribute-set name="partintro.titlepage.verso.style"/> + +<xsl:attribute-set name="reference.titlepage.recto.style"/> +<xsl:attribute-set name="reference.titlepage.verso.style"/> + +<xsl:attribute-set name="dedication.titlepage.recto.style"/> +<xsl:attribute-set name="dedication.titlepage.verso.style"/> + +<xsl:attribute-set name="preface.titlepage.recto.style"/> +<xsl:attribute-set name="preface.titlepage.verso.style"/> + +<xsl:attribute-set name="chapter.titlepage.recto.style"/> +<xsl:attribute-set name="chapter.titlepage.verso.style"/> + +<xsl:attribute-set name="appendix.titlepage.recto.style"/> +<xsl:attribute-set name="appendix.titlepage.verso.style"/> + +<xsl:attribute-set name="bibliography.titlepage.recto.style"/> +<xsl:attribute-set name="bibliography.titlepage.verso.style"/> + +<xsl:attribute-set name="glossary.titlepage.recto.style"/> +<xsl:attribute-set name="glossary.titlepage.verso.style"/> + +<xsl:attribute-set name="index.titlepage.recto.style"/> +<xsl:attribute-set name="index.titlepage.verso.style"/> + +<xsl:attribute-set name="section.titlepage.recto.style"/> +<xsl:attribute-set name="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect1.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect1.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect2.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect2.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect3.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect3.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect4.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect4.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect5.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect5.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="simplesect.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="simplesect.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="table.of.contents.titlepage.recto.style"/> +<xsl:attribute-set name="table.of.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.tables.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.tables.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.figures.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.figures.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.equations.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.equations.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.examples.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.examples.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.unknowns.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.unknowns.contents.titlepage.verso.style"/> + +<!-- ==================================================================== --> + +<xsl:template match="*" mode="titlepage.mode"> + <!-- if an element isn't found in this mode, try the default mode --> + <xsl:apply-templates select="."/> +</xsl:template> + +<xsl:template match="abbrev" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="abstract" mode="titlepage.mode"> + <fo:block> + <xsl:if test="title"> <!-- FIXME: add param for using default title? --> + <xsl:call-template name="formal.object.heading"> + <xsl:with-param name="title"> + <xsl:apply-templates select="." mode="title.markup"/> + </xsl:with-param> + </xsl:call-template> + </xsl:if> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="abstract/title" mode="titlepage.mode"/> + +<xsl:template match="abstract/title" mode="titlepage.abstract.title.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="address" mode="titlepage.mode"> + <!-- use the normal address handling code --> + <xsl:apply-templates select="."/> +</xsl:template> + +<xsl:template match="affiliation" mode="titlepage.mode"> + <fo:block> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="artpagenums" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="author" mode="titlepage.mode"> + <xsl:call-template name="person.name"/> + <xsl:apply-templates select="affiliation" mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="authorblurb" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="authorgroup" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="authorinitials" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="bibliomisc" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="bibliomset" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="collab" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="confgroup" mode="titlepage.mode"> + <fo:block> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="confdates" mode="titlepage.mode"> + <fo:block> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="conftitle" mode="titlepage.mode"> + <fo:block> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="confnum" mode="titlepage.mode"> + <!-- suppress --> +</xsl:template> + +<xsl:template match="contractnum" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="contractsponsor" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="contrib" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="copyright" mode="titlepage.mode"> + <xsl:variable name="years" select="year"/> + <xsl:variable name="holders" select="holder"/> + + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Copyright'"/> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">copyright</xsl:with-param> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="$years" mode="titlepage.mode"/> + <xsl:if test="holder"> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="$holders" mode="titlepage.mode"/> + </xsl:if> +</xsl:template> + +<xsl:template match="year" mode="titlepage.mode"> + <xsl:apply-templates/><xsl:text>, </xsl:text> +</xsl:template> + +<xsl:template match="year[position()=last()]" mode="titlepage.mode"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="holder" mode="titlepage.mode"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="corpauthor" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="corpname" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="date" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="edition" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> + <xsl:call-template name="gentext.space"/> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Edition'"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="editor" mode="titlepage.mode"> + <xsl:call-template name="person.name"/> +</xsl:template> + +<xsl:template match="editor[position()=1]" priority="2" mode="titlepage.mode"> + <xsl:call-template name="gentext.edited.by"/> + <xsl:call-template name="person.name"/> +</xsl:template> + +<xsl:template match="firstname" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="graphic" mode="titlepage.mode"> + <!-- use the normal graphic handling code --> + <xsl:apply-templates select="."/> +</xsl:template> + +<xsl:template match="honorific" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="isbn" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="issn" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="itermset" mode="titlepage.mode"> + <!-- discard --> +</xsl:template> + +<xsl:template match="invpartnumber" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="issuenum" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="jobtitle" mode="titlepage.mode"> + <fo:block> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="keywordset" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="legalnotice" mode="titlepage.mode"> + <fo:block> + <xsl:if test="title"> <!-- FIXME: add param for using default title? --> + <xsl:call-template name="formal.object.heading"> + <xsl:with-param name="title"> + <xsl:apply-templates select="." mode="title.markup"/> + </xsl:with-param> + </xsl:call-template> + </xsl:if> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="legalnotice/title" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="legalnotice/title" mode="titlepage.legalnotice.title.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="lineage" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="modespec" mode="titlepage.mode"> + <!-- discard --> +</xsl:template> + +<xsl:template match="orgdiv" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="orgname" mode="titlepage.mode"> + <fo:block> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="othercredit" mode="titlepage.mode"> + <xsl:call-template name="person.name"/> + <xsl:apply-templates mode="titlepage.mode" select="affiliation"/> +</xsl:template> + +<xsl:template match="othername" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="pagenums" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="printhistory" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="productname" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="productnumber" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="pubdate" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="publishername" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="pubsnumber" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="releaseinfo" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revhistory" mode="titlepage.mode"> + <fo:table table-layout="fixed"> + <fo:table-column column-number="1" column-width="33%"/> + <fo:table-column column-number="2" column-width="33%"/> + <fo:table-column column-number="3" column-width="33%"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell number-columns-spanned="3"> + <fo:block> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'RevHistory'"/> + </xsl:call-template> + </fo:block> + </fo:table-cell> + </fo:table-row> + <xsl:apply-templates mode="titlepage.mode"/> + </fo:table-body> + </fo:table> +</xsl:template> + +<xsl:template match="revhistory/revision" mode="titlepage.mode"> + <xsl:variable name="revnumber" select=".//revnumber"/> + <xsl:variable name="revdate" select=".//date"/> + <xsl:variable name="revauthor" select=".//authorinitials"/> + <xsl:variable name="revremark" select=".//revremark"/> + <fo:table-row> + <fo:table-cell> + <fo:block> + <xsl:if test="$revnumber"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Revision'"/> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/> + </xsl:if> + </fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block> + <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/> + </fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block> + <xsl:apply-templates select="$revauthor[1]" mode="titlepage.mode"/> + </fo:block> + </fo:table-cell> + </fo:table-row> + <xsl:if test="$revremark"> + <fo:table-row> + <fo:table-cell number-columns-spanned="3"> + <fo:block> + <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/> + </fo:block> + </fo:table-cell> + </fo:table-row> + </xsl:if> +</xsl:template> + +<xsl:template match="revision/revnumber" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/date" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/authorinitials" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/revremark" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="seriesvolnums" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="shortaffil" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="subjectset" mode="titlepage.mode"> + <!-- discard --> +</xsl:template> + +<xsl:template match="subtitle" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="surname" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="title" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="titleabbrev" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="volumenum" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<!-- ==================================================================== --> +<!-- Book templates --> + +<!-- book recto --> + +<xsl:template match="authorgroup" mode="book.titlepage.recto.mode"> + <xsl:apply-templates mode="book.titlepage.recto.auto.mode"/> +</xsl:template> + +<!-- book verso --> + +<xsl:template match="title" mode="book.titlepage.verso.mode"> + <fo:block> + <xsl:apply-templates mode="book.titlepage.verso.mode"/> + + <xsl:if test="following-sibling::subtitle + |following-sibling::bookinfo/subtitle"> + <xsl:text>: </xsl:text> + + <xsl:apply-templates select="(following-sibling::subtitle + |following-sibling::bookinfo/subtitle)[1]" + mode="book.titlepage.verso.mode"/> + </xsl:if> + </fo:block> +</xsl:template> + +<xsl:template match="subtitle" mode="book.titlepage.verso.mode"> + <xsl:apply-templates mode="book.titlepage.verso.mode"/> + <xsl:if test="following-sibling::subtitle"> + <xsl:text>: </xsl:text> + <xsl:apply-templates select="following-sibling::subtitle[1]"/> + </xsl:if> +</xsl:template> + +<xsl:template match="bookinfo/author" mode="book.titlepage.verso.mode"> + <fo:block> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'by'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:call-template name="person.name"/> + </fo:block> +</xsl:template> + +<xsl:template match="bookinfo/corpauthor" mode="book.titlepage.verso.mode"> + <fo:block> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'by'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:apply-templates/> + </fo:block> +</xsl:template> + +<xsl:template match="authorgroup" mode="book.titlepage.verso.mode"> + <fo:block> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'by'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:apply-templates mode="book.titlepage.verso.mode"/> + </fo:block> +</xsl:template> + +<xsl:template match="authorgroup/author" mode="book.titlepage.verso.mode"> + <xsl:variable name="before" select="count(preceding-sibling::*)"/> + <xsl:variable name="after" select="count(following-sibling::*)"/> + + <xsl:choose> + <xsl:when test="$before > 1"> + <xsl:text>, </xsl:text> + </xsl:when> + <xsl:when test="$before = 1 and $after > 0"> + <xsl:text>, </xsl:text> + </xsl:when> + </xsl:choose> + + <xsl:if test="$before > 0 and $after = 0"> + <xsl:text> </xsl:text> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'and'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + </xsl:if> + + <xsl:call-template name="person.name"/> +</xsl:template> + +<xsl:template match="authorgroup/corpauthor" mode="book.titlepage.verso.mode"> + <xsl:variable name="before" select="count(preceding-sibling::*)"/> + <xsl:variable name="after" select="count(preceding-sibling::*)"/> + + <xsl:choose> + <xsl:when test="$before > 1"> + <xsl:text>, </xsl:text> + </xsl:when> + <xsl:when test="$before = 1 and $after > 0"> + <xsl:text>, </xsl:text> + </xsl:when> + </xsl:choose> + + <xsl:if test="$after = 0"> + <xsl:text> </xsl:text> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'and'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + </xsl:if> + + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="pubdate" mode="book.titlepage.verso.mode"> + <fo:block> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'published'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:apply-templates mode="book.titlepage.verso.mode"/> + </fo:block> +</xsl:template> + +<!-- ==================================================================== --> +<!-- Part templates --> + +<!-- part recto --> + +<xsl:template match="title" mode="part.titlepage.recto.mode"> + <xsl:apply-templates select="ancestor::part" mode="title.markup"/> +</xsl:template> + +<!-- ==================================================================== --> + +</xsl:stylesheet> diff --git a/xsl/fo/toc.xsl b/xsl/fo/toc.xsl new file mode 100644 index 000000000..ea8c93fc7 --- /dev/null +++ b/xsl/fo/toc.xsl @@ -0,0 +1,21 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template match="toc"> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/fo/verbatim.xsl b/xsl/fo/verbatim.xsl new file mode 100644 index 000000000..693a1176f --- /dev/null +++ b/xsl/fo/verbatim.xsl @@ -0,0 +1,260 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" + xmlns:xverb="com.nwalsh.xalan.Verbatim" + xmlns:lxslt="http://xml.apache.org/xslt" + exclude-result-prefixes="sverb xverb lxslt" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<lxslt:component prefix="xverb" + functions="numberLines"/> + +<xsl:template match="programlisting|screen"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + + <!-- Obey the <?dbfo linenumbering.everyNth="x"?> PI --> + <xsl:variable name="pi.linenumbering.everyNth"> + <xsl:call-template name="dbfo-attribute"> + <xsl:with-param name="attribute" select="'everyNth'"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="everyNth"> + <xsl:choose> + <xsl:when test="$pi.linenumbering.everyNth != ''"> + <xsl:value-of select="$pi.linenumbering.everyNth"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$linenumbering.everyNth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- Obey the <?dbfo linenumbering.separator="x"?> PI --> + <xsl:variable name="pi.linenumbering.separator"> + <xsl:call-template name="dbfo-attribute"> + <xsl:with-param name="attribute" select="'linenumbering.separator'"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="separator"> + <xsl:choose> + <xsl:when test="$pi.linenumbering.separator != ''"> + <xsl:value-of select="$pi.linenumbering.separator"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$linenumbering.separator"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$suppress-numbers = '0' + and @linenumbering = 'numbered' + and $use.extensions != '0' + and $linenumbering.extension != '0'"> + <xsl:variable name="rtf"> + <xsl:apply-templates/> + </xsl:variable> + <fo:block wrap-option='no-wrap' + text-align='start' + white-space-collapse='false' + linefeed-treatment="preserve" + font-family='{$monospace.font.family}' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$separator"/> + </xsl:call-template> + </fo:block> + </xsl:when> + <xsl:otherwise> + <fo:block wrap-option='no-wrap' + text-align='start' + white-space-collapse='false' + linefeed-treatment="preserve" + font-family='{$monospace.font.family}' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:apply-templates/> + </fo:block> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="literallayout"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:variable name="rtf"> + <xsl:apply-templates/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$suppress-numbers = '0' + and @linenumbering = 'numbered' + and $use.extensions != '0' + and $linenumbering.extension != '0'"> + <xsl:choose> + <xsl:when test="@class='monospaced'"> + <fo:block wrap-option='no-wrap' + text-align='start' + linefeed-treatment="preserve" + font-family='{$monospace.font.family}' + white-space-collapse='false' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + </fo:block> + </xsl:when> + <xsl:otherwise> + <fo:block wrap-option='no-wrap' + text-align='start' + linefeed-treatment="preserve" + white-space-collapse='false' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + </fo:block> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="@class='monospaced'"> + <fo:block wrap-option='no-wrap' + text-align='start' + font-family='{$monospace.font.family}' + linefeed-treatment="preserve" + white-space-collapse='false' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:copy-of select="$rtf"/> + </fo:block> + </xsl:when> + <xsl:otherwise> + <fo:block wrap-option='no-wrap' + text-align='start' + linefeed-treatment="preserve" + white-space-collapse='false' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:copy-of select="$rtf"/> + </fo:block> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="address"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:variable name="rtf"> + <xsl:apply-templates/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$suppress-numbers = '0' + and @linenumbering = 'numbered' + and $use.extensions != '0' + and $linenumbering.extension != '0'"> + <fo:block wrap-option='no-wrap' + white-space-collapse='false' + linefeed-treatment="preserve" + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + </fo:block> + </xsl:when> + <xsl:otherwise> + <fo:block wrap-option='no-wrap' + text-align='start' + linefeed-treatment="preserve" + white-space-collapse='false' + space-before.minimum="0.8em" + space-before.optimum="1em" + space-before.maximum="1.2em"> + <xsl:apply-templates/> + </fo:block> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="number.rtf.lines"> + <xsl:param name="rtf" select="''"/> + <!-- the following parameters must have these names ... --> + <xsl:param name="linenumbering.everyNth" select="1"/> + <xsl:param name="linenumbering.width" select="3"/> + <xsl:param name="linenumbering.separator" select="' |'"/> + + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:choose> + <xsl:when test="contains($vendor, 'SAXON ')"> + <xsl:copy-of select="sverb:numberLines($rtf)"/> + </xsl:when> + <xsl:when test="contains($vendor, 'Apache Software Foundation')"> + <xsl:copy-of select="xverb:numberLines($rtf)"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Don't know how to do line numbering with </xsl:text> + <xsl:value-of select="$vendor"/> + </xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/fo/xref.xsl b/xsl/fo/xref.xsl new file mode 100644 index 000000000..21188b4fe --- /dev/null +++ b/xsl/fo/xref.xsl @@ -0,0 +1,305 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fo="http://www.w3.org/1999/XSL/Format" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template match="xref"> + <xsl:variable name="targets" select="id(@linkend)"/> + <xsl:variable name="target" select="$targets[1]"/> + <xsl:variable name="refelem" select="name($target)"/> + + <xsl:call-template name="check.id.unique"> + <xsl:with-param name="linkend" select="@linkend"/> + </xsl:call-template> + + <xsl:choose> + <xsl:when test="$refelem=''"> + <xsl:message> + <xsl:text>XRef to nonexistent id: </xsl:text> + <xsl:value-of select="@linkend"/> + </xsl:message> + <xsl:text>???</xsl:text> + </xsl:when> + + <xsl:when test="$target/@xreflabel"> + <fo:basic-link internal-destination="{@linkend}" + xsl:use-attribute-sets="xref.properties"> + <xsl:call-template name="xref.xreflabel"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + </fo:basic-link> + </xsl:when> + + <xsl:otherwise> + <fo:basic-link internal-destination="{@linkend}" + xsl:use-attribute-sets="xref.properties"> + <xsl:choose> + <xsl:when test="@endterm"> + <xsl:variable name="etargets" select="id(@endterm)"/> + <xsl:variable name="etarget" select="$etargets[1]"/> + <xsl:choose> + <xsl:when test="count($etarget) = 0"> + <xsl:message> + <xsl:value-of select="count($etargets)"/> + <xsl:text>Endterm points to nonexistent ID: </xsl:text> + <xsl:value-of select="@endterm"/> + </xsl:message> + <xsl:text>???</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="$etarget" mode="xref.text"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:otherwise> + <xsl:apply-templates select="$target" mode="xref-to"/> + </xsl:otherwise> + </xsl:choose> + </fo:basic-link> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!--- ==================================================================== --> + +<xsl:template match="*" mode="xref-to"> + <xsl:param name="target" select="."/> + <xsl:param name="refelem" select="local-name($target)"/> + + <xsl:message> + <xsl:text>Don't know what gentext to create for xref to: "</xsl:text> + <xsl:value-of select="$refelem"/> + <xsl:text>"</xsl:text> + </xsl:message> + <xsl:text>???</xsl:text> +</xsl:template> + +<xsl:template match="author" mode="xref-to"> + <xsl:call-template name="person.name"/> +</xsl:template> + +<xsl:template match="figure" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="example" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="table" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="equation" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="cmdsynopsis" mode="xref-to"> + <xsl:apply-templates select="(.//command)[1]" mode="xref"/> +</xsl:template> + +<xsl:template match="funcsynopsis" mode="xref-to"> + <xsl:apply-templates select="(.//function)[1]" mode="xref"/> +</xsl:template> + +<xsl:template match="dedication" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="preface" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="chapter" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="appendix" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="bibliography" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="biblioentry|bibliomixed" mode="xref-to"> + <!-- handles both biblioentry and bibliomixed --> + <xsl:text>[</xsl:text> + <xsl:choose> + <xsl:when test="local-name(*[1]) = 'abbrev'"> + <xsl:apply-templates select="*[1]"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@id"/> + </xsl:otherwise> + </xsl:choose> + <xsl:text>]</xsl:text> +</xsl:template> + +<xsl:template match="glossary" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="index" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="section|simplesect + |sect1|sect2|sect3|sect4|sect5 + |refsect1|refsect2|refsect3" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> + <!-- What about "in Chapter X"? --> +</xsl:template> + +<xsl:template match="question" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="answer" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="part" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="reference" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="co" mode="xref-to"> + <xsl:apply-templates select="." mode="callout-bug"/> +</xsl:template> + +<xsl:template match="book" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="link"> + <xsl:variable name="targets" select="id(@linkend)"/> + <xsl:variable name="target" select="$targets[1]"/> + + <xsl:call-template name="check.id.unique"> + <xsl:with-param name="linkend" select="@linkend"/> + </xsl:call-template> + + <fo:basic-link internal-destination="{@linkend}" + xsl:use-attribute-sets="xref.properties"> + <xsl:apply-templates/> + </fo:basic-link> +</xsl:template> + +<xsl:template match="ulink"> + <fo:basic-link external-destination="{@url}" + xsl:use-attribute-sets="xref.properties"> + <xsl:choose> + <xsl:when test="count(child::node())=0"> + <xsl:value-of select="@url"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </fo:basic-link> + <xsl:if test="count(child::node()) != 0"> + <fo:inline hyphenate="false"> + <xsl:text> [</xsl:text> + <xsl:value-of select="@url"/> + <xsl:text>]</xsl:text> + </fo:inline> + </xsl:if> +</xsl:template> + +<xsl:template match="olink"> + <xsl:apply-templates/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="title.xref"> + <xsl:param name="target" select="."/> + <xsl:choose> + <xsl:when test="local-name($target) = 'figure' + or local-name($target) = 'example' + or local-name($target) = 'equation' + or local-name($target) = 'table' + or local-name($target) = 'dedication' + or local-name($target) = 'preface' + or local-name($target) = 'bibliography' + or local-name($target) = 'glossary' + or local-name($target) = 'index' + or local-name($target) = 'setindex' + or local-name($target) = 'colophon'"> + <xsl:call-template name="gentext.startquote"/> + <xsl:apply-templates select="$target" mode="title.markup"/> + <xsl:call-template name="gentext.endquote"/> + </xsl:when> + <xsl:otherwise> + <fo:inline font-style="italic"> + <xsl:apply-templates select="$target" mode="title.markup"/> + </fo:inline> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="number.xref"> + <xsl:param name="target" select="."/> + <xsl:apply-templates select="$target" mode="label.markup"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="xref.xreflabel"> + <!-- called to process an xreflabel...you might use this to make --> + <!-- xreflabels come out in the right font for different targets, --> + <!-- for example. --> + <xsl:param name="target" select="."/> + <xsl:value-of select="$target/@xreflabel"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="title" mode="xref"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="command" mode="xref"> + <xsl:call-template name="inline.boldseq"/> +</xsl:template> + +<xsl:template match="function" mode="xref"> + <xsl:call-template name="inline.monoseq"/> +</xsl:template> + +<xsl:template name="insert.page.citation"> + <xsl:param name="id" select="'???'"/> + <xsl:if test="$insert.xref.page.number"> + <xsl:text> </xsl:text> + <fo:inline keep-together.within-line="always"> + <xsl:text>[</xsl:text> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'page.citation'"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <fo:page-number-citation ref-id="{$id}"/> + <xsl:text>]</xsl:text> + </fo:inline> + </xsl:if> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/.cvsignore b/xsl/html/.cvsignore new file mode 100644 index 000000000..c7dc21b88 --- /dev/null +++ b/xsl/html/.cvsignore @@ -0,0 +1 @@ +titlepage.templates.xsl diff --git a/xsl/html/Makefile b/xsl/html/Makefile new file mode 100644 index 000000000..0afd45c75 --- /dev/null +++ b/xsl/html/Makefile @@ -0,0 +1,4 @@ +all: titlepage.templates.xsl + +titlepage.templates.xsl: titlepage.templates.xml ../template/titlepage.xsl + saxon $< ../template/titlepage.xsl $@ diff --git a/xsl/html/admon.xsl b/xsl/html/admon.xsl new file mode 100644 index 000000000..09eae16fe --- /dev/null +++ b/xsl/html/admon.xsl @@ -0,0 +1,135 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<xsl:template name="admon.graphic.width"> + <xsl:param name="node" select="."/> + <xsl:text>25</xsl:text> +</xsl:template> + +<xsl:template match="note|important|warning|caution|tip"> + <xsl:choose> + <xsl:when test="$admon.graphics != 0"> + <xsl:call-template name="graphical.admonition"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="nongraphical.admonition"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="admon.graphic"> + <xsl:param name="node" select="."/> + <xsl:value-of select="$admon.graphics.path"/> + <xsl:choose> + <xsl:when test="name($node)='note'">note</xsl:when> + <xsl:when test="name($node)='warning'">warning</xsl:when> + <xsl:when test="name($node)='caution'">caution</xsl:when> + <xsl:when test="name($node)='tip'">tip</xsl:when> + <xsl:when test="name($node)='important'">important</xsl:when> + <xsl:otherwise>note</xsl:otherwise> + </xsl:choose> + <xsl:value-of select="$admon.graphics.extension"/> +</xsl:template> + +<xsl:template name="graphical.admonition"> + <div class="{name(.)}"> + <xsl:if test="$admon.style != ''"> + <xsl:attribute name="style"> + <xsl:value-of select="$admon.style"/> + </xsl:attribute> + </xsl:if> + <table border="0"> + <tr> + <td rowspan="2" align="center" valign="top"> + <xsl:attribute name="width"> + <xsl:call-template name="admon.graphic.width"/> + </xsl:attribute> + <img> + <xsl:attribute name="src"> + <xsl:call-template name="admon.graphic"/> + </xsl:attribute> + </img> + </td> + <th> + <a> + <xsl:attribute name="name"> + <xsl:call-template name="object.id"/> + </xsl:attribute> + </a> + <xsl:apply-templates select="." mode="object.title.markup"/> + </th> + </tr> + <tr> + <td colspan="2" align="left" valign="top"> + <xsl:apply-templates/> + </td> + </tr> + </table> + </div> +</xsl:template> + +<xsl:template name="nongraphical.admonition"> + <div class="{name(.)}"> + <xsl:if test="$admon.style"> + <xsl:attribute name="style"> + <xsl:value-of select="$admon.style"/> + </xsl:attribute> + </xsl:if> + + <h3 class="title"> + <a> + <xsl:attribute name="name"> + <xsl:call-template name="object.id"/> + </xsl:attribute> + </a> + <xsl:apply-templates select="." mode="object.title.markup"/> + </h3> + + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="note/title"></xsl:template> +<xsl:template match="important/title"></xsl:template> +<xsl:template match="warning/title"></xsl:template> +<xsl:template match="caution/title"></xsl:template> +<xsl:template match="tip/title"></xsl:template> + +<xsl:template match="title" mode="admonition.title.mode"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + <h3 class="title"> + <a name="{$id}"> + <xsl:apply-templates/> + </a> + </h3> +</xsl:template> + +<xsl:template match="title" mode="graphic.admonition.title.mode"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + <b class="title"> + <a name="{$id}"> + <xsl:apply-templates/> + </a> + </b> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/autoidx.xsl b/xsl/html/autoidx.xsl new file mode 100644 index 000000000..73eedd8cd --- /dev/null +++ b/xsl/html/autoidx.xsl @@ -0,0 +1,296 @@ +<?xml version="1.0"?> +<!DOCTYPE xsl:stylesheet [ + +<!ENTITY lowercase "abcdefghijklmnopqrstuvwxyz"> +<!ENTITY uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ"> + +<!ENTITY primary 'concat(primary/@sortas, primary[not(@sortas)])'> +<!ENTITY secondary 'concat(secondary/@sortas, secondary[not(@sortas)])'> +<!ENTITY tertiary 'concat(tertiary/@sortas, tertiary[not(@sortas)])'> + +<!ENTITY section '(ancestor-or-self::set + |ancestor-or-self::book + |ancestor-or-self::part + |ancestor-or-self::reference + |ancestor-or-self::partintro + |ancestor-or-self::chapter + |ancestor-or-self::appendix + |ancestor-or-self::preface + |ancestor-or-self::section + |ancestor-or-self::sect1 + |ancestor-or-self::sect2 + |ancestor-or-self::sect3 + |ancestor-or-self::sect4 + |ancestor-or-self::sect5 + |ancestor-or-self::refsect1 + |ancestor-or-self::refsect2 + |ancestor-or-self::refsect3 + |ancestor-or-self::simplesect + |ancestor-or-self::bibliography + |ancestor-or-self::glossary + |ancestor-or-self::index)[last()]'> + +<!ENTITY section.id 'generate-id(§ion;)'> +<!ENTITY sep '" "'> +]> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + +<xsl:import href="docbook.xsl"/> + +<!-- ==================================================================== --> +<!-- Jeni Tennison gets all the credit for what follows. + I think I understand it :-) Anyway, I've hacked it a bit, so the + bugs are mine. --> + +<xsl:key name="letter" + match="indexterm" + use="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/> + +<xsl:key name="primary" + match="indexterm" + use="&primary;"/> + +<xsl:key name="secondary" + match="indexterm" + use="concat(&primary;, &sep;, &secondary;)"/> + +<xsl:key name="tertiary" + match="indexterm" + use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/> + +<xsl:key name="primary-section" + match="indexterm[not(secondary) and not(see)]" + use="concat(&primary;, &sep;, §ion.id;)"/> + +<xsl:key name="secondary-section" + match="indexterm[not(tertiary) and not(see)]" + use="concat(&primary;, &sep;, &secondary;, &sep;, §ion.id;)"/> + +<xsl:key name="tertiary-section" + match="indexterm[not(see)]" + use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, §ion.id;)"/> + +<xsl:key name="see-also" + match="indexterm[seealso]" + use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso)"/> + +<xsl:key name="see" + match="indexterm[see]" + use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/> + +<xsl:key name="sections" match="*[@id]" use="@id"/> + +<xsl:template name="generate-index"> + <xsl:variable name="terms" select="//indexterm[count(.|key('letter', + translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[1]) = 1]"/> + + <xsl:variable name="alphabetical" + select="$terms[contains(concat(&lowercase;, &uppercase;), + substring(&primary;, 1, 1))]"/> + <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;, + &uppercase;), + substring(&primary;, 1, 1)))]"/> + <div class="index"> + <xsl:if test="$others"> + <div class="indexdiv"> + <h3> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'index symbols'"/> + </xsl:call-template> + </h3> + <dl> + <xsl:apply-templates select="$others[count(.|key('primary', + &primary;)[1]) = 1]" + mode="index-primary"> + <xsl:sort select="&primary;"/> + </xsl:apply-templates> + </dl> + </div> + </xsl:if> + <xsl:apply-templates select="$alphabetical[count(.|key('letter', + translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[1]) = 1]" + mode="index-div"> + <xsl:sort select="&primary;"/> + </xsl:apply-templates> + </div> +</xsl:template> + +<xsl:template match="indexterm" mode="index-div"> + <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/> + <div class="indexdiv"> + <h3> + <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/> + </h3> + <dl> + <xsl:apply-templates select="key('letter', $key)[count(.|key('primary', &primary;)[1]) = 1]" + mode="index-primary"> + <xsl:sort select="&primary;"/> + </xsl:apply-templates> + </dl> + </div> +</xsl:template> + +<xsl:template match="indexterm" mode="index-primary"> + <xsl:variable name="key" select="&primary;"/> + <xsl:variable name="refs" select="key('primary', $key)"/> + <dt> + <xsl:value-of select="primary"/> + <xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section', concat($key, &sep;, §ion.id;))[1])]"> + <xsl:apply-templates select="." mode="reference"/> + </xsl:for-each> + </dt> + <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::see or self::seealso]"> + <dd> + <dl> + <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[1])]" + mode="index-see"> + <xsl:sort select="see"/> + </xsl:apply-templates> + <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[1])]" + mode="index-seealso"> + <xsl:sort select="seealso"/> + </xsl:apply-templates> + <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[1]) = 1]" + mode="index-secondary"> + <xsl:sort select="&secondary;"/> + </xsl:apply-templates> + </dl> + </dd> + </xsl:if> +</xsl:template> + +<xsl:template match="indexterm" mode="index-secondary"> + <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/> + <xsl:variable name="refs" select="key('secondary', $key)"/> + <dt> + <xsl:value-of select="secondary"/> + <xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section', concat($key, &sep;, §ion.id;))[1])]"> + <xsl:apply-templates select="." mode="reference"/> + </xsl:for-each> + </dt> + <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::see or self::seealso]"> + <dd> + <dl> + <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[1])]" + mode="index-see"> + <xsl:sort select="see"/> + </xsl:apply-templates> + <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[1])]" + mode="index-seealso"> + <xsl:sort select="seealso"/> + </xsl:apply-templates> + <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[1]) = 1]" + mode="index-tertiary"> + <xsl:sort select="&tertiary;"/> + </xsl:apply-templates> + </dl> + </dd> + </xsl:if> +</xsl:template> + +<xsl:template match="indexterm" mode="index-tertiary"> + <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/> + <xsl:variable name="refs" select="key('tertiary', $key)"/> + <dt> + <xsl:value-of select="tertiary"/> + <xsl:for-each select="$refs[generate-id() = generate-id(key('tertiary-section', concat($key, &sep;, §ion.id;))[1])]"> + <xsl:apply-templates select="." mode="reference"/> + </xsl:for-each> + </dt> + <xsl:variable name="see" select="$refs/see | $refs/seealso"/> + <xsl:if test="$see"> + <dd> + <dl> + <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[1])]" + mode="index-see"> + <xsl:sort select="see"/> + </xsl:apply-templates> + <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[1])]" + mode="index-seealso"> + <xsl:sort select="seealso"/> + </xsl:apply-templates> + </dl> + </dd> + </xsl:if> +</xsl:template> + +<xsl:template match="indexterm" mode="reference"> + <xsl:text>, </xsl:text> + <xsl:choose> + <xsl:when test="@zone and string(@zone)"> + <xsl:call-template name="reference"> + <xsl:with-param name="zones" select="normalize-space(@zone)"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <a> + <xsl:variable name="title"> + <xsl:apply-templates select="§ion;" mode="title.markup"/> + </xsl:variable> + + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="§ion;"/> + </xsl:call-template> + </xsl:attribute> + + <xsl:value-of select="$title"/> <!-- text only --> + </a> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="reference"> + <xsl:param name="zones"/> + <xsl:choose> + <xsl:when test="contains($zones, ' ')"> + <xsl:variable name="zone" select="substring-before($zones, ' ')"/> + <xsl:variable name="target" select="key('sections', $zone)"/> + + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target[1]"/> + </xsl:call-template> + </xsl:attribute> + <xsl:apply-templates select="$target[1]" mode="index-title-content"/> + </a> + <xsl:text>, </xsl:text> + <xsl:call-template name="reference"> + <xsl:with-param name="zones" select="substring-after($zones, ' ')"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="zone" select="$zones"/> + <xsl:variable name="target" select="key('sections', $zone)"/> + + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target[1]"/> + </xsl:call-template> + </xsl:attribute> + <xsl:apply-templates select="$target[1]" mode="index-title-content"/> + </a> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="indexterm" mode="index-see"> + <dt><xsl:value-of select="see"/></dt> +</xsl:template> + +<xsl:template match="indexterm" mode="index-seealso"> + <dt><xsl:value-of select="seealso"/></dt> +</xsl:template> + +<xsl:template match="*" mode="index-title-content"> + <xsl:variable name="title"> + <xsl:apply-templates select="§ion;" mode="title.markup"/> + </xsl:variable> + + <xsl:value-of select="$title"/> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/autotoc.xsl b/xsl/html/autotoc.xsl new file mode 100644 index 000000000..45db0c64b --- /dev/null +++ b/xsl/html/autotoc.xsl @@ -0,0 +1,543 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<xsl:template name="href.target"> + <xsl:param name="object" select="."/> + <xsl:text>#</xsl:text> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$object"/> + </xsl:call-template> +</xsl:template> + +<xsl:variable name="toc.listitem.type"> + <xsl:choose> + <xsl:when test="$toc.list.type = 'dl'">dt</xsl:when> + <xsl:otherwise>li</xsl:otherwise> + </xsl:choose> +</xsl:variable> + +<!-- this is just hack because dl and ul aren't completely isomorphic --> +<xsl:variable name="toc.dd.type"> + <xsl:choose> + <xsl:when test="$toc.list.type = 'dl'">dd</xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> +</xsl:variable> + +<xsl:template name="set.toc"> + <xsl:variable name="nodes" select="book|setindex"/> + <xsl:if test="$nodes"> + <div class="toc"> + <p> + <b> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">TableofContents</xsl:with-param> + </xsl:call-template> + </b> + </p> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="$nodes" mode="toc"/> + </xsl:element> + </div> + </xsl:if> +</xsl:template> + +<xsl:template name="division.toc"> + <xsl:if test="$generate.division.toc != 0"> + <xsl:variable name="nodes" select="part|reference + |preface|chapter|appendix + |article + |bibliography|glossary|index + |refentry"/> + <xsl:if test="$nodes"> + <div class="toc"> + <p> + <b> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">TableofContents</xsl:with-param> + </xsl:call-template> + </b> + </p> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="$nodes" mode="toc"/> + </xsl:element> + </div> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template name="component.toc"> + <xsl:if test="$generate.component.toc != 0"> + <xsl:variable name="nodes" select="section|sect1|refentry + |article|bibliography|glossary + |appendix"/> + <xsl:if test="$nodes"> + <div class="toc"> + <p> + <b> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">TableofContents</xsl:with-param> + </xsl:call-template> + </b> + </p> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="$nodes" mode="toc"/> + </xsl:element> + </div> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template name="section.toc"> + <xsl:variable name="nodes" select="section|sect1|sect2|sect3|sect4|sect5|refentry"/> + <xsl:if test="$nodes"> + <div class="toc"> + <p> + <b> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">TableofContents</xsl:with-param> + </xsl:call-template> + </b> + </p> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="$nodes" mode="toc"/> + </xsl:element> + </div> + </xsl:if> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="book|setindex" mode="toc"> + <xsl:variable name="nodes" select="part|reference + |preface|chapter|appendix + |article + |bibliography|glossary|index + |refentry"/> + + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates mode="toc" select="$nodes"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>0 and count($nodes)>0"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>0 and count($nodes)>0"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="part|reference" mode="toc"> + <xsl:variable name="nodes" select="appendix|chapter|article + |index|glossary|bibliography + |preface|reference|refentry"/> + + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="$nodes" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>0 and count($nodes) > 0"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>0 and count($nodes) > 0"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="preface|chapter|appendix|article" mode="toc"> + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="section|sect1" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>0 and section|sect1"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>0 and section|sect1"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="sect1" mode="toc"> + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="sect2" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>1 and sect2"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>1 and sect2"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="sect2" mode="toc"> + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="sect3" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>2 and sect3"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>2 and sect3"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="sect3" mode="toc"> + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="sect4" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>3 and sect4"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>3 and sect4"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="sect4" mode="toc"> + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="sect5" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toc.section.depth>4 and sect5"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toc.section.depth>4 and sect5"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="sect5" mode="toc"> + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + </xsl:element> +</xsl:template> + +<xsl:template match="section" mode="toc"> + <xsl:variable name="subtoc"> + <xsl:element name="{$toc.list.type}"> + <xsl:apply-templates select="section" mode="toc"/> + </xsl:element> + </xsl:variable> + + <xsl:variable name="subtoc.list"> + <xsl:choose> + <xsl:when test="$toc.dd.type = ''"> + <xsl:copy-of select="$subtoc"/> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$toc.dd.type}"> + <xsl:copy-of select="$subtoc"/> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="toodeep"> + <xsl:choose> + <!-- if the depth is less than 2, we're already deep enough --> + <xsl:when test="$toc.section.depth < 2">yes</xsl:when> + <!-- if the current section has n-1 section ancestors --> + <!-- then we've already reached depth n --> + <xsl:when test="ancestor::section[position()=$toc.section.depth - 1]"> + <xsl:text>yes</xsl:text> + </xsl:when> + <!-- otherwise, keep going --> + <xsl:otherwise>no</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <xsl:apply-templates select="." mode="label.markup"/> + <xsl:text> </xsl:text> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + <xsl:if test="$toc.listitem.type = 'li' + and $toodeep='no' and section"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> + </xsl:element> + <xsl:if test="$toc.listitem.type != 'li' + and $toodeep='no' and section"> + <xsl:copy-of select="$subtoc.list"/> + </xsl:if> +</xsl:template> + +<xsl:template match="bibliography|glossary" mode="toc"> + <xsl:element name="{$toc.listitem.type}"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + </xsl:element> +</xsl:template> + +<xsl:template match="index" mode="toc"> + <!-- If the index tag is empty, don't point at it from the TOC --> + <xsl:if test="* or $generate.index"> + <xsl:element name="{$toc.listitem.type}"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:apply-templates select="." mode="title.markup"/> + </a> + </xsl:element> + </xsl:if> +</xsl:template> + +<xsl:template match="refentry" mode="toc"> + <xsl:variable name="refmeta" select=".//refmeta"/> + <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/> + <xsl:variable name="refnamediv" select=".//refnamediv"/> + <xsl:variable name="refname" select="$refnamediv//refname"/> + <xsl:variable name="title"> + <xsl:choose> + <xsl:when test="$refentrytitle"> + <xsl:apply-templates select="$refentrytitle[1]" mode="title"/> + </xsl:when> + <xsl:when test="$refname"> + <xsl:apply-templates select="$refname[1]" mode="title"/> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="{$toc.listitem.type}"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"/> + </xsl:attribute> + <xsl:copy-of select="$title"/> + </a> + </xsl:element> +</xsl:template> + +<xsl:template match="title" mode="toc"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:attribute> + <xsl:apply-templates/> + </a> +</xsl:template> + +</xsl:stylesheet> + diff --git a/xsl/html/biblio.xsl b/xsl/html/biblio.xsl new file mode 100644 index 000000000..220574911 --- /dev/null +++ b/xsl/html/biblio.xsl @@ -0,0 +1,932 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template match="bibliography"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="bibliography.titlepage"/> + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="bibliography/bibliographyinfo"></xsl:template> +<xsl:template match="bibliography/title"></xsl:template> +<xsl:template match="bibliography/subtitle"></xsl:template> +<xsl:template match="bibliography/titleabbrev"></xsl:template> + +<xsl:template match="bibliography/title" mode="component.title.mode"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + <h2 class="title"> + <a name="{$id}"> + <xsl:apply-templates/> + </a> + </h2> +</xsl:template> + +<xsl:template match="bibliography/subtitle" mode="component.title.mode"> + <h3> + <i><xsl:apply-templates/></i> + </h3> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="bibliodiv"> + <div class="{name(.)}"> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="bibliodiv/title"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + <h3 class="{name(.)}"> + <a name="{$id}"> + <xsl:apply-templates/> + </a> + </h3> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="biblioentry"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + <div id="{$id}" class="{name(.)}"> + <a name="{$id}"/> + <p> + <xsl:apply-templates mode="bibliography.mode"/> + </p> + </div> +</xsl:template> + +<xsl:template match="bibliomixed"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + <div id="{$id}" class="{name(.)}"> + <a name="{$id}"/> + <p> + <xsl:choose> + <xsl:when test="local-name(*[1]) = 'abbrev'"> + <xsl:apply-templates select="*[position()>1]|text()" + mode="bibliomixed.mode"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates mode="bibliomixed.mode"/> + </xsl:otherwise> + </xsl:choose> + </p> + </div> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="*" mode="bibliography.mode"> + <xsl:apply-templates select="."/><!-- try the default mode --> +</xsl:template> + +<xsl:template match="abbrev" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:text>[</xsl:text> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:text>] </xsl:text> + </span> +</xsl:template> + +<xsl:template match="abstract" mode="bibliography.mode"> + <!-- suppressed --> +</xsl:template> + +<xsl:template match="address" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="affiliation" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="shortaffil" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="jobtitle" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="artheader|articleinfo" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="artpagenums" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="author" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:call-template name="person.name"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="authorblurb" mode="bibliography.mode"> + <!-- suppressed --> +</xsl:template> + +<xsl:template match="authorgroup" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:call-template name="person.name.list"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="authorinitials" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="bibliomisc" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="bibliomset" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<!-- ================================================== --> + +<xsl:template match="biblioset" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + </span> +</xsl:template> + +<xsl:template match="biblioset/title|biblioset/citetitle" + mode="bibliography.mode"> + <xsl:variable name="relation" select="../@relation"/> + <xsl:choose> + <xsl:when test="$relation='article'"> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">ldquo</xsl:with-param> + </xsl:call-template> + <xsl:apply-templates/> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">rdquo</xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <I><xsl:apply-templates/></I> + </xsl:otherwise> + </xsl:choose> + <xsl:value-of select="$biblioentry.item.separator"/> +</xsl:template> + +<!-- ================================================== --> + +<xsl:template match="bookbiblio" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="citetitle" mode="bibliography.mode"> + <span class="{name(.)}"> + <i><xsl:apply-templates mode="bibliography.mode"/></i> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="collab" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="collabname" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="confgroup" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="confdates" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="conftitle" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="confnum" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="confsponsor" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="contractnum" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="contractsponsor" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="contrib" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<!-- ================================================== --> + +<xsl:template match="copyright" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Copyright'"/> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">copyright</xsl:with-param> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="year" mode="bibliography.mode"/> + <xsl:if test="holder"> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="holder" mode="bibliography.mode"/> + </xsl:if> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="year" mode="bibliography.mode"> + <xsl:apply-templates/><xsl:text>, </xsl:text> +</xsl:template> + +<xsl:template match="year[position()=last()]" mode="bibliography.mode"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="holder" mode="bibliography.mode"> + <xsl:apply-templates/> +</xsl:template> + +<!-- ================================================== --> + +<xsl:template match="corpauthor" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="corpname" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="date" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="edition" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="editor" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:call-template name="person.name"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="firstname" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="honorific" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="indexterm" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="invpartnumber" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="isbn" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="issn" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="issuenum" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="lineage" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="orgname" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="orgdiv" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="othercredit" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="othername" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="pagenums" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="printhistory" mode="bibliography.mode"> + <!-- suppressed --> +</xsl:template> + +<xsl:template match="productname" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="productnumber" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="pubdate" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="publisher" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + </span> +</xsl:template> + +<xsl:template match="publishername" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="pubsnumber" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="releaseinfo" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="revhistory" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="seriesinfo" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + </span> +</xsl:template> + +<xsl:template match="seriesvolnums" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="subtitle" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="surname" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="title" mode="bibliography.mode"> + <span class="{name(.)}"> + <I><xsl:apply-templates mode="bibliography.mode"/></I> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="titleabbrev" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<xsl:template match="volumenum" mode="bibliography.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliography.mode"/> + <xsl:value-of select="$biblioentry.item.separator"/> + </span> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="*" mode="bibliomixed.mode"> + <xsl:apply-templates select="."/><!-- try the default mode --> +</xsl:template> + +<xsl:template match="abbrev" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="abstract" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="address" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="affiliation" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="shortaffil" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="jobtitle" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="artpagenums" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="author" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="authorblurb" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="authorgroup" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="authorinitials" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="bibliomisc" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<!-- ================================================== --> + +<xsl:template match="bibliomset" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="bibliomset/title|bibliomset/citetitle" + mode="bibliomixed.mode"> + <xsl:variable name="relation" select="../@relation"/> + <xsl:choose> + <xsl:when test="$relation='article'"> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">ldquo</xsl:with-param> + </xsl:call-template> + <xsl:apply-templates/> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">rdquo</xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <I><xsl:apply-templates/></I> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ================================================== --> + +<xsl:template match="biblioset" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="citetitle" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <i><xsl:apply-templates mode="bibliomixed.mode"/></i> + </span> +</xsl:template> + +<xsl:template match="collab" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="confgroup" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="contractnum" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="contractsponsor" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="contrib" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="copyright" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="corpauthor" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="corpname" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="date" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="edition" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="editor" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="firstname" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="honorific" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="indexterm" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="invpartnumber" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="isbn" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="issn" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="issuenum" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="lineage" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="orgname" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="othercredit" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="othername" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="pagenums" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="printhistory" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="productname" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="productnumber" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="pubdate" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="publisher" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="publishername" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="pubsnumber" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="releaseinfo" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="revhistory" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="seriesvolnums" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="subtitle" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="surname" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="title" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="titleabbrev" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<xsl:template match="volumenum" mode="bibliomixed.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="bibliomixed.mode"/> + </span> +</xsl:template> + +<!-- ==================================================================== --> + +</xsl:stylesheet> diff --git a/xsl/html/block.xsl b/xsl/html/block.xsl new file mode 100644 index 000000000..9b171eec8 --- /dev/null +++ b/xsl/html/block.xsl @@ -0,0 +1,357 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template name="block.object"> + <div class="{name(.)}"> + <a> + <xsl:attribute name="name"> + <xsl:call-template name="object.id"/> + </xsl:attribute> + </a> + <xsl:apply-templates/> + </div> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="para"> + <p> + <xsl:if test="position() = 1 and parent::listitem"> + <a> + <xsl:attribute name="name"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="parent::listitem"/> + </xsl:call-template> + </xsl:attribute> + </a> + </xsl:if> + + <xsl:if test="@id"> + <a name="{@id}"/> + </xsl:if> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="simpara"> + <p> + <xsl:if test="@id"> + <a name="{@id}"/> + </xsl:if> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="formalpara"> + <p> + <xsl:if test="@id"> + <a name="{@id}"/> + </xsl:if> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="formalpara/title"> + <b><xsl:apply-templates/></b> + <xsl:call-template name="gentext.space"/> +</xsl:template> + +<xsl:template match="formalpara/para"> + <xsl:apply-templates/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="blockquote"> + <xsl:if test="@id"> + <a name="{@id}"/> + </xsl:if> + <xsl:choose> + <xsl:when test="attribution"> + <table border="0" width="100%" + cellspacing="0" cellpadding="0" class="blockquote" + summary="Block quote"> + <tr> + <td width="10%" valign="top"> </td> + <td width="80%" valign="top"> + <xsl:apply-templates + select="child::*[local-name(.)!='attribution']"/> + </td> + <td width="10%" valign="top"> </td> + </tr> + <tr> + <td colspan="2" align="right" valign="top"> + <xsl:text>--</xsl:text> + <xsl:apply-templates select="attribution"/> + </td> + <td width="10%" valign="top"> </td> + </tr> + </table> + </xsl:when> + <xsl:otherwise> + <blockquote class="blockquote"> + <xsl:apply-templates/> + </blockquote> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="epigraph"> + <div class="{name(.)}"> + <xsl:apply-templates select="para"/> + <span>--<xsl:apply-templates select="attribution"/></span> + </div> +</xsl:template> + +<xsl:template match="attribution"> + <span class="{name(.)}"><xsl:apply-templates/></span> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="sidebar"> + <div class="{name(.)}"> + <a> + <xsl:attribute name="name"> + <xsl:call-template name="object.id"/> + </xsl:attribute> + </a> + + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="sidebar/title"> + <p class="title"> + <b><xsl:apply-templates/></b> + </p> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="abstract"> + <div class="{name(.)}"> + <xsl:call-template name="formal.object.heading"> + <xsl:with-param name="title"> + <xsl:apply-templates select="." mode="title.markup"> + <xsl:with-param name="allow-anchors" select="'1'"/> + </xsl:apply-templates> + </xsl:with-param> + </xsl:call-template> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="abstract/title"> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="msgset"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="msgentry"> + <xsl:call-template name="block.object"/> +</xsl:template> + +<xsl:template match="simplemsgentry"> + <xsl:call-template name="block.object"/> +</xsl:template> + +<xsl:template match="msg"> + <xsl:call-template name="block.object"/> +</xsl:template> + +<xsl:template match="msgmain"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="msgmain/title"> + <b><xsl:apply-templates/></b> +</xsl:template> + +<xsl:template match="msgsub"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="msgsub/title"> + <b><xsl:apply-templates/></b> +</xsl:template> + +<xsl:template match="msgrel"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="msgrel/title"> + <b><xsl:apply-templates/></b> +</xsl:template> + +<xsl:template match="msgtext"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="msginfo"> + <xsl:call-template name="block.object"/> +</xsl:template> + +<xsl:template match="msglevel"> + <p> + <b> + <xsl:call-template name="gentext.template"> + <xsl:with-param name="context" select="'msgset'"/> + <xsl:with-param name="name" select="'MsgLevel'"/> + </xsl:call-template> + </b> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="msgorig"> + <p> + <b> + <xsl:call-template name="gentext.template"> + <xsl:with-param name="context" select="'msgset'"/> + <xsl:with-param name="name" select="'MsgOrig'"/> + </xsl:call-template> + </b> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="msgaud"> + <p> + <b> + <xsl:call-template name="gentext.template"> + <xsl:with-param name="context" select="'msgset'"/> + <xsl:with-param name="name" select="'MsgAud'"/> + </xsl:call-template> + </b> + <xsl:apply-templates/> + </p> +</xsl:template> + +<xsl:template match="msgexplan"> + <xsl:call-template name="block.object"/> +</xsl:template> + +<xsl:template match="msgexplan/title"> + <p><b><xsl:apply-templates/></b></p> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="revhistory"> + <div class="{name(.)}"> + <table border="0" width="100%" summary="Revision history"> + <tr> + <th align="left" valign="top" colspan="3"> + <b> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'RevHistory'"/> + </xsl:call-template> + </b> + </th> + </tr> + <xsl:apply-templates/> + </table> + </div> +</xsl:template> + +<xsl:template match="revhistory/revision"> + <xsl:variable name="revnumber" select=".//revnumber"/> + <xsl:variable name="revdate" select=".//date"/> + <xsl:variable name="revauthor" select=".//authorinitials"/> + <xsl:variable name="revremark" select=".//revremark|../revdescription"/> + <tr> + <td align="left"> + <xsl:if test="$revnumber"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Revision'"/> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="$revnumber"/> + </xsl:if> + </td> + <td align="left"> + <xsl:apply-templates select="$revdate"/> + </td> + <xsl:choose> + <xsl:when test="count($revauthor)=0"> + <td align="left"> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">nbsp</xsl:with-param> + </xsl:call-template> + </td> + </xsl:when> + <xsl:otherwise> + <td align="left"> + <xsl:apply-templates select="$revauthor"/> + </td> + </xsl:otherwise> + </xsl:choose> + </tr> + <xsl:if test="$revremark"> + <tr> + <td align="left" colspan="3"> + <xsl:apply-templates select="$revremark"/> + </td> + </tr> + </xsl:if> +</xsl:template> + +<xsl:template match="revision/revnumber"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="revision/date"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="revision/authorinitials"> + <xsl:text>, </xsl:text> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="revision/authorinitials[1]" priority="2"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="revision/revremark"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="revision/revdescription"> + <xsl:apply-templates/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="ackno"> + <p class="{name(.)}"> + <xsl:apply-templates/> + </p> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="highlights"> + <xsl:call-template name="block.object"/> +</xsl:template> + +<!-- ==================================================================== --> + +</xsl:stylesheet> diff --git a/xsl/html/callout.xsl b/xsl/html/callout.xsl new file mode 100644 index 000000000..242b3a48f --- /dev/null +++ b/xsl/html/callout.xsl @@ -0,0 +1,126 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" + xmlns:xverb="com.nwalsh.xalan.Verbatim" + xmlns:lxslt="http://xml.apache.org/xslt" + exclude-result-prefixes="sverb xverb lxslt" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<lxslt:component prefix="xverb" + functions="insertCallouts"/> + +<xsl:template match="programlistingco|screenco"> + <xsl:variable name="verbatim" select="programlisting|screen"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:choose> + <xsl:when test="$use.extensions != '0' + and $callouts.extension != '0'"> + <xsl:variable name="rtf"> + <xsl:apply-templates select="$verbatim"> + <xsl:with-param name="suppress-numbers" select="'1'"/> + </xsl:apply-templates> + </xsl:variable> + + <xsl:variable name="rtf-with-callouts"> + <xsl:choose> + <xsl:when test="contains($vendor, 'SAXON ')"> + <xsl:copy-of select="sverb:insertCallouts(areaspec,$rtf)"/> + </xsl:when> + <xsl:when test="contains($vendor, 'Apache Software Foundation')"> + <xsl:copy-of select="xverb:insertCallouts(areaspec,$rtf)"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Don't know how to do callouts with </xsl:text> + <xsl:value-of select="$vendor"/> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$verbatim/@linenumbering = 'numbered' + and $linenumbering.extension != '0'"> + <div class="{name(.)}"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf-with-callouts"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + <xsl:apply-templates select="calloutlist"/> + </div> + </xsl:when> + <xsl:otherwise> + <div class="{name(.)}"> + <xsl:copy-of select="$rtf-with-callouts"/> + <xsl:apply-templates select="calloutlist"/> + </div> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <div class="{name(.)}"> + <xsl:apply-templates/> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="areaspec|areaset|area"> +</xsl:template> + +<xsl:template match="areaset" mode="conumber"> + <xsl:number count="area|areaset" format="1"/> +</xsl:template> + +<xsl:template match="area" mode="conumber"> + <xsl:number count="area|areaset" format="1"/> +</xsl:template> + +<xsl:template match="co"> + <a name="{@id}"/> + <xsl:apply-templates select="." mode="callout-bug"/> +</xsl:template> + +<xsl:template match="co" mode="callout-bug"> + <xsl:call-template name="callout-bug"> + <xsl:with-param name="conum"> + <xsl:number count="co" format="1"/> + </xsl:with-param> + </xsl:call-template> +</xsl:template> + +<xsl:template name="callout-bug"> + <xsl:param name="conum" select='1'/> + + <xsl:choose> + <xsl:when test="$callout.graphics = '0' + or $conum > $callout.graphics.number.limit"> + + <xsl:text>(</xsl:text> + <xsl:value-of select="$conum"/> + <xsl:text>)</xsl:text> + </xsl:when> + <xsl:otherwise> + <img src="{$callout.graphics.path}{$conum}{$callout.graphics.extension}" + alt="{$conum}" border="0"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/changebars.xsl b/xsl/html/changebars.xsl new file mode 100644 index 000000000..fee001a13 --- /dev/null +++ b/xsl/html/changebars.xsl @@ -0,0 +1,73 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + +<xsl:import href="docbook.xsl"/> + +<xsl:param name="show.revisionflag" select="'1'"/> + +<xsl:template name="user.head.content"> +<style type="text/css"> +<xsl:text> +div.added { background-color: yellow; } +div.deleted { text-decoration: line-through; + background-color: #FF7F7F; } +div.changed { background-color: lime; } +div.off { } + +span.added { background-color: yellow; } +span.deleted { text-decoration: line-through; + background-color: #FF7F7F; } +span.changed { background-color: lime; } +span.off { } +</xsl:text> +</style> +</xsl:template> + +<xsl:template match="*[@revisionflag]"> + <xsl:choose> + <xsl:when test="local-name(.) = 'para' + or local-name(.) = 'section' + or local-name(.) = 'sect1' + or local-name(.) = 'sect2' + or local-name(.) = 'sect3' + or local-name(.) = 'sect4' + or local-name(.) = 'sect5' + or local-name(.) = 'chapter' + or local-name(.) = 'preface' + or local-name(.) = 'itemizedlist' + or local-name(.) = 'appendix'"> + <div class='{@revisionflag}'> + <xsl:apply-imports/> + </div> + </xsl:when> + <xsl:when test="local-name(.) = 'phrase' + or local-name(.) = 'ulink' + or local-name(.) = 'filename' + or local-name(.) = 'literal' + or local-name(.) = 'emphasis' + or local-name(.) = 'command' + or local-name(.) = 'xref'"> + <span class='{@revisionflag}'> + <xsl:apply-imports/> + </span> + </xsl:when> + <xsl:when test="local-name(.) = 'listitem' + or local-name(.) = 'title'"> + <!-- nop; these are handled directly in the stylesheet --> + <xsl:apply-imports/> + </xsl:when> + <xsl:otherwise> + <xsl:message> + <xsl:text>Revisionflag on unexpected element: </xsl:text> + <xsl:value-of select="local-name(.)"/> + <xsl:text>(Assuming block)</xsl:text> + </xsl:message> + <div class='{@revisionflag}'> + <xsl:apply-imports/> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/chunk-common.xsl b/xsl/html/chunk-common.xsl new file mode 100644 index 000000000..f655bac1a --- /dev/null +++ b/xsl/html/chunk-common.xsl @@ -0,0 +1,800 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:saxon="http://icl.com/saxon" + xmlns:lxslt="http://xml.apache.org/xslt" + xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + version="1.0" + exclude-result-prefixes="doc" + extension-element-prefixes="saxon xalanredirect lxslt"> + +<xsl:import href="docbook.xsl"/> + +<xsl:output method="html" + encoding="ISO-8859-1" + indent="no"/> + +<xsl:param name="html.ext" select="'.html'"/> +<xsl:param name="root.filename" select="'index'"/> +<xsl:param name="base.dir" select="''"/> +<doc:param name="base.dir" xmlns=""> +<refpurpose>Output directory for chunks</refpurpose> +<refdescription> +<para>If specified, the <literal>base.dir</literal> identifies +the output directory for chunks. (If not specified, the output directory +is system dependent.)</para> +</refdescription> +</doc:param> + +<!-- ==================================================================== --> +<!-- What's a chunk? + + appendix + article + bibliography in article or book + book + chapter + colophon + glossary in article or book + index in article or book + part + preface + refentry + reference + sect1 if position()>1 + section if position()>1 && parent != section + set + setindex + --> +<!-- ==================================================================== --> + +<xsl:template name="chunk"> + <xsl:param name="node" select="."/> + <!-- returns 1 if $node is a chunk --> + + <xsl:choose> + <xsl:when test="name($node)='sect1' + and count($node/preceding-sibling::sect1) > 0">1</xsl:when> + <xsl:when test="name($node)='section' + and count($node/parent::section) = 0 + and count($node/preceding-sibling::section) > 0">1</xsl:when> + <xsl:when test="name($node)='preface'">1</xsl:when> + <xsl:when test="name($node)='chapter'">1</xsl:when> + <xsl:when test="name($node)='appendix'">1</xsl:when> + <xsl:when test="name($node)='article'">1</xsl:when> + <xsl:when test="name($node)='part'">1</xsl:when> + <xsl:when test="name($node)='reference'">1</xsl:when> + <xsl:when test="name($node)='refentry'">1</xsl:when> + <xsl:when test="name($node)='index' + and (name($node/parent::*) = 'article' + or name($node/parent::*) = 'book')">1</xsl:when> + <xsl:when test="name($node)='bibliography' + and (name($node/parent::*) = 'article' + or name($node/parent::*) = 'book')">1</xsl:when> + <xsl:when test="name($node)='glossary' + and (name($node/parent::*) = 'article' + or name($node/parent::*) = 'book')">1</xsl:when> + <xsl:when test="name($node)='colophon'">1</xsl:when> + <xsl:when test="name($node)='book'">1</xsl:when> + <xsl:when test="name($node)='set'">1</xsl:when> + <xsl:when test="name($node)='setindex'">1</xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="*" mode="chunk-filename"> + <xsl:param name="recursive" select="false()"/> + + <!-- returns the filename of a chunk --> + <xsl:variable name="ischunk"> + <xsl:call-template name="chunk"/> + </xsl:variable> + + <xsl:variable name="dbhtml-filename"> + <xsl:call-template name="dbhtml-filename"/> + </xsl:variable> + + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="$dbhtml-filename != ''"> + <xsl:value-of select="$dbhtml-filename"/> + </xsl:when> + <!-- if there's no dbhtml filename, and if we're to use IDs as --> + <!-- filenames, *and* this isn't the root node, then use the ID --> + <!-- to generate the filename. --> + <xsl:when test="@id and $use.id.as.filename != 0 + and . != /*"> + <xsl:value-of select="@id"/> + <xsl:value-of select="$html.ext"/> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="dir"> + <xsl:call-template name="dbhtml-dir"/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$ischunk='0'"> + <!-- if called on something that isn't a chunk, walk up... --> + <xsl:choose> + <xsl:when test="count(parent::*)>0"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="$recursive"/> + </xsl:apply-templates> + </xsl:when> + <!-- unless there is no up, in which case return "" --> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:when test="not($recursive) and $filename != ''"> + <!-- if this chunk has an explicit name, use it --> + <xsl:if test="$dir != ''"> + <xsl:value-of select="$dir"/> + <xsl:text>/</xsl:text> + </xsl:if> + <xsl:value-of select="$filename"/> + </xsl:when> + + <xsl:when test="name(.)='set'"> + <xsl:value-of select="$root.filename"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='book'"> + <xsl:choose> + <xsl:when test="count(parent::*)>0"> + <xsl:text>bk</xsl:text> + <xsl:number level="any" format="01"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$root.filename"/> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='article'"> + <xsl:if test="/set"> + <!-- in a set, make sure we inherit the right book info... --> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:choose> + <xsl:when test="count(parent::*)>0"> + <!-- if we aren't the root, name them numerically ... --> + <xsl:text>ar</xsl:text> + <xsl:number level="any" format="01" from="book"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$root.filename"/> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='preface'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>pr</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='chapter'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>ch</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='appendix'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>ap</xsl:text> + <xsl:number level="any" format="a" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='part'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>pt</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='reference'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>rn</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='refentry'"> + <xsl:if test="parent::reference"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>re</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='colophon'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>co</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='sect1' or name(.)='section'"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + <xsl:text>s</xsl:text> + <xsl:number level="any" format="01" from="preface|chapter|appendix"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='bibliography'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>bi</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='glossary'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>go</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='index'"> + <xsl:if test="/set"> + <xsl:apply-templates mode="chunk-filename" select="parent::*"> + <xsl:with-param name="recursive" select="true()"/> + </xsl:apply-templates> + </xsl:if> + <xsl:text>ix</xsl:text> + <xsl:number level="any" format="01" from="book"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:when test="name(.)='setindex'"> + <xsl:text>si</xsl:text> + <xsl:number level="any" format="01" from="set"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:when> + + <xsl:otherwise> + <xsl:text>chunk-filename-error-</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:number level="any" format="01" from="set"/> + <xsl:if test="not($recursive)"> + <xsl:value-of select="$html.ext"/> + </xsl:if> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="href.target"> + <xsl:param name="object" select="."/> + <xsl:variable name="ischunk"> + <xsl:call-template name="chunk"> + <xsl:with-param name="node" select="$object"/> + </xsl:call-template> + </xsl:variable> + + <xsl:apply-templates mode="chunk-filename" select="$object"/> + + <xsl:if test="$ischunk='0'"> + <xsl:text>#</xsl:text> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$object"/> + </xsl:call-template> + </xsl:if> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="html.head"> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:variable name="home" select="/*[1]"/> + <xsl:variable name="up" select="parent::*"/> + + <head> + <xsl:call-template name="head.content"/> + <xsl:call-template name="user.head.content"/> + + <xsl:if test="$home"> + <link rel="home"> + <xsl:variable name="home-title"> + <xsl:apply-templates select="$home" mode="title.markup"/> + </xsl:variable> + + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$home"/> + </xsl:call-template> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$home-title"/> <!-- node-set ==> text only! --> + </xsl:attribute> + </link> + </xsl:if> + + <xsl:if test="$up"> + <link rel="up"> + <xsl:variable name="up-title"> + <xsl:apply-templates select="$up" mode="title.markup"/> + </xsl:variable> + + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$up"/> + </xsl:call-template> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$up-title"/> <!-- node-set ==> text only! --> + </xsl:attribute> + </link> + </xsl:if> + + <xsl:if test="$prev"> + <link rel="previous"> + <xsl:variable name="prev-title"> + <xsl:apply-templates select="$prev" mode="title.markup"/> + </xsl:variable> + + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$prev"/> + </xsl:call-template> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$prev-title"/> <!-- node-set ==> text only! --> + </xsl:attribute> + </link> + </xsl:if> + + <xsl:if test="$next"> + <link rel="next"> + <xsl:variable name="next-title"> + <xsl:apply-templates select="$next" mode="title.markup"/> + </xsl:variable> + + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$next"/> + </xsl:call-template> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$next-title"/> <!-- node-set ==> text only! --> + </xsl:attribute> + </link> + </xsl:if> + </head> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="header.navigation"> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:variable name="home" select="/*[1]"/> + <xsl:variable name="up" select="parent::*"/> + + <xsl:if test="$suppress.navigation = '0'"> + <div class="navheader"> + <table width="100%"> + <tr> + <th colspan="3" align="center"> + <xsl:apply-templates select="." mode="title.markup"/> + </th> + </tr> + <tr> + <td width="20%" align="left"> + <xsl:if test="count($prev)>0"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$prev"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">nav-prev</xsl:with-param> + </xsl:call-template> + </a> + </xsl:if> + <xsl:text> </xsl:text> + </td> + <th width="60%" align="center"> + <xsl:choose> + <xsl:when test="count($up) > 0 and $up != $home"> + <xsl:apply-templates select="$up" mode="title.markup"/> + </xsl:when> + <xsl:otherwise> </xsl:otherwise> + </xsl:choose> + </th> + <td width="20%" align="right"> + <xsl:text> </xsl:text> + <xsl:if test="count($next)>0"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$next"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">nav-next</xsl:with-param> + </xsl:call-template> + </a> + </xsl:if> + </td> + </tr> + </table> + <hr/> + </div> + </xsl:if> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="footer.navigation"> + <xsl:param name="prev" select="/foo"/> + <xsl:param name="next" select="/foo"/> + <xsl:variable name="home" select="/*[1]"/> + <xsl:variable name="up" select="parent::*"/> + + <xsl:if test="$suppress.navigation = '0'"> + <div class="navfooter"> + <hr/> + <table width="100%"> + <tr> + <td width="40%" align="left"> + <xsl:if test="count($prev)>0"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$prev"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">nav-prev</xsl:with-param> + </xsl:call-template> + </a> + </xsl:if> + <xsl:text> </xsl:text> + </td> + <td width="20%" align="center"> + <xsl:choose> + <xsl:when test="$home != ."> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$home"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">nav-home</xsl:with-param> + </xsl:call-template> + </a> + </xsl:when> + <xsl:otherwise> </xsl:otherwise> + </xsl:choose> + </td> + <td width="40%" align="right"> + <xsl:text> </xsl:text> + <xsl:if test="count($next)>0"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$next"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">nav-next</xsl:with-param> + </xsl:call-template> + </a> + </xsl:if> + </td> + </tr> + + <tr> + <td width="40%" align="left"> + <xsl:apply-templates select="$prev" mode="title.markup"/> + <xsl:text> </xsl:text> + </td> + <td width="20%" align="center"> + <xsl:choose> + <xsl:when test="count($up)>0"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$up"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="gentext"> + <xsl:with-param name="key">nav-up</xsl:with-param> + </xsl:call-template> + </a> + </xsl:when> + <xsl:otherwise> </xsl:otherwise> + </xsl:choose> + </td> + <td width="40%" align="right"> + <xsl:text> </xsl:text> + <xsl:apply-templates select="$next" mode="title.markup"/> + </td> + </tr> + </table> + </div> + </xsl:if> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="processing-instruction('dbhtml')"> + <!-- nop --> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="process-chunk-element"> + <xsl:variable name="root" select="count(parent::*) > 0"/> + + <xsl:variable name="prev" + select="(preceding::book[1] + |preceding::preface[1] + |preceding::chapter[1] + |preceding::appendix[1] + |preceding::part[1] + |preceding::reference[1] + |preceding::refentry[1] + |preceding::colophon[1] + |preceding::sect1[name(preceding-sibling::*[1]) = 'sect1'][1] + |preceding::section[name(preceding-sibling::*[1]) = 'section' + and name(parent::*) != 'section'][1] + |preceding::article[1] + |preceding::bibliography[1] + |preceding::glossary[1] + |preceding::index[1] + |preceding::setindex[1] + |ancestor::set + |ancestor::book[1] + |ancestor::preface[1] + |ancestor::chapter[1] + |ancestor::appendix[1] + |ancestor::part[1] + |ancestor::reference[1] + |ancestor::article[1])[last()]"/> + + <xsl:variable name="next" + select="(following::book[1] + |following::preface[1] + |following::chapter[1] + |following::appendix[1] + |following::part[1] + |following::reference[1] + |following::refentry[1] + |following::colophon[1] + |following::sect1[1] + |following::section[name(parent::*) != 'section'][1] + |following::bibliography[1] + |following::glossary[1] + |following::index[1] + |following::article[1] + |following::setindex[1] + |descendant::book[1] + |descendant::preface[1] + |descendant::chapter[1] + |descendant::appendix[1] + |descendant::article[1] + |descendant::bibliography[1] + |descendant::glossary[1] + |descendant::index[1] + |descendant::colophon[1] + |descendant::setindex[1] + |descendant::part[1] + |descendant::reference[1] + |descendant::refentry[1] + |descendant::sect1[2] + |descendant::section[name(parent::*) != 'section'][2])[1]"/> + + <xsl:variable name="ischunk"> + <xsl:call-template name="chunk"/> + </xsl:variable> + + <xsl:variable name="chunkfn"> + <xsl:if test="$ischunk='1'"> + <xsl:apply-templates mode="chunk-filename" select="."/> + </xsl:if> + </xsl:variable> + + <xsl:if test="$ischunk='0'"> + <xsl:message> + <xsl:text>Error </xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text> is not a chunk!</xsl:text> + </xsl:message> + </xsl:if> + + <xsl:variable name="filename"> + <xsl:call-template name="make-relative-filename"> + <xsl:with-param name="base.dir" select="$base.dir"/> + <xsl:with-param name="base.name" select="$chunkfn"/> + </xsl:call-template> + </xsl:variable> + + <xsl:message> + <xsl:text>Writing </xsl:text> + <xsl:value-of select="$filename"/> + <xsl:text> for </xsl:text> + <xsl:value-of select="name(.)"/> + </xsl:message> + + <xsl:call-template name="write.chunk"> + <xsl:with-param name="filename" select="$filename"/> + <xsl:with-param name="content"> + <xsl:call-template name="chunk-element-content"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + </xsl:call-template> + </xsl:with-param> + </xsl:call-template> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="chunk-element-content"> + <xsl:param name="prev"></xsl:param> + <xsl:param name="next"></xsl:param> + + <html> + <xsl:call-template name="html.head"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + </xsl:call-template> + + <body xsl:use-attribute-sets="body.attrs"> + <xsl:call-template name="user.header.navigation"/> + + <xsl:call-template name="header.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + </xsl:call-template> + + <xsl:call-template name="user.header.content"/> + + <xsl:apply-imports/> + + <xsl:call-template name="user.footer.content"/> + + <xsl:call-template name="footer.navigation"> + <xsl:with-param name="prev" select="$prev"/> + <xsl:with-param name="next" select="$next"/> + </xsl:call-template> + + <xsl:call-template name="user.footer.navigation"/> + </body> + </html> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="/"> + <xsl:choose> + <xsl:when test="$rootid != ''"> + <xsl:choose> + <xsl:when test="count(id($rootid)) = 0"> + <xsl:message terminate="yes"> + <xsl:text>ID '</xsl:text> + <xsl:value-of select="$rootid"/> + <xsl:text>' not found in document.</xsl:text> + </xsl:message> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="id($rootid)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="set|book|part|preface|chapter|appendix + |article + |reference|refentry + |sect1[position()>1] + |section[position()>1 and name(parent::*) != 'section'] + |book/glossary|article/glossary + |book/bibliography|article/bibliography + |colophon"> + <xsl:call-template name="process-chunk-element"/> +</xsl:template> + +<xsl:template match="setindex + |book/index + |article/index"> + <!-- some implementations use completely empty index tags to indicate --> + <!-- where an automatically generated index should be inserted. so --> + <!-- if the index is completely empty, skip it. --> + <xsl:if test="count(*)>0"> + <xsl:call-template name="process-chunk-element"/> + </xsl:if> +</xsl:template> + +<!-- ==================================================================== --> + +</xsl:stylesheet> diff --git a/xsl/html/chunk.xsl b/xsl/html/chunk.xsl new file mode 100644 index 000000000..fe7b24b47 --- /dev/null +++ b/xsl/html/chunk.xsl @@ -0,0 +1,15 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:saxon="http://icl.com/saxon" + xmlns:lxslt="http://xml.apache.org/xslt" + xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + version="1.1" + exclude-result-prefixes="doc" + extension-element-prefixes="saxon xalanredirect lxslt"> + +<!-- This stylesheet works with Saxon and Xalan; for XT use xtchunk.xsl --> + +<xsl:include href="chunk-common.xsl"/> +<xsl:include href="chunker.xsl"/> + +</xsl:stylesheet> diff --git a/xsl/html/chunker.xsl b/xsl/html/chunker.xsl new file mode 100644 index 000000000..15d151734 --- /dev/null +++ b/xsl/html/chunker.xsl @@ -0,0 +1,81 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:saxon="http://icl.com/saxon" + xmlns:lxslt="http://xml.apache.org/xslt" + xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + version="1.1" + exclude-result-prefixes="doc" + extension-element-prefixes="saxon xalanredirect lxslt"> + +<!-- This stylesheet works with Saxon and Xalan; for XT use xtchunker.xsl --> + +<!-- ==================================================================== --> + +<xsl:template name="make-relative-filename"> + <xsl:param name="base.dir" select="'./'"/> + <xsl:param name="base.name" select="''"/> + + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:choose> + <xsl:when test="contains($vendor, 'SAXON')"> + <!-- Saxon doesn't make the chunks relative --> + <xsl:value-of select="concat($base.dir,$base.name)"/> + </xsl:when> + <xsl:when test="contains($vendor, 'Apache')"> + <!-- Xalan doesn't make the chunks relative --> + <xsl:value-of select="concat($base.dir,$base.name)"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Chunking isn't supported with </xsl:text> + <xsl:value-of select="$vendor"/> + </xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="write.chunk"> + <xsl:param name="filename" select="''"/> + <xsl:param name="method" select="'html'"/> + <xsl:param name="encoding" select="'ISO-8859-1'"/> + <xsl:param name="content" select="''"/> + + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:choose> + <xsl:when test="contains($vendor, 'SAXON 6.2')"> + <!-- Saxon 6.2.x uses xsl:document --> + <xsl:document version="1.1" href="{$filename}" + method="{$method}" + encoding="{$encoding}"> + <xsl:copy-of select="$content"/> + </xsl:document> + </xsl:when> + <xsl:when test="contains($vendor, 'SAXON')"> + <!-- Saxon uses saxon:output --> + <saxon:output file="{$filename}" + href="{$filename}" + method="{$method}" + encoding="{$encoding}"> + <xsl:copy-of select="$content"/> + </saxon:output> + </xsl:when> + <xsl:when test="contains($vendor, 'Apache')"> + <!-- Xalan uses xalanredirect --> + <xalanredirect:write file="{$filename}"> + <xsl:copy-of select="$content"/> + </xalanredirect:write> + </xsl:when> + <xsl:otherwise> + <!-- it doesn't matter since we won't be making chunks... --> + <xsl:message terminate="yes"> + <xsl:text>Can't make chunks with </xsl:text> + <xsl:value-of select="$vendor"/> + <xsl:text>'s processor.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/component.xsl b/xsl/html/component.xsl new file mode 100644 index 000000000..14537c928 --- /dev/null +++ b/xsl/html/component.xsl @@ -0,0 +1,322 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template name="component.title"> + <xsl:param name="node" select="."/> + <xsl:variable name="id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$node"/> + </xsl:call-template> + </xsl:variable> + + <h2 class="title"> + <a name="{$id}"/> + <xsl:apply-templates select="$node" mode="object.title.markup"/> + </h2> +</xsl:template> + +<xsl:template name="component.subtitle"> + <xsl:param name="node" select="."/> + <xsl:variable name="subtitle" + select="($node/docinfo/subtitle + |$node/prefaceinfo/subtitle + |$node/chapterinfo/subtitle + |$node/appendixinfo/subtitle + |subtitle)[1]"/> + + <xsl:if test="$subtitle"> + <h3 class="subtitle"> + <i> + <xsl:apply-templates select="$node" mode="object.subtitle.markup"/> + </i> + </h3> + </xsl:if> +</xsl:template> + +<xsl:template name="component.separator"> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="dedication" mode="dedication"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="dedication.titlepage"/> + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="title" mode="dedication.titlepage.recto.mode"> + <xsl:call-template name="component.title"> + <xsl:with-param name="node" select="ancestor::dedication[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="subtitle" mode="dedication.titlepage.recto.mode"> + <xsl:call-template name="component.subtitle"> + <xsl:with-param name="node" select="ancestor::dedication[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="dedication"></xsl:template> <!-- see mode="dedication" --> +<xsl:template match="dedication/title"></xsl:template> +<xsl:template match="dedication/subtitle"></xsl:template> +<xsl:template match="dedication/titleabbrev"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="colophon"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="component.separator"/> + <xsl:call-template name="component.title"/> + <xsl:call-template name="component.subtitle"/> + + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="colophon/title"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="preface"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"/> + </xsl:variable> + + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="component.separator"/> + <xsl:call-template name="preface.titlepage"/> + <xsl:if test="$generate.preface.toc != '0'"> + <xsl:call-template name="component.toc"/> + </xsl:if> + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="title" mode="preface.titlepage.recto.mode"> + <xsl:call-template name="component.title"> + <xsl:with-param name="node" select="ancestor::preface[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="subtitle" mode="preface.titlepage.recto.mode"> + <xsl:call-template name="component.subtitle"> + <xsl:with-param name="node" select="ancestor::preface[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="preface/docinfo|prefaceinfo"></xsl:template> +<xsl:template match="preface/title"></xsl:template> +<xsl:template match="preface/titleabbrev"></xsl:template> +<xsl:template match="preface/subtitle"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="chapter"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"/> + </xsl:variable> + + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="component.separator"/> + <xsl:call-template name="chapter.titlepage"/> + <xsl:if test="$generate.chapter.toc != '0'"> + <xsl:call-template name="component.toc"/> + </xsl:if> + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="title" mode="chapter.titlepage.recto.mode"> + <xsl:call-template name="component.title"> + <xsl:with-param name="node" select="ancestor::chapter[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="subtitle" mode="chapter.titlepage.recto.mode"> + <xsl:call-template name="component.subtitle"> + <xsl:with-param name="node" select="ancestor::chapter[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="chapter/docinfo|chapterinfo"></xsl:template> +<xsl:template match="chapter/title"></xsl:template> +<xsl:template match="chapter/titleabbrev"></xsl:template> +<xsl:template match="chapter/subtitle"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="appendix"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"/> + </xsl:variable> + + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="component.separator"/> + <xsl:call-template name="appendix.titlepage"/> + <xsl:if test="$generate.appendix.toc != '0'"> + <xsl:call-template name="component.toc"/> + </xsl:if> + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="title" mode="appendix.titlepage.recto.mode"> + <xsl:call-template name="component.title"> + <xsl:with-param name="node" select="ancestor::appendix[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="subtitle" mode="appendix.titlepage.recto.mode"> + <xsl:call-template name="component.subtitle"> + <xsl:with-param name="node" select="ancestor::appendix[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="appendix/docinfo|appendixinfo"></xsl:template> +<xsl:template match="appendix/title"></xsl:template> +<xsl:template match="appendix/titleabbrev"></xsl:template> +<xsl:template match="appendix/subtitle"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="dedication" mode="component.number"> + <xsl:param name="add.space" select="false()"/> +</xsl:template> + +<xsl:template match="preface" mode="component.number"> + <xsl:param name="add.space" select="false()"/> +</xsl:template> + +<xsl:template match="chapter" mode="component.number"> + <xsl:param name="add.space" select="false()"/> + + <xsl:choose> + <xsl:when test="@label"> + <xsl:value-of select="@label"/> + <xsl:text>.</xsl:text> + <xsl:if test="$add.space"> + <xsl:call-template name="gentext.space"/> + </xsl:if> + </xsl:when> + <xsl:when test="$chapter.autolabel"> + <xsl:number from="book" count="chapter" format="1."/> + <xsl:if test="$add.space"> + <xsl:call-template name="gentext.space"/> + </xsl:if> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="appendix" mode="component.number"> + <xsl:param name="add.space" select="false()"/> + + <xsl:choose> + <xsl:when test="@label"> + <xsl:value-of select="@label"/> + <xsl:text>.</xsl:text> + <xsl:if test="$add.space"> + <xsl:call-template name="gentext.space"/> + </xsl:if> + </xsl:when> + <xsl:when test="$chapter.autolabel"> + <xsl:number from="book" count="appendix" format="A."/> + <xsl:if test="$add.space"> + <xsl:call-template name="gentext.space"/> + </xsl:if> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="article" mode="component.number"> + <xsl:param name="add.space" select="false()"/> +</xsl:template> + +<xsl:template match="bibliography" mode="component.number"> + <xsl:param name="add.space" select="false()"/> +</xsl:template> + +<xsl:template match="glossary" mode="component.number"> + <xsl:param name="add.space" select="false()"/> +</xsl:template> + +<xsl:template match="index" mode="component.number"> + <xsl:param name="add.space" select="false()"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="article"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="article.titlepage"/> + <xsl:if test="$generate.article.toc != '0'"> + <xsl:call-template name="component.toc"/> + </xsl:if> + <xsl:apply-templates/> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="title" mode="article.titlepage.recto.mode"> + <xsl:call-template name="component.title"> + <xsl:with-param name="node" select="ancestor::article[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="subtitle" mode="article.titlepage.recto.mode"> + <xsl:call-template name="component.subtitle"> + <xsl:with-param name="node" select="ancestor::article[1]"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="article/artheader|article/articleinfo"></xsl:template> +<xsl:template match="article/title"></xsl:template> +<xsl:template match="article/titleabbrev"></xsl:template> +<xsl:template match="article/subtitle"></xsl:template> + +<xsl:template match="article/appendix"> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + + <div id="{$id}" class="{name(.)}"> + <xsl:call-template name="section.heading"> + <xsl:with-param name="level" select="2"/> + <xsl:with-param name="title"> + <xsl:apply-templates select="." mode="title.markup"/> + </xsl:with-param> + </xsl:call-template> + + <xsl:apply-templates/> + + <xsl:if test="not(ancestor::article)"> + <xsl:call-template name="process.footnotes"/> + </xsl:if> + </div> +</xsl:template> + +<!-- ==================================================================== --> + +</xsl:stylesheet> + diff --git a/xsl/html/division.xsl b/xsl/html/division.xsl new file mode 100644 index 000000000..63760ee8b --- /dev/null +++ b/xsl/html/division.xsl @@ -0,0 +1,134 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template match="set"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"/> + </xsl:variable> + + <div class="{name(.)}" id="{$id}"> + <xsl:call-template name="set.titlepage"/> + <xsl:if test="$generate.set.toc != '0'"> + <xsl:call-template name="set.toc"/> + </xsl:if> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="set/setinfo"></xsl:template> +<xsl:template match="set/title"></xsl:template> +<xsl:template match="set/titleabbrev"></xsl:template> +<xsl:template match="set/subtitle"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="book"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"/> + </xsl:variable> + + <div class="{name(.)}" id="{$id}"> + <xsl:call-template name="book.titlepage"/> + <xsl:apply-templates select="dedication" mode="dedication"/> + <xsl:if test="$generate.book.toc != '0'"> + <xsl:call-template name="division.toc"/> + </xsl:if> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="book/bookinfo"></xsl:template> +<xsl:template match="book/title"></xsl:template> +<xsl:template match="book/titleabbrev"></xsl:template> +<xsl:template match="book/subtitle"></xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="part"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"/> + </xsl:variable> + + <div class="{name(.)}" id="{$id}"> + <xsl:call-template name="part.titlepage"/> + <xsl:if test="not(partintro) and $generate.part.toc != '0'"> + <xsl:call-template name="division.toc"/> + </xsl:if> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="part" mode="make.part.toc"> + <xsl:call-template name="division.toc"/> +</xsl:template> + +<xsl:template match="reference" mode="make.part.toc"> + <xsl:call-template name="division.toc"/> +</xsl:template> + +<xsl:template match="part/docinfo"></xsl:template> +<xsl:template match="part/partinfo"></xsl:template> +<xsl:template match="part/title"></xsl:template> +<xsl:template match="part/titleabbrev"></xsl:template> +<xsl:template match="part/subtitle"></xsl:template> + +<xsl:template match="partintro"> + <div class="{name(.)}"> + <xsl:call-template name="partintro.titlepage"/> + <xsl:apply-templates/> + <xsl:if test="$generate.part.toc != '0'"> + <!-- not ancestor::part because partintro appears in reference --> + <xsl:apply-templates select="parent::*" mode="make.part.toc"/> + </xsl:if> + <xsl:call-template name="process.footnotes"/> + </div> +</xsl:template> + +<xsl:template match="partintro/title"></xsl:template> +<xsl:template match="partintro/titleabbrev"></xsl:template> +<xsl:template match="partintro/subtitle"></xsl:template> + +<xsl:template match="partintro/title" mode="partintro.title.mode"> + <xsl:variable name="id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + <h2> + <a name="{$id}"> + <xsl:apply-templates/> + </a> + </h2> +</xsl:template> + +<xsl:template match="partintro/subtitle" mode="partintro.title.mode"> + <h3> + <i><xsl:apply-templates/></i> + </h3> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="book" mode="division.number"> + <xsl:number from="set" count="book" format="1."/> +</xsl:template> + +<xsl:template match="part" mode="division.number"> + <xsl:number from="book" count="part" format="I."/> +</xsl:template> + +</xsl:stylesheet> + diff --git a/xsl/html/docbook.xsl b/xsl/html/docbook.xsl new file mode 100644 index 000000000..13d2f5e04 --- /dev/null +++ b/xsl/html/docbook.xsl @@ -0,0 +1,203 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + exclude-result-prefixes="doc" + version='1.0'> + +<xsl:output method="html" + encoding="ISO-8859-1" + indent="no"/> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:include href="../VERSION"/> +<xsl:include href="../lib/lib.xsl"/> +<xsl:include href="../common/l10n.xsl"/> +<xsl:include href="../common/common.xsl"/> +<xsl:include href="../common/labels.xsl"/> +<xsl:include href="../common/titles.xsl"/> +<xsl:include href="../common/subtitles.xsl"/> +<xsl:include href="../common/gentext.xsl"/> +<xsl:include href="param.xsl"/> +<xsl:include href="autotoc.xsl"/> +<xsl:include href="lists.xsl"/> +<xsl:include href="callout.xsl"/> +<xsl:include href="verbatim.xsl"/> +<xsl:include href="graphics.xsl"/> +<xsl:include href="xref.xsl"/> +<xsl:include href="formal.xsl"/> +<xsl:include href="table.xsl"/> +<xsl:include href="sections.xsl"/> +<xsl:include href="inline.xsl"/> +<xsl:include href="footnote.xsl"/> +<xsl:include href="html.xsl"/> +<xsl:include href="info.xsl"/> +<xsl:include href="keywords.xsl"/> +<xsl:include href="division.xsl"/> +<xsl:include href="toc.xsl"/> +<xsl:include href="index.xsl"/> +<xsl:include href="refentry.xsl"/> +<xsl:include href="math.xsl"/> +<xsl:include href="admon.xsl"/> +<xsl:include href="component.xsl"/> +<xsl:include href="biblio.xsl"/> +<xsl:include href="glossary.xsl"/> +<xsl:include href="block.xsl"/> +<xsl:include href="qandaset.xsl"/> +<xsl:include href="synop.xsl"/> +<xsl:include href="titlepage.xsl"/> +<xsl:include href="titlepage.templates.xsl"/> +<xsl:include href="pi.xsl"/> + +<!-- ==================================================================== --> + +<xsl:template match="*"> + <xsl:message> + <xsl:text>No template matches </xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>.</xsl:text> + </xsl:message> + + <font color="red"> + <xsl:text><</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>></xsl:text> + <xsl:apply-templates/> + <xsl:text></</xsl:text> + <xsl:value-of select="name(.)"/> + <xsl:text>></xsl:text> + </font> +</xsl:template> + +<xsl:template match="text()"> + <xsl:value-of select="."/> +</xsl:template> + +<xsl:template name="head.content"> + <xsl:param name="node" select="."/> + <xsl:variable name="info" select="($node/docinfo + |$node/chapterinfo + |$node/appendixinfo + |$node/prefaceinfo + |$node/bookinfo + |$node/setinfo + |$node/articleinfo + |$node/artheader + |$node/sect1info + |$node/sect2info + |$node/sect3info + |$node/sect4info + |$node/sect5info + |$node/refsect1info + |$node/refsect2info + |$node/refsect3info + |$node/bibliographyinfo + |$node/glossaryinfo + |$node/indexinfo + |$node/refentryinfo + |$node/partinfo + |$node/referenceinfo)[1]"/> + + <title> + <xsl:variable name="title"> + <xsl:apply-templates select="$node" mode="title.markup"/> + </xsl:variable> + <xsl:value-of select="$title"/> <!-- text only --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID ' + + ' not found in document. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/html/ebnf.xsl b/xsl/html/ebnf.xsl new file mode 100644 index 000000000..598d577b4 --- /dev/null +++ b/xsl/html/ebnf.xsl @@ -0,0 +1,350 @@ + + + + + + + + +$Id$ + +Walsh +Norman +19992000 +Norman Walsh + + +HTML EBNF Reference + + +
Introduction + +This is technical reference documentation for the DocBook XSL +Stylesheets; it documents (some of) the parameters, templates, and +other elements of the stylesheets. + +This reference describes the templates and parameters relevant +to formatting EBNF markup. + +This is not intended to be user documentation. +It is provided for developers writing customization layers for the +stylesheets, and for anyone who's interested in how it +works. + +Although I am trying to be thorough, this documentation is known +to be incomplete. Don't forget to read the source, too :-) +
+
+
+ + + + + + + + + +#F5DCB3 + + +Background color for EBNF tables + +Sets the background color for EBNF tables. No bgcolor +attribute is output if ebnf.table.bgcolor is set to +the null string. The default value matches the value used in recent +online versions of the W3C's XML Spec productions. + + + +1 + + +Selects border on EBNF tables + +Selects the border on EBNF tables. If non-zero, the tables have +borders, otherwise they don't. + + + + + + + + + + + + + + 1 + + + + + + EBNF + + for + + + + + + + + + + + + +
+ +
+ + + + + + + + + + EBNF productions + +
+
+
+ + + + + + + + + + + [ + + ] + + + + + + + + + + + + + + + + + + + + ::= + + + + + + + + + + +   + + + + + + + + + + + + + + Error: no ID for productionrecap linkend: + + . + + + + + + Warning: multiple "IDs" for productionrecap linkend: + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + production + + + + + + + + + Non-terminals with no content must point to + production elements in the current document. + + + Invalid xpointer for empty nt: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ??? + + + + + + + + + + + + + /*  + +  */ + + + + + + + + + + constraintdef + + + + + + + + + + + +
+
+ [ + + + + + : + + + + + + + : + + + + + + + + + + ] +
+ + +
+ +
+
+ + +

+
+ + + +
diff --git a/xsl/html/footnote.xsl b/xsl/html/footnote.xsl new file mode 100644 index 000000000..a5c7ec7d5 --- /dev/null +++ b/xsl/html/footnote.xsl @@ -0,0 +1,138 @@ + + + + + + + + + + + #ftn. + + + + + + + [ + + + + ] + + + + + [ + + + + ] + + + + + + + + + + #ftn. + + + + + + [ + + + + ] + + + + + + + + + + + + + + + + + + + + + ftn. + + + + + + # + + + + +

+ + [ + + + + ] + + +

+
+ + + + + + + + + +
+
+
+ +
+
+
+ + +
+ +
+
+ + + + + +
+ +
+
+ +
diff --git a/xsl/html/formal.xsl b/xsl/html/formal.xsl new file mode 100644 index 000000000..a53f159ef --- /dev/null +++ b/xsl/html/formal.xsl @@ -0,0 +1,89 @@ + + + + + + +
+ + + + + + +
+
+ + + +

+ + + + + + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/xsl/html/glossary.xsl b/xsl/html/glossary.xsl new file mode 100644 index 000000000..be7c3e3f3 --- /dev/null +++ b/xsl/html/glossary.xsl @@ -0,0 +1,183 @@ + + + + + + + + + + +
+ +
+ +
+ +
+
+ + + + + + + +

+ +

+
+ + +

+ +

+
+ + + + +
+ + + + + + +
+ +
+
+ + + + + +
+ +
+
+ + +

+ +

+
+ + + + + + + + + + +
+ +
+
+ + +
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+

+ + + + + + + + + + + + + + + . +

+
+
+ + +
+
+ + + + + +

+ + + + + + + + + + + + + + + . +

+
+ + + + + + + + + + + + + + diff --git a/xsl/html/graphics.xsl b/xsl/html/graphics.xsl new file mode 100644 index 000000000..d7b4e009a --- /dev/null +++ b/xsl/html/graphics.xsl @@ -0,0 +1,291 @@ + + + + + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + A fileref or entityref is required on + + + + + + + + + + + + + + + + + % + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to insert files with + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to insert files with + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
diff --git a/xsl/html/html.xsl b/xsl/html/html.xsl new file mode 100644 index 000000000..839c8ac68 --- /dev/null +++ b/xsl/html/html.xsl @@ -0,0 +1,56 @@ + + + + + + + bullet + + + + + + + + + + + + + + + + bullet + + + © + + + ® + (SM) +   + + + + + + + + + + + + + + + + diff --git a/xsl/html/index.xsl b/xsl/html/index.xsl new file mode 100644 index 000000000..5035ce809 --- /dev/null +++ b/xsl/html/index.xsl @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
+ + + + + + + + + + + +

+ + + +

+ + + +

+ +

+
+ + + + +
+ +
+ +
+
+
+ + + + + + + + + + + +

+ + + +

+
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+ + +
+ +
+ + +
+
+ +
+
+
+ +
+
+ +
+
+
+
+
+ + +
+ +
+ +
+
+ +
+
+
+
+ + +
+ +
+
+ + + + + + diff --git a/xsl/html/info.xsl b/xsl/html/info.xsl new file mode 100644 index 000000000..b1d664927 --- /dev/null +++ b/xsl/html/info.xsl @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/html/inline.xsl b/xsl/html/inline.xsl new file mode 100644 index 000000000..95358ba1b --- /dev/null +++ b/xsl/html/inline.xsl @@ -0,0 +1,692 @@ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + , + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + element + + + + + + + + + + + + + + + + + </ + + > + + + + + + + & + + ; + + + + + + + &# + + ; + + + + + + + % + + ; + + + + + + + <? + + > + + + + + + + <? + + ?> + + + + + + + < + + > + + + + + + + < + + /> + + + + + + + <!-- + + --> + + + + + + + + + + + + + < + + mailto: + + + > + + + + + + + + + + + + - + - + - + + - + + + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + + + + + + + + + + + -> + + + + + + + + + + + + + + + + + + + + + + + + [ + + ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/html/keywords.xsl b/xsl/html/keywords.xsl new file mode 100644 index 000000000..c3b5f706e --- /dev/null +++ b/xsl/html/keywords.xsl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + diff --git a/xsl/html/lists.xsl b/xsl/html/lists.xsl new file mode 100644 index 000000000..bca4f31bc --- /dev/null +++ b/xsl/html/lists.xsl @@ -0,0 +1,626 @@ + + + + + + + + +
+ + + +
    + + + + + + +
+
+
+ + +

+
+ + + + + 1 + + + + 2 + + + + + + + + + + + + + + + + + + + + + 1 + + + + + 1 + a + i + A + I + + + + + + 1 + a + i + A + I + + + + +
+ + + +
    + + + + + + + + + + + + + + + + +
+
+
+ + +

+
+ + +
+ + + +
+ +
+
+
+ + +

+
+ + + + + + + + + + + + + + + + + + + + + disc + square + + + + + + +
  • + + + list-style-type: + + + + + + + + + + + +
    + +
    +
    + + + +
    +
  • +
    + + + + + + + + + +
    +
    + + + + , + + + + + + + + + +
    + +
    +
    + + + +
    +
    + + + + + + + + + + + + + + 1 + + + +
    +
    + + + + + + + + + + + + + + 1 + + + +
    +
    + + + + + + + + + + 1 + + + +
    +
    + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + 1 + 1 + + 1 + + + + + + + + + + +   + + + &nbsp; + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + 1 + + 1 + + + + + + + + + + +   + + + &nbsp; + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + +
    + + + +
    +
    +
    + + + + + +

    + + + +

    +
    + + +
    +
    + + +
  • +
    + + + + + + + + + + + + +

    +
    + + + + + + + + + + + + + + + + + + + +

    + + + : + + +

    +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ??? + + +
    + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ??? + + + + + + +
    + diff --git a/xsl/html/math.xsl b/xsl/html/math.xsl new file mode 100644 index 000000000..502a930d8 --- /dev/null +++ b/xsl/html/math.xsl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/xsl/html/param.xsl b/xsl/html/param.xsl new file mode 100644 index 000000000..5f16be9d1 --- /dev/null +++ b/xsl/html/param.xsl @@ -0,0 +1,1048 @@ + + + + + + + + +$Id$ + +Walsh +Norman +19992000 +Norman Walsh + + +HTML Parameter Reference + + +
    Introduction + +This is technical reference documentation for the DocBook XSL +Stylesheets; it documents (some of) the parameters, templates, and +other elements of the stylesheets. + +This reference describes each of the HTML Stylesheet parameters. +These are the easily customizable parts of the stylesheet. +If you want to specify an alternate value for one or more of these +parameters, you can do so in a driver stylesheet. + +For example, if you want to change the html.stylesheet +to reference.css, you might create a driver +stylesheet like this: + + + + + + reference.css + +]]> + +Naturally, you have to change the +href attribute on +<xsl:import> +to point to docbook.xsl +on your system. (Or chunk.xsl, if you're using +chunking.) + +This is not intended to be user documentation. +It is provided for developers writing customization layers for the +stylesheets, and for anyone who's interested in how it +works. + +Although I am trying to be thorough, this documentation is known +to be incomplete. Don't forget to read the source, too :-) +
    +
    +
    + + + + + +Is othername in author a +middle name? + +If true (non-zero), the othername of an author +appears between the firstname and +surname. Otherwise, othername +is suppressed. + + + + + + + + +Name of the stylesheet to use in the generated HTML + +The name of the stylesheet to place in the HTML LINK +tag, or the empty string to suppress the stylesheet LINK. + + + + + +text/css + + +The type of the stylesheet used in the generated HTML + +The type of the stylesheet to place in the HTML link tag. + + + + + + + + +An HTML base URI + +If html.base is set, it is used for the BASE +element in the HEAD of the HTML documents. +This is useful for dynamically served HTML where the base URI needs +to be shifted. + + + + + + + +The HTML anchor target for ULinks + +If ulink.target is set, its value will +be used for the target attribute +on anchors generated for ulinks. + + + + + + + +Output manvolnum as part of +refentry cross-reference? + +if true (non-zero), the manvolnum is used when cross-referencing +refentrys, either with xref +or citerefentry. + + + + + +1 + + +Display comment elements? + +If true (non-zero), comments will be displayed, otherwise they are suppressed. +Comments here refers to the comment element, +which will be renamed remark in DocBook V4.0, +not XML comments (<-- like this -->) which are unavailable. + + + + + +kr + + +What style of 'FuncSynopsis' should be generated? + +If funcsynopsis.style is ansi, +ANSI-style function synopses are generated for a +funcsynopsis, otherwise K&R-style +function synopses are generated. + + + + + + + + +Decorate elements of a FuncSynopsis? + +If true (non-zero), elements of the FuncSynopsis will be decorated (e.g. bold or +italic). The decoration is controlled by functions that can be redefined +in a customization layer. + + + + + +0 + + +Generate parens after a function? + +If not 0, the formatting of +a function element will include +generated parenthesis. + + + + + + + + +Output NAME header before 'RefName'(s)? + +If true (non-zero), a "NAME" section title is output before the list +of 'RefName's. + + + + + + + + +Use graphics in admonitions? + +If true (non-zero), admonitions are presented in an alternate style that uses +a graphic. Default graphics are provided in the distribution. + + + + + +../images/ + + +Path to admonition graphics + +Sets the path, probably relative to the directory where the HTML +files are created, to the admonition graphics. + + + + + + + + +Extension for admonition graphics + +Sets the extension to use on admonition graphics. + + + + + + margin-left: 0.5in; margin-right: 0.5in; + + + +CSS style attributes for admonitions + +Specifies the value of the STYLE +attribute that should be added to admonitions. + + + + + + + + +Are sections enumerated? + +If true (non-zero), unlabeled sections will be enumerated. + + + + + + + + +Do section labels include the component label? + +If true (non-zero), section labels are prefixed with the label of the +component that contains them. + + + + + + + + + +Are chapters and appendixes enumerated? + +If true (non-zero), unlabeled chapters and appendixes will be enumerated. + + + + + + + + +Are prefaces enumerated? + +If true (non-zero), unlabeled prefaces will be enumerated. + + + + + + + + +Are parts and references enumerated? + +If true (non-zero), unlabeled parts and references will be enumerated. + + + + + + + + +Are divisions in QAndASets enumerated? + +If true (non-zero), unlabeled qandadivs will be enumerated. + + + + + + + + +Does enumeration of QandASet components inherit the numeration of parent elements? + +If true (non-zero), numbered QandADiv elements and Questions and Answers inherit +the numeration of the ancestors of the QandASet. + + + + + +number + + +Sets the default for defaultlabel on QandASet. + +If no defaultlabel attribute is specified on a QandASet, this +value is used. It must be one of the legal values for the defaultlabel +attribute. + + + + + +1 + + +Is a Table of Contents created for QandASets? + +If true (non-zero), a ToC is constructed for QandASets. + + + + + +0 + + +Is a Table of Contents created for QandADivs? + +If true (non-zero), a ToC is constructed for QandADivs. + + + + + +. + + +Text to separate bibliography entries + +Text to separate bibliography entries + + + + + +2 + + +How deep should recursive sections appear +in the TOC? + +Specifies the depth to which recursive sections should appear in the +TOC. + + + + + + + + +Will the output be chunked? + +In addition to providing chunking, the chunker can cleanup a +number of XML to HTML issues. If the chunker is not being used, the +stylesheets try to avoid producing results that will not appear properly +in browsers. + + + + + + + + +Should TOCs be genereated in components (Chapters, Appendixes, etc.)? + +If true (non-zero), they are. + + + + + + + +Should TOCs be genereated in divisions (Books, Parts, etc.)? + +If true (non-zero), they are. + + + + + + + + +Mailto URL for the LINK REL=made HTML HEAD element + +If not the empty string, this address will be used for the +REL=made LINK element in the HTML HEAD. + + + + + + + + +Default extension for graphic filenames + +If a graphic or mediaobject +includes a reference to a filename that does not include an extension, +and the format attribute is +unspecified, the default extension will be used. + + + + + +dl + + +Type of HTML list element to use for Tables of Contents + +When an automatically generated Table of Contents (or List of Titles) +is produced, this HTML element will be used to make the list. + + + + + +1 + + +Test the target of IDREF attributes? + +If 1, the target of IDREF attributes are tested for presence +(and uniqueness). This can be very expensive in large documents. + + + + + + + + +Use the XPath id() function to find link targets? + +If 1, the stylesheets use the id() function +to find the targets of cross reference elements. This is more +efficient, but only works if your XSLT processor implements the +id() function, naturally. +THIS PARAMETER IS NOT SUPPORTED. IT IS ALWAYS ASSUMED TO BE 1. +SEE xref.xsl IF YOU NEED TO TURN IT OFF. + + + + + + + +Insert additional <p> elements for spacing? + +When non-zero, additional, empty paragraphs are inserted in +several contexts (for example, around informal figures), to create a +more pleasing visual appearance in many browsers. + + + + + + + white + black + #0000FF + #840084 + #0000FF + + + +Additional attributes for the HTML body tag + +The attributes defined by this attribute set are added to the +HTML <body> tag. + + + + + +1 + + +Enable CSS decoration of elements + + +If css.decoration is turned on, then HTML elements +produced by the +stylesheet may be decorated with STYLE attributes. For example, the +LI tags produced for list items may include a fragment of CSS in the +STYLE attribute which sets the CSS property "list-style-type". + + + + + +0 + + +Enable decoration of elements that have a revisionflag + + +If show.revisionflag is turned on, then the stylesheets +may produce additional markup designed to allow a CSS stylesheet to +highlight elements that have specific revisionflag settings. + +The markup inserted will be usually be either a <span> or <div> +with an appropriate class attribute. (The value of +the class attribute will be the same as the value of the revisionflag +attribute). In some contexts, for example tables, where extra markup +would be structurally illegal, the class attribute will be added to the +appropriate container element. + +In general, the stylesheets only test for revisionflag in contexts +where an importing stylesheet would have to redefine whole templates. +Most of the revisionflag processing is expected to be done by another +stylesheet, for example changebars.xsl. + + + + +0 + + +Disable header and footer navigation + + +If suppress.navigation is turned on, header and +footer navigation will be suppressed. + + + + + + + +Specify the root element to format + +If rootid is specified, it must be the +value of an ID that occurs in the document being formatted. The entire +document will be loaded and parsed, but formatting will begin at the +element identified, rather than at the root. For example, this allows +you to process only chapter 4 of a book. +Because the entire document is available to the processor, automatic +numbering, cross references, and other dependencies are correctly +resolved. + + + + + + + +Present callout lists using a table? + +The default presentation of CalloutLists uses +an HTML DL. Some browsers don't align DLs very well +if callout.graphics are used. With this option +turned on, CalloutLists are presented in an HTML +TABLE, which usually results in better alignment +of the callout number with the callout description. + + + + + + + +Use graphics for callouts? + +If non-zero, callouts are presented with graphics (e.g., reverse-video +circled numbers instead of "(1)", "(2)", etc.). +Default graphics are provided in the distribution. + + + + + + + + +Extension for callout graphics + +Sets the extension to use on callout graphics. + + + + + + + +Path to callout graphics + +Sets the path, probably relative to the directory where the HTML +files are created, to the callout graphics. + + + + + + + + +Number of the largest callout graphic + +If callout.graphics +is non-zero, graphics are used to represent +callout numbers. The value of +callout.graphics.number.limit +is +the largest number for which a graphic exists. If the callout number +exceeds this limit, the default presentation "(nnn)" will always +be used. + + + + + + + + +Enable extensions + +If non-zero, extensions may be used. Each extension is +further controlled by its own parameter. But if +use.extensions is zero, no extensions will +be used. + + + + + + + + +Enable the textinsert extension element + +The textinsert extension element inserts the contents of a +a file into the result tree (as text). + + + + + + + + +Enable the line numbering extension + +If true, verbatim environments (elements that have the +format='linespecific' notation attribute: address, literallayout, +programlisting, screen, synopsis) that specify line numbering will +have, surprise, line numbers. + + + + + + + + +Enable the line numbering extension + +If true, verbatim environments (elements that have the +format='linespecific' notation attribute: address, literallayout, +programlisting, screen, synopsis) that specify line numbering will +have, surprise, line numbers. + + + + + + + + +Indicate which lines should be numbered + +If line numbering is enabled, everyNth line will be numbered. + + + + + + + + +Indicates the width of line numbers + +If line numbering is enabled, line numbers will appear right +justified in a field "width" characters wide. + + + + + + + + +Specify a separator between line numbers and lines + +The separator is inserted between line numbers and lines in +the verbatim environment. + + + + + + + + +Enable the callout extension + +The callouts extension processes areaset +elements in ProgramListingCO and other text-based +callout elements. + + + + + + + + +Enable the callout extension + +The callouts extension processes areaset +elements in ProgramListingCO and other text-based +callout elements. + + + + + + + + +Indicates what column callouts appear in by default + +If a callout does not identify a column (for example, if it uses +the linerange unit), +it will appear in the default column. + + + + + + + + +Identifies the output format of this stylesheet + +The Saxon extension functions need to know if the output format +is HTML ('html') or XSL Formatting Objects ('fo'). This variable answers +that question. Valid settings are 'html' or 'fo'. + + + + + + + +The (absolute) nominal width of tables + +In order to convert CALS column widths into HTML column widths, it +is sometimes necessary to have an absolute table width to use for conversion +of mixed absolute and relative widths. This value must be an absolute +length (not a percentag). + + + + + + + +The default width of tables + +If specified, this value will be used for the WIDTH attribute on +tables that do not specify an alternate width (with the dbhtml processing +instruction). + + + + + + + +Enable the table columns extension function + +The table columns extension function adjusts the widths of table +columns in the HTML result to more accurately reflect the specifications +in the CALS table. + + + + + + + + +Enable the table columns extension function + +The table columns extension function adjusts the widths of table +columns in the HTML result to more accurately reflect the specifications +in the CALS table. + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +FIXME: + +FIXME: + + + + + + + + +Number of the largest callout graphic + +If callout.graphics +is non-zero, graphics are used to represent +callout numbers. The value of +callout.graphics.number.limit +is +the largest number for which a graphic exists. If the callout number +exceeds this limit, the default presentation "(nnn)" will always +be used. + + + + + + + + +Number of the largest callout graphic + +If callout.graphics +is non-zero, graphics are used to represent +callout numbers. The value of +callout.graphics.number.limit +is +the largest number for which a graphic exists. If the callout number +exceeds this limit, the default presentation "(nnn)" will always +be used. + + + + + + + + +Use ID value of chunk elements as the filename? + +If use.id.as.filename +is non-zero, the filename of chunk elements that have IDs will be +derived from the ID value. + + + + +
    diff --git a/xsl/html/pi.xsl b/xsl/html/pi.xsl new file mode 100644 index 000000000..b9220aa9f --- /dev/null +++ b/xsl/html/pi.xsl @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + filename + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + filename + + + + + + + + dir + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    +
    + + + + + + No cmdsynopsis elements matched dbcmdlist PI, perhaps it's nested too deep? + + + +
    + + + +
    +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    +
    + + + + + + No funcsynopsis elements matched dbfunclist PI, perhaps it's nested too deep? + + + +
    + + + +
    +
    + + + +
    diff --git a/xsl/html/qandaset.xsl b/xsl/html/qandaset.xsl new file mode 100644 index 000000000..5109dc149 --- /dev/null +++ b/xsl/html/qandaset.xsl @@ -0,0 +1,202 @@ + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + + + + + + + + +
    +

    + + + + + + + +

    + +
    +
    + + + + + +
    +

    + + + + + +

    + +
    +
    + + + + + + + + +
    + + +
    +
    + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +
    +
    + + + + + + + + + + + + + +
    diff --git a/xsl/html/refentry.xsl b/xsl/html/refentry.xsl new file mode 100644 index 000000000..814874677 --- /dev/null +++ b/xsl/html/refentry.xsl @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + ) + + + + + + + + + + + + + + + + + + , + + + + + +

    + + + +

    +
    + + + , + +
    + + + + + em-dash + + + + + + + + + + +

    + + + + : + + + +

    +
    + + +
    + + + + + +

    Synopsis

    + +
    +
    + + + + + + + + + + + +

    + + + + + + + + +

    +
    + + +

    + + + + + + + + +

    +
    + + +

    + + + + + + + + +

    +
    + + + + + + + +
    diff --git a/xsl/html/sections.xsl b/xsl/html/sections.xsl new file mode 100644 index 000000000..0f3430938 --- /dev/null +++ b/xsl/html/sections.xsl @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + title + + + clear: all + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + title + + + clear: all + + + + + + + + + + + + + + + + + +

    +
    + +
    + diff --git a/xsl/html/synop.xsl b/xsl/html/synop.xsl new file mode 100644 index 000000000..9c0f30d70 --- /dev/null +++ b/xsl/html/synop.xsl @@ -0,0 +1,939 @@ + + + +]> + + + + + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + + +
    + ( + + ) + + + + + + + + + + + + +

    + + ( + + ) + + + +

    +
    + + + + + + +
    +
    + + +

    + + + + + + +

    +
    + + + + + + + + + + + + + + + + + + + + + + (void); + + + (); + + + + + + (...); + + + + + + + ( + + + + + + + + + + + , + + + ); + + + + + + + + + + + + + + + + + , + + + + +
    + + ; +
    + + + ( + + ) + + + + +java + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized language on classsynopsis: + + + + + + + + + + + + +
    +    
    +    
    +       extends
    +      
    +      
    +	&RE;    
    +      
    +    
    +    
    +      implements
    +      
    +      
    +	&RE;    
    +      
    +    
    +    
    +      throws
    +      
    +    
    +     {&RE;&RE;
    +    
    +    }
    +  
    +
    + + + + + + + + + , + + + + + + + + + + + + + +   + + + + + + , + + + + + + + + + , + + + + + + + + + , + + + + + + + +
    +    + + ; +
    +
    + + + + +   + + + + + + +   + + + + + + + + + + + + + void  + + + + + + + + + + + 0 + + ,&RE; + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + ( + + + + ) + + &RE;    throws  + + + ; +
    +
    + + + + +
    +    
    +    
    +      : 
    +      
    +      
    +	&RE;    
    +      
    +    
    +    
    +       implements
    +      
    +      
    +	&RE;    
    +      
    +    
    +    
    +       throws
    +      
    +    
    +     {&RE;&RE;
    +    
    +    }
    +  
    +
    + + + + + + + + , + + + + + + + + + +   + + + + + + , + + + + + + + + + , + + + + + + + + + , + + + + + + + +
    +    + + ; +
    +
    + + + + +   + + + + + + +   + + + + + + + + + + + + + void  + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + ( + + ) + + &RE;    throws  + + + ; +
    +
    + + + + +
    +    interface 
    +    
    +    
    +      : 
    +      
    +      
    +	&RE;    
    +      
    +    
    +    
    +       implements
    +      
    +      
    +	&RE;    
    +      
    +    
    +    
    +       throws
    +      
    +    
    +     {&RE;&RE;
    +    
    +    }
    +  
    +
    + + + + + + + + , + + + + + + + + + +   + + + + + + , + + + + + + + + + , + + + + + + + + + , + + + + + + + +
    +    + + ; +
    +
    + + + + +   + + + + + + +   + + + + + + + + + + + + + void  + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + ( + + ) + + &RE;    raises( + + ) + + ; +
    +
    + + + + +
    +    package 
    +    
    +    ;&RE;
    +
    +    
    +      @ISA = (
    +      
    +      );&RE;
    +    
    +
    +    
    +  
    +
    + + + + + + + + , + + + + + + + + + +   + + + + + + , + + + + + + + + + , + + + + + + + + + , + + + + + + + +
    +    + + ; +
    +
    + + + + +   + + + + + + +   + + + + + + + + + + + + + void  + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + +
    + sub + + + { ... }; +
    +
    + + + +
    diff --git a/xsl/html/table.xsl b/xsl/html/table.xsl new file mode 100644 index 000000000..83869b132 --- /dev/null +++ b/xsl/html/table.xsl @@ -0,0 +1,623 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100% + + + + + + + + + + + 0 + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 100% + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to do convert lengths with + + + + + + + + + + + + + + + + + + + + + + + + + + + + Don't know how to do adjust column widths with + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + th + + + + + + td + + + + + + th + + + + + td + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + +Determine the column number in which a given entry occurs + +If an entry has a +colname or +namest attribute, this template +will determine the number of the column in which the entry should occur. +For other entrys, nothing is returned. + + + +entry + +The entry-element which is to be tested. + + + + + + +This template returns the column number if it can be determined, +or nothing (the empty string) + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + 1 + + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + diff --git a/xsl/html/titlepage.templates.xml b/xsl/html/titlepage.templates.xml new file mode 100644 index 000000000..30a0b6f05 --- /dev/null +++ b/xsl/html/titlepage.templates.xml @@ -0,0 +1,593 @@ + + + + + + + + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <hr/> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="set" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <hr/> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="book" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <hr/> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="part" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="partintro" wrapper="div"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="reference" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <hr/> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + + <t:titlepage element="dedication" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::dedication[1]"/> + <subtitle predicate="[1]"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="preface" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="chapter" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="appendix" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="section" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect1" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect2" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect3" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect4" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="sect5" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<t:titlepage element="simplesect" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + <corpauthor/> + <authorgroup/> + <author/> + <releaseinfo/> + <copyright/> + <legalnotice/> + <pubdate/> + <revision/> + <revhistory/> + <abstract/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + <xsl:if test="count(parent::*)='0'"><hr/></xsl:if> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="bibliography" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::bibliography[1]"/> + <subtitle predicate="[1]"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="glossary" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]"/> + <subtitle predicate="[1]"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +<t:titlepage element="index" wrapper="div" class="titlepage"> + <t:titlepage-content side="recto"> + <title predicate="[1]" + force="1" + named-template="component.title" + param:node="ancestor-or-self::index[1]"/> + <subtitle predicate="[1]"/> + </t:titlepage-content> + + <t:titlepage-content side="verso"> + </t:titlepage-content> + + <t:titlepage-separator> + </t:titlepage-separator> + + <t:titlepage-before side="recto"> + </t:titlepage-before> + + <t:titlepage-before side="verso"> + </t:titlepage-before> +</t:titlepage> + +<!-- ==================================================================== --> + +</t:templates> diff --git a/xsl/html/titlepage.xsl b/xsl/html/titlepage.xsl new file mode 100644 index 000000000..8395ddacd --- /dev/null +++ b/xsl/html/titlepage.xsl @@ -0,0 +1,632 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:attribute-set name="book.titlepage.recto.style"/> +<xsl:attribute-set name="book.titlepage.verso.style"/> + +<xsl:attribute-set name="article.titlepage.recto.style"/> +<xsl:attribute-set name="article.titlepage.verso.style"/> + +<xsl:attribute-set name="set.titlepage.recto.style"/> +<xsl:attribute-set name="set.titlepage.verso.style"/> + +<xsl:attribute-set name="part.titlepage.recto.style"/> +<xsl:attribute-set name="part.titlepage.verso.style"/> + +<xsl:attribute-set name="partintro.titlepage.recto.style"/> +<xsl:attribute-set name="partintro.titlepage.verso.style"/> + +<xsl:attribute-set name="reference.titlepage.recto.style"/> +<xsl:attribute-set name="reference.titlepage.verso.style"/> + +<xsl:attribute-set name="dedication.titlepage.recto.style"/> +<xsl:attribute-set name="dedication.titlepage.verso.style"/> + +<xsl:attribute-set name="preface.titlepage.recto.style"/> +<xsl:attribute-set name="preface.titlepage.verso.style"/> + +<xsl:attribute-set name="chapter.titlepage.recto.style"/> +<xsl:attribute-set name="chapter.titlepage.verso.style"/> + +<xsl:attribute-set name="appendix.titlepage.recto.style"/> +<xsl:attribute-set name="appendix.titlepage.verso.style"/> + +<xsl:attribute-set name="bibliography.titlepage.recto.style"/> +<xsl:attribute-set name="bibliography.titlepage.verso.style"/> + +<xsl:attribute-set name="glossary.titlepage.recto.style"/> +<xsl:attribute-set name="glossary.titlepage.verso.style"/> + +<xsl:attribute-set name="index.titlepage.recto.style"/> +<xsl:attribute-set name="index.titlepage.verso.style"/> + +<xsl:attribute-set name="section.titlepage.recto.style"/> +<xsl:attribute-set name="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect1.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect1.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect2.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect2.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect3.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect3.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect4.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect4.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="sect5.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="sect5.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="simplesect.titlepage.recto.style" + use-attribute-sets="section.titlepage.recto.style"/> +<xsl:attribute-set name="simplesect.titlepage.verso.style" + use-attribute-sets="section.titlepage.verso.style"/> + +<xsl:attribute-set name="table.of.contents.titlepage.recto.style"/> +<xsl:attribute-set name="table.of.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.tables.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.tables.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.figures.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.figures.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.equations.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.equations.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.examples.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.examples.contents.titlepage.verso.style"/> + +<xsl:attribute-set name="list.of.unknowns.titlepage.recto.style"/> +<xsl:attribute-set name="list.of.unknowns.contents.titlepage.verso.style"/> + +<!-- ==================================================================== --> + +<xsl:template match="*" mode="titlepage.mode"> + <!-- if an element isn't found in this mode, try the default mode --> + <xsl:apply-templates select="."/> +</xsl:template> + +<xsl:template match="abbrev" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="abstract" mode="titlepage.mode"> + <div class="{name(.)}"> + <xsl:call-template name="formal.object.heading"> + <xsl:with-param name="title"> + <xsl:apply-templates select="." mode="title.markup"/> + </xsl:with-param> + </xsl:call-template> + <xsl:apply-templates mode="titlepage.mode"/> + </div> +</xsl:template> + +<xsl:template match="abstract/title" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="address" mode="titlepage.mode"> + <xsl:apply-templates select="."/> +</xsl:template> + +<xsl:template match="affiliation" mode="titlepage.mode"> + <div class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </div> +</xsl:template> + +<xsl:template match="artpagenums" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="author" mode="titlepage.mode"> + <h3 class="{name(.)}"><xsl:call-template name="person.name"/></h3> + <xsl:apply-templates mode="titlepage.mode" select="./affiliation"/> +</xsl:template> + +<xsl:template match="authorblurb" mode="titlepage.mode"> + <div class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </div> +</xsl:template> + +<xsl:template match="authorgroup" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="authorinitials" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="bibliomisc" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="bibliomset" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="collab" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="confgroup" mode="titlepage.mode"> + <div class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </div> +</xsl:template> + +<xsl:template match="confdates" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="conftitle" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="confnum" mode="titlepage.mode"> + <!-- suppress --> +</xsl:template> + +<xsl:template match="contractnum" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="contractsponsor" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="contrib" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="copyright" mode="titlepage.mode"> + <xsl:variable name="years" select="year"/> + <xsl:variable name="holders" select="holder"/> + + <p class="{name(.)}"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Copyright'"/> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:call-template name="dingbat"> + <xsl:with-param name="dingbat">copyright</xsl:with-param> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="$years" mode="titlepage.mode"/> + <xsl:call-template name="gentext.space"/> +<!-- + <xsl:call-template name="gentext.by"/> + <xsl:call-template name="gentext.space"/> +--> + <xsl:apply-templates select="$holders" mode="titlepage.mode"/> + </p> +</xsl:template> + +<xsl:template match="year" mode="titlepage.mode"> + <xsl:apply-templates/><xsl:text>, </xsl:text> +</xsl:template> + +<xsl:template match="year[position()=last()]" mode="titlepage.mode"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="holder" mode="titlepage.mode"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="corpauthor" mode="titlepage.mode"> + <h3 class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </h3> +</xsl:template> + +<xsl:template match="corpname" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="date" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="edition" mode="titlepage.mode"> + <p class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <xsl:call-template name="gentext.space"/> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Edition'"/> + </xsl:call-template> + </p> +</xsl:template> + +<xsl:template match="editor" mode="titlepage.mode"> + <h3 class="{name(.)}"><xsl:call-template name="person.name"/></h3> +</xsl:template> + +<xsl:template match="editor[position()=1]" mode="titlepage.mode"> + <h4 class="editedby"><xsl:call-template name="gentext.edited.by"/></h4> + <h3 class="{name(.)}"><xsl:call-template name="person.name"/></h3> +</xsl:template> + +<xsl:template match="firstname" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="graphic" mode="titlepage.mode"> + <!-- use the normal graphic handling code --> + <xsl:apply-templates select="."/> +</xsl:template> + +<xsl:template match="honorific" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="isbn" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="issn" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="itermset" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="invpartnumber" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="issuenum" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="jobtitle" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="keywordset" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="legalnotice " mode="titlepage.mode"> + <div class="{local-name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </div> +</xsl:template> + +<xsl:template match="legalnotice/title" mode="titlepage.mode"> + <p class="legalnotice-title"><b><xsl:apply-templates/></b></p> +</xsl:template> + +<xsl:template match="lineage" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="modespec" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="orgdiv" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="orgname" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="othercredit" mode="titlepage.mode"> + <h3 class="{name(.)}"><xsl:call-template name="person.name"/></h3> + <xsl:apply-templates mode="titlepage.mode" + select="./affiliation"/> +</xsl:template> + +<xsl:template match="othername" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="pagenums" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="printhistory" mode="titlepage.mode"> + <div class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </div> +</xsl:template> + +<xsl:template match="productname" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="productnumber" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="pubdate" mode="titlepage.mode"> + <p class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </p> +</xsl:template> + +<xsl:template match="publishername" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="pubsnumber" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="releaseinfo" mode="titlepage.mode"> + <p class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </p> +</xsl:template> + +<xsl:template match="revhistory" mode="titlepage.mode"> + <xsl:variable name="numcols"> + <xsl:choose> + <xsl:when test="//authorinitials">3</xsl:when> + <xsl:otherwise>2</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <div class="{name(.)}"> + <table border="1" width="100%" summary="Revision history"> + <tr> + <th align="left" valign="top" colspan="{$numcols}"> + <b> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'RevHistory'"/> + </xsl:call-template> + </b> + </th> + </tr> + <xsl:apply-templates mode="titlepage.mode"> + <xsl:with-param name="numcols" select="$numcols"/> + </xsl:apply-templates> + </table> + </div> +</xsl:template> + +<xsl:template match="revhistory/revision" mode="titlepage.mode"> + <xsl:param name="numcols" select="'3'"/> + <xsl:variable name="revnumber" select=".//revnumber"/> + <xsl:variable name="revdate" select=".//date"/> + <xsl:variable name="revauthor" select=".//authorinitials"/> + <xsl:variable name="revremark" select=".//revremark|.//revdescription"/> + <tr> + <td align="left"> + <xsl:if test="$revnumber"> + <xsl:call-template name="gentext"> + <xsl:with-param name="key" select="'Revision'"/> + </xsl:call-template> + <xsl:call-template name="gentext.space"/> + <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/> + </xsl:if> + </td> + <td align="left"> + <xsl:apply-templates select="$revdate[1]" mode="titlepage.mode"/> + </td> + <xsl:choose> + <xsl:when test="$revauthor"> + <td align="left"> + <xsl:apply-templates select="$revauthor[1]" mode="titlepage.mode"/> + </td> + </xsl:when> + <xsl:when test="$numcols > 2"> + <td> </td> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> + </tr> + <xsl:if test="$revremark"> + <tr> + <td align="left" colspan="{$numcols}"> + <xsl:apply-templates select="$revremark[1]" mode="titlepage.mode"/> + </td> + </tr> + </xsl:if> +</xsl:template> + +<xsl:template match="revision/revnumber" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/date" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/authorinitials" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/revremark" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="revision/revdescription" mode="titlepage.mode"> + <xsl:apply-templates mode="titlepage.mode"/> +</xsl:template> + +<xsl:template match="seriesvolnums" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="shortaffil" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="subjectset" mode="titlepage.mode"> +</xsl:template> + +<xsl:template match="subtitle" mode="titlepage.mode"> + <h2 class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + </h2> +</xsl:template> + +<xsl:template match="surname" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="title" mode="titlepage.mode"> + <xsl:variable name="id"> + <xsl:choose> + <!-- if title is in an *info wrapper, get the grandparent --> + <xsl:when test="contains(local-name(..), 'info')"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="../.."/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <h1 class="{name(.)}"> + <a name="{$id}"/> + <xsl:choose> + <xsl:when test="$show.revisionflag and @revisionflag"> + <span class="{@revisionflag}"> + <xsl:apply-templates mode="titlepage.mode"/> + </span> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates mode="titlepage.mode"/> + </xsl:otherwise> + </xsl:choose> + </h1> +</xsl:template> + +<xsl:template match="titleabbrev" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<xsl:template match="volumenum" mode="titlepage.mode"> + <span class="{name(.)}"> + <xsl:apply-templates mode="titlepage.mode"/> + <br/> + </span> +</xsl:template> + +<!-- ==================================================================== --> + +</xsl:stylesheet> diff --git a/xsl/html/toc.xsl b/xsl/html/toc.xsl new file mode 100644 index 000000000..55d471626 --- /dev/null +++ b/xsl/html/toc.xsl @@ -0,0 +1,31 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template match="toc"> +</xsl:template> + +<xsl:template match="tocpart|tocchap|tocfront|tocback|tocentry"> +</xsl:template> + +<xsl:template match="toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="lot|lotentry"> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/verbatim.xsl b/xsl/html/verbatim.xsl new file mode 100644 index 000000000..d958d91c3 --- /dev/null +++ b/xsl/html/verbatim.xsl @@ -0,0 +1,298 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim" + xmlns:xverb="com.nwalsh.xalan.Verbatim" + xmlns:lxslt="http://xml.apache.org/xslt" + exclude-result-prefixes="sverb xverb lxslt" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<lxslt:component prefix="xverb" + functions="numberLines"/> + +<xsl:template match="programlisting|screen|synopsis"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable> + + <!-- Obey the <?dbhtml linenumbering.everyNth="x"?> PI --> + <xsl:variable name="pi.linenumbering.everyNth"> + <xsl:call-template name="dbhtml-attribute"> + <xsl:with-param name="attribute" select="'everyNth'"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="everyNth"> + <xsl:choose> + <xsl:when test="$pi.linenumbering.everyNth != ''"> + <xsl:value-of select="$pi.linenumbering.everyNth"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$linenumbering.everyNth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- Obey the <?dbhtml linenumbering.separator="x"?> PI --> + <xsl:variable name="pi.linenumbering.separator"> + <xsl:call-template name="dbhtml-attribute"> + <xsl:with-param name="attribute" select="'linenumbering.separator'"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="separator"> + <xsl:choose> + <xsl:when test="$pi.linenumbering.separator != ''"> + <xsl:value-of select="$pi.linenumbering.separator"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$linenumbering.separator"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:if test="@id"> + <a href="{$id}"/> + </xsl:if> + + <xsl:choose> + <xsl:when test="$suppress-numbers = '0' + and @linenumbering = 'numbered' + and $use.extensions != '0' + and $linenumbering.extension != '0'"> + <xsl:variable name="rtf"> + <xsl:apply-templates/> + </xsl:variable> + <pre class="{name(.)}"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$separator"/> + </xsl:call-template> + </pre> + </xsl:when> + + <xsl:otherwise> + <pre class="{name(.)}"> + <xsl:apply-templates/> + </pre> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="literallayout"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:variable name="rtf"> + <xsl:apply-templates/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$suppress-numbers = '0' + and @linenumbering = 'numbered' + and $use.extensions != '0' + and $linenumbering.extension != '0'"> + <xsl:choose> + <xsl:when test="@class='monospaced'"> + <pre class="{name(.)}"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + </pre> + </xsl:when> + <xsl:otherwise> + <div class="{name(.)}"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + </div> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:otherwise> + <xsl:choose> + <xsl:when test="@class='monospaced'"> + <pre class="{name(.)}"> + <xsl:copy-of select="$rtf"/> + </pre> + </xsl:when> + <xsl:otherwise> + <div class="{name(.)}"> + <xsl:copy-of select="$rtf"/> + </div> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="literallayout[not(@class) + or @class != 'monospaced']//text()"> + <xsl:call-template name="make-verbatim"> + <xsl:with-param name="text" select="."/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="address"> + <xsl:param name="suppress-numbers" select="'0'"/> + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:variable name="rtf"> + <xsl:apply-templates/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$suppress-numbers = '0' + and @linenumbering = 'numbered' + and $use.extensions != '0' + and $linenumbering.extension != '0'"> + <div class="{name(.)}"> + <xsl:call-template name="number.rtf.lines"> + <xsl:with-param name="rtf" select="$rtf"/> + <xsl:with-param name="linenumbering.everyNth" + select="$linenumbering.everyNth"/> + <xsl:with-param name="linenumbering.width" + select="$linenumbering.width"/> + <xsl:with-param name="linenumbering.separator" + select="$linenumbering.separator"/> + </xsl:call-template> + </div> + </xsl:when> + + <xsl:otherwise> + <div class="{name(.)}"> + <xsl:apply-templates/> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="number.rtf.lines"> + <xsl:param name="rtf" select="''"/> + <!-- the following parameters must have these names ... --> + <xsl:param name="linenumbering.everyNth" select="1"/> + <xsl:param name="linenumbering.width" select="3"/> + <xsl:param name="linenumbering.separator" select="' |'"/> + + <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> + + <xsl:choose> + <xsl:when test="contains($vendor, 'SAXON ')"> + <xsl:copy-of select="sverb:numberLines($rtf)"/> + </xsl:when> + <xsl:when test="contains($vendor, 'Apache Software Foundation')"> + <xsl:copy-of select="xverb:numberLines($rtf)"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Don't know how to do line numbering with </xsl:text> + <xsl:value-of select="$vendor"/> + </xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="address//text()"> + <xsl:call-template name="make-verbatim"> + <xsl:with-param name="text" select="."/> + </xsl:call-template> +</xsl:template> + +<xsl:template name="make-verbatim"> + <xsl:param name="text" select="''"/> + + <xsl:variable name="starts-with-space" + select="substring($text, 1, 1) = ' '"/> + + <xsl:variable name="starts-with-nl" + select="substring($text, 1, 1) = ' '"/> + + <xsl:variable name="before-space"> + <xsl:if test="contains($text, ' ')"> + <xsl:value-of select="substring-before($text, ' ')"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="before-nl"> + <xsl:if test="contains($text, ' ')"> + <xsl:value-of select="substring-before($text, ' ')"/> + </xsl:if> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$starts-with-space"> + <xsl:text> </xsl:text> + <xsl:call-template name="make-verbatim"> + <xsl:with-param name="text" select="substring($text,2)"/> + </xsl:call-template> + </xsl:when> + + <xsl:when test="$starts-with-nl"> + <br/><xsl:text> </xsl:text> + <xsl:call-template name="make-verbatim"> + <xsl:with-param name="text" select="substring($text,2)"/> + </xsl:call-template> + </xsl:when> + + <!-- if the string before a space is shorter than the string before + a newline, fix the space...--> + <xsl:when test="$before-space != '' + and ((string-length($before-space) + < string-length($before-nl)) + or $before-nl = '')"> + <xsl:value-of select="$before-space"/> + <xsl:text> </xsl:text> + <xsl:call-template name="make-verbatim"> + <xsl:with-param name="text" select="substring-after($text, ' ')"/> + </xsl:call-template> + </xsl:when> + + <!-- if the string before a newline is shorter than the string before + a space, fix the newline...--> + <xsl:when test="$before-nl != '' + and ((string-length($before-nl) + < string-length($before-space)) + or $before-space = '')"> + <xsl:value-of select="$before-nl"/> + <br/><xsl:text> </xsl:text> + <xsl:call-template name="make-verbatim"> + <xsl:with-param name="text" select="substring-after($text, ' ')"/> + </xsl:call-template> + </xsl:when> + + <!-- the string before the newline and the string before the + space are the same; which means they must both be empty --> + <xsl:otherwise> + <xsl:value-of select="$text"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/xref.xsl b/xsl/html/xref.xsl new file mode 100644 index 000000000..2de5dcac2 --- /dev/null +++ b/xsl/html/xref.xsl @@ -0,0 +1,328 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + exclude-result-prefixes="doc" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + ******************************************************************** --> + +<!-- ==================================================================== --> + +<xsl:template match="anchor"> + <a> + <xsl:attribute name="name"> + <xsl:call-template name="object.id"/> + </xsl:attribute> + </a> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="xref"> + <xsl:variable name="targets" select="id(@linkend)"/> + <xsl:variable name="target" select="$targets[1]"/> + <xsl:variable name="refelem" select="local-name($target)"/> + + <xsl:call-template name="check.id.unique"> + <xsl:with-param name="linkend" select="@linkend"/> + </xsl:call-template> + + <xsl:if test="@id"> + <a name="{@id}"/> + </xsl:if> + + <xsl:choose> + <xsl:when test="$refelem=''"> + <xsl:message> + <xsl:text>XRef to nonexistent id: </xsl:text> + <xsl:value-of select="@linkend"/> + </xsl:message> + <xsl:text>???</xsl:text> + </xsl:when> + + <xsl:when test="$target/@xreflabel"> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target"/> + </xsl:call-template> + </xsl:attribute> + <xsl:call-template name="xref.xreflabel"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + </a> + </xsl:when> + + <xsl:otherwise> + <a> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target"/> + </xsl:call-template> + </xsl:attribute> + + <xsl:choose> + <xsl:when test="@endterm"> + <xsl:variable name="etargets" select="id(@endterm)"/> + <xsl:variable name="etarget" select="$etargets[1]"/> + <xsl:choose> + <xsl:when test="count($etarget) = 0"> + <xsl:message> + <xsl:value-of select="count($etargets)"/> + <xsl:text>Endterm points to nonexistent ID: </xsl:text> + <xsl:value-of select="@endterm"/> + </xsl:message> + <xsl:text>???</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="$etarget" mode="xref.text"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:otherwise> + <xsl:apply-templates select="$target" mode="xref-to"/> + </xsl:otherwise> + </xsl:choose> + </a> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="*" mode="xref-to"> + <xsl:param name="target" select="."/> + <xsl:param name="refelem" select="local-name($target)"/> + + <xsl:message> + <xsl:text>Don't know what gentext to create for xref to: "</xsl:text> + <xsl:value-of select="$refelem"/> + <xsl:text>"</xsl:text> + </xsl:message> + <xsl:text>???</xsl:text> +</xsl:template> + +<xsl:template match="author" mode="xref-to"> + <xsl:param name="target" select="."/> + <xsl:param name="refelem" select="local-name($target)"/> + + <xsl:call-template name="person.name"/> +</xsl:template> + +<xsl:template match="figure" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="example" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="table" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="equation" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="cmdsynopsis" mode="xref-to"> + <xsl:apply-templates select="(.//command)[1]" mode="xref"/> +</xsl:template> + +<xsl:template match="funcsynopsis" mode="xref-to"> + <xsl:apply-templates select="(.//function)[1]" mode="xref"/> +</xsl:template> + +<xsl:template match="dedication" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="preface" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="chapter" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="appendix" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="bibliography" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="biblioentry|bibliomixed" mode="xref-to"> + <!-- handles both biblioentry and bibliomixed --> + <xsl:text>[</xsl:text> + <xsl:choose> + <xsl:when test="local-name(*[1]) = 'abbrev'"> + <xsl:apply-templates select="*[1]"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@id"/> + </xsl:otherwise> + </xsl:choose> + <xsl:text>]</xsl:text> +</xsl:template> + +<xsl:template match="glossary" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="index" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="section|simplesect + |sect1|sect2|sect3|sect4|sect5 + |refsect1|refsect2|refsect3" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> + <!-- What about "in Chapter X"? --> +</xsl:template> + +<xsl:template match="question" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="answer" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="part" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="reference" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<xsl:template match="co" mode="xref-to"> + <xsl:apply-templates select="." mode="callout-bug"/> +</xsl:template> + +<xsl:template match="book" mode="xref-to"> + <xsl:apply-templates select="." mode="object.xref.markup"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="link"> + <xsl:variable name="targets" select="id(@linkend)"/> + <xsl:variable name="target" select="$targets[1]"/> + + <xsl:call-template name="check.id.unique"> + <xsl:with-param name="linkend" select="@linkend"/> + </xsl:call-template> + + <a> + <xsl:if test="@id"> + <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> + </xsl:if> + + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target"/> + </xsl:call-template> + </xsl:attribute> + + <xsl:apply-templates/> + </a> +</xsl:template> + +<xsl:template match="ulink"> + <a> + <xsl:if test="@id"> + <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute> + </xsl:if> + <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute> + <xsl:if test="$ulink.target != ''"> + <xsl:attribute name="target"> + <xsl:value-of select="$ulink.target"/> + </xsl:attribute> + </xsl:if> + <xsl:choose> + <xsl:when test="count(child::node())=0"> + <xsl:value-of select="@url"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </a> +</xsl:template> + +<xsl:template match="olink"> + <xsl:if test="@id"> + <a name="{@id}"/> + </xsl:if> + <xsl:apply-templates/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="title.xref"> + <xsl:param name="target" select="."/> + <xsl:choose> + <xsl:when test="local-name($target) = 'figure' + or local-name($target) = 'example' + or local-name($target) = 'equation' + or local-name($target) = 'table' + or local-name($target) = 'dedication' + or local-name($target) = 'preface' + or local-name($target) = 'bibliography' + or local-name($target) = 'glossary' + or local-name($target) = 'index' + or local-name($target) = 'setindex' + or local-name($target) = 'colophon'"> + <xsl:call-template name="gentext.startquote"/> + <xsl:apply-templates select="$target" mode="title.markup"/> + <xsl:call-template name="gentext.endquote"/> + </xsl:when> + <xsl:otherwise> + <i> + <xsl:apply-templates select="$target" mode="title.markup"/> + </i> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="number.xref"> + <xsl:apply-templates select="." mode="label.markup"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="xref.xreflabel"> + <!-- called to process an xreflabel...you might use this to make --> + <!-- xreflabels come out in the right font for different targets, --> + <!-- for example. --> + <xsl:param name="target" select="."/> + <xsl:value-of select="$target/@xreflabel"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="title" mode="xref"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="command" mode="xref"> + <xsl:call-template name="inline.boldseq"/> +</xsl:template> + +<xsl:template match="function" mode="xref"> + <xsl:call-template name="inline.monoseq"/> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/html/xtchunk.xsl b/xsl/html/xtchunk.xsl new file mode 100644 index 000000000..b1db4d2d9 --- /dev/null +++ b/xsl/html/xtchunk.xsl @@ -0,0 +1,9 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xt="http://www.jclark.com/xt" + extension-element-prefixes="xt" + version="1.0"> + +<xsl:include href="chunk-common.xsl"/> +<xsl:include href="xtchunker.xsl"/> + +</xsl:stylesheet> \ No newline at end of file diff --git a/xsl/html/xtchunker.xsl b/xsl/html/xtchunker.xsl new file mode 100644 index 000000000..202e2851e --- /dev/null +++ b/xsl/html/xtchunker.xsl @@ -0,0 +1,39 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xt="http://www.jclark.com/xt" + extension-element-prefixes="xt" + version="1.0"> + +<!-- This stylesheet works with XT; for others use chunker.xsl --> + +<!-- ==================================================================== --> + +<xsl:template name="make-relative-filename"> + <xsl:param name="base.dir" select="'./'"/> + <xsl:param name="base.name" select="''"/> + + <!-- XT makes chunks relative --> + <xsl:choose> + <xsl:when test="count(parent::*) = 0"> + <xsl:value-of select="concat($base.dir,$base.name)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$base.name"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="write.chunk"> + <xsl:param name="filename" select="''"/> + <xsl:param name="method" select="'html'"/> + <xsl:param name="encoding" select="'ISO-8859-1'"/> + <xsl:param name="content" select="''"/> + + <!-- apparently XT doesn't support AVTs for method and encoding --> + <xt:document href="{$filename}" + method="html" + encoding="ISO-8859-1"> + <xsl:copy-of select="$content"/> + </xt:document> +</xsl:template> + +</xsl:stylesheet> diff --git a/xsl/images/callouts/1.png b/xsl/images/callouts/1.png new file mode 100644 index 000000000..7d473430b Binary files /dev/null and b/xsl/images/callouts/1.png differ diff --git a/xsl/images/callouts/10.png b/xsl/images/callouts/10.png new file mode 100644 index 000000000..997bbc824 Binary files /dev/null and b/xsl/images/callouts/10.png differ diff --git a/xsl/images/callouts/2.png b/xsl/images/callouts/2.png new file mode 100644 index 000000000..5d09341b2 Binary files /dev/null and b/xsl/images/callouts/2.png differ diff --git a/xsl/images/callouts/3.png b/xsl/images/callouts/3.png new file mode 100644 index 000000000..ef7b70047 Binary files /dev/null and b/xsl/images/callouts/3.png differ diff --git a/xsl/images/callouts/4.png b/xsl/images/callouts/4.png new file mode 100644 index 000000000..adb8364eb Binary files /dev/null and b/xsl/images/callouts/4.png differ diff --git a/xsl/images/callouts/5.png b/xsl/images/callouts/5.png new file mode 100644 index 000000000..4d7eb4600 Binary files /dev/null and b/xsl/images/callouts/5.png differ diff --git a/xsl/images/callouts/6.png b/xsl/images/callouts/6.png new file mode 100644 index 000000000..0ba694af6 Binary files /dev/null and b/xsl/images/callouts/6.png differ diff --git a/xsl/images/callouts/7.png b/xsl/images/callouts/7.png new file mode 100644 index 000000000..472e96f8a Binary files /dev/null and b/xsl/images/callouts/7.png differ diff --git a/xsl/images/callouts/8.png b/xsl/images/callouts/8.png new file mode 100644 index 000000000..5e60973c2 Binary files /dev/null and b/xsl/images/callouts/8.png differ diff --git a/xsl/images/callouts/9.png b/xsl/images/callouts/9.png new file mode 100644 index 000000000..a0676d26c Binary files /dev/null and b/xsl/images/callouts/9.png differ diff --git a/xsl/images/caution.gif b/xsl/images/caution.gif new file mode 100644 index 000000000..d9f5e5b1b Binary files /dev/null and b/xsl/images/caution.gif differ diff --git a/xsl/images/caution.png b/xsl/images/caution.png new file mode 100644 index 000000000..5b7809ca4 Binary files /dev/null and b/xsl/images/caution.png differ diff --git a/xsl/images/caution.tif b/xsl/images/caution.tif new file mode 100644 index 000000000..4a282948c Binary files /dev/null and b/xsl/images/caution.tif differ diff --git a/xsl/images/home.png b/xsl/images/home.png new file mode 100644 index 000000000..cbb711de7 Binary files /dev/null and b/xsl/images/home.png differ diff --git a/xsl/images/important.gif b/xsl/images/important.gif new file mode 100644 index 000000000..6795d9a81 Binary files /dev/null and b/xsl/images/important.gif differ diff --git a/xsl/images/important.png b/xsl/images/important.png new file mode 100644 index 000000000..12c90f607 Binary files /dev/null and b/xsl/images/important.png differ diff --git a/xsl/images/important.tif b/xsl/images/important.tif new file mode 100644 index 000000000..184de6371 Binary files /dev/null and b/xsl/images/important.tif differ diff --git a/xsl/images/next.png b/xsl/images/next.png new file mode 100644 index 000000000..45835bf89 Binary files /dev/null and b/xsl/images/next.png differ diff --git a/xsl/images/note.gif b/xsl/images/note.gif new file mode 100644 index 000000000..f329d359e Binary files /dev/null and b/xsl/images/note.gif differ diff --git a/xsl/images/note.png b/xsl/images/note.png new file mode 100644 index 000000000..d0c3c645a Binary files /dev/null and b/xsl/images/note.png differ diff --git a/xsl/images/note.tif b/xsl/images/note.tif new file mode 100644 index 000000000..08644d6b5 Binary files /dev/null and b/xsl/images/note.tif differ diff --git a/xsl/images/prev.png b/xsl/images/prev.png new file mode 100644 index 000000000..cf24654f8 Binary files /dev/null and b/xsl/images/prev.png differ diff --git a/xsl/images/tip.gif b/xsl/images/tip.gif new file mode 100644 index 000000000..823f2b417 Binary files /dev/null and b/xsl/images/tip.gif differ diff --git a/xsl/images/tip.png b/xsl/images/tip.png new file mode 100644 index 000000000..5c4aab3bb Binary files /dev/null and b/xsl/images/tip.png differ diff --git a/xsl/images/tip.tif b/xsl/images/tip.tif new file mode 100644 index 000000000..4a3d8c75f Binary files /dev/null and b/xsl/images/tip.tif differ diff --git a/xsl/images/toc-blank.png b/xsl/images/toc-blank.png new file mode 100644 index 000000000..6ffad17a0 Binary files /dev/null and b/xsl/images/toc-blank.png differ diff --git a/xsl/images/toc-minus.png b/xsl/images/toc-minus.png new file mode 100644 index 000000000..abbb020c8 Binary files /dev/null and b/xsl/images/toc-minus.png differ diff --git a/xsl/images/toc-plus.png b/xsl/images/toc-plus.png new file mode 100644 index 000000000..941312ce0 Binary files /dev/null and b/xsl/images/toc-plus.png differ diff --git a/xsl/images/up.png b/xsl/images/up.png new file mode 100644 index 000000000..07634de26 Binary files /dev/null and b/xsl/images/up.png differ diff --git a/xsl/images/warning.gif b/xsl/images/warning.gif new file mode 100644 index 000000000..3adf19129 Binary files /dev/null and b/xsl/images/warning.gif differ diff --git a/xsl/images/warning.png b/xsl/images/warning.png new file mode 100644 index 000000000..1c33db8f3 Binary files /dev/null and b/xsl/images/warning.png differ diff --git a/xsl/images/warning.tif b/xsl/images/warning.tif new file mode 100644 index 000000000..7b6611ec7 Binary files /dev/null and b/xsl/images/warning.tif differ diff --git a/xsl/lib/lib.xsl b/xsl/lib/lib.xsl new file mode 100644 index 000000000..7aa690b47 --- /dev/null +++ b/xsl/lib/lib.xsl @@ -0,0 +1,242 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + exclude-result-prefixes="doc" + version='1.0'> + +<!-- ******************************************************************** + $Id$ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://nwalsh.com/docbook/xsl/ for copyright + and other information. + + This module implements DTD-independent functions + + ******************************************************************** --> + +<doc:reference xmlns=""> +<referenceinfo> +<releaseinfo role="meta"> +$Id$ +</releaseinfo> +<author><surname>Walsh</surname> +<firstname>Norman</firstname></author> +<copyright><year>1999</year><year>2000</year> +<holder>Norman Walsh</holder> +</copyright> +</referenceinfo> +<title>Library Template Reference + + +
    Introduction + +This is technical reference documentation for the DocBook XSL +Stylesheets; it documents (some of) the parameters, templates, and +other elements of the stylesheets. + +This is not intended to be user documentation. +It is provided for developers writing customization layers for the +stylesheets, and for anyone who's interested in how it +works. + +Although I am trying to be thorough, this documentation is known +to be incomplete. Don't forget to read the source, too :-) +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Substitute one text string for another in a string + +The string.subst template replaces all +occurances of target in string +with replacement and returns the result. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Extract IDREF from an XPointer + +The xpointer.idref template returns the +ID portion of an XPointer which is a pointer to an ID within the current +document, or the empty string if it is not. +In other words, xpointer.idref returns +foo when passed either #foo +or #xpointer(id('foo')), otherwise it returns +the empty string. + + + + + http://... + + + + + + + + + + + + + + + + +Return the unqualified dimension from a length specification + +The length-magnitude template returns the +unqualified length ("20" for "20pt") from a dimension. + + + + + + + + + + + + + + + + + + + + + +Return a fully qualified length specification + +The length-spec template returns the +qualified length from a dimension. If an unqualified length is given, +the default.units will be added to it. + + + + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized unit of measure: + + . + + + + + + diff --git a/xsl/xhtml/docbook.xsl b/xsl/xhtml/docbook.xsl new file mode 100644 index 000000000..31a556291 --- /dev/null +++ b/xsl/xhtml/docbook.xsl @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/xsl/xhtml/xtchunk.xsl b/xsl/xhtml/xtchunk.xsl new file mode 100644 index 000000000..f1ca18d66 --- /dev/null +++ b/xsl/xhtml/xtchunk.xsl @@ -0,0 +1,135 @@ + + + + + + + + + +.xhtm + + + + + + + + + + + + + + + + + + Error + + is not a chunk! + + + + + Writing + + for + + + + + + + + + + + + + + + + + + + + + + + + + + + + +