Practical XML

Goals | XML Overview | XSLT | Websites using XML | Presentations using XML | XML Usage Tips

Goals

XML Overview

XML Syntax | XML Formats | Format Design

“Extensible Markup Language (XML) is a simple, very flexible text format derived from SGML. Originally designed to meet the challenges of large-scale electronic publishing, XML is also playing an increasingly important role in the exchange of a wide variety of data on the Web and elsewhere.” — W3C XML Introduction.

XML Syntax

Leading Elements | Validity | Processing Instructions | Namespaces

Leading Elements

Validity

Processing Instructions

Namespaces

XML Formats

Format Design

XSLT

XSLT Overview | Work Flow | Discussion

“XSLT is designed for use as part of XSL, which is a stylesheet language for XML. In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.”

“XSLT is also designed to be used independently of XSL. However, XSLT is not intended as a completely general-purpose XML transformation language. Rather it is designed primarily for the kinds of transformations that are needed when XSLT is used as part of XSL.” — W3C XSLT Abstract.

XSLT Overview

Work Flow

Discussion

Websites using XML

XML Format | Advantages over HTML | Stylesheets | Stylesheet Setup | AxKit | Alternatives | Conclusion

XML Format

Advantages over HTML

Stylesheets

Stylesheet Setup

AxKit

AxKit Needs | Needs for AxKit | Request Overview | Browser Requests | Apache Config for AxKit

“Apache AxKit is an XML Application Server for Apache. It provides on-the-fly conversion from XML to any format, such as HTML, WAP or text using either W3C standard techniques, or flexible custom code. AxKit also uses a built-in Perl interpreter to provide some amazingly powerful techniques for XML transformation.” — AxKit.org Introduction.

AxKit Needs

As of AxKit version 1.6; see the AxKit mailing list for discussion of potential problems with specific releases (e.g. XML and XSLT libraries).

Needs for AxKit

Request Overview

Browser Requests

Apache Config for AxKit

Configuration Sections | Files & Exceptions | Browser/XML Mapping | Random Tips
Configuration Sections

Inside <Files>, <Location>, <Directory>, or .htaccess.

# limit what filetypes AxKit deals with
AddHandler axkit .xml .dkb

# use libxml2/libxslt for XSLT work
AxAddStyleMap text/xsl Apache::AxKit::Language::LibXSLT

# custom page instead of "500 server in flames"
AxErrorStylesheet text/xsl /_xs/axkit/error.xsl

# good for static content
AxCacheDir /tmp/axkit-cache
AxGzipOutput On

# make various request data available to stylesheets
AxAddPlugin Apache::AxKit::Plugin::AddXSLParams::Request
PerlSetVar AxAddXSLParamGroups "Request-Common"

Files & Exceptions

# file extension mapping
<Files *.dkb>
AxAddProcessor text/xsl /_xs/docbook/html/docbook.xsl
</Files>

# spare /wc3/p3p.xml from AxKit
<Location /w3c/>
AxResetStyleMap
AxResetProcessors
</Location>

Browser/XML Mapping

# map HTTP User-Agent by regex to stylesheet title
AxAddPlugin Apache::AxKit::StyleChooser::UserAgent
PerlSetVar AxUAStyleMap "lynx => Lynx,\
mozmac => ^Mozilla\/.+?Macintosh.+?Gecko"

# map ?style=lynx arguments to stylesheet title
AxAddPlugin Apache::AxKit::StyleChooser::QueryString

# map stylesheet titles to various XML formats
<AxStyleName "#default">
AxAddRootProcessor text/xsl /_xs/eolas/default.xsl eolas

AxAddRootProcessor text/xsl /_xs/docbook/xhtml/docbook.xsl book

AxAddRootProcessor text/xsl /_xs/cvs2cl/default.xsl changelog
</AxStyleName>

<AxStyleName "lynx">
AxAddRootProcessor text/xsl /_xs/eolas/lynx.xsl eolas

AxAddRootProcessor text/xsl /_xs/docbook/html/docbook.xsl book

AxAddRootProcessor text/xsl /_xs/cvs2cl/lynx.xsl changelog
</AxStyleName>

<AxStyleName "mozmac">

Random Tips

Alternatives

Conclusion

Presentations using XML

XML Format | XSLT to XSL-FO | XSL | FOP | XSL for Presentations | Publication Alternatives | Conclusion

XML Format

XSLT to XSL-FO

XSL

FOP

FOP Needs | Usage | Limitations of FOP

“FOP (Formatting Objects Processor) is the world's first print formatter driven by XSL formatting objects and the world's first output independent formatter. It is a Java application that reads a formatting object tree and then renders the resulting pages to a specified output. Output formats currently supported are PDF, PCL, PS, SVG, XML (area tree representation), Print, AWT, MIF and TXT. The primary output target is PDF.” — FOP Introduction.

FOP Needs

Usage

Need to render XSL-FO to PDF for presentation.

Limitations of FOP

XSL for Presentations

Publication Alternatives

Conclusion

XML Usage Tips

Working with XSLT

Testing | Creation

Testing

Creation