Finish Schemas and XPath, XML Storage




CS257

Chris Pollett

Feb 5, 2024

Outline

Introduction

XSLT

XSLT Example -- Initial XML Document

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="xslplane.xsl" ?>
<plane>
    <year>1970</year>
</plane>

XSLT Example -- The Transformation

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl= "http://www.w3.org/1999/XSL/Transform"
   xmlns = "http://www.w3.org/1999/xhtml"
>
<xsl:template match="plane">
<html><head>
<title>result of applying a stylesheet to plane</title>
</head><body><h1>Plane Description</h1>
     <xsl:apply-templates />
     </body></html>
 </xsl:template>
<xsl:template match="year">
    <p style="color:red">
    <xsl:value-of select="." />
    </p>
</xsl:template>
</xsl:stylesheet>

XPath

XPath Expressions

XPath

URL:

https://apnews.com/apf-topnews

Channel:

//article[contains(@class, 'feed')]

Item Separator:

//div[contains(@class, 'FeedCard')]

Title:

//div[contains(@class, 'CardHeadline')]//h1

Description:

//div[contains(@class, 'content')]

Link:

//a[contains(@data-key, 'story-link')]

Quiz

Which of the following is true?

  1. A single <!ATTLIST ...> in a DTD can be used to specify/define multiple attributes of a element (tag).
  2. An XML document is only allowed to contain tags/elements from one XML language.
  3. The complexType element is used in an XMLSchema to define a new element.

Processing XML Documents

XML processing steps

DOM API

DOM tree for wine example

SAX API

Storage of XML Documents

RDBMS Data Storage Approaches for XML

Differences Between XML and Relational Data