DocBook XSL NS (namespaced) Stylesheets =========================================== Bob Stayton bobs@sagehill.net This package contains a release of XSL stylesheets for processing namespaced DocBook documents (DocBook 5 or later). The stylesheets are the same as the concurrent stylesheet release except that the templates match on elements in the DocBook namespace. Note, the stylesheets in the directories listed below have not yet been converted to use the DocBook namespace: slides website roundtrip Background ------------- DocBook 5 differs from preceding versions of DocBook because its elements are in a namespace, "http://docbook.org/ns/docbook". Because the elements are in a namespace, the regular DocBook XSL templates do not match on the elements. In XSLT, a match attribute must explicitly specify the namespace prefix to match an element in that namespace (the default namespace does not apply to pattern matches). The non-namspaced DocBook XSL stylesheets (created originally for processing DocBook 4 and earlier documents, before DocBook was put into a namespace for the DocBook 5 release) are able to process a namespaced DocBook document by preprocessing the document to strip the namespace. When the non-namspaced stylesheet detects that the root element of a document is in the DocBook namespace, it processes the document with mode="stripNS" to copy all the nodes to a variable, but without the DocBook namespace. Then it converts the variable to a nodeset, and processes the nodeset with the regular templates. The alternative approach is to create a set of templates that match on the native namespace of DocBook 5 and later documents. These stylesheets do that. These stylesheets completely mimic the behavior of the existing stylesheets. These are not XSLT 2.0 stylesheets, and they do not have any other significant changes than handling the namespaced elements. The two main advantages of these stylesheets are: a. You can write customization layers using the DocBook namespace. b. The xml:base of the root element is not lost during processing (so things like images and the olink database can be found more easily). How these stylesheets were produced ---------------------------------------- These stylesheets were created from a DocBook XSL snapshot. Each xsl file was processed with a Perl script and its output placed in a parallel directory tree. Any non-xsl files were simply copied into place. Perl was used because of its excellent regular expression handling, and because Perl is able to preserve all whitespace. This retains the pretty-printed format that makes the stylesheets easier to read and understand. The stylesheet transforms each XSL match, select, test, count, from, use, and elements attribute to add a "d:" prefix to each element referenced in the attribute. For example: <xsl:template match="para"> becomes: <xsl:template match="d:para"> In addition, each stylesheet file has a namespace declaration added in its root element: <xsl:stylesheet xslns:d="http://docbook.org/ns/docbook" The combination of these two changes means that the templates now recognize DocBook 5 elements in their native namespace. How to use these stylesheets -------------------------------- DocBook 5 and later documents hav the DocBook namespace declaration in the root element, along with the version attribute: <book xslns="http://docbook.org/ns/docbook" version="5.0"> You can process a namespaced DocBook document with these stylesheets using any XSLT processor, including xsltproc, Saxon 6 or 8, and Xalan. Use these stylesheets as you would a stylesheet from the regular distribution (except for slides, website, and roundtrip). If you happen to process a DocBook document whose root element is without the namespace declaration, the stylesheet does not fail. Rather, it detects that the document does not have the namespace, and preprocesses it to add the namespace declaration to all elements in the document. In a manner similar to stripNS, it copies the elements to a variable while adding the namespace, converts the variable to a nodeset, and then processes the nodeset with the namespace-aware templates. If the stylesheet encounters an element from your file for which the stylesheet has no matching template, it reports the unmatched element. In these stylesheets, it also reports the namespace URI that the element has. Customizing these stylesheets -------------------------------- These stylesheets are customized with a customization layer in the same manner as for the regular stylesheets, with two differences. When you create a customization layer, you must do two things: a. Add the namespace declaration (with a prefix of your choice): <xsl:stylesheet xslns:d="http://docbook.org/ns/docbook" b. Use the namespace prefix on all DocBook element names: <xsl:template match="d:formalpara"> Be sure to include the namespace prefix on all element references, including those in match, select, and test attributes, even when using an axis specifier. Here are some examples: <xsl:if test="d:title"> <xsl:apply-templates select="d:title" mode="list.title.mode"/> <xsl:apply-templates select="*[not(self::d:listitem or self::d:title or self::d:titleabbrev)] | comment()[not(preceding-sibling::d:listitem)] | processing-instruction()[not(preceding-sibling::d:listitem)]"/> Failure to add the prefix to an element name will cause the stylesheet to silently not match the intended element, with consequences that are most likely undesirable. Report any problems ------------------------ These are new stylesheets and need thorough testing. Please report any problems to the docbook-apps mailing list or the SourceForge bug tracker.
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 26953 | Paul Allen | Move //guest/perforce_software/p4convert to //guest/perforce_software/p4convert/main | ||
//guest/perforce_software/p4convert/docs/docbook-xsl-ns-1.78.1/README.ns | |||||
#2 | 14806 | Paul Allen | Update docs and add +w. | ||
#1 | 13920 | Paul Allen | copy part 2 (no errors) | ||
//guest/paul_allen/p4convert-maven/docs/docbook-xsl-ns-1.78.1/README.ns | |||||
#1 | 13895 | Paul Allen | Copying using p4convert-docbook | ||
//guest/perforce_software/doc_build/main/docbook-xsl-ns-1.78.1/README.ns | |||||
#1 | 12728 | eedwards |
Upgrade ANT doc build infrastructure to assemble PDFs: - remove non-namespaced DocBook source and add namespaced DocBook source. - add Apache FOP 1.1 - copy fonts, images, XSL into _build, establishing new asset structure. The original structure remains until all guides using it can be upgraded, and several other issues can be resolved. - updated build.xml to allow for per-target build properties. - upgraded the P4SAG to use the new infrastructure. - tweaked admonition presentation in PDFs to remove admonition graphics, and resemble closely the presentation used in the new HTML layout, including the same colors. With these changes, building PDFs involves using a shell, navigating into the guide's directory (just P4SAG for now), and executing "ant pdf". Issues still to be resolved: - PDF generation encounters several warnings about missing fonts (bold versions of Symbol and ZapfDingbats), and a couple of locations where the page content exceeds the defined content area. - Due to issues within Apache FOP, PDF generation emits a substantial amount of output that is not easily suppressed without losing important warning information. - Apache FOP's interface to ANT does not expose a way to set the font base directory. The current configuration does work under Mac OSX, but further testing on Windows will need to be done to determine if the relative paths defined continue to work. The workaround is for Windows users to customize the fop-config.xml to provide absolute system paths to the required fonts. - HTML generation needs further browser testing, and exhibits broken navigation on iOS browsers within the TOC sidebar. - A number of PDF and HTML presentation tweaks still need to be made, for example: sidebars, gui* DocBook tags, whitespace, section separation, etc. |