Η παρουσίαση φορτώνεται. Παρακαλείστε να περιμένετε

Η παρουσίαση φορτώνεται. Παρακαλείστε να περιμένετε

XML. 2 Ο Παγκόσμιος Ιστός Σήμερα Ένα απλό, κοινό πρότυπο για ανταλλαγή και διάδοση πληροφοριών. Η πληροφορία κατατέμνεται σε τμήματα, τα οποία μπορούν.

Παρόμοιες παρουσιάσεις


Παρουσίαση με θέμα: "XML. 2 Ο Παγκόσμιος Ιστός Σήμερα Ένα απλό, κοινό πρότυπο για ανταλλαγή και διάδοση πληροφοριών. Η πληροφορία κατατέμνεται σε τμήματα, τα οποία μπορούν."— Μεταγράφημα παρουσίασης:

1 XML

2 2 Ο Παγκόσμιος Ιστός Σήμερα Ένα απλό, κοινό πρότυπο για ανταλλαγή και διάδοση πληροφοριών. Η πληροφορία κατατέμνεται σε τμήματα, τα οποία μπορούν να κατονομασθούν και να μεταδοθούν. Ένα τμήμα είναι συνήθως ένα αρχείο το οποίο επονομάζεται σαν ένα URL. Τι είναι η HTML; Ένας τρόπος δόμησης των πληροφοριών με στόχο την γραφική τους στοιχειοθέτηση-εμφάνιση σε κάποια τερματική συσκευή. Ένας τρόπος για τον καθορισμό συσχετίσεων ανάμεσα σε στοιχεία ενός αρχείου και ανάμεσα σε διαφορετικά αρχεία.

3 3 Τι ξέρουμε από τις Βάσεις Δεδομένων Η δόμηση των πληροφοριών παρουσιάζεται με εναλλακτικούς τρόπους: Σχεσιακά σχήματα ΒΔ. Διαγράμματα Οντοτήτων-Συσχετίσεων. Πως επιτυγχάνουμε την κοινοχρησία των πληροφοριών ΒΔ: Με χρήση γλωσσών επερωτήσεων για πρόσβαση προς τις πληροφορίες. Με μηχανισμούς για έλεγχο ταυτοχρονίας (concurrency control) και ανάνηψη πληροφοριών (recovery). Διαχωρισμός ανάμεσα στη λογική όψη των ΒΔ και στην φυσική τους υλοποίηση.

4 4 Ανάγκη για γεφύρωση Ιστού και ΒΔ Γιατί υπάρχει ανάγκη γεφύρωσης; Ολοένα και περισσότερα δεδομένα Ιστού παράγονται από ΒΔ. Προκύπτει συχνά η ανάγκη εξαγωγής δεδομένων από ιστοσελίδες για ανάλυση, καταγραφή σε ΒΔ κλπ. Π.χ.: Οικονομικά δεδομένα ΒΔ, δημοσιοποιούνται σε κάποια ιστοσελίδα αφού γίνει μορφοποίηση των καταλλήλων επερωτήσεων προς τη ΒΔ σε HTML. Κάποιος άλλος οργανισμός που θέλει να αναλύσει τα δεδομένα αυτής της ιστοσελίδας, έχει πρόσβασή μόνο στον κώδικα HTML (μέσω Διαδικτύου). Η κωδικοποίηση των δεδομένων σε HTML έχει τα ακόλουθα μειονεκτήματα: Αστάθεια: τα προγράμματα ανάλυσης ιστοσελίδων «σπάνε» εύκολα μετά από επουσιώδεις αλλαγές στον κώδικα της ΗΤΜL (και όχι στη λογική δομή των δεδομένων). Σπατάλη πόρων: για την ανάκτηση της χρήσιμης πληροφορίας μπορεί να χρειάζεται να ανακτήσουμε όγκο αχρείαστων πληροφοριών μεγαλύτερο από αυτό που θα παίρναμε με απευθείας εκτέλεση επερώτησης προς κάποια βάση.

5 5 Ανάγκη για γεφύρωση Ιστού και ΒΔ Από την σκοπιά των ψηφιακών εγγράφων, θέματα όπως η γρήγορη ανάκτηση, ο έλεγχος έκδοσης, οι επερωτήσεις πάνω στα έγγραφα κοκ καθίστανται ολοένα και πιο σημαντικά. Από την σκοπιά των ΒΔ, ο Ιστός έχει δημιουργήσει ζήτηση για νέες αρχιτεκτονικές και έχει οδηγήσει στη δημιουργία μοντέλων και γλωσσών για ημιδομημένα δεδομένα.

6 6 XML Μια μετα-γλώσσα για κωδικοποίηση πληροφοριών. Απλό συνταντικό το οποίο μπορεί να διαβασθεί και από άνθρωπο και από μηχανή. Ένα πρώτο βήμα προς τη σύγκλιση ιστού και ΒΔ: Συντακτικό παρόμοιο με της HTML (υποσύνολο της SGML). Περιγράφει δομημένα δεδομένα. Ώριμη διαπροσωπεία και ευσταθή εργαλεία σάρωσης, ανεξάρτητα της εμφάνισης-παρουσίασης του περιεχομένου. Από μόνη της η XML δεν αρκεί για την εξαγωγή δεδομένων από ΧΜL αρχεία, αλλά χρειάζεται και άλλες τεχνολογίες όπως γλώσσες επερωτήσεων σε σχήματα ΧΜL, οντολογίες, κοκ.

7 7 XML New standard adopted by W3C to complement HTML for data exchange. HTML describes the structure of the presentation and not the structure of the content. XML describes the content (stylesheets can be used for defining how to display an XML document) XML allows the definition of new tags. An XML document can contain an optional description of its grammar.

8 8 Η οικογένεια της XML XML: μετα-γλώσσα, η οποία χρησιμοποιείται για τον ορισμό γλωσσών σήμανσης. XML Namespaces: προδιαγραφή για την αποφυγή ονοματολογικών συγκρούσεων μέσω καθορισμού χώρων ονομάτων για έγγραφα XML. XML Schema: καθορίζει τύπους στοιχείων που μπορούν να περιέχονται σε ένα έγγραφο XML, και τα δεδομένα που μπορούν να περιλαμβάνουν αυτοί οι τύποι. XPath και XPointer: επιτρέπουν την αναφορά σε τμήματα ενός εγγράφου XML και τον ορισμό fragment identifiers. XLink: δίνει τη δυνατότητα ορισμού υπερσυνδέσμων ανάμεσα σε έγγραφα XML. XForms: επιτρέπει τον καθορισμό φορμών εισαγωγής στοιχείων σε XML. XML Signature: παράσχει συντακτικό και κανόνες επεξεργασίας για ψηφιακές υπογραφές σε XML.

