Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied...
Transcript of Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied...
![Page 1: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/1.jpg)
Sebastian Maneth
Lecture 18XPath and XSLT
University of Edinburgh - March 23rd, 2017
Applied Databases
![Page 2: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/2.jpg)
2
Outline
→ Lecture 19 (Monday March 27th): Recap / Exam preparation
→ Lecture 20 (Monday March 27th): Recap / Exam preparation
→ no lectures after that! [ i.e., no lectures on April 3 & 6 ]
![Page 3: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/3.jpg)
3
Outline
1. XPath
2. XSLT – eXtensible Stylesheet Language Transformations
![Page 4: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/4.jpg)
![Page 5: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/5.jpg)
5
1. XPath
Query that selects c-nodes that have a b-child?
![Page 6: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/6.jpg)
6
1. XPath
Query that selects c-nodes that have a b-child? //c[b]
![Page 7: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/7.jpg)
7
XPath
Query that selects c-nodes that have a b-child? //c[b]
c-nodes that have NO b-child?
![Page 8: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/8.jpg)
8
XPath
Query that selects c-nodes that have a b-child? //c[b]
c-nodes that have NO b-child? //c[not(b)]
![Page 9: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/9.jpg)
9
XPath
Query that selects c-nodes that have a b-child? //c[b]
c-nodes that do NOT have a b-child? //c[not(b)]
does there exist a b-node?
NEGATE
![Page 10: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/10.jpg)
10
XPath
Query that selects c-nodes that have a b-child? //c[b]
c-nodes that have a child not labeled b?
![Page 11: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/11.jpg)
11
XPath
Query that selects c-nodes that have a b-child? //c[b]
c-nodes that have a child not labeled b? //c[*[not(self::b)]]
![Page 12: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/12.jpg)
12
XPath
Query that selects a-attributes with maximal value?
![Page 13: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/13.jpg)
13
XPath
Query that selects a-attributes with maximal value? //@a[not(.< //@a)]
![Page 14: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/14.jpg)
14
XPath
Query that selects element nodes at level 3 of the tree?
level 0
level 1
level 2
level 3
![Page 15: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/15.jpg)
15
XPath
Query that selects element nodes at level 3 of the tree? /*/*/*/*
level 0
level 1
level 2
level 3
![Page 16: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/16.jpg)
16
XPath
Query that selects element and text nodes at level 3 of the tree?
level 0
level 1
level 2
level 3
![Page 17: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/17.jpg)
17
XPath
Query that selects element and text nodes at level 3 of the tree? /*/*/*/child::node()
//node()[count(ancestor::*)=3]
level 0
level 1
level 2
level 3
![Page 18: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/18.jpg)
http://xpath.online-toolz.com/tools/xpath-editor.php
![Page 19: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/19.jpg)
19
Recall: //a abbreviates //descendant-or-self::node()/child::a
![Page 20: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/20.jpg)
20
Recall: //a abbreviates //descendant-or-self::node()/child::a
![Page 21: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/21.jpg)
21
Recall: //a abbreviates //descendant-or-self::node()/child::a
![Page 22: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/22.jpg)
22
![Page 23: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/23.jpg)
23
![Page 24: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/24.jpg)
24
Melvil Dewey
![Page 25: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/25.jpg)
25
Melvil Dewey
![Page 26: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/26.jpg)
26
![Page 27: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/27.jpg)
27
What is the result for//d[position() = last()]
![Page 28: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/28.jpg)
28
![Page 29: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/29.jpg)
29
![Page 30: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/30.jpg)
30
XPath Evaluation
→ can be done polynomial time
→ based on “context-value tables”
→ careful recording of unique values (no duplicates)
![Page 31: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/31.jpg)
31
2. XSLT
![Page 32: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/32.jpg)
32
2. XSLT
→ Extensible Stylesheet Language Transformations
→ W3C Standard
→ developed early on (XSL in 1998)
→ Version 2.0 (W3C recommendation 2007)
→ Version 3.0 (streaming) W3C candidate recommendation (15. November 2015)
All major browsers (Chrome, Firefox, IE, Safari, etc)support XSLT
→ if an XML document has an XSL stylesheet associated with it, the browser will transform it on-the-fly
![Page 33: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/33.jpg)
33
![Page 34: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/34.jpg)
![Page 35: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/35.jpg)
![Page 36: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/36.jpg)
Example Transformations
→ XML to HTML – for browser display→ XML to LaTeX – for TeX layout→ XML to SVG – graphs, charts, trees→ XML to tab-delimited – for DB/stat packages→ XML to plain text, e.g., PDF – for printing
e.g. print bills for a telecom company→ data comes in XML→ want to produce bills in PDF
![Page 37: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/37.jpg)
Example Transformations
e.g. print bills for a telecom company→ data comes in XML→ want to produce bills in PDF
XSLT vs. custom SAX/DOM traversal (as your XML→CSV from Assignment 1)
→ smaller code
→ better readability & maintainability
→ let XSLT compiler attempt to stream the transformation
→ XML to HTML – for browser display→ XML to LaTeX – for TeX layout→ XML to SVG – graphs, charts, trees→ XML to tab-delimited – for DB/stat packages→ XML to plain text, e.g., PDF – for printing
![Page 38: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/38.jpg)
Example Transformations
→ smaller code
→ better readability & maintainability
→ let XSLT compiler attempt to stream the transformation
→ “best effort” approach→ very hard to detect statically (interesting research question)→ XSLT 3.0
Some academic transformation languages even have
→ static type checking→ compiler can verify if all outputs are, e.g., correct XHTML
![Page 39: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/39.jpg)
XSLTImplementation
XSLT program
XML documentoutput string
XSLT program: list of template (rules) – written in XML syntaxTemplate: pattern → action
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
(relative) XPath expression→ current node labeled “para”?
output p-node (in XML)
recursively descent & apply templates
Template
![Page 40: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/40.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> para.xslt
XSLT program→ changes “para” nodes to “p”-nodes→ deletes all other element nodes
$ cat t1.xml<x><t/><para><para/></para></x>
$ xsltproc para.xslt t1.xml<?xml version="1.0"?><p><p/></p>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet>
![Page 41: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/41.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> para.xslt
XSLT program→ changes “para” nodes to “p”-nodes→ deletes all other element nodes→ keeps all text-nodes!
$ cat t2.xml<a z="TT">this<b>is a <d a="1278"/><e/></b><para u="18">hello world<c/></para></a>
$ xsltproc para.xslt t2.xml<?xml version="1.0"?>thisis a <p>hello world</p>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet>
![Page 42: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/42.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> trans.xslt
$ cat t2.xml<a z="TT">this<b>is a <d a="1278"/><e/></b><para u="18">hello world<c/></para></a>
$ xsltproc trans.xslt t2.xml<?xml version="1.0"?><a>this<b>is a <d/><e/></b><para>hello world<c/></para></a>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node()"> <xsl:copy><xsl:apply-templates/></xsl:copy></xsl:template>
</xsl:stylesheet>
→ all nodes are matched and taken over→ except attributes nodes (they are deleted)
![Page 43: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/43.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
$ cat t2.xml<a z="TT">this<b>is a <d a="1278"/><e/></b><para u="18">hello world<c/></para></a>
$ xsltproc identity.xslt t2.xml<?xml version="1.0"?><a z="TT">this<b>is a <d a="1278"/><e/></b><para u="18">hello world<c/></para></a>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="node() | @*"/></xsl:copy></xsl:template>
</xsl:stylesheet>
→ all nodes are matched and taken over
identity.xslt
![Page 44: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/44.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
$ cat t2.xml<a z="TT">this<b>is a <d a="1278"/><e/></b><para u="18">hello world<c/></para></a>
$ xsltproc identity.xslt t2.xml<?xml version="1.0"?><a z="TT">this<b>is a <d a="1278"/><e/></b><para u="18">hello world<c/></para></a>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="node() | @*"/></xsl:copy></xsl:template>
</xsl:stylesheet>
→ all nodes are matched and taken over→ compare the (size of the) above XSLT program to a SAX program for the same task!
identity.xslt
![Page 45: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/45.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="node() | @*"/></xsl:copy></xsl:template>
</xsl:stylesheet>
→ all nodes are matched and taken over→ compare the (size of the) above XSLT program to SAX program for the same task!
→ would be interesting to rewrite the ebay XML→ CSV converter in XSLT
identity.xslt
![Page 46: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/46.jpg)
http://xpath.online-toolz.com/tools/xpath-editor.php
![Page 47: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/47.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="."/></xsl:copy></xsl:template>
</xsl:stylesheet>
What will this program do?
![Page 48: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/48.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
$ xsltproc identity.xslt t2.xmlruntime error: file loop.xslt line 6 element copyxsltApplyXSLTTemplate: A potential infinite template recursion was detected.You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).Templates:#0 name node() | @*#1 name node() | @*#2 name node() | @*
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="."/></xsl:copy></xsl:template>
</xsl:stylesheet>
$ xsltproc identity.xslt t2.xmlruntime error: file loop.xslt line 6 element copyxsltApplyXSLTTemplate: A potential infinite template recursion was detected.You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).Templates:#0 name node() | @*#1 name node() | @*#2 name node() | @*
![Page 49: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/49.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="."/></xsl:copy></xsl:template>
</xsl:stylesheet>
→ XSLT is Turing-complete→ easy to write non-terminating programs
![Page 50: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/50.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="."/></xsl:copy></xsl:template>
<xsl:template match="b"> <fff><xsl:apply-templates select="."/></fff></xsl:template>
</xsl:stylesheet>
→ both templates are applicable to b-nodes
![Page 51: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/51.jpg)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="para"> <p><xsl:apply-templates/></p></xsl:template>
</xsl:stylesheet> identity.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="node() | @*"> <xsl:copy><xsl:apply-templates select="."/></xsl:copy></xsl:template>
<xsl:template match="b"> <fff><xsl:apply-templates select="."/></fff></xsl:template>
</xsl:stylesheet>
→ both templates are applicable to b-nodes→ more specific template is used (“b” before “node()”)
![Page 52: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/52.jpg)
![Page 53: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/53.jpg)
![Page 54: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/54.jpg)
→ if no priorities are given, what is the output?
![Page 55: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/55.jpg)
![Page 56: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/56.jpg)
![Page 57: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/57.jpg)
![Page 58: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/58.jpg)
![Page 59: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/59.jpg)
![Page 60: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/60.jpg)
![Page 61: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/61.jpg)
![Page 62: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/62.jpg)
![Page 63: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/63.jpg)
![Page 64: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/64.jpg)
![Page 65: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/65.jpg)
<colors> <color>red</color> <color>green</color> <color>blue</color> <color>yellow</color></colors>
<xsl:template match="color"> <xsl:number/>. <xsl:apply-templates/></xsl:template>
1. red2. green3. blue4. yellow
![Page 66: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/66.jpg)
<colors> <color>red</color> <color>green</color> <color>blue <color>robin's egg</color> <color>navy</color> <color>cerulean</color> </color> <color>yellow</color></colors>
<xsl:template match="color"> <xsl:number level="multiple" format="1. "/> <xsl:apply-templates/> </xsl:template>
1. red2. green3. blue 3.1. robin's egg 3.2. navy 3.3. cerulean4. yellow
![Page 67: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/67.jpg)
![Page 68: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/68.jpg)
68
That's all folks!
This ends the main lectures of “Applied Databases”.
→ Lectures 19 & 20 (next week): Recap / Exam preparation
→ no lectures after that! [ i.e., no lectures on April 3 & 6 ]
Thank you for your attention!
![Page 69: Applied Databases - The University of Edinburgh · This ends the main lectures of “Applied Databases”. → Lectures 19 & 20 (next week): Recap / Exam preparation → no lectures](https://reader033.fdocuments.us/reader033/viewer/2022052723/5f0d377d7e708231d4393f6e/html5/thumbnails/69.jpg)
ENDLecture 18