Web Technologies — Part III

Web-Based Services (INFOSYS 290-3)

Erik Wilde, UC Berkeley iSchool
Wednesday, September 13, 2006
Creative Commons License

This work is licensed under a Creative Commons
Attribution-NonCommercial-ShareAlike 2.5 License.

Abstract

XML's three most important companions are XML Namespaces for combining XML names from different vocabularies; XML Schema for defining XML vocabularies; and XSL Transformations (XSLT) for transforming XML data into other structures, either another XML vocabulary, or something else entirely. These technologies are the basic toolbox for any Web-based technology today.

Outline (XML Namespaces)

  1. XML Namespaces [12]
    1. Using Namespaces [5]
    2. Defining Namespaces [4]
  2. XML Schema [6]
  3. XSL Transformations (XSLT) [5]
  4. Conclusions [1]

Name Spaces

URI Philosophy

The Namespace Problem

Outline (Using Namespaces)

  1. XML Namespaces [12]
    1. Using Namespaces [5]
    2. Defining Namespaces [4]
  2. XML Schema [6]
  3. XSL Transformations (XSLT) [5]
  4. Conclusions [1]

Declaring Namespaces

Unhealthy Namespace Usages

Unhealthy Namespace Usages in Practice

<neurotic>
 <prefix:elem xmlns:prefix="http://ns1.com/">
  <prefix:child>content</prefix:child>
 </prefix:elem>
 <prefix:elem xmlns:prefix="http://ns2.com/">
  <prefix:child>content</prefix:child>
 </prefix:elem>
</neurotic>
<borderline>
 <prefix1:elem xmlns:prefix1="http://ns1.com/">
  <prefix1:child>content</prefix1:child>
 </prefix1:elem>
 <prefix2:elem xmlns:prefix2="http://ns1.com/">
  <prefix2:child>content</prefix2:child>
 </prefix2:elem>
</borderline>
<psychotic xmlns:prefix1="http://ns1.com/" xmlns:prefix2="http://ns1.com/">
 <prefix1:elem>
  <prefix2:child>content</prefix2:child>
 </prefix1:elem>
 <prefix2:elem>
  <prefix1:child>content</prefix1:child>
 </prefix2:elem>
</psychotic>

Elements and Attributes

Other Usages

<xsl:template match="section" xmlns:mathml="http://www.w3.org/1998/Math/MathML/">
 <xsl:if test="exists(.//mathml:*)">

Outline (Defining Namespaces)

  1. XML Namespaces [12]
    1. Using Namespaces [5]
    2. Defining Namespaces [4]
  2. XML Schema [6]
  3. XSL Transformations (XSLT) [5]
  4. Conclusions [1]

Any URI is Possible

Namespace Definitions

Fixed or Extensible?

Namespace Descriptions

Erik Wilde, Structuring Namespace Descriptions, 15th International World Wide Web Conference (WWW2006), Edinburgh, UK, May 2006.

Outline (XML Schema)

  1. XML Namespaces [12]
    1. Using Namespaces [5]
    2. Defining Namespaces [4]
  2. XML Schema [6]
  3. XSL Transformations (XSLT) [5]
  4. Conclusions [1]

XML Schemas

Schema-Validation and Applications

XML Schema vs. DTD

DTD XML Schema
Concepts some conceptual model (formal/informal)
Types ID/IDREF and (#P)CDATA Hierarchy of Simple and Complex Types
Markup Constructs Element Type Declarations
<!ELEMENT order …
Element Definitions
<xs:element name="order"> …
Instances (Documents) <order date=""> [ order content ] </order>

Simple Types

Schemas in Practice

XML Schema vs. DTD

<!ELEMENT people (customer | employee | temporary_employee)* >
<!ELEMENT customer (name, address) >
<!ATTLIST customer %added; >
<!ELEMENT name (#PCDATA)>
<!ELEMENT address (#PCDATA) >
 <xs:element name="people">
  <xs:complexType>
   <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="customer"/>
    <xs:element ref="employee"/>
    <xs:element ref="temporary_employee"/>
   </xs:choice>
  </xs:complexType>
 </xs:element>
 <xs:element name="customer">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="name"/>
    <xs:element ref="address"/>
   </xs:sequence>
   <xs:attribute name="added" type="xs:anySimpleType" use="required"/>

Outline (XSL Transformations (XSLT))

  1. XML Namespaces [12]
    1. Using Namespaces [5]
    2. Defining Namespaces [4]
  2. XML Schema [6]
  3. XSL Transformations (XSLT) [5]
  4. Conclusions [1]

Origin

Client-Side XSLT

XSLT Processors

XML, XSLT, and HTML

<?xml-stylesheet type="text/xsl" href="book.xsl"?>
<book>
 <author>Erik Wilde</author>
 <author>David Lowe</author>
 <title>XPath, XLink, XPointer, and XML: A Practical Guide to Web Hyperlinking and Transclusion</title>
 <date>July 2002</date>
 <publisher>Addison Wesley</publisher>
 <isbn>0201703440</isbn>
</book>
 <xsl:template match="/">
  <html>
   <body>
    <xsl:for-each select="/book/author">
     <xsl:value-of select="."/>
     <xsl:choose>
      <xsl:when test="position() = last() - 1"> and </xsl:when>
      <xsl:otherwise>, </xsl:otherwise>
     </xsl:choose>
<html>
   <body>Erik Wilde and David Lowe, <em>"XPath, XLink, XPointer, and XML: A Practical Guide to Web Hyperlinking and Transclusion",</em> Addison Wesley, July 2002, ISBN: 0201703440.
   </body>
</html>

XSLT Processing Model

Outline (Conclusions)

  1. XML Namespaces [12]
    1. Using Namespaces [5]
    2. Defining Namespaces [4]
  2. XML Schema [6]
  3. XSL Transformations (XSLT) [5]
  4. Conclusions [1]

XML Toolbox