9 9 Η οικογένεια της XML (συνέχεια) DOM (document object model): API για την περιγραφή ενός εγγράφου XML ως δένδρου κόμβων και για τον καθορισμό του πως οι κόμβοι αυτοί είναι δομημένοι, πως μπορούμε να έχουμε πρόσβαση σε αυτούς και πως μπορούμε να τους αλλάξουμε. XSL (eXtensible Stylesheet Language): αποτελείται από το XSL-T (XSL Transformations) και XSL-FO (XSL Formatting Objects) και είναι μια γλώσσα για μετασχηματισμό εγγράφων XML σε άλλα έγγραφα XML και για την αναπαράστασή τους, π.χ. σε HTML, Braille, κλπ. XQuery : γλώσσα επερωτήσεων XML εγγράφων, η οποία θεωρεί ένα XML αρχείο σαν ΒΔ. CSS: απλή γλώσσα περιγραφής οδηγών στοιχειοθεσίας. XHTML: ορισμός της HTML4.0 σε XML.

10 10 Η οικογένεια της XML (συνέχεια) RDF (Resource Description Framework): ακρογωνιαίος λίθος του σημασιολογικού Ιστού (semantic web). Ορίζει ένα απλό μοντέλο δεδομένων για την περιγραφή των σημασιολογικών χαρακτηριστικών πόρων του Ιστού. RDF Schema: σχήμα για τον ορισμό γλωσσών RDF. DAML+OIL (DARPA Agent Markup Language + Ontology Inference Layer): γλώσσες για την περιγραφή οντολογιών που επεκτείνουν το RDF Schema.

11 11 Παράδειγμα εγγράφου XML Sarah Bellum Colonel Timeslip Robot-sitting instructions Thanks for watching my robot pal Zonky while I'm away. He needs to be recharged twice a day and if he starts to get cranky, give him a quart of oil. I'll be back soon, after I've tracked down that evil mastermind Dr. Indigo Riceway.

12 12 Χρήση XML: αποθήκευση/ανάκτηση δεδομένων Για την επεξεργασία δεδομένων εκπεφρασμένων σε XML χρησιμοποιούμε σαρωτές XML, οι οποίοι διαβάζουν XML περιεχόμενο και το μετατρέπουν σε πιο εύχρηστη μορφή. Η XML δουλεύει καλύτερα στην περίπτωση μικρών αρχείων δεδομένων, στα οποία δεν γίνεται τυχαία αναζήτηση ή πρόσβαση (random search/access), καθώς η XML αποτελεί σειριακό μέσο αποθήκευσης. Υπάρχουν συστήματα και προτάσεις για υπέρβαση αυτού του περιορισμού.

13 13 Παράδειγμα New Year's Day January 1 Erik's birthday April 23 Independance Day July 4 Religious December 25

14 14 Χρήση XML: Στοιχειοθεσία εγγράφων Με χρήση CSS και XML, προσθέτοντας ειδικές εντολές στα αρχεία XML: Με μετασχηματισμό εγγράφου XML σε έγγραφο άλλης γλώσσας σήμανσης (π.χ. HTML 4.0). Οι κανόνες του μετασχηματισμού περιγράφονται με γλώσσα XSLT. Με μετασχηματισμό σε ενδιάμεση μορφή, στην XSL-FO, με χρήση XSLT. Τα formatting objects είναι αφαιρετικές αναπαραστάσεις τμημάτων ενός εγγράφου XML. Στη συνέχεια, τα FΟs μετατρέπονται σε μια μορφή αναπαράστασης (π.χ. PDF) μέσω κάποιου εξειδικευμένου XSL formatter. Με προγραμματισμό μέσω κάποιας γενικής γλώσσας προγραμματισμού, όπως η JAVA.

15 15 Παράδειγμα XSLT script <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> telegram telegram

16 16 Παράδειγμα XSLT script from: to: subj:

17 17 Παράδειγμα XSLT script

18 18 Χρήση XML: ακεραιότητα δεδομένων Η XML μας δίνει τη δυνατότητα να διασφαλίζουμε έναν μίνιμουμ επίπεδο εμπιστοσύνης στα δεδομένα μας με μηχανισμούς όπως: Έλεγχος απλών συντακτικών κανόνων (well-formedness) με απλούς σαρωτές (parsers). Έλεγχος «καλής σύνταξης» με σαρωτές σύνταξης (validating parsers), με βάση κάποιο μοντέλο εγγράφου (document model) εκφρασμένου ως: Document Type Definition (DTD file): δεν υποστηρίζει πολλούς ελέγχους στο περιεχόμενο XML Schema: προσφέρει μεγαλύτερες δυνατότητες ελέγχου της σύνταξης των στοιχείων ενός εγγράφου XML.

19 19 Παράδειγμα DTD

20 20 Παράδειγμα XML Schema

21 21 Παράδειγμα XML Schema

22 22 Χρήση XML: υποστήριξη πολλών γλωσσών Υιοθετεί το σύνολο χαρακτήρων (character set) Unicode, το οποίο υποστηρίζει διαφορετικές γραφές: λατινική, αραβική, ελληνική, εβραϊκή κλπ. Υποστηρίζει διαφορετικές κωδικοποιήσεις των χαρακτήρων. Π.χ.: UTF-8, iso-8859-1 κλπ.

23 23 Πως ξεκινάμε; Συγγραφή XML: με χρήση του emacs με το κατάλληλο plugin (psgml), με χρήση εργαλείων όπως το XMLSpy. Εμφάνιση-στοιχειοθεσία αρχείων XML: με χρήση σύγχρονων φυλλομετρητών (IE, Amaya, Mozilla 1.4, Opera, Safari). Σάρωση: η επεξεργασία ενός XML αρχείου προϋποθέτει καταρχάς τη σάρωσή του για τον διαχωρισμό και την αναγνώριση των στοιχείων που περιέχονται σε αυτό και την περαιτέρω επεξεργασία τους. Στη συνέχεια, τον συνταντικό έλεγχο του αρχείου, μέσω validating parser, όπως ο Xerxes της Apache.

24 24 Πως ξεκινάμε; Μετασχηματισμός: απαιτεί το αρχικό έγγραφο και ένα stylesheet μετασχηματισμού (συνήθως κωδικοποιημένο σε XSLT). Ο μετασχηματισμός γίνεται από έναν XSLT processor, όπως ο Xalan της Apache. Στοιχειοθεσία για εκτύπωση: Η χρήση απευθείας μετασχηματισμού από XML σε εκτυπώσιμη κωδικοποίηση (pdf, ps κλπ) είναι πολύ δύσκολη. Γι’ αυτό, χρησιμοποιούμε μετασχηματισμό σε μια ενδιάμεση XML μορφή, την XSL- FO, η οποία περιλαμβάνει δεδομένα και οδηγίες στοιχειοθεσίας. Η δημιουργία της XSL-FΟ μορφής γίνεται με χρήση XSLT. Η XSL-FO μορφή μετατρέπεται σε PDF από μορφοιποιητές όπως ο XSL- FO της apache.

