XML and XSLT
Upcoming SlideShare
Loading in...5
×
 

XML and XSLT

on

  • 2,132 views

This workshop introduced the power of XML and XSLT to delegates. It used an innovative solution of Apache Cocoon on a single server and form-based file upload to allow delegates to quickly and simply ...

This workshop introduced the power of XML and XSLT to delegates. It used an innovative solution of Apache Cocoon on a single server and form-based file upload to allow delegates to quickly and simply see the effect of applying XSL transformations on their markup.

Statistics

Views

Total Views
2,132
Views on SlideShare
2,132
Embed Views
0

Actions

Likes
2
Downloads
61
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • How many people have heard of W3C?
  • Web created to reduce information management costs by distributing back on information owners.
  • How many people know what XML is? How many people have used it or seen it used? What context?
  • How many people here have heard of XSL? How many people know what it is? How many people have used it?
  • Explain the need for publishing engines Benefits of publishing engines over browser-based xml translations

XML and XSLT XML and XSLT Presentation Transcript

  • XML and XSL
      • Institutional Web Management 2001:
      • Organising Chaos
  • Running order
    • Background
    • All about XML
    • All about XSL
    • Hands-on XML and XSL
    • Publishing engines
    • Example applications
    • Crystal balls
  • Background
    • Mark Ray and Andrew Savory
    • Using XML since 1996
    • Used a variety of tools and methods
  • XML and XSL
    • W3C specifications
    • Separation of Concerns
      • Reuse of data
      • Multiple output formats
      • Styles tailored to reader / Standardised styles
  • Applications of XML and XSL
    • Static information
      • Institutional web sites
      • Prospectuses
      • Course catalogues
    • Dynamic information
      • News or event information services
      • Course catalogues
      • Staff directories
  • Benefits of XML and XSL
    • Standards-based, format-independent
    • Serve sites and formats based on user need
      • Text-based (text readers, slow links, low-tech)
      • Netscape / Internet Explorer specifc
      • TV, Phone, PDA
      • PDF, SVG, VRML, ...
    • Simplification of web site management...
  • The management bit
    • Management
      • Decide what the site should contain, how it should behave and how it should appear
    • Content
      • Responsible for writing, owning, managing the site content
  • The management bit
    • Logic
      • Responsible for integration with dynamic content generation
    • Style
      • Responsible for information presentation, look & feel, site graphics and maintenance
  • What is XML?
    • eXtensible Markup Language
      • Not a fixed format
      • 'Metalanguage'
      • For describing information
  • XML Design Goals
      • XML shall be straightforwardly usable over the Internet.
      • XML shall support a wide variety of applications.
      • XML shall be compatible with SGML.
      • It shall be easy to write programs which process XML documents.
      • The number of optional features in XML is to be kept to the absolute minimum, ideally zero.
  • XML Design Goals
      • XML documents should be human-legible and reasonably clear.
      • The XML design should be prepared quickly.
      • The design of XML shall be formal and concise.
      • XML documents shall be easy to create.
      • Terseness is of minimal importance.
  • Structure of an XML document
    • <?xml version=&quot;1.0&quot;?>
    • <PARENT>
      • <CHILD>
        • This is content.
      • </CHILD>
      • <EMPTY/>
    • </PARENT>
  • A first XML document
    • Construct a well-formed XML document using the following tags:
      • xml opening tag
      • page
      • title
      • content
      • para
    • Don't forget to add the closing tags!
  • Differences to HTML
    • Order:
        • <tag1><tag2></tag1></tag2> WRONG
        • <tag1><tag2></tag2></tag1> RIGHT
    • Balance
        • <tag1><tag2></tag2> WRONG
        • <tag1><tag2></tag2></tag1> RIGHT
    • Case
        • <tag1><tag2></TAG2></TAG1> WRONG
        • <tag1><tag2></tag2></tag1> RIGHT
  • Differences to HTML
    • Attributes
        • <tag1 class=wrong> WRONG
        • <tag1 class=&quot;right&quot;> RIGHT
    • Empty Tags
        • <tag1 class=&quot;wrong&quot;> WRONG
        • <tag1 class=&quot;wrong&quot; /> RIGHT
    • XML is stricter
      • ...and therefore better!
  • Well-formed vs. Valid
    • Exactly what they say:
      • Well-formed means it's written correctly
      • Valid means we can validate it
  • A well-formed example
    • <?xml version=&quot;1.0&quot;?>
    • <PARENT>
      • <CHILD>
        • <MARK NUMBER=&quot;1&quot; LISTED=&quot;yes&quot; TYPE=&quot;natural&quot;/>
        • <NAME>
          • <LASTNAME>child</LASTNAME>
          • <FIRSTNAME>second</FIRSTNAME>
        • </NAME>
      • </CHILD>
    • </PARENT>
  • A valid example
    • <?xml version=&quot;1.0&quot;?>
    • <!DOCTYPE PARENT [
      • <!ELEMENT PARENT (CHILD*)>
      • <!ELEMENT CHILD (MARK?,NAME+)>
      • <!ELEMENT MARK EMPTY>
      • <!ELEMENT NAME (LASTNAME+,FIRSTNAME+)*>
      • <!ELEMENT LASTNAME (#PCDATA)>
      • <!ELEMENT FIRSTNAME (#PCDATA)>
      • <!ATTLIST MARK
        • NUMBER ID #REQUIRED
        • LISTED CDATA #FIXED &quot;yes&quot;
        • TYPE (natural|adopted) &quot;natural&quot;>
      • <!ENTITY STATEMENT &quot;This is well-formed XML&quot;>
    • ]>
    • <PARENT>
      • &STATEMENT;
      • <CHILD>
        • <MARK NUMBER=&quot;1&quot; LISTED=&quot;yes&quot; TYPE=&quot;natural&quot;/>
        • <NAME>
          • <LASTNAME>child</LASTNAME>
          • <FIRSTNAME>second</FIRSTNAME>
        • </NAME>
      • </CHILD>
    • </PARENT>
  • Document Type Definitions
    • First standard mechanism for XML validation
    • Define the role and structure of XML elements
    • Sufficient for simple XML schemas
    • Don't support namespaces
    • Use non-XML syntax
  • XSchema
    • XML structural definition language of choice
    • Defines a class of XML document
    • Supports name spaces
    • More powerful
  • Xschema example
    • <?xml version=&quot;1.0&quot;?>
    • <xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;>
    • <xsd:annotation>
    • <xsd:documentation xml:lang=&quot;en&quot;>
    • Example Schema for IWM workshop
    • </xsd:documentation>
    • </xsd:annotation>
    • <xsd:element name=&quot;page&quot; type=&quot;page&quot;/>
    • <xsd:complexType name=&quot;page&quot;>
    • <xsd:sequence>
    • <xsd:element name=&quot;title&quot; type=&quot;xsd:string&quot;/>
    • <xsd:element name=&quot;content&quot; type=&quot;pageContent&quot;/>
    • </xsd:sequence>
    • </xsd:complexType>
    • <xsd:complexType name=&quot;pageContent&quot;>
    • <xsd:sequence>
    • <xsd:element name=&quot;para&quot; type=&quot;xsd:string&quot; minOccurs=&quot;0&quot;/>
    • </xsd:sequence>
    • </xsd:complexType>
    • </xsd:schema>
  • What is XSL?
    • Preferred style sheet language of XML
      • a method for transforming XML documents
      • a method for defining XML parts and patterns
      • a method for formatting XML documents
    • An application of XML (same formatting rules)
  • Hands-on XML
    • Create the following XML document:
          • <?xml version=&quot;1.0&quot;?>
          • <page>
            • <title>Hello</title>
            • <content>
            • <para>This is my first XML page!</para>
            • </content>
          • </page>
    • Save it as hello_world.xml
  • Uploading the file
    • Navigate to the site provided
    • Click on &quot;upload.html&quot;
    • Beside the &quot;file to upload&quot; box, click on &quot;choose&quot;
    • Select the file you want to upload
    • Click on &quot;upload&quot;
  • Viewing the file
      • If you see the file you wanted to upload and receive a &quot;File written successfully&quot; message...
    • Click on &quot;Content&quot;, then the name of the file
  • Structure of an XSL stylesheet
    • Most templates have the following form:
        • <xsl:template match=&quot;emphasis&quot;>
          • <i><xsl:apply-templates/></i>
        • </xsl:template>
    • The whole <xsl:template> element is a template
    • The match pattern determines where this template applies
  • Structure of an XSL stylesheet
    • Literal result element(s) come from non-XSL namespace(s)
    • XSLT elements come from the XSL namespace
  • Hands-on XSL
    • Create the following XSL stylesheet:
    • <?xml version=&quot;1.0&quot;?>
    • <xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;>
      • <xsl:template match=&quot;page&quot;>
        • <html>
          • <head>
            • <title><xsl:value-of select=&quot;title&quot;/></title>
          • </head>
          • <body bgcolor=&quot;white&quot; alink=&quot;red&quot; link=&quot;blue&quot; vlink=&quot;blue&quot;>
            • <xsl:apply-templates/>
          • </body>
        • </html>
      • </xsl:template>
    • </xsl:stylesheet>
  • Uploading the file
    • Navigate to the site provided
    • Click on &quot;upload.html&quot;
    • Beside the &quot;file to upload&quot; box, click on &quot;choose&quot;
    • Select the file you want to upload
    • Click on &quot;upload&quot;
  • Publishing engines
    • Cocoon
      • Java-based
    • AxKit
      • Perl-based
    • 4Suite
      • Python
    • Others or roll your own
  • Viewing the file
      • If you see the file you wanted to upload and receive a &quot;File written successfully&quot; message...
    • Click on &quot;View site in cocoon&quot;
    • Select the file you uploaded and the stylesheet you want to view it in
  • Hands-on XSL
    • Add the following to the XSL stylesheet:
      • <xsl:template match=&quot;title&quot;>
        • <h2 style=&quot;color: navy; text-align: center&quot;>
          • <xsl:apply-templates/>
        • </h2>
      • </xsl:template>
      • <xsl:template match=&quot;para&quot;>
        • <p align=&quot;left&quot;>
          • <i><xsl:apply-templates/></i>
        • </p>
      • </xsl:template>
  • New platforms, new beginnings?
    • The old way of publishing
      • Repurposing
    • The new way of publishing
      • Target multiple platforms
      • Multiple stylesheets
      • Multiple formats
  • Browser-specific content
    • <map:select>
      • <map:when test=&quot;lynx&quot;>
        • <map:transform src=&quot;stylesheets/simple-page2html-lynx.xsl&quot;/>
      • </map:when>
      • <map:otherwise>
        • <map:transform src=&quot;stylesheets/simple-page2html.xsl&quot;/>
      • </map:otherwise>
    • </map:select>
  • Lynx-friendly XSL stylesheet
    • Add the following to your XSL stylesheet:
      • <h2>This site is lynx-friendly</h2>
    • Save the stylesheet as
      • simple-page2html-lynx.xsl
  • Uploading the file
    • Navigate to the site provided
    • Click on &quot;upload.html&quot;
    • Beside the &quot;file to upload&quot; box, click on &quot;choose&quot;
    • Select the file you want to upload
    • Click on &quot;upload&quot;
  • Viewing the file
      • If you see the file you wanted to upload and receive a &quot;File written successfully&quot; message...
    • Click on &quot;View site in cocoon&quot;
    • Select the file you uploaded and the stylesheet you want to view it in
  • Where next?
    • The semantic web
  • References
    • http://www.ibm.com/developerworks/papers.nsf/dw/xml-papers-bytopic?OpenDocument&Count=500
    • http://www.xml101.com/
    • http://nwalsh.com/docs/tutorials/xsl/