This chapter covers the following topics:
Modularizing documents by splitting them into XIncludes
Using a consistent set of entities throughout a documentation project
Creating document variants by using profiling
Combining profiling and entities
Instead of putting the contents of a complete article or book into the
MAIN file, DocBook allows you to divide the text into separate document files. They are
then assembled in the MAIN file using XIncludes
as
shown in Example 2.9, “MAIN file of a Set (DocBook 4.x)”. XIncludes can be used for
splitting up sets, books, articles or chapters into separate files. For
more information, refer to
Physical Divisions: Breaking a Document into Separate
Files (http://www.docbook.org/tdg51/en/html/ch02.html).
XIncludes are fully supported and do not cause any problems with
DAPS. For example, daps
commands like
linkcheck
or spellcheck
also follow XIncludes.
When maintaining a large number of documents for a product, it can be difficult to keep a consistent set of entities if these entities are declared in the document type declarations of individual XML files. For large documentation projects, it is therefore useful to put all entity declarations into a separate file and reference that file in the individual XML files.
entity-decl.ent
#<?xml version="1.0" encoding="iso-8859-1" ?> <!ENTITY exampleuser "tux"> <!ENTITY exampleuserII "wilber"> <!ENTITY examplegroup "users"> [...]
<?xml version="1.0"?> <!DOCTYPE chapter PUBLIC [...] [ <!ENTITY % entities SYSTEM "entity-decl.ent"> 1 %entities; 2 ]> <chapter> <title>Managing User Accounts</title> [...]
For more information, refer to Modular DocBook Files: Shared text entities (http://www.sagehill.net/docbookxsl/ModularDoc.html).
Separate entity files do not cause any problems with DAPS— during generation of output, the entities will be treated equally to entities declared in individual XML files.
It is also possible to use multiple entity files by including them into the separate entity file that is referenced in the XML file.
Similar products often share a considerable amount of features and differ in details only. It is therefore convenient to apply the same approach to the documentation of similar products or product families: Share most of the XML source code and only differentiate text snippets where necessary. DocBook allows you to create documentation variants from the same pool of XML sources by means of profiling.
In DocBook XML files you can mark some elements as conditional by using profiling attributes. When processing the files to generate output, specify which conditions apply to the output. The stylesheets will then include or exclude the marked text, according to the conditions.
Profiling allows you to keep both common and product-specific content in one XML file and select at production time which information to include in the output.
DocBook offers profiling attributes for various purposes as illustrated in Table 26.1. Profiling attributes (http://www.sagehill.net/docbookxsl/Profiling.html). All of them are supported by DAPS.
Generally, profiling attributes can be used on many
elements—from high-level elements like book
or
chapter
down to low-level elements like
para
. With the phrase
element, you
can even profile inline elements, like one sentence within a paragraph.
Based on the conditions that you want to apply , select one or more profiling attributes and
add them to the text snippets that are conditional. The tagged snippets
will only be included in the output if the required condition is
fulfilled. Any content that is valid for all
conditions does not need any profiling
attributes. The respective content will always be included in the output
formats generated from the XML sources. You are free in defining the
attribute values (condition="foo"
), but they must be
used consistently in all files belonging to a documentation project.
Example 6.4, “Product-specific Profiling (One Attribute)” shows how to profile
product-specific information in a software description. Let us assume we
need to write documentation for the fictional software Frog
Sound Recordings
. The software is available in two editions: a
basic edition for home users and a professional edition for enterprise
customers. Both editions share common features, but some features are
only available in the basic or the professional edition, respectively.
<simplelist>
<member>Common Feature 1</member>
<member>Common Feature 2</member>
<member>Common Feature 3</member>
<member condition="basic">Basic Feature 1</member>
<member condition="prof">Professional Feature 1</member>
<member condition="prof">Professional Feature 2</member>
</simplelist>
When generated for the basic edition or for the professional edition, respectively, the example source code would result in the following output:
Basic Edition |
Professional Edition |
---|---|
Common Feature 1 Common Feature 2 Common Feature 3 Basic Feature 1 |
Common Feature 1 Common Feature 2 Common Feature 3 Professional Feature 1 Professional Feature 2 |
If the profiling attributes are not processed during output, the source code in Example 6.4, “Product-specific Profiling (One Attribute)” would result in the following (identical) output for both editions:
Basic Edition |
Professional Edition |
---|---|
Common Feature 1 Common Feature 2 Common Feature 3 Basic Feature 1 Professional Feature 1 Professional Feature 2 |
Common Feature 1 Common Feature 2 Common Feature 3 Basic Feature 1 Professional Feature 1 Professional Feature 2 |
Let us suppose the professional edition of the software is also available
as OEM (original equipment manufacturer) version by the vendor
OEM Company
. It contains additional features that are
only available in the OEM version:
<simplelist>
<member>Common Feature 1</member>
<member>Common Feature 2</member>
<member>Common Feature 3</member>
<member condition="basic">Basic Feature 1</member>
<member condition="prof">Professional Feature 1</member>
<member condition="prof">Professional Feature 2</member>
<member condition="prof" vendor="oemcompany">OEM Feature 1</member>
</simplelist>
When generated for the professional edition or for the professional edition in the OEM version, respectively, the example source code would result in the following output:
Professional Edition |
Professional Edition (OEM Version) |
---|---|
Common Feature 1 Common Feature 2 Common Feature 3 Professional Feature 1 Professional Feature 2 |
Common Feature 1 Common Feature 2 Common Feature 3 Professional Feature 1 Professional Feature 2 OEM Feature 1 |
To create multiple documentation variants of the same pool of DocBook files with DAPS, the following requirements need to be fulfilled:
For a comprehensive example showing all requirements in detail, refer to Section 6.3.2.4, “Profiling Example”.
In DAPS, each profiling attribute has a corresponding profiling parameter to be used in the DC file, see Section 6.3.2.3, “DC Files: Profiling Parameters”. The profiling parameters define which profiling attributes and values to interpret during generation of output.
The names of the profiling parameters are derived from the profiling
attributes, but written in uppercase letters and preceded by the prefix
PROF
.
Attribute Name |
Use |
Profiling Parameter |
---|---|---|
|
Computer or chip architecture, such as | PROFARCH |
|
Intended audience of the content, such as | PROFAUDIENCE |
|
No preassigned semantics, general purpose attribute. | PROFCONDITION |
|
Conformance to standards, as for example | PROFCONFORMANCE |
|
Language code, such as | PROFLANG |
|
Operating system. | PROFOS |
|
Output format to which the element applies (for example, print or EPUB). Only available for DocBook 5.1 or later. | PROFOUTPUTFORMAT |
|
Editorial revision, such as | PROFREVISION |
|
Revision status of the element, such as | PROFREVISIONFLAG |
|
General purpose attribute, with no preassigned semantics. As the role attribute is not solely “reserved” for profiling but can be used for other purposes in a document, we would recommend to not use this for profiling. For further details, see http://sagehill.net/docbookxsl/ProfilingWithRole.html. | PROFROLE |
|
Security level, such as | PROFSECURITY |
|
Editorial or publication status, such as | PROFSTATUS |
|
Level of user experience, such as | PROFUSERLEVEL |
|
Product vendor. | PROFVENDOR |
|
Word size (width in bits) of the computer architecture, such as | PROFWORDSIZE |
To activate generation of profiled output in DAPS, the following processing instruction (PI) must be included in the header of the MAIN file, before the root element.
As the profiling PI includes the DocBook version number, it needs to be adjusted according to the DocBook version you use. See Example 6.6, “Profiling PI in a DocBook 4.5 File” and Example 6.7, “Profiling PI in a DocBook 5.0 File”.
<?xml-stylesheet href="urn:x-daps:xslt:profiling:docbook45-profile.xsl" type="text/xml" ?>
<?xml-stylesheet href="urn:x-daps:xslt:profiling:docbook50-profile.xsl" type="text/xml" ?>
The MAIN file of a documentation project is referenced by the MAIN parameter in the DC file. If the processing instruction is missing in the MAIN file, any profiling parameters in the DC file will be ignored during generation of the output.
Although DAPS only checks for the profiling PI in the MAIN file, it is a good idea to include the PI in all XML files for any projects that need profiling. Otherwise you might forget to move the PI to the respective MAIN file in case of restructuring the XML sources. Having the PI in all XML files does not hurt: Generation of profiled output is only triggered if your DC files contain profiling parameters.
Depending on the profiling attributes used in your XML files, a DC file may contain multiple profiling parameters, see Table 6.4, “Profiling Attributes (DocBook) and Profiling Parameters (DAPS)”. Profiling parameters define which of the profiling attributes should be interpreted by DAPS when generating output. For each profiling parameter, set the respective attribute values for which you want to filter during the profiling process. The spelling of the values must be the same that is used in the XML files.
In the following, find a comprehensive example that shows the basic
DAPS profiling requirements in more detail. It is based on the
examples in Section 6.3.1, “Introduction to DocBook Profiling”
about the fictional software Frog Sound Recordings
. The
software is available in a basic edition, a professional edition and a
professional OEM edition, shipped by an OEM vendor. The following
example shows all files that you need to consider
(XML files, MAIN file, and DC file).
<?xml version="1.0" encoding="utf-8"?> [...] <chapter id="frog.features"> [...] <simplelist> <member>Common Feature 1</member> 1 <member>Common Feature 2</member> 1 <member>Common Feature 3</member> 1 <member condition="basic">Basic Feature 1</member> 2 <member condition="prof">Professional Feature 1</member> 3 <member condition="prof">Professional Feature 2</member> 3 <member condition="prof" vendor="oemcompany">OEM Feature 1</member> 4 </simplelist> [...] </chapter>
Unprofiled list items. The common features 1-3 are available in all software editions or versions. | |
List item profiled with attribute
| |
List item profiled with attribute
| |
List item profiled with two attributes: Attribute
|
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet
href="urn:x-daps:xslt:profiling:docbook45-profile.xsl"
type="text/xml"
title="Profiling step"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.docbook.org/xml/4.5/docbookx.dtd"
[<!ENTITY % entities SYSTEM "entity-decl.ent">
%entities;
]>
<!--the following article is contained in the file art_frog.xml-->
<article lang="en" id="art.frog">
<title>Frog Sound Recordings</title>
<subtitle>Product Description</subtitle>
[...]
</article>
If the processing instruction (PI) is missing, any profiling parameters in the DC file will be ignored.
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet
href="urn:x-daps:xslt:profiling:docbook50-profile.xsl"
type="text/xml"
title="Profiling step"?>
<!DOCTYPE article
[<!ENTITY % entities SYSTEM "entity-decl.ent">
%entities;
]>
<!--the following article is contained in the file art_frog.xml-->
<article xml:lang="en" xml:id="art.frog"
xmlns="http://docbook.org/ns/docbook">
<title>Frog Sound Recordings</title>
<subtitle>Product Description</subtitle>
[...]
</article>
If the processing instruction (PI) is missing, any profiling parameters in the DC file will be ignored.
Use the PI <?xml-stylesheet
href="urn:x-daps:xslt:profiling:docbook51-profile.xsl"
type="text/xml" title="Profiling step">
for DocBook version 5.1.
## Doc Config File for Frog Sound Recordings ## (Home Edition) ## Mandatory Parameters MAIN="art_frog.xml" 1 ## Profiling PROFCONDITION="basic" 2 [...]
MAIN parameter referencing the MAIN file. See Example 6.9 (DocBook 4) or Example 6.10 (DocBook 5). | |
DAPS profiling parameter for the
|
## Doc Config File for Frog Sound Recordings ## (Professional Edition) ## Mandatory Parameters MAIN="art_frog.xml" 1 ## Profiling PROFCONDITION="prof" 2 [...]
MAIN parameter referencing the MAIN file. See Example 6.9 (DocBook 4) or Example 6.10 (DocBook 5). | |
DAPS profiling parameter for the
|
## Doc Config File for Frog Sound Recordings ## (Professional Edition, OEM Version) ## Mandatory Parameters MAIN="art_frog.xml" 1 ## Profiling PROFCONDITION="prof" 2 PROFVENDOR="oemcompany" 3 [...]
MAIN parameter referencing the MAIN file. See Example 6.9, “MAIN file With PI for Profiling (DocBook 4.5)” or Example 6.10, “MAIN file With PI for Profiling (DocBook 5.0)” . | |
DAPS profiling parameter for the
| |
DAPS profiling parameter for the
|
For maximum flexibility in generating documentation variants from the same source, DAPS also supports the combination of entities and profiling. As you already learned in Section 6.2, “Declaring Entities in a Separate File”, it is useful for modularization purposes to declare entities in a separate file and to re-use it in multiple documentation projects.
For multiple use of entities like &productname;
or
&productnumber;
, declare them in a separate file
and add profiling within the entities as shown in
Example 6.14. During generation of
output, DAPS then automatically replaces the entities with different
values during output, depending on the context.
<!--the following declarations are contained in the file entity-decl.ent --> <!ENTITY productname '<phrase cond="basic">Frog Sound Recordings (Basic)</phrase> <phrase cond="prof">Frog Sound Recordings (Professional)</phrase> <phrase cond="prof" vendor="oemcompany">Gecko Sound Recordings (Professional)</phrase>'> <!ENTITY productnumber '<phrase cond="basic">1.0</phrase> <phrase cond="prof">4.2</phrase> <phrase cond="prof" vendor="oemcompany">4.21</phrase>'>
After declaring the entities as shown in Example 6.14 you can use
them throughout your documents. For DAPS to process them correctly,
you only need to “introduce” the entities once within the
*info
element of each document as described below. For
examples showing the result, see Example 6.9 (DocBook 4) or Example 6.10
(DocBook 5).
Open the XML file that contains the root element for your respective
document (set
, book
, or
article
).
If you use DocBook 4, insert a setinfo
,
bookinfo
, or articleinfo
element,
(respectively) within the root element.
If you use DocBook 5, insert the generic info
element within the root element of your documentation. (DocBook 5 does no
longer distinguish between setinfo
,
bookinfo
, or articleinfo
).
Within all of the *info
elements in your documentation,
add the following elements: productname
and
productnumber
.
Within the productname
elements, add the
&productname;
entity.
Within the productnumber
elements, add the
&productnumber;
entity.
Now that you have “introduced” the entities for each document, use the entities in the text wherever you need them.
&productname;
and
&productnumber;
Entities (DocBook 4.5) #<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="urn:x-daps:xslt:profiling:docbook45-profile.xsl" type="text/xml" title="Profiling step"?> 1 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd" [<!ENTITY % entities SYSTEM "entity-decl.ent"> %entities; ]> 2 <!--the following article is contained in the file art_frog.xml--> <article lang="en" id="art.frog"> <title>Frog Sound Recordings</title> <subtitle>Product Description</subtitle> <articleinfo> 3 <productname>&productname;</productname> 4 <productnumber>&productnumber;</productnumber> 5 </articleinfo> <abstract> <para> &productname; &productnumber; is a software for recording, editing, 6 and mixing audio data. </para> </abstract> [...] </article>
Processing instruction (PI) in the header of the MAIN file. If it is missing, any profiling parameters in the DC file will be ignored. | |
Reference to the separate entity declaration file (with a parameter entity). | |
Element | |
Element | |
Element | |
Paragraph containing the entities |
&productname;
and
&productnumber;
Entities (DocBook 5.0) #<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="urn:x-daps:xslt:profiling:docbook50-profile.xsl" type="text/xml" title="Profiling step"?> 1 <!DOCTYPE article [<!ENTITY % entities SYSTEM "entity-decl.ent"> %entities; ]> 2 <!--the following article is contained in the file art_frog.xml--> <article xml:lang="en" xml:id="art.frog" xmlns="http://docbook.org/ns/docbook"> <title>Frog Sound Recordings</title> <subtitle>Product Description</subtitle> <info> 3 <productname>&productname;</productname> 4 <productnumber>&productnumber;</productnumber> 5 </info> <abstract> <para> &productname; &productnumber; is a software for recording, editing, 6 and mixing audio data. </para> </abstract> [...] </article>
Processing instruction (PI) in the header of the MAIN file. If it is missing, any profiling parameters in the DC file will be ignored. | |
Reference to the separate entity declaration file (with a parameter entity). | |
Element | |
Element | |
Element | |
Paragraph containing the entities |
In any output format, the entities (4, 5, 6) will automatically be replaced with different values. The actual values depend on the profiling parameters contained in the DC file that you use for generating the output. For an example, refer to Table 6.5. It shows output variants that can be generated from the XML code in Example 6.15 or Example 6.16 plus the entity declaration in Example 6.14 by using different DC files.
DC File |
Output |
---|---|
Frog Sound Recordings (Basic) 1.0 is a software for recording, editing, and mixing audio data. | |
Frog Sound Recordings (Professional) 4.2 is a software for recording, editing, and mixing audio data. | |
DC File with Profiling for Professional Edition (OEM Version) |
Gecko Sound Recordings (Professional) 4.21 is a software for recording, editing, and mixing audio data. |