Make It Easier to Create Tutorials
9.2.2 Show Our Audience That We Use the Technologies We Advocate
Another goal was to actually use the technologies we espouse. We were certainly aware of the irony of a site that promotes open, standards-based computing creating content with a closed-source, proprietary tool, such as Microsoft Word. One attraction of building tools from XML documents and XSLT stylesheets was that it enabled us to show the world that XML and XSLT can do useful work today. Choosing these technologies to manipulate structured data was a no-brainer for us.9.2.3 See Just How Much We Could Accomplish Through Stylesheets
Our final goal was to see how much we could do with XSLT. As youll see, we exercise all the advanced capabilities of XSLT in the Toot-O-Matic, including multiple input files, multiple output files, and extension functions. Through our stylesheets, we convert an XML document into: • A web of interlinked HTML documents • A menu for the entire tutorial • A table of contents for each section of the tutorial • JPEG graphics containing the title of the tutorial and each of the individual sections • A letter-sized PDF file • An A4-sized PDF file • A zip file containing everything users need to run the tutorial on their machine page 171 As well discuss, creating all of these things through stylesheets required us to push XSLT to its limits. The design of the XML document allows us to manipulate the information for a tutorial in a variety of sophisticated ways, and the structure of our stylesheets makes it easy for us to change the look and feel of our tutorials without having to modify the original XML content. In addition to these goals, we decided to make the XSLT stylesheets and the necessary extensions open source. We did this so our readers could see what we were doing to eat our own dog food, and to see if tight integration with a standards-compliant stylesheet processor would allow us to use existing tools to generate tutorials in a semi-WYSIWYG environment.9.3 Tutorial Layout
Before we talk about the details of the XML document design and the XSLT source code, well review the actual HTML, zip, and PDF files we need to create. One advantage we had in this project is that we didnt have any existing XML documents to contend with; this advantage gave us complete freedom over the XML document design.9.3.1 Menu Panel
The menu panel is the first HTML document a user sees. It looks like Figure 9-1 . Figure 9-1. Toot-O-Matic menu panel In this example, the string Building tutorials with the Toot-O-Matic and all section titles are JPEG graphics created with our stylesheets and extensions. If you mouseover a section title, its background color changes, as shown in Figure 9-2 . Figure 9-2. Mouseover effect for section titles In this sample, notice that the text of the menu item appears as a tooltip. This appearance is useful for sight-impaired users, and is consistent with the Web Accessibility Guidelines defined by the W3C.Parts
» O'Reilly-XSLT-Mastering.XML.Transformati... 2264KB Mar 29 2010 05:03:43 AM
» An XML document must be contained in a single element
» XML declarations Document Type Definitions DTDs and XML Schemas
» Well-formed versus valid documents
» Tags versus elements XML Document Rules
» Namespaces XML Document Rules
» The Extensible Stylesheet Language XSL
» Document Object Model DOM Level 1
» Document Object Model DOM Level 2
» Namespaces in XML XML Standards
» Associating stylesheets with XML documents
» Installing Xalan Getting Started
» Our Sample Document A Sample Stylesheet
» Transforming the XML Document
» Stylesheet Results Transforming Hello World
» Parsing the Stylesheet How a Stylesheet Is Processed
» Parsing the Transformee How a Stylesheet Is Processed
» Lather, Rinse, Repeat How a Stylesheet Is Processed
» The xsl:template for greeting Elements
» Built-in template rule for element and root nodes
» Built-in template rule for modes
» Built-in template rule for text and attribute nodes
» Top-Level Elements Stylesheet Structure
» Other Approaches Stylesheet Structure
» The Hello World Java Program
» Goals of This Chapter Summary
» The Root Node The XPath Data Model
» Element Nodes The XPath Data Model
» Attribute Nodes The XPath Data Model
» Text Nodes The XPath Data Model
» Comment Nodes The XPath Data Model
» Processing Instruction Nodes The XPath Data Model
» Namespace Nodes The XPath Data Model
» Simple Location Paths Location Paths
» Relative and Absolute Expressions
» Selecting attributes Selecting Things Besides Elements with Location Paths
» Selecting the text of an element
» Selecting comments, processing instructions, and namespace nodes
» Using Wildcards Location Paths
» Numbers in predicates Predicates
» Functions in predicates Predicates
» Attribute Value Templates XPath Datatypes
» Output View The XPath View of an XML Document
» The Stylesheet The XPath View of an XML Document
» Summary XPath: A Syntax for Describing Needles and Haystacks
» Converting to boolean values
» Boolean examples The xsl:if Element
» xsl:for-each example The xsl:for-each Element
» How It Works Invoking Templates by Name
» Templates à la Mode Invoking Templates by Name
» Defining a Parameter in a Template
» Microsofts XSLT tools Global Parameters
» Setting global parameters in a Java program
» Are These Things Really Variables?
» Procedural design Implementing a String Replace Function
» Recursive design Implementing a String Replace Function
» Template Design Implementation A Stylesheet That Emulates a for Loop
» The Complete Example A Stylesheet That Emulates a for Loop
» XML Input A Stylesheet That Generates a Stylesheet That Emulates a for Loop
» Template Design A Stylesheet That Generates a Stylesheet That Emulates a for Loop
» Complications A Stylesheet That Generates a Stylesheet That Emulates a for Loop
» Summary Branching and Control Elements
» The ID, IDREF, and IDREFs Datatypes
» An XML Document in Need of Links
» A Stylesheet That Uses the id Function
» Limitations of IDs Generating Links with the id Function
» Defining a key Generating Links with the key Function
» A Slightly More Complicated XML Document in Need of Links
» The key function and the IDREFS datatype
» Solution 1: Replace the IDREFS datatype
» Solution 2: Use the XPath contains function
» Solution 3: Use recursion to process the IDREFS datatype
» Solution 4: Use an extension function
» Advantages of the key Function
» An Unstructured XML Document in Need of Links
» The generate-id Function Generating Links in Unstructured Documents
» Summary Creating Links and Cross-References
» Our First Example Sorting Data with xsl:sort
» Whats the deal with that syntax?
» Attributes The Details on the xsl:sort Element
» Another Example Sorting Data with xsl:sort
» Our First Attempt Grouping Nodes
» A Brute-Force Approach Grouping with xsl:variable
» Summary Sorting and Grouping Elements
» Recursive design An Aside: Doing Math with Recursion
» Generating output to initialize a variable
» Overview Invoking the document Function
» The document Function and Sorting
» Implementing Lookup Tables More Sophisticated Techniques
» Grouping Across Multiple Documents
» Summary Combining XML Documents
» Example: Generating multiple output files
» Example: Using extension functions from multiple processors
» Example: A library of trigonometric functions
» Example: Writing extensions in other languages
» Fallback Processing Extension Elements, Extension Functions, and Fallback Processing
» Extending the Saxon Processor
» Generating JPEG Files from XML Content
» About the Toot-O-Matic Case Study: The Toot-O-Matic
» Make It Easier to Create Tutorials
» Individual Panels Tutorial Layout
» Email Panel Zip File PDF Files
» Individual Panels XML Document Design
» Stylesheets and Modes XSLT Source Code
» Initializing Global Variables XSLT Source Code
» Generating the Main Menu Panel
» Generating the Section Indexes
» Generating the Individual Panels
Show more