A demonstration of DITA specialization Showing information type, domain, and processing specializations June 14, 2004 2004 IBM Corporation Prerequisite reading This demonstration assumes you are familiar with the following materials: http://xml.coverpages.org/DITA-IntroductionBrief.ppt slides 18-24 of the first briefing presentation provide an overview of specialization http://xml.coverpages.org/DITA-EXTREME-SpecializationPres.pdf provides a more technical overview, with checklists/instructions Additional recommended reading: http://xml.coverpages.org/priestleySIGDOC2002-DITA.pdf
provides in-depth view of the technology, process, and policy issues of specialization http://www.ibm.com/developerworks/xml/library/x-dita2/index.html specifics of information type specialization http://www.ibm.com/developerworks/xml/library/x-dita5/index.html specifics of domain specialization 2 DITA specialization 2004 IBM Corporation Overview Setting up Creating samples (in base markup, then in specialized markup) Identifying new tags Creating the information type Creating the domain Adding override processing
Summary 3 DITA specialization 2004 IBM Corporation Setting up Install DITA package http://www.ibm.com/developerworks/xml/library/x-dita6/x-dita_downloads.html Install an XSLT interpreter (eg xalan, saxon, xt...) 4 DITA specialization 2004 IBM Corporation Creating samples
Always easiest to start with something concrete and then figure out the general rules So start by authoring a sample document in the closest existing information type Then go through and rename tags that should be more specific Then reverse-engineer the document type from its instance 5 DITA specialization 2004 IBM Corporation Sample: A task for a wizard Assuming that wizards do sometimes require documentation A series of screens with next, back, and finish buttons Let's say that each wizard task needs to describe how to open and finish the wizard, with one step per page in between
Can use markup to enforce consistency Can also use special markup for the wizard title and the wizardspecific controls (next and finish) This sample is for demonstration purposes only, not a best practice 6 DITA specialization 2004 IBM Corporation Sample using task.dtd (mytask.xml) Creating a foo Click File New Foo to open the New Foo wizard. The New Foo wizard opens to the Name page, where you provide a name for the foo.
Click Next and turn to the Properties page. The Properties page lets you define the color and shape of your foo. Set the color of the foo using the color wheel. Set the shape of the foo using the shape selection bar. You can edit the shape of the foo after you create it; this shape is just your starting point. Click Next and turn to the Location page. Select the project you want to save your foo in. Click Finish to close the wizard and create your foo. The foo, with the shape and color you selected, should appear in your project folder. 7
DITA specialization 2004 IBM Corporation Sample output from mytask.xml 8 DITA specialization 2004 IBM Corporation Sample with renamed tags Creating a foo Click File New Foo to open the New Foo wizard.
The New Foo wizard opens to the Name page, where you provide a name for the foo. Click Next and turn to the Properties page. The Properties page lets you define the color and shape of your foo. Set the color of the foo using the color wheel. Set the shape of the foo using the shape selection bar. You can edit the shape of the foo after you create it; this shape is just your starting point. > Click Next and turn to the Location page. Select the project you want to save your foo in. Click Finish to close the wizard and create your foo. The foo, with the shape and color you selected, should appear in your project folder.
9 DITA specialization 2004 IBM Corporation Identify information type and domain tags Structural (information type) - tags you need in certain places, plus their containers wiztask (from task) wizbody (from body) wizsteps (from steps) wizopen, wizpage, wizclose (from step) Pervasive (domain) - tags you want available everywhere wiztitle (from wintitle) wiznext (from uicontrol) wizfinish (from uicontrol) 10
DITA specialization 2004 IBM Corporation Creating the information type Copy the parent module (task.mod) to a new module (wiztask.mod) Keep anything related to task, taskbody, steps, and step Three main sections: entities, element declarations, specialization attributes In the entity section, delete everything except the DTD entity, included- domains entity, and entities for elements you're specializing, and the taskinfo-types entity In the element section, delete everything except the elements you're specializing In the specialization attributes section, delete everything except the elements you're specializing Review wiztask-intermediate.mod to compare your results
11 DITA specialization 2004 IBM Corporation Specialize entities In the entities section, change entity names and values from task ones to wiztask ones eg: becomes "wiztask"> you'll need to create three copies of step, since step has three specializations (wizopen, wizpage, wizclose) eg:
"step"> becomes This prepares your specialized elements for extension by domains Rename task-info-types entity to wiztask-info-types This prepares your module for integration with other modules in a DTD 12
DITA specialization 2004 IBM Corporation Specialize elements In the elements section, rename the element and attribute declarations to wiztask equivalents, and rename and adjust entities in the content model where you have changed entities from the original. For example: %univ-atts; outputclass CDATA #IMPLIED>> becomes:
%univ-atts; outputclass CDATA #IMPLIED> Again, you need three copies of the declaration for , since it gets specialized to , , and 13 DITA specialization 2004 IBM Corporation Specialize specialization attributes Add copies of the entry for step, since you need to specialize it three times Rename the attribute declarations to point to your new element names To the end of each attribute value string, add wiztask/elementname
For example: becomes: Make sure you include a space after the value before the string closes 14 DITA specialization 2004 IBM Corporation Result: wiztask.mod Review file to compare results
15 DITA specialization 2004 IBM Corporation Creating wiztask-simple_shell.dtd Copy task.dtd to wiztask-simple_shell.dtd in your wiztask directory Adjust paths (to point back to the .mod and .ent files in the dtd directory) Change to Lets wiztask topics nest, for no good reason Add an entry after "Embed task to get specific elements" that does the same things for wiztask: %wiztask-typemod; 16
DITA specialization 2004 IBM Corporation Testing wiztask-simple_shell.dtd Create a copy of your sample file (eg mywiztask-test.xml) and rename the element wiztitle to wintitle, and wiznext and wizfinish to uicontrol (since we haven't added support for them yet) Add a DTD reference at the top of your sample file: Try opening the file in IE to test it (quickest/easiest way to validate against a DTD on Windows) Try processing it to HTML, eg: saxon mywiztask-test.xml d:\dita13\xsl\dita2html_shell.xsl >mywiztask-test.html Compare results with mywiztask-test.html in the accompanying samples
17 DITA specialization 2004 IBM Corporation Sample output: mywiztask-test.html 18 DITA specialization 2004 IBM Corporation Creating the wiztask domain We have three new elements: wiztitle (from wintitle) wiznext (from uicontrol) wizfinish (from uicontrol) All are specialized from elements in the user interface domain, so
start by copying its files over to wiztask: ui-domain.ent to wiztask-domain.ent ui-domain.mod to wiztask-domain.mod 19 DITA specialization 2004 IBM Corporation Creating wiztask-domain.mod As with wiztask.mod, there are three sections: entities, element declarations, and specialization attributes. In each section: Delete everything except the entries for uicontrol and wintitle
Create an extra copy of entries for uicontrol (since we have two specializations of it) Rename the entities and values to wiztask equivalents - eg: to Rename the element declarations Rename the specialization attribute declarations, and add wiztask-d values to the end of each attribute, eg: %global-atts; class CDATA "+ topic/keyword ui-d/wintitle Compare with wiztask.mod in the accompanying samples 20 DITA specialization 2004 IBM Corporation
domain.ent files The domain.ent files are what make domains different from information types - they allow the elements declared in the domain to be substituted wherever an ancestor element is declared. For each parent element, you need an entity that declares the elements you are specializing off of it. You also need an entity that declares the ancestry of the domain as a whole, for inclusion in the domains attribute. We need the information separated into two files - .ent and .mod - so that they can be included in the right order in the integrating DTD file. 21 DITA specialization 2004 IBM Corporation
Creating wiztask-domain.ent Delete the existing entries for the UI specializations, leaving only the last entity (the d-att entity) Create the entity for specializations of wintitle: the name of the entity says this entity is part of the wiztask domain, and is defining specializations of wintitle Create the entity for specializations of uicontrol: note that there are two specializing elements, separated by a bar Rename the d-att entity, and add the wiztask domain to its list: this gets used in the domains attribute, so that processes can tell what domains are in use by a document
22 DITA specialization 2004 IBM Corporation Integrating domains with information types Create a copy of wiztask-simple_shell.dtd called wiztask_shell.dtd We are specializing ui-domain, so look for existing entries for that module (ui-domain, or ui-d) It appears in four places: vocabulary declarations (where the .ent files are pulled in) vocabulary substitutions (where content models that allow parent elements are extended to allow elements specialized off them) vocabulary attributes (where the domain attribute is defined) vocabulary definitions (where the .mod files are finally pulled in) 23
DITA specialization 2004 IBM Corporation Integrating wiztask-domain At the end of vocabulary definitions, add an entry for wiztask-d: %wiztask-d-dec; At the end of vocabulary substitutions, add entries for wintitle and uicontrol (which you are expanding to allow specialized elements): Under vocabulary attributes, add the wiztask domain to the end of the included domains entity: At the end of the vocabulary definition section, pull in the .mod file:
%wiztask-d-def; 24 DITA specialization 2004 IBM Corporation Testing the newly integrated DTD Go back to your original sample file, mywiztask.xml Add a DTD reference at the top of your sample file: Try opening the file in IE to test it (quickest/easiest way to validate against a DTD on Windows) Try processing it to HTML, eg: saxon mywiztask.xml d:\dita13\xsl\dita2html_shell.xsl >mywiztask.html
Compare results with mywiztask.html in the accompanying samples 25 DITA specialization 2004 IBM Corporation Sample output (mywiztask.html) 26 DITA specialization 2004 IBM Corporation Are all these outputs starting to look the same? They should - we've added new markup, but are reusing existing processing rules that get applied based on the class attribute of each element.
As long as each specialized element obeys the rules of specialization - the same or more restrictive content models - the processing can safely handle what the specialized element throws at it. In the next exercise, let's see what it takes to shake up the output a little. 27 DITA specialization 2004 IBM Corporation Specializing output 1: copy an existing template Create a new XSLT module: wiztask-d.xsl Add XSLT header stuff, and copy the template match for wintitle to use as a start:
28 DITA specialization 2004 IBM Corporation Specializing output 2: change match statement and code Change the match statement to point to wintitle, and change the behavior to make wiztitle bold:
29 DITA specialization 2004 IBM Corporation Specializing output 3: integrating the specialized code
Copy dita2html_shell.xsl into the wiztask directory, and rename it to dita2html-wiztask_shell.xsl Modify the paths of the existing imports, and add a reference to the wiztask-d.xsl module at the end of the import list: 30 DITA specialization 2004 IBM Corporation Test output saxon mywiztask.xml dita2html-new_shell.xsl >mywiztask-new.html Compare with mywiztask-new.html in the accompanying samples. The wizard title should now be bold.
Note that generic wintitles in the same document are not affected. Exercise for the reader: create an equivalent specialization module and shell for PDF output, and re-run the taskbook build to get specialized output for wiztitle in PDF as well. 31 DITA specialization 2004 IBM Corporation Sample output (mywiztask-new.html) 32 DITA specialization 2004 IBM Corporation Mechanics class attribute for a new information type element:
starts with lists ancestor elements plus current element, scoped by information type (the topiclevel element name) ends with a space class attribute for a new domain element: starts with + lists ancestor elements plus current element, scoped by domain package name (arbitrary name, typically something-d, used consistently for element names and in domains attribute) ends with a space domains attribute lists the domains, and their ancestors, in use by the current document type allows comparison of constraints (does task 1 allow the same things as task 2?) 33 DITA specialization 2004 IBM Corporation Summary
Mechanics are simple Design implementation is copy and extend, but copy only the parts you need to change - reuse everything else by reference Design hierarchy has one module per information type or domain, that are integrated into doctypes by a shell DTD Processing hierarchy has an equivalent structure: processing modules integrated into a transform by a shell XSLT But processing hierarchy can get away with a subset of the design modules: don't need processing modules for every design module, only the ones that need special processing 34 DITA specialization 2004 IBM Corporation
What's the value? A lot of work to define just seven elements But no work to define the other 100-odd already defined No work to get those tags enabled in existing processes No work to get the content integrated in existing books and Webs And reuse by reference means you can pick up enhancements to both base design and base processes when you want to. The real work is in figuring out what your tags need to be. What DITA does is simplify the mechanics of getting those tags into an authoring and processing environment you can test with your users - shorten the feedback cycle, improve more quickly. A rapid prototyping architecture that scales to a production one. 35 DITA specialization 2004 IBM Corporation