XML technologies / DITA / Specialization / topics
(Excerpt from “DITA – Der neue Standard für Technische Dokumentation” by Johannes Hentrich)
Specializing topics is called structural specialization because it creates new information structures. Topics can be specialized as follows:
New topic types are created from the generic topic type. The three familiar DITA topic types, task, concept and reference, originated in this way.
Modified topic types are created from the familiar topic types. The glossary topic type introduced in DITA 1.1 specializes the existing concept topic type.
The procedure is the same for both forms of specialization. Both start from an existing information structure used as the basis for specialization.
The following example presents topic specialization for the concept topic type. A topic type is developed to hold support requests. It then shows how the XSLT stylesheets can be adapted for the specialization.
Example of topic specialization
Topic specialization starts by developing a content model for the new topic type. The content model defines the individual elements. Note that the specialized topic type’s content model must be more restrictive than the original model. For the rules to follow when creating a content model, see Flexible extensibility.
Once specialization is complete, the sample document resulting from the content model is used to test the topic specialization.
A sample document for recording and answering a support request could have the following structure:
<?xml version="1.0"?>
<!DOCTYPE support SYSTEM "support.dtd">
<support id="support-id">
<support-frage>Unter welchen Telefonnummern ist der Support erreichbar?</support-frage>
<support-kurze-antwort>
<p>Unter der Nummer <b>12345</b> sind wir jederzeit für Sie da!</p>
</support-kurze-antwort>
<support-lange-antwort>
<p>Außerdem können Sie uns per E-Mail und per Fax erreichen</p>
</support-lange-antwort>
</support>The root element of the new topic type is the <support> element. It has a unique ID. The support request is recorded in the <support-frage> element. A short answer is recorded in the <support-kurze-antwort> element. This element is required. A longer, more detailed answer is stored in the <support-lange-antwort> element.
The following table shows which concept topic elements are to be specialized into the elements of the support topic type.
concept.dtd | support.dtd |
| |
| |
| |
| |
Table: Specialized elements for the support topic type
The following steps are required to specialize a topic:
Create a shell DTD for the new topic type.
Create a
modfile defining the elements of the new topic type.
The first step in topic specialization is to create a shell DTD for the new topic type. The easiest way is to copy an existing DTD file and adapt it to your requirements. You can add declarations to the new shell DTD or remove declarations you do not need. Creating a shell DTD is also called “integration”.
Proceed as follows to create a shell DTD for the support topic type:
Make a copy of
concept.dtdand give the copy the new namesupport.dtd.Remove all references to
modfiles andentfiles that are not needed for the topic type.
Which references tomodfiles andentfiles are removed depends on the sample document’s content model. In this example, only the highlighting and indexing domains are used.Replace the entry
<!ENTITY % concept-info-types "concept" > with the entry
<!ENTITY % support-info-types "no-topic-nesting" > In the
TOPIC ELEMENT INTEGRATIONsection, add the following entry:
<!ENTITY % support-typemod SYSTEM "support.mod" >
%support-typemod;This is the reference to the mod file support.mod that is created in the second step of topic specialization. The support-mod file defines the specialized elements of the support topic type.
With the headings customary in DITA DTDs, the support.dtd file then looks as follows:
<!-- ================================================= -->
<!-- HEADER -->
<!-- ================================================= -->
<!-- MODULE: Support -->
<!-- VERSION: 1.0 -->
<!-- DATE: Mai 2008 -->
<!-- ================================================= -->
<!-- ================================================= -->
<!-- DOMAIN ENTITY DECLARATIONS -->
<!-- ================================================ -->
<!ENTITY % hi-d-dec PUBLIC "-//OASIS//ENTITIES DITA Highlight Domain//EN" "highlightDomain.ent" >
%hi-d-dec;
<!ENTITY % indexing-d-dec PUBLIC "-//OASIS//ENTITIES DITA Indexing Domain//EN" "indexingDomain.ent" >
%indexing-d-dec;
<!-- ================================================= -->
<!-- DOMAIN ATTRIBUTE DECLARATIONS -->
<!-- ================================================= -->
<!-- ================================================= -->
<!-- DOMAIN EXTENSIONS ->
<!-- ================================================= -->
<!ENTITY % pre "pre | %pr-d-pre; | %sw-d-pre; | %ui-d-pre;" >
<!ENTITY % keyword "keyword | %pr-d-keyword; | %sw-d-keyword; | %ui-d-keyword;" >
<!ENTITY % ph "ph | %pr-d-ph; | %sw-d-ph; | %hi-d-ph; | %ui-d-ph;" >
<!ENTITY % fig "fig | %pr-d-fig; | %ut-d-fig;" >
<!ENTITY % dl "dl | %pr-d-dl;" >
<!ENTITY % index-base "index-base | %indexing-d-indexbase;" >
<!-- ================================================= -->
<!-- DOMAIN ATTRIBUTE EXTENSIONS -->
<!-- ================================================= -->
<!ENTITY % props-attribute-extensions "" >
<!ENTITY % base-attribute-extensions "" >
<!-- ================================================ -->
<!-- TOPIC NESTING OVERRIDE -->
<!-- ================================================= -->
<!ENTITY % support-info-types "no-topic-nesting">
<!-- ============================= =================== -->
<!-- DOMAINS ATTRIBUTE OVERRIDE -->
<!-- ================================================= -->
<!ENTITY included-domains "&hi-d-att; &indexing-d-att;" >
<!-- ================================================= -->
<!-- TOPIC ELEMENT INTEGRATION -->
<!-- ================================================= -->
<!ENTITY % topic-type PUBLIC "-//OASIS//ELEMENTS DITA Topic//EN" "topic.mod2 >
%topic-type;
<!ENTITY % concept-typemod PUBLIC "-//OASIS//ELEMENTS DITA Concept//EN" "concept.mod" >
%concept-typemod;
<!ENTITY % support-typemod SYSTEM "support.mod" >
%support-typemod;
<!-- ================================================= -->
<!-- DOMAIN ELEMENT INTEGRATION -->
<!-- ================================================= -->
<!ENTITY % hi-d-def PUBLIC "-//OASIS//ELEMENTS DITA Highlight Domain//EN" "highlightDomain.mod" >
%hi-d-def;
<!ENTITY % indexing-d-def PUBLIC "-//OASIS//ELEMENTS DITA Indexing Domain//EN" "indexingDomain.mod" >
%indexing-d-def;
<!-- ============= End Support DTD ================== -->The second step in topic specialization creates a mod file defining the specialized elements. Since the support topic type specializes the concept topic type, the easiest way to create a mod file is to make a copy of the concept.mod file and edit it.
Proceed as follows to create the mod file:
Make a copy of the
concept.modfile and give the copy the new namesupport.mod.Replace the entry
<!ENTITY % concept-info-types "%info-types;"> with the entry
<!ENTITY % support-info-types "no-topic-nesting"> Replace the <
concept>element declaration
<!ELEMENT concept ((%title;), (%titlealts;)?, (%shortdesc; | %abstract;)?, (%prolog;)?, (%conbody;)?, (%related-links;)?, (%concept-info-types;)*) >with the <
support>element declaration
<!ELEMENT support ((%support-frage;), (%titlealts;)?, (%support-kurze-antwort;), (%prolog;)?, (%support-lange-antwort;)?, (%related-links;)?, (%concept-info-types;)*) >In this content model, the
<support-kurze-antwort>element is required. This makes the content model more restrictive than the model for the<concept>element, as an optional element is replaced by a required element.
Replace the attribute definitions for the
<concept>element
<!ATTLIST concept
id ID #REQUIRED
conref CDATA #IMPLIED
%select-atts;
%localization-atts;
%arch-atts;
outputclass
CDATA #IMPLIED
domains CDATA "&included-domains;" >with the attribute definitions for the
<support>element
<!ATTLIST support
id ID #REQUIRED
conref CDATA #IMPLIED
%select-atts;
%localization-atts;
%arch-atts;
outputclass
CDATA #IMPLIED
domains CDATA "&included-domains;" >Replace the <
conbody>element declaration
<!ELEMENT conbody ((%body.cnt;)*,(%section;|%example;)*) > with the <
support-lange-antwort>element declaration
<!ELEMENT support-lange-antwort ((%body.cnt;)*, (%section;|%example;)* )>Replace the attribute definitions for the
<conbody>element
<!ATTLIST conbody
%id-atts;
%localization-atts;
base CDATA #IMPLIED
%base-attribute-extensions;
outputclass
CDATA #IMPLIED>with the attribute definitions for the
<support-lange-antwort>element
<!ATTLIST support-lange-antwort
%id-atts;
%localization-atts;
base CDATA #IMPLIED
%base-attribute-extensions;
outputclass
CDATA #IMPLIED>From the
commonElements.modfile, copy the <title>element declaration and the attribute definitions for the<title>element into theELEMENT DECLARATIONSsection of thesupport.modfile.In both the
<title>element declaration and the attribute definitions for the<title>element, replacetitlewithsupport-frage.
<!ELEMENT support-frage (%title.cnt;)* >
<!ATTLIST support-frage
%id-atts;
%localization-atts;
base CDATA #IMPLIED
%base-attribute-extensions;
outputclass
CDATA #IMPLIED>From the
commonElements.modfile, copy the <shortdesc>element declaration and the attribute definitions for the<shortdesc>element into theELEMENT DECLARATIONSsection of thesupport.modfile.In both the
<shortdesc>element declaration and the attribute definitions for the<shortdesc>element, replaceshortdescwithsupport-kurze-antwort.
<!ELEMENT support-kurze-antwort (%title.cnt;)* >
<!ATTLIST support-kurze-antwort
%univ-atts;
outputclass
CDATA #IMPLIED>This defines the newly specialized elements
<support>,<support-frage>,<support-kurze-antwort>and<support-lange-antwort>.
In the
ELEMENT NAME ENTITIESsection, define the parameter entities for the specialized elements:
<!ENTITY % support "support">
<!ENTITY % support-lange-antwort "support-lange-antwort">
<!ENTITY % support-kurze-antwort "support-kurze-antwort">
<!ENTITY % support-frage "support-frage">In the
SPECIALIZATION ATTRIBUTE DECLARATIONSsection, define theclassattributes for the specialized elements:
<!ATTLIST support %global-atts;class CDATA "- topic/topic concept/concept support/support">
<!ATTLIST support-kurze-antwort %global-atts; class CDATA "- topic/shortdesc support/support-kurze-antwort">
<!ATTLIST support-lange-antwort %global-atts; class CDATA "- topic/body concept/conbody support/support-lange-antwort">
<!ATTLIST support-frage %global-atts; class CDATA "- topic/title support/support-frage">With the headings customary in DITA, the
support.modfile now looks as follows:
<!-- ================================================= -->
<!-- HEADER -->
<!-- ================================================= -->
<!-- MODULE: Support -->
<!-- VERSION: Mai 2008 -->
<!-- ================================================= -->
<!-- ================================================= -->
<!-- ARCHITECTURE ENTITIES -->
<!-- ================================================= -->
<!ENTITY % DITAArchNSPrefix,"ditaarch" >
<!ENTITY % arch-atts " xmlns:%DITAArchNSPrefix; CDATA #FIXED‚http://dita.oasis-open.org/architecture/2005/‘ %DITAArchNSPrefix;:DITAArchVersion CDATA ‚1.1‘" >
<!-- ================================================= -->
<!-- SPECIALIZATION OF DECLARED ELEMENTS -->
<!-- ================================================= -->
<!ENTITY % support-info-types "no-topic-nesting">
<!-- ================================================= -->
<!-- ELEMENT NAME ENTITIES -->
<!-- ================================================= -->
<!ENTITY % support "support" >
<!ENTITY % support-lange-antwort "support-lange-antwort" >
<!ENTITY % support-kurze-antwort "support-kurze-antwort" >
<!ENTITY % support-frage "support-frage" >
<!-- ================================================= -->
<!-- DOMAINS ATTRIBUTE OVERRIDE -->
<!-- ================================================= -->
<!ENTITY included-domains "" >
<!-- ================================================= -->
<!-- ELEMENT DECLARATIONS -->
<!-- ================================================= -->
<!ELEMENT support ((%support-frage;), (%titlealts;)?, (%support-kurze-antwort;), (%prolog;)?, (%support-lange-antwort;)?, (%related-links;)?, (%concept-info-types;)*) >
<!ATTLIST support id ID #REQUIRED conref CDATA #IMPLIED %select-atts; %localization-atts; %arch-atts; outputclass CDATA #IMPLIED domains CDATA "&included-domains;">
<!ELEMENT support-frage (%title.cnt;)* >
<!ATTLIST support-frage %id-atts; %localization-atts; base CDATA #IMPLIED %base-attribute-extensions; outputclass CDATA #IMPLIED>
<!ELEMENT support-kurze-antwort (%title.cnt;)*>
<!ATTLIST support-kurze-antwort %univ-atts; outputclass CDATA #IMPLIED>
<!ELEMENT support-lange-antwort ((%body.cnt;)*, (%section;|%example;)* )>
<!ATTLIST support-lange-antwort %id-atts; %localization-atts; base CDATA #IMPLIED %base-attribute-extensions; outputclass CDATA #IMPLIED>
<!-- ================================================= -->
<!-- SPECIALIZATION ATTRIBUTE DECLARATIONS -->
<!-- ================================================= -->
<!ATTLIST support %global-atts;class CDATA "- topic/topic concept/concept support/support">
<!ATTLIST support-kurze-antwort %global-atts; class CDATA "- topic/shortdesc support/support-kurze-antwort">
<!ATTLIST support-lange-antwort %global-atts; class CDATA "- topic/body concept/conbody support/support-lange-antwort">
<!ATTLIST support-frage %global-atts; class CDATA "- topic/title support/support-frage">
<!-- ================== End Support ================== -->Once the support-mod file is complete, you can use the shell DTD support.dtd to create support topics.
Adapting XSLT stylesheets
XSLT stylesheets are adapted much like DTDs or module files. Instructions responsible for processing the parent elements are taken from existing XSLT stylesheets and modified as required. Often the difficulty lies in finding both the appropriate XSLT stylesheets and the relevant instructions, that is, XSLT templates, within them. The starting point for finding the instructions that process elements is the elements’ class attribute. If a class attribute has no instructions or an XSLT template in the XSLT stylesheets, look for the class attribute of the parent elements.
The following example shows how the XSLT stylesheets for producing XHTML files must be changed so that they can process the specialized elements <support>, <support-frage>, <support-kurze-antwort> and <support-lange-antwort> from the previous section.
The xsl directory of the DITA Open Toolkit contains the XSLT stylesheets controlling production of the various output media. The dita2xhtml.xsl file produces XHTML files.
A newly created XSLT stylesheet defining templates to process the specialized elements imports the dita2xhtml.xsl file. This adds new processing rules to the existing processing.
Specifically, creating an XSLT stylesheet to process specialized elements requires the following steps:
Create an XSLT stylesheet importing the
dita2xhtml.xslfile.Copy the XSLT templates processing the parent elements into the new XSLT stylesheet.
Modify the XSLT templates to produce the desired output for the specialized elements.
Create a CSS to format the transformed elements in XHTML.
In the following example, the XSLT stylesheets are modified to place the text “Frage:” before the output of the <support-frage> element’s content. When the content of the <support-kurze-antwort> element is output, the text “Antwort:” should be displayed.
Proceed as follows to create the XSLT stylesheet:
Create the following empty XSLT stylesheet named
support2xhtml.xsl.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY gt ">">
<!ENTITY lt "<">
<!ENTITY rbl " ">
<!ENTITY nbsp " ">
<!ENTITY quot """>
<!ENTITY copyr "©">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="toolkitDir" select="'file:///c:/ditaot14/'"/>
<xsl:import href="{$toolkitDir}xsl/dita2xhtml.xsl"/>
</xsl:stylesheet>The XSLT stylesheet declaration gives the path to the DITA Open Toolkit installation directory, here
c:/ditaot14.
Save the XSLT stylesheet in a directory outside the DITA Open Toolkit installation directory.
In the
support2xhtml.xslfile, create an XSLT template for each specialized element:
<xsl:template match="*[contains(@class, ' support/support ')]"></xsl:template>
<xsl:template match="*[contains(@class, ' support/support-frage ')]" ></xsl:template>
<xsl:template match="*[contains(@class, ' support/support-lange-antwort ')]"></xsl:template>
<xsl:template match="*[contains(@class, ' support/support-kurze-antwort ')]"></xsl:template>The
matchattribute specifies that theclassattribute is to be found with values containing the topic-name/element-name combination for the specialized elements. Pay attention to the spaces in thematchattribute.
In the file
c:/ditaot14/xsl/xslhtm/dita2htmlImpl.xsl, find the XSLT template with the followingmatchattribute*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]. This XSLT template processes the<title>element. The<title>element was specialized into the<support-frage>element, so this XSLT template must be adapted to display “Frage:” before the content of the<support-frage>element.Copy the XSLT template’s content into the
support2xhtml.xslfile, into the XSLT template processing the<support-frage>element.Change the
matchattribute from*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]to*[contains(@class, ' support/support-frage ')]. Thesupport2html.xslfile then looks as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY gt ">">
<!ENTITY lt "<">
<!ENTITY rbl " ">
<!ENTITY nbsp " ">
<!ENTITY quot """>
<!ENTITY copyr "©2>
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="toolkitDir" select="'file:///c:/ditaot14/'"/>
<xsl:import href="{$toolkitDir}xsl/dita2xhtml.xsl"/>
<xsl:template match="*[contains(@class, ' support/support ')]"></xsl:template>
<xsl:template match="*[contains(@class, ' support/support-frage ')]">
<xsl:param name="headinglevel">
<xsl:choose>
<xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')])> 6">6</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ‚)])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:element name="h{$headinglevel}">
<xsl:attribute name="class">topictitle <xsl:value-of select="$headinglevel"/></xsl:attribute>
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</xsl:element>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' support/support-lange-antwort ')]"></xsl:template>
<xsl:template match="*[contains(@class, ' support/support-kurze-antwort ')]"></xsl:template>Define the HTML code producing the text “Frage:”.
The HTML code could look as follows:
<div class="support-frage">
<span class="support-frage-txt">Frage: </span>
</div>Incorporate the HTML code into the XSLT template processing the
<support-frage>element as follows:
<xsl:template match="*[contains(@class, ' support/support-frage ')]">
<xsl:param name="headinglevel">
<xsl:choose>
<xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')])> 6">6</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ‚)])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:element name="h{$headinglevel}">
<xsl:attribute name="class">topictitle <xsl:value-of select="$headinglevel"/></xsl:attribute>
<xsl:call-template name="commonattributes"/>
<div class="support-frage">
<span class="support-frage-txt">Frage:</span>
<xsl:apply-templates/>
</div>
</xsl:element>
<xsl:value-of select="$newline"/>
</xsl:template>This completes the XSLT template definition for processing the
<support-frage>element.
Next, define the XSLT template processing the
<support-kurze-antwort>element. The<support-kurze-antwort>element was specialized from the<shortdesc>element and made required in the content model. In the original content model, the<shortdesc>element is optional and can be replaced by the optional<abstract>element. Since the<support-kurze-antwort>element is required, there is no need to use the existing XSLT template processing the optional<shortdesc>element and the<abstract>element. A new XSLT template is therefore defined below to produce the HTML code for displaying the text “Antwort:”.
Define the HTML code producing the text “Antwort:”.
The HTML code could look as follows:
<div class="support-kurze-antwort">
<span class="support-kurze-antwort-txt">Antwort: </span>
</div>Incorporate the HTML code into the XSLT template processing the
<support-kurze-antwort>element as follows:
<xsl:template match="*[contains(@class, ' support/support-kurze-antwort ')]" mode="outofline">
<div class="support-kurze-antwort">
<span class="support-kurze-frage-txt">Antwort </span>
<xsl:apply-templates/>
</div>
</xsl:template>This completes the XSLT template definition for processing the
<support-kurze-frage>element.
For the
<support-lange-antwort>element, specialized from the<conbody>element, searching for thematchattribute with the valueconcept/conbodyproduces no result, because the<conbody>element has no formatting of its own. It is therefore necessary to search for the parent information structure, that is, fortopic/body.
Copy the content of the XSLT template with the
matchattribute*[contains(@class,‘ topic/body ‚)]into the XSLT template processing the<support-lange-antwort>element.
<xsl:template match="*[contains(@class,' support/supportlange-antwort ')]" name="topic.body">
<xsl:variable name="flagrules">
<xsl:call-template name="getrules"/>
</xsl:variable>
<xsl:variable name="conflictexist">
<xsl:call-template name="conflict-check">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
</xsl:variable>
<div>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="setidaname"/>
<xsl:call-template name="gen-style">
<xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="start-flagit">
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="start-revflag">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
<xsl:apply-templates select="precedingsibling::*[contains(@class,' topic/abstract ')]" mode="outofline"/>
<xsl:apply-templates select="precedingsibling::*[contains(@class,' topic/shortdesc ')]" mode="outofline"/>
<xsl:apply-templates select="followingsibling::*[contains(@class,' topic/related-links ')]" mode="prereqs"/>
<xsl:apply-templates/>
<xsl:call-template name="end-revflag">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
<xsl:call-template name="end-flagit">
<xsl:with-param name="flagrules" select="$flagrules">
</xsl:with-param>
</xsl:call-template>
</div>
<xsl:value-of select="$newline"/>
</xsl:template>Since the
<abstract>element was removed from the content model, all instructions concerning the<abstract>element can be removed from the XSLT template.
The content of the
<support-lange-antwort>element should be output in a<div>-block with the classsupport-lange-antwort. Insert the appropriate<xsl:apply-templates>instruction for this purpose.
The XSLT template processing the
<support-lange-antwort>element now looks as follows:
<xsl:template match="*[contains(@class,' support/supportlange-antwort ')]" name="topic.body">
<xsl:variable name="flagrules">
<xsl:call-template name="getrules"/>
</xsl:variable>
<xsl:variable name="conflictexist">
<xsl:call-template name="conflict-check">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
</xsl:variable>
<div>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="setidaname"/>
<xsl:call-template name="gen-style">
<xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="start-flagit">
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="start-revflag">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
<xsl:apply-templates select="precedingsibling::*[contains(@class,' topic/shortdesc ')]" mode="outofline"/>
<div class="support-lange-antwort">
<xsl:apply-templates/>
</div>
<xsl:call-template name="end-revflag">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
<xsl:call-template name="end-flagit">
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
</div>
<xsl:value-of select="$newline"/>
</xsl:template>This completes the XSLT template definition for processing the
<support-kurze-frage>element.
For the
<support>element, it is only necessary to ensure that it is processed.
In the XSLT template processing the
<support>element, add the instruction<xsl:apply-imports/>.
<xsl:template match="*[contains(@class, ' support/support ')]">
<xsl:apply-imports/>
</xsl:template>This uses all XSLT templates applicable to the
<support>element.
The complete
support2html.xslfile processing the elements<support>,<support-frage>,<support-kurze-antwort>and<support-lange-antwort>now looks as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY gt ">">
<!ENTITY lt "<">
<!ENTITY rbl " ">
<!ENTITY nbsp " ">
<!ENTITY quot """>
<!ENTITY copyr "©2>
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="toolkitDir" select="'file:///c:/ditaot14/'"/>
<xsl:import href="{$toolkitDir}xsl/dita2xhtml.xsl"/>
<xsl:template match="*[contains(@class, ' support/support ')]">
<xsl:apply-imports/>
</xsl:template>
<xsl:template match="*[contains(@class, ' support/support-frage ')]">
<xsl:param name="headinglevel">
<xsl:choose>
<xsl:when test="count(ancestor::*[contains(@class,' topic/topic ')])> 6">6</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(ancestor::*[contains(@class,' topic/topic ‚)])"/>
</xsl:otherwise'>
</xsl:choose>
</xsl:param>
<xsl:element name="h{$headinglevel}">
<xsl:attribute name="class">topictitle <xsl:value-of select="$headinglevel"/></xsl:attribute>
<xsl:call-template name="commonattributes"/>
<div class="support-frage">
<span class="support-frage-txt">Frage: </span>
<xsl:apply-templates/>
</div>
</xsl:element>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template match="*[contains(@class,' support/supportlange-antwort ')]" name="topic.body">
<xsl:variable name="flagrules">
<xsl:call-template name="getrules"/>
</xsl:variable>
<xsl:variable name="conflictexist">
<xsl:call-template name="conflict-check">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
</xsl:variable>
<div>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="setidaname"/>
<xsl:call-template name="gen-style">
<xsl:with-param name="conflictexist" select="$conflictexist"></xsl:with-param>
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="start-flagit">
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="start-revflag">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
<xsl:apply-templates select="precedingsibling::*[contains(@class,' topic/shortdesc ')]" mode="outofline"/>
<div class="support-lange-antwort">
<xsl:apply-templates/>
</div>
<xsl:call-template name="end-revflag">
<xsl:with-param name="flagrules" select="$flagrules"/>
</xsl:call-template>
<xsl:call-template name="end-flagit">
<xsl:with-param name="flagrules" select="$flagrules"></xsl:with-param>
</xsl:call-template>
</div>
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template match="*[contains(@class, ' support/support-kurze-antwort ')]" mode="outofline">
<div class="support-kurze-antwort">
<span class="support-kurze-frage-txt">Antwort </span>
<xsl:apply-templates/>
</div>
</xsl:template>This completes the XSLT stylesheet for processing the specialized elements.
The final step is to define CSS to format the classes
support-frage,support-frage-txt,support-kurze-antwortandsupport-kurze-antwort-txtgenerated in the XHTML files by the XSLT transformation.
Create CSS such as the following:
@import "commonltr.css";
*[class = 'support-kurze-aantwort-txt'] {
font-family: Arial;
font-size: 16pt;
font-weight: bold;
}
*[class = 'support-kurze-aantwort'] {
margin-left: 5px;
}
*[class = 'support-lange-antwort-txt'] {
font-family: Arial;
font-size: 16pt;
font-weight: bold;
}
*[class = 'support-lange-aantwort'] {
margin-left: 5px;
}Save the CSS in the directory containing the
commonltr.cssfile and the transformed XML file.
To test the XSLT stylesheet, first create an XML file using the support topic type. Then transform the XML file with ant -f support2html.xsl into an XHTML file. Check the XHTML file in the browser.
Copyright © 2008 XLcontent Verlag
You may print the online version for your private use.
Otherwise, this chapter from “DITA - Der neue Standard für Technische Dokumentation” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
XLcontent Verlag, Pflegerstraße 40, 81247 München