First slide  Next slide
Using Style Sheets to Publish XML to the Web
Alan Houser

arh@groupwellesley.com

2000 FrameUsers Conference

1 November 2000

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Contents

Using Style Sheets to Publish XML to the Web
Contents
The Changing World of Publishing
The Changing World of Publishing
The Changing World of Publishing
The Cusp of a Publishing Revolution
How to keep up?
Today's answer: XML
Content vs. Format
Displaying XML
Style Sheets for Publishing XML
Evolution of HTML
Evolution of HTML (2)
Cascading Style Sheets
Example CSS
Advantages of CSS and XML
Disadvantages of CSS and XML
XML Transformation Language (XSLT)
XSLT and the Browser
Pre-processing XML with XSLT
XSLT Advantages
Example XSLT Fragments
XPath
Example XPath Statements
Possible Applications of XSLT
XSLT Advantages
XSLT Disadvantages
XML Myths
Next Year's Topics


Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
The Changing World of Publishing
The Early Days

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
The Changing World of Publishing
Enter Online Help

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
The Changing World of Publishing
The Brave New World

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
The Cusp of a Publishing Revolution
  print-on-demand
  new output devices (including voice and audio)
  customized content
  database integration
  document-based applications

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
How to keep up?
  Single-source solutions
  Conditional text
  Write for each publishing format

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Today's answer: XML
  Extensible Markup Language
  information about your content embedded within your content
  your documents become databases of content
  select, sort, manipulate the right content, for the right audience, for the right display device
  convert the content you have to the content you need

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Content vs. Format
The more tightly content and format of a document are inter-twined, the more difficult it is to reuse/repurpose/republish the contents of the document.

Examples:
  Bitmaps, PDF
  proprietary binary file formats
  ascii text
  HTML
  SGML/XML

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Displaying XML
XML is about content, not about format.

Your browser knows how to display a <p>, but probably doesn't know what to do with a <partNumber>.

Something must tell the browser how to render the contents of your XML documents.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Style Sheets for Publishing XML
Cascading Style Sheets (CSS)

XML Transformation Language (XSLT)

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Evolution of HTML
Early HTML:
  simple tag set
  "weak" semantic markup

Then things got ugly.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Evolution of HTML (2)
Is this a heading? Maybe.

<font color="red" "ptsize"="24" family="serif" face="Times-roman">
Troubleshooting your Acme Widget</font>

Is this a heading? Probably.

<h1>Troubleshooting your Acme Widget</h1>

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Cascading Style Sheets
  Extend semantic markup capabilities of HTML
  Increase control over page design
  Simplify "body" HTML, increase ease of maintenance

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Example CSS
Including CSS in XML document:

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="recipecollection.css"?>
<recipeCollection>

Example CSS fragment:

title {display:block; font-family:'Helvetica, sans-serif';
       font-weight: bold; font-size:140%; color:#000000;
       line-height:150%;}

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Advantages of CSS and XML
  Relatively simple
  New application of existing technology
  Maintains separation of content and format. To change your browser's rendition of an XML document, change your CSS.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Disadvantages of CSS and XML
Only works with Microsoft Internet Explorer 5.0 or later.

Cannot tranform or manipulate content (all or nothing).

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XML Transformation Language (XSLT)
A language for transforming XML documents to other XML documents.

Can select, sort, filter, and manipulate the content of an XML document.

Can also convert XML to HTML and text.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XSLT and the Browser
Microsoft Internet Explorer 5.0 or later supports an older version of XSLT.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Pre-processing XML with XSLT
Don't depend on user's brower to perform transformation.

Process XML with XSLT processor, send result HTML to browser.

Examples: XT, Saxon, Xalan.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XSLT Advantages
  Can manipulate, select, or transform the content of XML documents
  Provides the full capabilities of XML documents
  Can transform and XML document to HTML for display in any browser

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Example XSLT Fragments
Make <partNumber> elements bold:

<xsl:template match="partNumber">
  <b>
    <xsl:value-of select="."/>
  </b>
</xsl:template>


Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XPath
XML language for specifying sections of XML documents.

Provides means for selecting and filtering content of XML documents for publishing.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Example XPath Statements
<xsl:template match="para[@role='example']">

<xsl:when test="preceding-sibling::slide">
  <a href="{concat($slideNum - 1, '.html')}">
  <img src="icons/prev.gif" /> 
  </a>
  </xsl:when>

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
Possible Applications of XSLT
  Display only "cookie" recipes from an XML cookbook
  Select news headlines for display on a cell phone or PDA display
  Convert a document to a voice markup language

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XSLT Advantages
  Separates content and format. To change the display of an XML file, edit the XSLT stylesheet, not the original XML document.
  Can create multiple renditions of our XML data by applying different XSLT transformations to an XML document.
  Can create HTML rendition of XML content for display in any browser.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XSLT Disadvantages
  Only supported by MS IE5 or later browsers (with caveat). Transformation is normally done by the Web server.
  Provides a powerful, complex language for manipulating XML documents. Learning curve can be steep.

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  Next slide
XML Myths
  XML will replace HTML
  Until all browsers can handle XML, using XML doesn't make sense
  XML is the answer to all things

Copyright © 2000 Group Wellesley
www.groupwellesley.com


  First slide  Previous slide  
Next Year's Topics
  Print Publishing with XML
  Designing XML Schemas for your Documentation Set
  Exploiting XML Pointers

Copyright © 2000 Group Wellesley
www.groupwellesley.com