25 25 Πως ξεκινάμε; Προγραμματισμός: αναπτύσσοντας προγράμματα τα οποία επεξεργάζονται έγγραφα XML και τα οποία ακολουθούν δύο πιθανές στρατηγικές: Push: αντιστοιχεί σε stream processing ενός αρχείου XML. Ο σαρωτής διαβάζει το έγγραφο και καλεί το πρόγραμμά μας για την διαχείριση του κάθε νέου στοιχείου XML που προκύπτει στην ροή. Γρήγορη μέθοδος, αλλά με περιορισμένη ευελιξία. Pull: επιτρέπει την ανάγνωση ολόκληρου του εγγράφου XML και την αποθήκευσή του σαν δομή δεδομένων (δένδρο). Στη συνέχεια, το πρόγραμμά μας μπορεί να διαχειριστεί τη δομή αυτή.

26 26 SAX και DOM Για την ενσωμάτωση των τεχνικών αυτών σε προγράμματα, έχουν ορισθεί δύο αντίστοιχες προδιαγραφές προγραμματιστικών διαπροσωπειών: Simple API for XML (SAX): καθορίζει πως ένας σαρωτής αλληλεπιδρά με ένα πρόγραμμα κατά τη διάρκεια της επεξεργασίας ροής εγγράφων XML. Document Object Model (DOM): καθορίζει μεθόδους για πρόσβαση στη δενδρική δομή δεδομένων, η οποία αποθηκεύει ένα έγγραφο XML.

27 Βασικά στοιχεία XML εγγράφων

28 28 Αντικείμενα XML

29 29 Δομή εγγράφων XML Πρόλογος Εγγράφου (document prolog): Περιέχει μεταδεδομένα σχετικά με το έγγραφο. Η χρήση του είναι προαιρετική. Στοιχείο ρίζας (root element): Περιλαμβάνει όλα τα στοιχεία που ανήκουν στο έγγραφο.

30 30 Δομή Εγγράφου XML

31 31 XML declaration Προαιτετική χρήση - αν χρησιμοποιηθεί πρέπει να βρίσκεται στην πρώτη γραμμή ενός εγγράφου. Οι παράμετροι έχουν τη μορφή: name = “value” όπου το “name” είναι: version: έκδοση της XML encoding: χρησιμοποιούμενο σύνολο χαρακτήρων standalone: ενημερώνει τον σαρωτή αν υπάρχουν δηλώσεις εκτός του εγγράφου, οι οποίες να χρειάζονται για την σύνταξη και επικύρωση του.

32 32 Document Type Declaration Χρησιμοποιείται για: Τον ορισμό των στοιχείων (elements) και των κατηγορημάτων (attributes) που υπάρχουν σε ένα έγγραφο XML. Την υποστήριξη σαρωτών επικύρωσης (validating parsers), οι οποίοι ελέγχουν την γραμματική και το λεξιλόγιο των γλωσσών σήμανσης.

33 33 Περιεχόμενα Document Type Declaration Element: προσδιορίζει τον τύπο του XML εγγράφου. DTD identifier (προσδιοριστής γραμματικής εγγράφου) : προαιρετικός προσδιορισμός της γραμματικής (document type definition) του εγγράφου. Μπορεί να έχει τη μορφή: SYSTEM identifier: προσδιορίζει τη φυσική διεύθυνση ενός αρχείου στο σύστημά μας, στο οποίο περιέχεται η γραμματική. PUBLIC identifier: Προσδιορίζει μέσω μοναδικού ονόματος την γραμματική που ακολουθεί το αρχείο μας. Επειδή το όνομα αυτό μπορεί να μην είναι γνωστό σε κάποιον σαρωτή, συνοδεύεται από το URL ενός αρχείου το οποίο ορίζει τη γραμματική.

34 34 System identifiers

35 35 Public identifiers

36 36 Declarations Περιλαμβάνει ορισμούς που είναι χρήσιμοι για την συναρμολόγηση και την επικύρωση του εγγράφου. “Εμπλουτίζουν” τις δηλώσεις που υπάρχουν στο DTD του XML εγγράφου μας. Ένας σαρωτής XML θα διαβάσει πρώτα τις δηλώσεις που υπάρχουν στο εξωτερικό DTD αρχείο (που ορίζεται από τον προσδιοριστή της γραμματικής του εγγράφου) και μετά θα διαβάσει τις δηλώσεις που είναι ενσωματωμένες στον πρόλογο του αρχείου XML. Παράδειγμα: Δηλώσεις οντοτήτων (entity declarations) Δηλώσεις στοιχείων (element declarations)

