summaryrefslogtreecommitdiff
path: root/Year_2/Databases
diff options
context:
space:
mode:
Diffstat (limited to 'Year_2/Databases')
-rw-r--r--Year_2/Databases/README.md4
-rw-r--r--Year_2/Databases/university_marks.dtd14
-rw-r--r--Year_2/Databases/university_marks.xml43
-rw-r--r--Year_2/Databases/university_marks.xquery11
4 files changed, 72 insertions, 0 deletions
diff --git a/Year_2/Databases/README.md b/Year_2/Databases/README.md
new file mode 100644
index 0000000..5af8687
--- /dev/null
+++ b/Year_2/Databases/README.md
@@ -0,0 +1,4 @@
+# XQuery
+XQuery files are compiled by xqilla.
+
+[debian](https://packages.debian.org/bullseye/xqilla) | [ubuntu](https://packages.ubuntu.com/focal/xqilla)
diff --git a/Year_2/Databases/university_marks.dtd b/Year_2/Databases/university_marks.dtd
new file mode 100644
index 0000000..caab080
--- /dev/null
+++ b/Year_2/Databases/university_marks.dtd
@@ -0,0 +1,14 @@
+<!ELEMENT libretti (libretto)*>
+<!ELEMENT libretto (studente, esami)?>
+<!ELEMENT studente (nome, cognome)>
+<!ELEMENT nome (#PCDATA)>
+<!ELEMENT cognome (#PCDATA)>
+<!ATTLIST studente
+ cdl CDATA #REQUIRED
+ matricola CDATA #REQUIRED
+>
+<!ELEMENT esami (esame)+>
+<!ELEMENT esame (materia, data, voto)>
+<!ELEMENT materia (#PCDATA)>
+<!ELEMENT data (#PCDATA)>
+<!ELEMENT voto (#PCDATA)>
diff --git a/Year_2/Databases/university_marks.xml b/Year_2/Databases/university_marks.xml
new file mode 100644
index 0000000..fcd0eb5
--- /dev/null
+++ b/Year_2/Databases/university_marks.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" ?>
+<!DOCTYPE libretti SYSTEM "university_marks.dtd">
+<libretti>
+ <libretto>
+ <studente cdl="Computer engineering" matricola="0000122">
+ <nome>Luke</nome>
+ <cognome>Don</cognome>
+ </studente>
+ <esami>
+ <esame>
+ <materia>Algebra</materia>
+ <data>2021-02-02</data>
+ <voto>30</voto>
+ </esame>
+ </esami>
+ </libretto>
+ <libretto>
+ <studente cdl="Computer science" matricola="0000123">
+ <nome>John</nome>
+ <cognome>Doe</cognome>
+ </studente>
+ <esami>
+ <esame>
+ <materia>Databases</materia>
+ <data>2021-02-06</data>
+ <voto>18</voto>
+ </esame>
+ </esami>
+ </libretto>
+ <libretto>
+ <studente cdl="Computer science" matricola="0000125">
+ <nome>Mark</nome>
+ <cognome>Zuck</cognome>
+ </studente>
+ <esami>
+ <esame>
+ <materia>Databases</materia>
+ <data>2021-02-06</data>
+ <voto>30</voto>
+ </esame>
+ </esami>
+ </libretto>
+</libretti>
diff --git a/Year_2/Databases/university_marks.xquery b/Year_2/Databases/university_marks.xquery
new file mode 100644
index 0000000..e2f0e4e
--- /dev/null
+++ b/Year_2/Databases/university_marks.xquery
@@ -0,0 +1,11 @@
+<students>
+{
+for $student in doc("university_marks.xml")//libretto
+where $student/esami//voto/text()=30
+return <student>
+ {$student/studente/nome/text()}
+ { ' ' }
+ {$student/studente/cognome/text()}
+ </student>
+}
+</students>