37 37 Παράδειγμα προλόγου <!DOCTYPE Beginning of the DOCTYPE declaration reminder Root element name SYSTEM "/home/eray/reminder.dtd" DTD identifier [ Internal subset start delimiter "> Entity declaration ]> Internal subset end delimiter Start of document element &smile; Reference to the entity declared above Smile! It can always get worse. End of document element

38 38 Στοιχεία εγγράφων XML (doc. Elements) Τα στοιχεία (elements) είναι τα συστατικά ενός εγγράφου XML, τα οποία διαιρούν το έγγραφο σε μια ιεραρχία περιοχών, καθορίζοντας τη λογική δομή του εγγράφου. Υπάρχουν: Στοιχεία εγκυβωτισμού (container elements) τα οποία περιέχουν άλλα στοιχεία ή κείμενο. Άδεια στοιχεία (empty elements), τα οποία χρησιμοποιούνται για να σημειώσουν ένα σημείο στο οποίο πρέπει να γίνει ειδική επεξεργασία ή να ενσωματωθεί κάποιος ειδικός μορφότυπος.

39 39 Alan 42 agb@abc.com XML Elements XML-element: a piece of text bounded by matching tags. Inside the tags there may be a combination of text and other elements. Tags are user-defined. Tags must be balanced. Abbreviation for empty elements: can be abbreviated to

40 40 XML Elements

41 41 Κατηγορήματα στοιχείων (attributes) Δίνουν τη δυνατότητα να προσθέτουμε περισσότερες πληροφορίες σε ένα στοιχείο XML. Τα κατηγορήματα ορίζονται σαν ζεύγη (name,value) και εντάσσονται μετά το όνομα του εναρκτήριου σημαντήρα ενός στοιχείου. Π.χ.: trompette six trous 420.12 Η τιμή ενός κατηγορήματος είναι πάντοτε μια συμβολοσειρά (string) που πρέπει να περικλείεται σε εισαγωγικά. Ένα κατηγόρημα μπορεί να υπάρξει το πολύ μία φορά μέσα σε έναν σημαντήρα.

42 42 Alan 42 agb@abc.com <person name=“Alan” age=“42” email= “agb@abc.com” /> XML Attributes XML attributes provide an alternative way of representing elements.

43 43 XML Entities (οντότητες XML) Αποτελούν μηχανισμό καθορισμού συντομογραφιών Διευκολύνουν την ενσωμάτωση σε αρχείο XML: Χαρακτήρων που είναι δύσκολο ή αδύνατο να πληκτρολογηθούν. Κειμένου το οποίο επαναλαμβάνεται συχνά. Κειμένου και σημάνσεων που βρίσκονται σε κάποιο εξωτερικό αρχείο. Η εισαγωγή γίνεται μέσω παραπομπής στο όνομα της οντότητας.

44 44 Entity Declarations & references

45 45 Είδη οντοτήτων XML Οι παραμετρικές οντότητες εμφανίζονται mόνο μέσα σε DTDs

46 46 Κατηγορίες Οντοτήτων XML Οντότητες χαρακτήρων: Προκαθορισμένες: amp, apos, gt, lt, quot. Αριθμητικές παραπομπές χαρακτήρων Unicode: &# decimal number ; &#x hexadecimal number ; Μνημονικά ονόματα χαρακτήρων Unicode: Þ Μεικτού περιεχομένου: μη πεπερασμένου μήκους, μπορεί να συμπεριλαμβάνουν σεσημασμένο περιεχόμενο και κείμενο. Δύο είδη: Εσωτερικές:το περιεχόμενο αντικατάστασης καθορίζεται με τη δήλωση της οντότητας. Εξωτερικές: το περιεχόμενο αντικατάστασης βρίσκεται σε άλλο αρχείο (αποτελούν μηχανισμό ενσωμάτωσης αποσπασμάτων XML μέσα σε ένα αρχείο). Στη δήλωση της οντότητας πρέπει να καθορίζουμε τη θέση του περιεχομένου αντικατάστασης. Μη σαρωνόμενες οντότητες (unparsed entities): χρησιμοποιούνται για την περιγραφή περιεχομένου το οποίο δεν πρέπει να σαρωθεί γιατί περιέχει πολυμεσική κωδικοποίηση.

47 47 Παραδείγματα Οντοτήτων XML

48 48 Παραδείγματα Οντοτήτων XML

49 49 Δενδρική απεικόνιση εγγράφου XML

50 50 Alan 42 agb@abc.com XML person nameageemail Alan42 agb@abc.com Graphical Representation XML denotes graphs with labels on nodes.

51 Ορισμός Γραμματικών XML

52 52 Σχήματα XML (Schemas) Σχήμα (schema): γενική αναπαράσταση μιας κατηγορίας πραγμάτων. Τι είναι το σχήμα: ένα μοντέλο για την περιγραφή της δομής πληροφοριών. Στο πλαίσιο της XML περιγράφει ένα μoντέλο για μια κατηγορία εγγράφων, προσδιορίζοντας: Επιτρεπόμενους συνδυασμούς σημαντήρων και περιεχομένου σε ένα έγκυρο έγγραφο.

53 53 Σχήματα XML (Schemas) Τα μοντέλα περιγράφονται σαν περιορισμοί (constraints). Ένας περιορισμός καθορίζει τι σημαντήρες, περιεχόμενο κλπ μπορούν να εμφανίζονται σε κάποιο συγκεκριμένο πλαίσιο. Ένας περιορισμός μπορεί να είναι: Μοντέλου περιεχομένου (content model constraint), ο οποίος προσδιορίζει τη διάταξη και τη σειρά υπαρχόντων στοιχείων Τύπου δεδομένων, ο οποίος προσδιορίζει έγκυρους τύπους δεδομένων (π.χ. σε κάποιο στοιχείο XML).

54 54 Σχήματα XML Μπορούμε να το δούμε σαν μια συμφωνία για ένα κοινό λεξιλόγιο ανάμεσα σε εφαρμογές που ανταλλάσσουν έγγραφα. Σχήμα στην XML: ένας τρόπος ελέγχου της εγκυρότητας εγγράφων. Ένα σχήμα XML ενημερώνει έναν επεξεργαστή περιεχομένου XML για το πώς αυτός θα πρέπει να διαβάσει και να επεξεργαστεί το έγγραφο. Ο επεξεργαστής διαβάζει τους κανόνες και τις δηλώσεις του σχήματος και τα χρησιμοποιεί για να παράξει έναν σαρωτή επικύρωσης, ο οποίος μπορεί στη συνέχεια να ελέγξει την εγκυρότητα οποιουδήποτε αρχείου XML που ακολουθεί το συγκεκριμένο σχήμα.

55 55 Έλεγχος εγκυρότητας Αφορά σε τέσσερα επίπεδα: Δομή:χρήση και τοποθέτηση σημαντήρων και κατηγορημάτων. Τύπος δεδομένων: ορθότητα περιεχομένων στοιχείων XML. Ακεραιότητα: η κατάσταση των συνδέσμων ανάμεσα σε κόμβους και πόρους. Επιχειρησιακοί κανόνες (business rules): διάφοροι λογικοί έλεγχοι. An XML document is well-formed, if its tags nest properly, and its attributes are unique. An XML document is valid, if it has a DTD and it conforms to that DTD

56 56 Η χρησιμότητα των σχημάτων Αποτελούν δημοσιοποιήσιμες προδιαγραφές γραμματικής εγγράφων: μας επιτρέπουν να περιγράψουμε με συνοπτικό τρόπο το πως πρέπει να οργανώνονται έγγραφα μιας συγκεκριμένης κατηγορίας. Επιτρέπουν την ανίχνευση συντακτικών σφαλμάτων στη δομή εγγράφων XML. Αποτελούν έναν “φορητό” και αποδοτικό τρόπο ελέγχου της εγκυρότητας εγγράφων XML. Είναι επεκτάσιμα και μπορούν να επαναχρησιμοποιηθούν από άλλα σχήματα.

57 57 Document Type Definition (DTD) Ο παλαιότερος μηχανισμός ορισμού του μοντέλου (γραμματικής) εγγράφων XML. Αποτελεί τρόπο περιγραφής μιας γραμμικής ανεξάρτητης από τα συμφραζόμενα (context-free grammar) για κατηγορίες εγγράφων XML. Ένα DTD είναι ένα σύνολο κανόνων (rules) ή δηλώσεων (declarations), καθένας από τους οποίους εισαγάγει ένα νέο στοιχείο, κατηγόρημα, οντότητα ή συμβολισμό της γραμματικής που ορίζει. Επιτρέπεται η χρήση αναδρομικών ορισμών:

58 58 DTDs Ένα DTD μιας κατηγορίας εγγράφων XML: Δηλώνει το σύνολο των στοιχείων που μπορούν να υπάρξουν σε έγγραφα αυτής της κατηγορίας. Καθορίζει τη δομή και τα περιεχόμενα του κάθε στοιχείου. Δηλώνει τα κατηγορήματα που επιτρέπονται σε κάθε στοιχείο. Παρέχει μηχανισμούς που καθιστούν ευκολότερη τη διαχείριση μοντέλων XML. Η σειρά εμφάνισης των δηλώσεων είναι σημαντική όταν: Πρόκειται για πολλαπλές δηλώσεις της ίδιας οντότητας (προτεραιότητα στην πρώτη δήλωση). Έχουμε παραμετρικές οντότητες, οι δηλώσεις των οποίων πρέπει να προηγούνται της χρήσης των οντοτήτων.

59 59 DTDs Ένα DTD μπορεί να βρίσκεται: Ενσωματωμένο σε ένα XML αρχείο Αποθηκευμένο σε ξεχωριστό αρχείο, στο οποίο γίνεται παραπομπή μέσα από το έγγραφο XML: Αποθηκευμένο σε αρχείο κάπου στο διαδίκτυο (το οποίο να διαθέτει URL):

60 60 Παράδειγμα Document Type Definition <! DOCTYPE bibliography [ )> <!ATTLIST price currency CDATA #REQUIRED taxed CDATA #FIXED “yes”> ]>

61 61 <! DOCTYPE family [ <!ATTLIST person id ID #REQUIRED mother IDREF #IMPLIED father IDRED #IMPLIED children IDREFS #IMPLIED> ]> Δήλωση κατηγορημάτων Type ID declares attributes that define the entity’s unique identifier within the scope of a document. Attributes of type IDREF (IDREFS) have values that are some other element’s identifier(s).

62 62 Οδηγίες σχεδιασμού DTDs Οργανώστε τις δηλώσεις σε διαφορετικές παραγράφους, ανάλογα με την χρησιμότητά τους. Χρησιμοποιείστε κενό χώρο και σχόλια για να κάνετα τα DTD σας πιο ευανάγνωστα. Οργανώστε τις αλλαγές που κάνετε σε διαδοχικές εκδόσεις (versions). Η αποθήκευσή τους μπορεί να γίνεται με συστήματα όπως το RCS και το CVS. Χρησιμοποιείστε παραμετρικές οντότητες (parameter entities) για την δήλωση δηλώσεων XML, οι οποίες επαναλαμβάνονται συχνά σε διάφορα σημεία. Π.χ.: <!ENTITY % common.atts ” id ID #IMPLIED Class CDATA #IMPLIED”>

63 63 Οδηγίες σχεδιασμού DTD Χρησιμοποιείτε απλά και μνημονικά ονόματα στοιχείων. Αξιοποιείστε τις δυνατότητες ιεραρχικής οργάνωσης της πληροφορίας που σας παρέχει η XML. Είναι προτιμητέο να δημιουργείτε δένδρα με εξισορροπημένο σχήμα (ούτε πολύ βαθειά, ούτε πολύ πλατιά). Προσέξτε πότε θα χρησιμοποιείτε κατηγορήματα και πότε θα χρησιμοποιείτε στοιχεία. Διασπάστε μεγάλα DTD σε περισσότερα του ενός δομοστοιχεία, τα οποία αποθηκεύονται χωριστά και ενσωματώνονται στο κεντρικό αρχείο ενός DTD.

64 64 Ενσωμάτωση δομοστοιχείων DTD Για την ενσωμάτωση εξωτερικών δομοστοιχείων σε ένα DTD χρησιμοποιούμε παραμετρικές οντότητες. Π.χ.: %basic.stuff; %front.matter; <!ENTITY % metadata PUBLIC “-Standards Stuff//DTD Metadata v3.2//EN” http://www.standards.org/dtds/metadata.dtd> %metadata

65 65 Μειονεκτήματα DTD DTDs can be used to define content model constraints and some datatype constraints on attributes. They have the following limitations: They are written in non-XML syntax. They do not support namespaces. They offer very limited datatyping. They do not make relationships between elements with the same content model explicit. However, they are widely spread and well-understood, they have widespread tool support.

66 XML Namespaces

67 67 Ονοματολογίες στην XML Ένας τρόπος για να διαχωρίζουμε στοιχεία και κατηγορήματα ενός εγγράφου XML, είναι η χρήση των «ονοματολογιών» (namespaces), οι οποίες προσδιορίζονται με αντιστοίχισή τους σε μοναδικά URI. Η χρήση των ονοματολογιών επιτρέπει σε ένα μοναδικό έγγραφο XML να περιλαμβάνει κατηγορίες στοιχείων και κατηγορημάτων, οι οποίες τυγχάνουν ειδικής διαχείρισης από δομοστοιχεία λογισμικού. Για παράδειγμα, μπορούμε σε ένα έγγραφο XML να χρησιμοποιήσουμε σημαντήρες της MathML, οι οποίοι είναι αναγνωρίσιμοι και επεξεργάσιμοι από ειδικό λογισμικό στοιχειοθεσίας μαθηματικών εκφράσεων.

68 68 Ονοματολογίες στην XML Μια ονοματολογία XML (namespace) είναι μια συλλογή ονομάτων, που αναγνωρίζονται μέσω ενός ονόματος που παραπέμπει σε ένα μοναδικό URI. Το όνομα χρησιμοποιείται σε έγγραφα ΧML για τον προσδιορισμό στοιχείων και κατηγορημάτων. Ονόματα από ονοματολογίες XML εμφανίζονται σαν επιθετικοί προσδιορισμοί της μορφής: nsprefix : localpart όπου το nsprefix αντιστοιχίζεται σε μοναδικό URI. Ένα κατηγορικό συντακτικό χρησιμοποιείται για την δήλωση των αντιστοιχιών ανάμεσα σε ονόματα και URI.

69 69 Δήλωση Ονοματολογιών A namespace can be declared by one of the following xmlns : name = URI xmlns = URI where xmlns is a reserved attribute. In the first case name gives the namespace prefix used to associate element and attribute names with the namespace name. In the second case the namespace name is the default namespace. Namespaces are declared within elements and their associations hold within the scope of those elements.

70 70 Δήλωση Ονοματολογιών <!-- the “edi” prefix is bound to http://ecommerce.org/schema for the “x” element and contents --> …

71 71 Χρήση επιγραφομένων ονομάτων Qualified names contain a prefix (which must be associated with a namespace URI reference in a namespace declaration) and a local part. Qualified names can serve as an element type: 32 <!-- the “price” element’s namespace is http://ecommerce.org/schema -->

72 72 Χρήση επιγραφομένων ονομάτων Qualified names can serve as attribute names:... <!-- the “taxClass” attribute’s namespace is http://ecommerce.org/schema -->

73 73 Πεδίο ισχύος ονοματολογιών A namespace declaration applies to the element where it is specified and to all elements within its content, unless it is overriden by another namespace declaration. <html:html xmlns:html = ‘http://www.w3.org/TR/REC-html40’> <!-- all elements here are in the HTML namespace --> … …

74 74 Πεδίο ισχύος ονοματολογιών Multiple namespace prefixes can be declared as attributes of a single element. <bk:book xmlns:book = … xmlns:isbn =... > …

75 75 Προκαθορισμενες Ονοματολογίες A default namespace is considered to apply to the element where it is declared (if it has no prefix) and to all the unprefixed element’s subelements. The default namespace can be set to the empty string. <book xmlns = ‘urn:loc.gov:books’ xmlns:isbn =... > <!-- unprefixed elements are from namespace urn:loc.gov:books’ --> …

76 XML Schema

77 77 Σχήματα Το XML Schema προσφέρει νέες δυνατότητες έναντι των DTD: Πλουσιότερη συλλογή τύπων (booleans, numbers, date and times, URIs, integers, intervals, etc). Διευκολύνσεις για δημιουργία νέων τύπων και αρχετύπων. Refinable archetypes: models can be defined as “open” - all required elements must be present but additional elements may also be present, or “refinable” - additional elements may be present if the schema defines what they are (inheritance). Namespace support. Attribute grouping.

78 78 XML Schema The purpose of a schema is to define a class of XML documents, and so the term "instance document" is often used to describe an XML document that conforms to a particular schema. In fact, neither instances nor schemas need to exist as documents per se -- they may exist as streams of bytes sent between applications, as fields in a database record, etc.

79 79 Example: Purchase Order (po.xml) Alice Smith 123 Maple Street Mill Valley CA 90952 Robert Smith 8 Oak Avenue Old Town PA 95819 Hurry, my lawn is going wild!

80 80 Example: Purchase Order (po.xml) Lawnmower 1 148.95 Confirm this is electric Baby Monitor 1 39.98 1999-05-21 The purchase order schema is not mentioned. An instance is not actually required to reference a schema (many will). We assume that any processor of the instance document can obtain the purchase order schema without any information from the instance document.

81 81 Example XML Schema po.xsd Purchase order schema for Example.com. Copyright 2000 Example.com. All rights reserved.

82 82 Example XML Schema po.xsd <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>

83 83 Example XML Schema po.xsd

84 84 XML Schema po.xsd

85 85 XML Schema The purchase order schema consists of a schema element and a variety of subelements (element, complexType, simpleType, etc.) which determine the appearance of elements and their content in instance documents. Each of the elements in the schema has a prefix xsd: which is associated with the XML Schema namespace through the declaration, xmlns:xsd="http://www.w3.org/2001/XMLSchema", that appears in the schema element. The prefix xsd: is used by convention to denote the XML Schema namespace. The same prefix, and hence the same association, also appears on the names of built-in simple types, e.g. xsd:string. The purpose of the association is to identify the elements and simple types as belonging to the vocabulary of the XML Schema language rather than the vocabulary of the schema author.

86 86 Complex Type Definitions In XML Schema, there is a basic difference between: complex types which allow elements in their content and may carry attributes simple types which cannot have element content and cannot carry attributes There is also a major distinction between definitions which: create new types (both simple and complex) enable elements and attributes with specific names and types (both simple and complex) to appear in document instances New complex types are defined using the complexType element, containing a set of element declarations, element references, and attribute declarations. The declarations are not themselves types, but rather an association between a name and the constraints which govern the appearance of that name in documents governed by the associated schema. Elements are declared using the element element, and attributes are declared using the attribute element.

87 87 Complex Type Definitions: example Any element appearing in an instance whose type is declared to be USAddress must consist of five elements and one attribute. These elements must be called name, street, city, state and zip, and the elements must appear in the same sequence (order) in which they are declared. The first four of these elements will each contain a string, and the fifth will contain a number. The element whose type is declared to be USAddress may appear with an attribute called country which must contain the string US.

88 88 Complex Type Definitions: example In PurchaseOrderType, shipTo and billTo, associate different element names with the same complex type: USAddress. The PurchaseOrderType definition contains an orderDate attribute declaration which identifies a simple type. All attribute declarations must reference simple types because attributes cannot contain other elements or other attributes. Sometimes, element declarations use an existing element rather than declare a new element. These declarations reference an existing element. In general, the value of the ref attribute must reference a global element, i.e. one that has been declared under schema rather than as part of a complex type definition.

89 89 Occurrence constraints An element is required to appear when the value of minOccurs is 1 or more. The maximum number of times an element may appear is determined by the value of a maxOccurs attribute in its declaration. This value may be a positive integer or the term unbounded to indicate there is no maximum number of occurrences. The default value for both the minOccurs and the maxOccurs attributes is 1. Attributes may appear once or not at all. Attributes can be declared with a use attribute to indicate whether the attribute is required (see for example, the partNum attribute declaration), optional, or even prohibited. Default values of both attributes and elements are declared using the default attribute. Default attribute values apply when attributes are missing, and default element values apply when elements are empty. The fixed attribute is used in both attribute and element declarations to ensure that the attributes and elements are set to particular values.

90 90 Global elements and attributes Global elements and global attributes are created by declarations that appear as the children of the schema element. Once declared, they can be referenced in one or more declarations using the ref attribute. A declaration that references a global element enables the referenced element to appear in the instance document in the context of the referencing declaration. The declaration of a global element also enables the element to appear at the top-level of an instance document. Hence purchaseOrder, which is declared as a global element in po.xsd, can appear as the top-level element in po.xml. There are a number of caveats concerning the use of global elements and attributes: One caveat is that global declarations cannot contain references; global declarations must identify simple and complex types directly. Put concretely, global declarations cannot contain the ref attribute, they must use the type attribute. A second caveat is that cardinality constraints cannot be placed on global declarations, although they can be placed on local declarations that reference global declarations. In other words, global declarations cannot contain the attributes minOccurs, maxOccurs, or use.

91 91 Simple types and derived types Built-in: string, byte, integer, decimal, time, date, ID, IDREF, IDREFS, NTOKEN, etc. New simple types are defined by restricting existing simple types (built-in's and derived), by : i.e., the legal range of values for the new type are a subset of the existing type's range of values. We use: the simpleType element to define and name the new simple type the restriction element to indicate the existing (base) type, and to identify the "facets" that constrain the range of values. E.g., to create myInteger, we restrict the range of the integer base type by employing two facets called minInclusive and maxInclusive:

92 92 Derived types E.g.a simple type called SKU is derived (by restriction) from the simple type string, restricting its values using a facet called pattern in conjunction with a regular expression "\d{3}-[A-Z]{2}" that is read "three digits followed by a hyphen followed by two upper-case ASCII letters": XML Schema defines fifteen facets, such as the enumeration facet (used to constrain the values of almost every simple type, except the boolean). The enumeration facet limits a simple type to a set of distinct values. E.g.:

93 93 List types List types are comprised of sequences of atomic types; the parts of a sequence (the "atoms") themselves are meaningful. You can create new list types by derivation from existing atomic types. E.g: and an element in an instance document whose content conforms to listOfMyIntType is: 20003 15037 95977 95945 Several facets can be applied to list types: length, minLength, maxLength, and enumeration. For example, to define a list of exactly six US states (SixUSStates), we first define a new list type called USStateList from USState, and then we derive SixUSStates by restricting USStateList to only six items:

94 94 Union types A union type enables an element or attribute value to be one or more instances of one type drawn from the union of multiple atomic and list types. E.g.: we create a union type for representing American states as singleton letter abbreviations or lists of numeric codes. E.g.: the zipUnion union type is built from one atomic type and one list type: When we define a union type, the memberTypes attribute value is a list of all the types in the union. Now, assuming we have declared an element called zips of type zipUnion, valid instances of the element are: CA 95630 95977 95945 AK Two facets, pattern and enumeration, can be applied to a union type.

95 95 Anonymous Type Definitions The definitions of sets of named types can be unwieldy, especially if you define many types that are referenced only once and contain very few constraints. In these cases, a type can be more succinctly defined as an anonymous type which saves the overhead of having to be named and explicitly referenced. Anonymous types can be identified by the lack of a type= in an element (or attribute) declaration, and by the presence of an un-named (simple or complex) type definition.E.g.:

96 96 Complex types from simple types Simple types cannot have attributes. Therefore, to add an attribute to an element containing a simple value, we must define a complex type to carry the attribute declaration. To this end, we derive a new complex type from the simple type. E.g.: We use the complexType element to start the definition of a new (anonymous) type. To indicate that the content model of the new type contains only character data and no elements, we use a simpleContent element. Finally, we derive the new type by extending the simple decimal type, adding a currency attribute using a standard attribute declaration.

97 97 Mixed content Character data can appear alongside subelements, and character data not confined to the deepest subelements. E.g.: Dear Mr. Robert Smith. Your order of 1 Baby Monitor shipped from our warehouse on 1999-05-21..... The following snippet of a schema declares letterBody: To enable character data to appear between the child-elements of letterBody, the mixed attribute on the type definition is set to true.

98 98 Empty content To define a type whose content is empty, we define a type that allows only elements in its content, but we do not actually declare any elements and so the type's content model is empty: In this example, we define an (anonymous) type having complexContent, i.e. only elements. The complexContent element signals that we intend to restrict or extend the content model of a complex type, and the restriction of anyType declares two attributes but does not introduce any element content. Alternatively:

99 99 Any content The anyType type represents an abstraction which is the base type from which all simple and complex types are derived. An anyType type does not constrain its content in any way. It is possible to use anyType like other types, for example: The content of the element declared in this way is unconstrained, so the element value may be 423.46, but it may be any other sequence of characters as well, or indeed a mixture of characters and elements. In fact, anyType is the default type when none is specified, so the above could also be written as follows:

100 100 Annotations XML Schema provides three elements for annotating schemas for the benefit of both human readers and applications: The documentation element, which is the recommended location for human readable material. The xml:lang attribute indicates the language of the information. The appInfo element, can be used to provide information for tools, stylesheets and other applications. Both documentation and appInfo appear as subelements of annotation, which may itself appear at the beginning of most schema constructions. The following example shows annotation elements appearing at the beginning of an element declaration and a complex type definition: element declared with anonymous type empty anonymous type with 2 attributes

101 101 Building content models XML Schema enables groups of elements to be defined and named, so that the elements can be used to build up the content models of complex types (thus mimicking common usage of parameter entities in XML 1.0). Un-named groups of elements can also be defined, and along with elements in named groups, they can be constrained to appear in the same order (sequence) as they are declared. Alternatively, they can be constrained so that only one of the elements may appear in an instance.

102 102 Group elements E.g.: purchase orders may contain either separate shipping and billing addresses, or a single address. The choice group element allows only one of its children to appear in an instance: one child is an inner group element that references the named group shipAndBill consisting of the element sequence shipTo, billTo the second child is a singleUSAddress The choice group is followed by the comment and items element declarations, and both the choice group and the element declarations are children of a sequence group. The effect of these various groups is that the address element(s) must be followed by comment and items elements in that order.

103 103 Group elements (ctd’) All the elements in the group may appear once or not at all, and they may appear in any order. Moreover, the group's children must all be individual elements (no groups), and no element in the content model may appear more than once, i.e. the permissible values of minOccurs and maxOccurs are 0 and 1. By this definition, a comment element may optionally appear within purchaseOrder, and it may appear before or after any shipTo, billTo and items elements, but it can appear only once. Moreover, the stipulations of an all group do not allow us to declare an element such as comment outside the group as a means of enabling it to appear more than once. XML Schema stipulates that an all group must appear as the sole child at the top of a content model. Allowing the child elements of purchaseOrder to appear in any order.

104 104 Namespaces, Schemas & Qualification A schema can be viewed as a collection (vocabulary) of type definitions and element declarations whose names belong to a particular namespace called a target namespace. Target namespaces enable us to distinguish between definitions and declarations from different vocabularies. For example, target namespaces would enable us to distinguish between the declaration for element in the XML Schema language vocabulary, and a declaration for element in a hypothetical chemistry language vocabulary. The former is part of the http://www.w3.org/2001/XMLSchema target namespace, and the latter is part of another target namespace. When we want to check that an instance document conforms to one or more schemas (through schema validation), we need to identify which element and attribute declarations and type definitions in the schemas should be used. The target namespace plays an important role in the identification process. The schema author also has several options that affect how the identities of elements and attributes are represented in instance documents. More specifically, the author can decide whether or not the appearance of locally declared elements and attributes in an instance must be qualified by a namespace, using either an explicit prefix or implicitly by default.

105 105 Target namespaces & unqualified locals We can explicitly declare a target namespace, and specify that both locally defined elements and locally defined attributes must be unqualified. Qualification of local elements and attributes can be globally specified by a pair of attributes, elementFormDefault and attributeFormDefault, on the schema element, or can be specified separately for each local declaration using the form attribute. All such attributes' values may each be set to unqualified or qualified, to indicate whether or not locally declared elements and attributes must be unqualified. In the following example we globally specify the qualification of elements and attributes by setting the values of both elementFormDefault and attributeFormDefault to unqualified. Strictly speaking, these settings are unnecessary because the values are the defaults for the two attributes; we make them here to highlight the contrast between this case and other cases we describe later.

106 106 Example <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO1" targetNamespace="http://www.example.com/PO1" elementFormDefault="unqualified" attributeFormDefault="unqualified">

107 107 Explanation Starting from the end of the schema, we first define a type called USAddress that consists of the elements name, street, etc. One consequence of this type definition is that the USAddress type is included in the schema's target namespace. We next define a type called PurchaseOrderType that consists of the elements shipTo, billTo, comment, etc. PurchaseOrderType is also included in the schema's target namespace. Notice that the type references in the three element declarations are prefixed, i.e. po:USAddress, po:USAddress and po:comment, and the prefix is associated with the namespace http://www.example.com/PO1. This is the same namespace as the schema's target namespace, and so a processor of this schema will know to look within this schema for the definition of the type USAddress and the declaration of the element comment It is also possible to refer to types in another schema with a different target namespace, hence enabling re-use of definitions and declarations between schemas. At the beginning of the schema po1.xsd, we declare the elements purchaseOrder and comment. They are included in the schema's target namespace. The comment element's type, string, is not prefixed. The po1.xsd schema contains a default namespace declaration, and so unprefixed types such as string and unprefixed elements such as element and complexType are associated with the default namespace http://www.w3.org/2001/XMLSchema. In fact, this is the target namespace of XML Schema itself, and so a processor of po1.xsd will know to look within the schema of XML Schema -- otherwise known as the "schema for schemas" -- for the definition of the type string and the declaration of the element called element.

108 108 Example (ctd’) The instance document declares one namespace, http://www.example.com/PO1, and associates it with the prefix apo:. The namespace is the same as the target namespace of the schema in po1.xsd, and so a processor of the instance document will know to look in that schema for the declarations of purchaseOrder and comment. The prefix apo: is applied to the global elements purchaseOrder and comment elements. elementFormDefault and attributeFormDefault require that the prefix is not applied to any of the locally declared elements (shipTo, billTo, name and street), and it is not applied to any of the attributes. <apo:purchaseOrder xmlns:apo="http://www.example.com/PO1" orderDate="1999-10-20"> Alice Smith 123 Maple Street Robert Smith 8 Oak Avenue Hurry, my lawn is going wild!

109 109

110 110 Συντακτικό XML-Schema Το ίδιο συντακτικό με της XML. Καθορίζει περίπου 30 στοιχεία και κατηγορήματα. Έγγραφα XML είναι έγκυρα με ένα XML σχήμα, μόνο αν ακολουθούν το γενικό σχήμα των XML Schema (για το οποίο υπάρχει DTD).

111 111 Συντακτικό XML-Schema Ένας τύπος στοιχείου (element type) ορίζει το έγκυρο περιεχόμενο των περιεχομένων στιγμιοτύπων αυτού του στοιχείου. Π.χ.: Το στοιχείο name έχει περιεχόμενο, δηλαδή οι σημαντήρες του μπορούν να περικλείουν και κείμενο (text) και άλλα στοιχεία.

112 112 Συντακτικό XML-Schema Ένα στοιχείο datatype καθορίζει κάποιο τύπο δεδομένων: 99999 99999-9999 ΜΕ το παραπάνω στοιχείο, ορίζουμε ένα νέο τύπο δεδομένων zipCode ο οποίος είναι συμβολοσειρά που περιέχει είτε 5 ψηφία είτε 9 ψηφία, ακολουθούμενα από μία παύλα και άλλα τέσσερα στοιχεία.

113 113 Συντακτικό XML-Schema Με τον τρόπο αυτό μπορούμε να ορίσουμε δικούς μας τύπους περιεχομένου για στοιχεία XML, ως εξής:

114 114 Συντακτικό XML-Schema Ορισμός σύνθετων τύπων: <elementTypeRef name =“street” minOccur= “1” maxOccur = “2”/> <elementTypeRef name =“country” minOccur= “0” maxOccur = “1”/>

115 115 Συντακτικό XML-Schema Defining archetypes <elementTypeRef name =“street” minOccur= “1” maxOccur = “2”/> <elementTypeRef name =“country” minOccur= “0” maxOccur = “1”/>

116 116 Συντακτικό XML-Schema The relationship between elements of the same archetype is explicit (unlike DTDs)

117 117 XML-Schema Syntax Archetypes are refinable. Thus new types can be derived extended with new fields. <elementtypeRef name = “RMA” minOccur = “1” maxOccur = “2”/>

118 118 Έλεγχος εγκυρότητας Ένα έγγραφο είναι έγκυρο αν συμβαδίζει με το σχήμα του. Validity is important to ensure that documents (received from a form/to be inserted in a database/to be presented by a stylesheet/to control some process) have the expected form of content and the right type. Εγκυρότητα μοντέλου περιεχομένου: testing whether the order and nesting of tags is correct. Εγκυρότητα τύπου δεδομένων: testing whether specific units of information are of the correct type and fall within the specified legal values.

119 119 Useful Links World-Wide Web´s consortium information on XML-schema http://www.w3.org/XML/Schema.html XML Schema Part 0: Primer: http://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-0/ XML Schema Part 0: Structures http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-1/ XML Schema Part 0: Datatypes http://www.w3.org/TR/xmlschema-2/http://www.w3.org/TR/xmlschema-2/ XML Data: http://www.w3.org/TR/1998/NOTE-XML-data-0105/http://www.w3.org/TR/1998/NOTE-XML-data-0105/ Schemas for object-oriented XML: http://www.w3.org/TR/NOTE-SOX/http://www.w3.org/TR/NOTE-SOX/


Κατέβασμα ppt "XML. 2 Ο Παγκόσμιος Ιστός Σήμερα Ένα απλό, κοινό πρότυπο για ανταλλαγή και διάδοση πληροφοριών. Η πληροφορία κατατέμνεται σε τμήματα, τα οποία μπορούν."

Παρόμοιες παρουσιάσεις


Διαφημίσεις Google