COMP60411 Semi-structured Data and the Web A bit of XPath, namespaces, and XML schema
|
|
- Magdalen Barrett
- 5 years ago
- Views:
Transcription
1 COMP60411 Semi-structured Data and the Web A bit of XPath, namespaces, and XML schema week 2 Uli Sattler University of Manchester 1
2 .plagiarism again... Work through the COMP609PM Plagiarism and Malpractice Test..possibly a second time if you have questions, ask! don t risk your marks don t risk your degree 2
3 ...blackboard again... Bijan and yourself have answered hundreds of questions discussed various solutions given numerous hints Some of you were stuck, mostly with M1 but didn t read those hints rather, waited for us to explain (waste of time), or panicked... 3
4 Errata Last week, I defined validity of an XML document w.r.t. a schema and I forgot 1 condition - here is the correct definition: A document D is valid if D is well-formed, D is associated with a DTD (internal or external or both), D is valid w.r.t. that DTD, and the declaration element is D s root element 4
5 Any questions? 5
6 XML documents... There are various standards, tools, APIs, data models for XML: to describe XML documents & validate XML document against: we have seen: DTDs today: XML schema to parse & manipulate manipulate XML documents: we have seen: SAX (and DOM) in next week s coursework: DOM transform and XML document into another XML document or into an instance of aother formats, e.g., html, excel, relational tables 6
7 Manipulation of XML documents XPath for navigating and querying through XML documents XQuery more expressive than XPath, uses XPath for querying and data manipulation Turing complete designed to access large amounts of data, to interface with relational systems XSLT similar to XQuery in that it uses XPath,... designed for styling, together with XSL-FO or CSS contrast this with DOM and SAX: a collection of APIs for programmatic manipulation includes data model and parser to build your own applications 7
8 XPath ML Schema later more designed to navigate to/select parts in a well-formed XML document no transformational capabilities (as in XQuery and XSLT) is a W3C standard: XPath 1.0 is a 1999 W3C standard XPath 2.0 is a 2007 W3C standard that extends/is a superset of XPath 1.0 richer set of WXS datatypes support type information from WXS validation see allows to select/define parts of an XML document: sequence of nodes uses path expressions Difference sequence - set? to navigate in XML documents to select node-lists in an XML document similar to expressions in a traditional computer file system rm */*/*.pdf provides numerous built-in functions e.g., for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, etc. 8
9 XPath: Datamodel remember how an XML document can be seen as a node-labelled tree with element names as labels XPath operates on the abstract, logical structure of an XML document, rather than its surface syntax - but not on DOM tree! XPath uses XQuery/XPath Datamodel there is a translation at see XPath process model... 9
10 Level Data unit examples cognitive application choice: DOM Infoset XPath. tree adorned with... namespace tree complex token simple character schema Element Element Element Attribute Element Element Element Attribute <foo:name t= 8 >Bob <foo:name t= 8 >Bob < foo:name t= 8 >Bob bit Information or Property required nothing a schema well-formedness which encoding (e.g., UTF-8) parsing serializing 10
11 11
12 XPath: Datamodel the XPath DM uses the following concepts nodes: element attribute text namespace processing-instruction comment document (root) document (root) node element node atomic value: behave like nodes without children or parents is an atomic value, e.g., xsd:string item: atomic values or nodes <?xml version="1.0" encoding="iso "?> <bookstore> <book> <title lang="en">harry Potter</title> <author>j K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore> text node attribute node
13 XPath Data Model From: <?xml version="1.0" encoding="utf-8"?> <network> <description name="boston"> This is the configuration of our network in the Boston office. </description> <host name="agatha" type="server" os="linux"> <interface name="eth0" type="ethernet"> <arec>agatha.example.edu</arec> <cname>mail.example.edu</cname> <addr> </addr> </interface> <service>smtp</service> <service>pop3</service> <service>imap4</service> </host> <host name="gil" type="server" os="linux"> 13
14 Comparison XPath DM and DOM datamodel Document nodetype = DOCUMENT_NODE nodename = #document nodevalue = (null) Element nodetype = ELEMENT_NODE nodename = mytext nodevalue = (null) firstchild lastchild attributes XPath DM and DOM DM are similar, but different most importantly regarding names and values of nodes but also structurally (see ) in XPath, only attributes, elements, processing instructions, and namespace nodes have names, of form (local part, namespace URI) whereas DOM uses pseudo-names like #document, #comment, #text In XPath, the value of an element or root node is the concatenation of the values of all its text node descendants, not null as it is in DOM: e.g, XPath value of <a>a<b>b</b></a> is AB XPath does not have separate nodes for CDATA sections (they are merged with their surrounding text) XPath has no representation of the DTD <N>here is some text and <![CDATA[some CDATA < >]]> </N> 14
15 XPath: core terms -- relation between nodes each node has at most one parent each node but the root node has exactly one parent the root node has no parent each node has zero or more children ancestor is the transitive closure of parent, i.e., a node s parent, its parent, its parent,... descendant is the transitive closure of child, i.e., a node s children, their children, their children,... when evaluating an XPath expression p, we assume that we know which document and which context we are evaluating p over we see later how they are chosen/given an XPath expression evaluates to a node sequence, a node is a document/element/attribute node or an atomic value document order is preserved among items 15
16 XPath - by example <?xml version="1.0" encoding="utf-8"?> <network> <description name="boston"> This is the configuration of our network in the Boston office. </description> <host name="agatha" type="server" os="linux"> <interface name="eth0" type="ethernet"> <arec>agatha.example.edu</arec> <cname>mail.example.edu</cname> <addr> </addr> </interface> <service>smtp</service> <service>pop3</service> <service>imap4</service> </host> <host name="gil" type="server" os="linux"> 16
17 XPath - abbreviated syntax by example context node XPath expression: */*[2] <?xml version="1.0" encoding="utf-8"?> <network> <description name="boston"> This is the configuration of our network in the Boston office. </description> <host name="agatha" type="server" os="linux"> <interface name="eth0" type="ethernet"> <arec>agatha.example.edu</arec> <cname>mail.example.edu</cname> <addr> </addr> </interface> <service>smtp</service> <service>pop3</service> <service>imap4</service> </host> <host name="gil" type="server" os="linux"> 17
18 XPath - abbreviated syntax by example context node XPath expression: */*[2]/*[1]/*[3] <?xml version="1.0" encoding="utf-8"?> <network> <description name="boston"> This is the configuration of our network in the Boston office. </description> <host name="agatha" type="server" os="linux"> <interface name="eth0" type="ethernet"> <arec>agatha.example.edu</arec> <cname>mail.example.edu</cname> <addr> </addr> </interface> <service>smtp</service> <service>pop3</service> <service>imap4</service> </host> <host name="gil" type="server" os="linux"> 18
19 XPath - abbreviated syntax know your context node context node XPath expression: *[1] <?xml version="1.0" encoding="utf-8"?> <network> <description name="boston"> This is the configuration of our network in the Boston office. </description> <host name="agatha" type="server" os="linux"> <interface name="eth0" type="ethernet"> <arec>agatha.example.edu</arec> <cname>mail.example.edu</cname> <addr> </addr> </interface> <service>smtp</service> <service>pop3</service> <service>imap4</service> </host> <host name="gil" type="server" os="linux"> 19
20 XPath - abbreviated syntax absolute paths context node XPath expression: /*/*[1] <?xml version="1.0" encoding="utf-8"?> <network> <description name="boston"> This is the configuration of our network in the Boston office. </description> <host name="agatha" type="server" os="linux"> <interface name="eth0" type="ethernet"> <arec>agatha.example.edu</arec> <cname>mail.example.edu</cname> <addr> </addr> </interface> <service>smtp</service> <service>pop3</service> <service>imap4</service> </host> <host name="gil" type="server" os="linux"> 20
21 21
22 Modelling Or, how to make do
23 Modelling Or, how to make do
24 Case study
25 Let us consider a simple format Arithmetic expressions! This is our domain High level description: addition, multiplication, subtraction over the integers Example in informal notation 4+5*7 Twelve minus fifty-nine plus one, that sort of thing. Request Design a reasonable XML format for this domain Provide a DTD that describes that format (Schema as medium of communication) We have choices! First choice is the root element name Let s say, expression
26 Work from an example!
27 Pick a root element
28 Work from an example!
29 Picking example(s) Different principles Coverage (hit all the features) Simplicity (easy to get right or get something) Corner cases (the hard situations) Realism (hit an actual situation) Trade off principles E.g., coverage vs. simplicity More examples are (or can be) better! Your example(s) should Give you insight into the domain Highlight benefits or drawbacks Force (or elicit) design decisions Ours 2+3*(5-4)
30 Initial design thoughts Three design issue families Elements vs. attributes vs. text Also type of textual content Structural relationships E.g., nesting Naming Choices on one constrain the others Suppose we decide to represent operators with elements We cannot then use the names +, *, and - They aren t legal element names Design 1 Elements for everything Names: plus, minus, times, open_parens, close_parens, int Structure?
31 A flat style
32 How to evaluate? Establish evaluation axes Coverage Did I capture all of my domain? E.g., is there an arithmetic expression I can t encode? Usability Can people write/read/otherwise use your format? Is working with the format error prone? Naturalness or Fit or Fidelity Is your format natural? Does your format make good (standard, best practice) use of the data model? Evolvability Can we extend the format with minimal disruption? Can we change the format with minimal disruption? Again, there may be trade offs It depends on the context and interests
33 Structure?
34 Maybe indentation will help?
35 The system ignores it!
36 The system ignores it? Why should we care what the formatter does? It s a warning sign We cannot enforce key syntax constraints E.g., Parenthesis must balance For every open there is a close We cannot express that to an arbitrary depth! Wait! maybe we can? Cool CS fact: Regular expressions can t express nesting!
37 Really can t!
38 Other aspects of the system Queries! (over (10 + 5) * (6-4) ) Get all parenthesized expressions I.e., (10 + 5) and (6-4) Get the content of the first parenthesized expression I.e., Get the first element of the first parenthesized expression I.e., 10 We need to parse! We need a stack! (Can we do this in XPath?) DTD constraints We talked about SAX processing DOM processing Looks like the SAX! No nesting! No tree!
39 SAX Processing startdocument startelement [null] [expression] [expression] comment [ A simple expression which touches all features. 2+3*(5-4) ] [21] [68] startelement [null] [int] [int] characters [2] [102] [1] endelement [null] [int] [int] startelement [null] [plus] [plus] endelement [null] [plus] [plus] startelement [null] [int] [int] characters [3] [131] [1] endelement [null] [int] [int] startelement [null] [times] [times] endelement [null] [times] [times] startelement [null] [open_parens] [open_parens] endelement [null] [open_parens] [open_parens] startelement [null] [int] [int] characters [5] [180] [1] endelement [null] [int] [int] startelement [null] [minus] [minus] endelement [null] [minus] [minus] startelement [null] [int] [int] characters [4] [210] [1] endelement [null] [int] [int] startelement [null] [close_parens] [close_parens]
40 Ok already! New design Design 1 Elements for everything Names: plus, minus, times, open_parens, close_parens, int Structure = Flat Design 2 Elements for everything Names: plus, minus, times, parens, int Structure = Nested parens Is this better?
41 Doesn t look too different!
42 But the system knows!
43 Evaluating Design 2 Design 2 Elements for everything Names: plus, minus, times, parens, int Structure = Nested parens DTD constraints More! Nested parens work SAX/DOM processing Some tree structure, but still some flat analysis Queries? <!ELEMENT expression ( parens)> <!ELEMENT parens ((int, (minus times plus), int) parens )> <!ELEMENT plus EMPTY> <!ELEMENT minus EMPTY> <!ELEMENT times EMPTY> <!ELEMENT int (#PCDATA)>
44 Queries are better! (10 + 5) * (6-4) Get all parenthesized expressions //parens
45 Queries are better! (10 + 5) * (6-4) Get the content of the first parenthesized expression //parens[1]/*
46 Queries are better! (10 + 5) * (6-4) Get the first element of the first parenthesized expression //parens[1]/*[1]
47 Good use of the data model Flat vs. nested parens Both encode parenthesization! But Design 2 does it in more a XML natural way How can we tell? All XML sensitive tools and languages do more with Design 2 Key features of our information are salient to those tools! Is this the best use of the model?
48 Take it further! Design 1 Elements for everything Names: plus, minus, times, open_parens, close_parens, int Structure = Flat Design 2 Elements for everything Names: plus, minus, times, parens, int Structure = Nested parens Design 3 Elements for everything Names: plus, minus, times, int Structure = Nested operators (no parens!)
49 Nesting, nesting everywhere?
50 Evaluating Design 3 Design 3 Elements for everything Names: plus, minus, times, int Structure = Nested operators (no parens!) DTD constraints Lots! SAX/DOM processing Natural tree structure Usability Fewer elements (and concepts!) Queries? All our old ones are irrelevant! Our new ones are more content oriented Get all additions of subtractions <!ELEMENT expression (plus times minus int )> <!ELEMENT plus ((plus times minus int ), (plus times minus int ))> <!ELEMENT times ((plus times minus int ), (plus times minus int ))> <!ELEMENT minus ((plus times minus int ), (plus times minus int ))> <!ELEMENT int (#PCDATA)>
51 Last twiddle to get to calc1 Design 3.2 Elements for everything Elements for everything except int values Names: plus, minus, times, int, value Structure = Nested operators (no parens!) The change From: <int>3</int> To: <int value="3"/> Why prefer one to the other?
52 Look familiar?
53 We have our language design! Design 3.2 Elements for everything Elements for everything except int values Names: plus, minus, times, int, value Structure = Nested operators (no parens!) We re done, right? We need to capture it Say in a DTD Our DTD needs evaluation too!
54 Two versions <!ELEMENT expression (plus times minus int )> <!ELEMENT plus ((plus times minus int ), (plus times minus int )+)> <!ELEMENT times ((plus times minus int ), (plus times minus int )+)> <!ELEMENT minus ((plus times minus int ), (plus times minus int ))> <!ELEMENT int EMPTY> <!ATTLIST int value NMTOKEN #REQUIRED> <!ENTITY % expr "(plus times minus int )"> <!ELEMENT expression %expr;> <!ELEMENT plus (%expr;, (%expr;)+)> <!ELEMENT times (%expr;, (%expr;)+)> <!ELEMENT minus (%expr;, %expr;)> <!ELEMENT int EMPTY> <!ATTLIST int value NMTOKEN #REQUIRED> They say the same thing! Exactly One says it better (slightly)
55 What does calc1.dtd give us? For SaxCalc It documented the format It could be used for authoring Both as documentation and in tools Autocompletion, error correction Can (partially) generate examples It could be used to check input By validation or by hard coded checks But it doesn t Say what to do with the format! Capture all the constraints Some must be hard coded (Integers!)
56 What is validity? XML 1.0 Definition < [Definition: An XML document is valid if it has an associated document type declaration and if the document complies with the constraints expressed in it.] Two conditions (beyond being well-formed): A declaration document type declaration Meets the constraints of the definition document type definition (the DTD) Sometimes known as internally valid (Though thatʼs a bit of misnomer; the spec calls this Valid ) The document says what it is
57 Is this a good notion? SaxCalc Error handling What would a user want us to do? <expression> <plus> <times> <int value="7"/> <minus> <int value="4"/> <int value="24"/> </minus> </times> <int value="7"/> </plus> </expression> <html> <expression> <plus> <times> <int value="7"></int> <minus> <int value="4"></int> <int value="24"></int> </minus> </times> <int value="7"></int> </plus> </expression> </html> <html> <expression> <plus> Multiplication is cool! <times> <int value="7"></int> <minus> <int value="4"></int> <int value="24"></int> </minus> </times> <int value="7"></int> </plus> </expression> </html>
58 External validation XML Documents conform to many DTDs That is, are valid with respect to many DTDs Some tighter, some looser Different schemas can offer different things External validation breaks self-describingness
59 External validation (2) Internal validation can go wrong in a lot of ways Missing declaration User forgot! Missing definition Internal subsets are verbose and hard to update Web based schema have problems Can t depend on them (app breaks if the server dies) Hard on the server External validation with DTDs Poorly handled by SAX Even redirecting is a bit of a PITA Other schema languages fare better javax.xml.validation.validator;
60 Error handling Do we need anything? In SaxCalc, you could get errors for free parseint failures Keep track of arguments Why not hard code? May need to track characters() But throwing unhandled exceptions is cool, right? You ll get a stack trace! Separate input checking and evaluation Allow the format to evolve more or less separately Within certain constraints What about non-well-formed documents?
61 DTDs as a language We can evaluate it! Usability Syntax isn t too bad Regular expression syntax is terse, yet readable(ish)» Some things get awkward Expressivity What can we say?» Can t constrain text to be integers Maintainability, readability, evolvability Parameter entities are pretty weak» Textual macros! Computability How hard is it to validate? Can we do better?
62 Case study 2 or, my brain hurts
63 M1: An XML Syntax for DTDs DTDs do not have an XML based syntax, which makes their manipulation by XML tools difficult. In this assignment, you will create an XML format (called "DTD/XML") for a subset of the DTD formalism. The root element of your format is named dtdx. The children of your root element are element declarations, attribute declarations, or comments, roughly following the markupdecl production from the XML 1.0 Recommendation. Note that you are not covering the full DTD language. DTD is a language for describing/manipulating XML But DTDs are not homoiconic That is, they are not represented in the same language they represent The meta level and the object level are distinct Thus, e.g., can t use XPath to count element declarations Can t use DTDs to define subsets or extensions Is homoiconicity desirable?
64 An argument the first striking and unexpected observation is that most published DTDs are not correct, with missing elements, wrong syntax or incompatible attribute declarations. This might prove that such DTDs are being used for documentation purposes only and are not meant to be used for validation at all. The reason might be that because of the ad-hoc syntax of DTDs (inherited from SGML), there are no standard tools to validate them. The observation: Published DTDs are broken Explanation: Ad hoc syntax inhibits tools Solution: Use XML for the syntax This issue will be addressed by proposals that use XML as the syntax to describe DTDs themselves Everything You Ever Wanted to Know About DTDs, But Were Afraid to Ask
65 A modelling challenge! First, get clear on the domain What are we trying to represent? Element declarations, attribute declarations, and comments M1 said so! What is the structure of the information? Perhaps an example? <!ELEMENT foo EMPTY> Covering? Simple? Corner case? Realistic? Whatʼs a reasonable, simple first design? I trust we donʼt need to consider flat designs. How about a bit of CDATA? <dtdx> <![CDATA[<!ELEMENT foo EMPTY>]]> </dtdx>
66 That was not a good design Design 1 Move the DTD into an element Doesn t really change the DTD syntax Validation is not helpful No nice querying Still need a traditional DTD (DTD/trad) syntax parser Design 2 Lots of elements, some attributes comment, element, choice, seq, plus, etc. Some nesting Mirror the syntax tree!
67 It s verbose <!DOCTYPE dtdx SYSTEM "dtdx1.dtd"> <dtdx> <comment>i omit most comments for brevity in this example.</comment> <element name="expression"> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </element> <element name="plus"> <seq> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> <plus> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </plus> </seq> </element> Why all the attributes? <element name="times"> <seq> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> <plus> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </plus> </seq> </element> <element name="minus"> <seq> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </seq> </element> <element name="int"><empty/></element> <attlist on="int"> <attdef name="value"> <tokenized type="nmtoken"/> <required/> </attdef> </attlist> </dtdx>
68 Why attributes? DTDs can constrain attributes More than elements In two ways: Type constraints Key constraints Both are helpful for representing DTD syntax!
69 Examples Key constraints Every element can have at most one declaration <!ATTLIST element name ID #REQUIRED> Every ref must have a corresponding def <!ATTLIST ref to IDREF #REQUIRED> Every attlist ref must have a corresponding def <!ATTLIST attlist on IDREF #REQUIRED> Type constraints ID and IDREFs must be NMTOKENS Convenient! Tokenized attribute values have a constraint set <!ATTLIST tokenized type (ID IDREF IDREFS ENTITY ENTITIES NMTOKEN NMTOKENS) #REQUIRED> (This could be done with an element.)
70 Our Design Design 1 Move the DTD into an element Doesn t really change the DTD syntax Validation is not helpful No nice querying Still need a traditional DTD (DTD/trad) syntax parser Design 2.1 Lots of elements, attributes for type and key constraints comment, element, choice, seq, plus, etc. Some nesting Mirror the syntax tree! Use ID and IDREF as appropriate
71 Tail wagging dog One design decision is odd Attributes for name, ref, etc. Not driven by general design considerations Driven by limitations of our schema langauge! Another strike against DTDs! Ad hoc syntax Expressivity limitations (enough to distort modelling) Key constraints only on attribute content Type constraints only on attribute content Limited types (no integers!) Poor structured development support Parameter entities!
72 Evaluating Design 2.1 Design 2.1 Lots of elements, attributes for type and key constraints comment, element, choice, seq, plus, etc. Some nesting Mirror the syntax tree! Use ID and IDREF as appropriate Authoring Bit verbose, but good editor support DTD constraints Not bad at all! SAX/DOM processing Pretty good Queries?
73 Queries Get all comments //comment Get all elements with a top level choice //element/choice/.. Get all elements with a choice anywhere /*/element//choice/ancestor::element Get all attribute declarations on <int> /*/attlist[@on="int"] How many comments? count(/*/comment) Queryability excellent!
74 XML Namespaces or, making things simpler by making them much more complex
75 An observation Both calc1-bjp and dtdx-bjp have a plus element <plus> <int value="4"/> <int value="5"/> </plus> <plus> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </plus> We have an element name conflict! How do we distinguish them? Semantically? In a combined document?
76 Uniquing the names (1) We can add some characters <calcplus> <int value="4"/> <int value="5"/> </calcplus> <dtdxplus> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </dtdxplus> No name clash now But the meaningful part of the name is hard to see calcplus isn t a real word!
77 Uniquing the names (2) We can use a separator or other convention <calc:plus> <int value="4"/> <int value="5"/> </calc:plus> <dtdx:plus> <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </dtdx:plus> No name clash now The meaningful part of the name is clear The disambiguator is clear But we can get clashes! Need a registry to coordinate?
78 Uniquing the names (3) Use URls for disambiguation < <int value="4"/> <int value="5"/> </ < <choice> <ref to="plus"/> <ref to="times"/> <ref to="minus"/> <ref to="int"/> </choice> </ No name clash now The meaningful part of the name clear The disambiguator is clear Clashes are hard to get Existing URI allocation mechanism But not well formed!
79 Uniquing the names (4) Combine the two! <dtdx:plus xmlns:dtdx=" <calc:plus <choice> xmlns:calc=" <ref to="plus"/> <int value="4"/> <ref to="times"/> <int value="5"/> <ref to="minus"/> </calc:plus> <ref to="int"/> </choice> </dtdx:plus> No name clash now The meaningful part of the name clear The disambiguator is clear Clashes are hard to get Existing URI allocation mechanism Well formed! But the model doesn t know
80 Layered!
81 Anatomy of Namespaces Namespace declarations Qualified names ( QNames ) Prefix Local name Expanded name { Namespace name <calc:plus xmlns:calc=" <int value="4"/> <int value="5"/> </calc:plus>
82 We don t need a prefix We can have default namespaces Terser Less cluttered Retrofit legacy documents Safer for non-namespace aware processors But trickiness! What s the expanded name of int in each document? Default namespaces and attributes interact weirdly <plus xmlns=" <int value="4"/> <int value="5"/> </plus> <calc:plus xmlns:calc=" <int value="4"/> <int value="5"/> </calc:plus>
83 Multiple namespaces We can have multiple declarations Each declaration has a scope The scope of a declaration is: The element where the declaration appears The descendants of that element......except those descendants which have a conflicting declaration (and their descendants, etc.) I.e., a declaration with the same prefix Scopes nest and shadow Nested declaration redefine outer declarations <plus xmlns=" xmlns:n=" > <n:int value="4"/> <n:int value="5"/> </plus> <plus xmlns=" <int xmlns=" value="4"/> <int value="5"/> </plus>
84 Much more about NS in our future Issues Namespaces are increasingly controversial Modelling principles Schema language support Speaking of which...
85 DTDs and Namespaces Another expressivity limitation DTDs came before namespaces And were never updated DTDs only understand XML without namespaces Namespaces are syntactically layered So we can do something with them But not with full generality General schema principle If two documents are the same (equivalent) according to the data model, the if one is valid wrt a schema so should the other Not true for namespace equivalent documents and DTDs
86 An example A simple document with a namespace <foo xmlns=" <bar/> </foo> We can write a DTD for it <!DOCTYPE foo [ <!ELEMENT foo (bar)> <!ATTLIST foo xmlns CDATA #FIXED " <!ELEMENT bar EMPTY> ]> <foo xmlns=" <bar/> </foo> This document is valid!
87 An example (cont) A simple document with a namespace a) <foo xmlns=" <bar/> </foo> We can compare with another document b) <ex:foo xmlns:ex=" <ex:bar/> </ex:foo> This is, from a namespace point of view, the same as a) But it is not valid wrt: <!ELEMENT foo (bar)> <!ATTLIST foo xmlns CDATA #FIXED " <!ELEMENT bar EMPTY> Not the same!
88 Problems with DTDs Ad hoc, non-xml based syntax Expressivity limitations (enough to distort modelling) Key constraints only on attribute content Type constraints only on attribute content Limited types (no integers!) No namespace support (We ll see more!) Poor structured development support Parameter entities! Poor support from tools and APIs External validation tricky in SAX Some security issues
89 Security aside Consumers Entity expansion attacks ( ) Million laughs attack Quadratic Blowup Disappearing DTDs Network failure or removal Publishers Accidental DOS ( the RSS 0.91 DTD is retrieved over 4 million times per day. That s nuts. Burdening a single third party like that for something as useless as a DTD makes no sense.
90 Should you use DTDs? Probably not, but The syntax is reasonable for authoring and reading So prototyping There are a fair number of DTDs out there A common denominator Namespace lack hurts a lot As we ll see They are more interesting as a starting point
91 XML Schema - another schema language for XML 91
92 Schema languages for XML provide means to define the legal structure of an XML document <?xml version="1.0" encoding="utf-8"?> <!ELEMENT cartoon (prolog, panels)> <!ATTLIST cartoon copyright CDATA #REQUIRED> <!ATTLIST cartoon year CDATA #REQUIRED> <!ELEMENT prolog (series, author, characters)> <!ELEMENT series (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT characters (character)*>... cartoon.dtd, a DTD for cartoon descriptions... <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE cartoon SYSTEM "cartoon.dtd"> <cartoon copyright="united Feature Syndicate" year="2000"> <prolog> <series>dilbert</series> <author>scott Adams</author> <characters> <character>the Pointy-Haired Boss</character> <character>dilbert</character> </characters>... <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE cartoon SYSTEM "cartoon.dtd"> <cartoon copyright="bill Watterson" year="1994"> <prolog> <series>calvin and Hobbs</series> <author>bill Watterson</author> <characters> <character>calvin</character> <character>hobbs</character> <character>snowman</character> </characters>
93 Schema languages for XML A variety of schema languages have been developed for XML; they vary w.r.t. their expressive power: do I have a means to express foo? how hard is it to describe foo? e.g., try to say, in a DTD that element must contain, in any order, an element1, an element2,..., and an element27? ease of use/understanding: how easy it is to write a schema? how easy is it to understand a schema written by somebody else? the complexity of validating a document w.r.t. a schema: how much space/time does it take to verify whether a document is valid w.r.t. a schema (in the size of document and schema)? e.g., checking this for DTDs requires only space linear in depth of the document 93
94 Schema languages for XML provide means to define the legal structure of an XML document <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs=" elementformdefault="qualified"> <xs:element name="cartoon"> <xs:complextype> <xs:sequence> <xs:element ref="prolog"/> <xs:element ref="panels"/> </xs:sequence> <xs:attributegroup ref="attlist.cartoon"/>... cartoon.xsd, an XML schema for cartoon descriptions... <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE cartoon SYSTEM "cartoon.dtd"> <cartoon copyright="united Feature Syndicate" year="2000"> <prolog> <series>dilbert</series> <author>scott Adams</author> <characters> <character>the Pointy-Haired Boss</character> <character>dilbert</character> </characters>... <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE cartoon SYSTEM "cartoon.dtd"> <cartoon copyright="bill Watterson" year="1994"> <prolog> <series>calvin and Hobbs</series> <author>bill Watterson</author> <characters> <character>calvin</character> <character>hobbs</character> <character>snowman</character> </characters>
95 XML Schema XML Schema is also referred to as XML Schema Definition (XSD) is a W3C standard, see can be seen as successor of DTDs: a DTD is not a well-formed XML document an XML Schema is a well-formed XML document XML Schema is mostly more expressive than DTDs we ll talk about this at length in contrast to DTDs, XML Schema supports namespaces, so we can combine several documents: for schema validation, universal names are used (rather than qualified names) datatypes, including simple datatypes for parsed character data and for attribute values, e.g., for date (when was 11/10/2006?) XML provides more support for describing the (element and mixed) content of elements 95
96 XML Schema: a first example Example with DTD: <?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>tove</to> <from>jani</from> <senton> </senton> <body> Have a nice weekend! </body> </note> note.dtd : <?xml version="1.0" encoding="utf-8"?> <!ELEMENT note (to, from, senton,heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT senton (#PCDATA)> <!ELEMENT body (#PCDATA)> 96
97 XML Schema: a first example note.xsd: <?xml version="1.0"?> <note xmlns= " xmlns:xs= " xmlns:xsi= " <to>tove</to> <from>jani</from> <senton> </senton> <body> Have a nice weekend! </body> </note> <?xml version="1.0"?> <xs:schema xmlns:xs= " targetnamespace= " xmlns=" elementformdefault="qualified"> <xs:element name="note"> <xs:complextype> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="senton" type="xs:date"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complextype></xs:element></xs:schema>
98 XML Schema: some remarks to validate an XML document against an XML schema, we use a validating XML parser that supports XML Schema e.g., DOM level 2, SAX2 in XML Schema, each element and type can only be declared once almost all elements can contain an element <xs:annotation>...</xs:annotation> as their first child: useful, e.g., for <xs:simpletype name="northweststates"> <xs:annotation><xs:documentation>states in the Pacific Northwest of US </xs:documentation></xs:annotation> <xs:restriction base="xs:string"></xs:restriction> </xs:simpletype> XML Schema provides support for modularity & re-use through xs:import xs:include xs:redefine 98
99 XML Schema & Namespaces most XML schemas start like this, in note.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs=" targetnamespace=" xmlns=" elementformdefault="qualified" >.. </xs:schema> XML Schema namespace e.g. for datatypes Target namespace of elements defined in this schema and a document using such a schema looks like this: <?xml version="1.0"?> <note xmlns=" xmlns:xsi=" Local (default) namespace This document uses a schema 99
100 XML Schema & Namespaces in contrast to DTDs, XML Schema supports namespaces a XML Schema either has no namespace or 2 namespaces: targetnamespace for those elements defined in schema and XMLSchema namespace note.xsd: <?xml version="1.0"?> <p:note xmlns:p=" xmlns:xs=" xmlns:xsi=" <p:to>tove</p:to> <?xml version="1.0"?> <note xmlns=" xmlns:xs=" xmlns:xsi=" <to>tove</to> <?xml version="1.0"?> <xs:schema xmlns:xs= " targetnamespace= " xmlns=" elementformdefault="qualified"> <xs:element name="note"> <xs:complextype> <xs:sequence> <xs:element name="to" type="xs:string"/>
101 XML Schema core concepts: datatypes in the previous examples, we used 2 Built-in datatypes: xs:string xs:date many more: built-in/atomic/ primitive e.g., xs:datetime composite/ user-defined e.g., xs:lists, xs:union through restrictions/ user-defined e.g., ints <
102 XML Schema core concepts: datatypes each XML datatype comes with a value space, e.g., for xs:boolean, this is {true, false}. lexical space, e.g., for xs:boolean, this is {true, false, 1, 0}, and lexical-to-value mapping that has to be neither injective nor surjective (for boolean, it s surjective, but not injective) constraining facets that can be used in restrictions of that datatype, e.g., maxinclusive, maxexclusive, mininclusive, minexclusive for most 102
103 XML Schema: types We can define types in XSD, in two ways: xs:simpletype for simple types, to be used for attribute values and elements without element child nodes and without attributes xs:complextype for complex types, to be used for elements with element content or mixed element content or text content and attributes 103
104 XML Schema: type declarations can be anonymous, e.g., in the definition of age or person below: <xs:element name="age"> <xs:simpletype> <xs:restriction base="xs:integer"> <xs:mininclusive value="3"/> <xs:maxinclusive value="7"/> </xs:restriction> </xs:simpletype> </xs:element> can be named, e.g., agetype or persontype <xs:element name="person"> <xs:complextype> <xs:sequence> <xs:element name="name" type="nametype"/> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean"/> </xs:complextype> </xs:element> <xs:element name="age" type="agetype"/> <xs:simpletype name="agetype"> <xs:restriction base="xs:integer"> <xs:mininclusive value="3"/> <xs:maxinclusive value="7"/> </xs:restriction> </xs:simpletype> <xs:element name="person" type="persontype"/> <xs:complextype name ="PersonType"> <xs:sequence> <xs:element name="name" type="nametype"/> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean"/> </xs:complextype> 104
105 XML Schema: atomic simple types are based on the numerous built-in datatypes that can be restricted using xs:restriction facets, e.g., enumeration length maxlength minlength maxexclusive/maxinclusive minexclusive/mininclusive patterns (using regular expressions close to Perl s) <xs:simpletype name= biketype > <xs:restriction base="xs:string"> <xs:enumeration value= MTB"/> <xs:enumeration value= road"/> </xs:restriction></ xs:simpletype> <xs:simpletype name= eightchar ><xs:restriction base="xs:string"> <xs:length value="8"/> </xs:restriction></xs:simpletype> <xs:simpletype name= medstr > <xs:restriction base="xs:string"> <xs:minlength value="5"/> <xs:maxlength value="8"/> </xs:restriction></xs:simpletype> <xs:simpletype name= age > <xs:restriction base="xs:integer > <xs:mininclusive value="0"/> <xs:maxinclusive value="120"/> </xs:restriction></xs:simpletype> <xs:simpletype name= simplestr ><xs:restriction base="xs:string"> <xs:pattern value="([a-z][a-z])+"/> </xs:restriction></xs:simpletype> 105
106 XML Schema: composite simple types we can use built-in datatypes not only in restrictions, but also in compositions to : xs:list xs:union <xs:simpletype name='mylist'> <xs:list itemtype='xs:integer'/> </xs:simpletype> <xs:simpletype name='shortlist'> <xs:restriction base='mylist'> <xs:maxlength value='8'/> </xs:restriction> </xs:simpletype> <xs:simpletype name="colourlistordate"> <xs:union membertypes="colourlist xs:date"/> </xs:simpletype> <xs:simpletype name="colourlist"> <xs:list> <xs:simpletype> <xs:restriction base="xs:string"> <xs:enumeration value="red"/> <xs:enumeration value="green"/> <xs:enumeration value="blue"/> </xs:restriction> </xs:simpletype> </xs:list> </xs:simpletype> 106
107 XML Schema: simple types can be used in element declarations, for elements without element child nodes (instead of PCDATA in DTDs) <xs:complextype name="persontype"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean" default="true"/> <xs:attribute name="phone" type="xs:string"/> </xs:complextype> attribute declarations (instead of CDATA in DTDs) as in DTDs, we can specify fixed or default values 107
108 XML Schema: simple content xs:simpletype for attribute values and elements without element child nodes and without attributes for elements where we cannot use xs:simpletype because of attribute declarations but that have simple (e.g., text) content only, we can use xs:simplecontent, e.g. <xs:element name="size"> <xs:complextype> <xs:simplecontent> <xs:extension base="xs:integer"> <xs:attribute name="country" type="xs:string"/> </xs:extension> </xs:simplecontent> </xs:complextype> </xs:element> 108
109 XML Schema: complex types xs:complextype for elements with element content or mixed element content or text content and attributes element order enforcement constructs: sequence: order preserving all: like sequence, but not order preserving choice: choose exactly one <xs:complextype name="nametype"> <xs:sequence> <xs:element name="fname" type="xs:string"/> <xs:element name="lname" type="xs:string"/> </xs:sequence> </xs:complextype> these constructs can be combined with minoccurs and maxoccurs, by default, both are set to 1, but they can be set to any non-negative integer or unbounded, e.g. <xs:complextype name="nametype"> <xs:sequence> <xs:element name="fname" type="xs:string"/> <xs:element name="mname" type="xs:string" minoccurs="0" maxoccurs="7"/> <xs:element name="lname" type="xs:string"/> </xs:sequence> </xs:complextype> 109
110 XML Schema: mixed content to allow for mixed content, set attribute mixed= true, e.g., <xs:complextype name="persontype" mixed="true"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean" default="true"/> <xs:attribute name="phone" type="xs:string"/> </xs:complextype> like in DTDs, we cannot constrain where the text occurs between elements, can only say that content can be mixed 110
111 XML Schema: restriction and extension we have already used xs:extension and xs:restriction both for simple types and complex types they are XML Schema s mechanisms for inheritance extension: specifying a new type X by extending Y this appends X s definition to Y s, e.g., <xs:simpletype name="agetype"> <xs:restriction base="xs:integer"> <xs:mininclusive value="3"/> <xs:maxinclusive value="7"/> </xs:restriction> </xs:simpletype> <xs:complextype name="newagetype"> <xs:simplecontent> <xs:extension base="agetype"> <xs:attribute name="range" type="xs:string"/> </xs:extension> </xs:simplecontent> </xs:complextype> <xs:complextype name="persontype"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean" default="true"/> <xs:attribute name="phone" type="xs:string"/> </xs:complextype> <xs:complextype name="longpersontype"> <xs:complexcontent> <xs:extension base="persontype"> <xs:sequence> <xs:element name="address" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexcontent></xs:complextype> 111
112 XML Schema: restriction and extension restriction: easy for simple types we have seen it several times <xs:simpletype name="agetype"> <xs:restriction base="xs:integer"> <xs:mininclusive value="3"/> <xs:maxinclusive value="7"/> </xs:restriction> </xs:simpletype> cumbersome for complex types: specifying a new type X by restricting a complex type Y requires the reproduction of Y s definition, e.g., <xs:complextype name="persontype"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean"/> <xs:attribute name="phone" type="xs:string"/> </xs:complextype> <xs:complextype name="strictpersontype"> <xs:complexcontent> <xs:restriction base="persontype"> <xs:sequence> <xs:element name="name"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:pattern value="[a-z]([a-z]+) "/> </xs:restriction> </xs:simpletype> </xs:element> <xs:element name="dob" type="xs:date"/> </xs:sequence> <xs:attribute name="friend" type="xs:boolean"/> <xs:attribute name="phone" type="xs:string"/> </xs:restriction> </xs:complexcontent></xs:complextype> 112
113 XML Schema: restriction and extension usage: in a document, an element of a type derived by restriction or extension from Y can be used in place of an element of type Y provided you say so explicitly, e.g., in <person phone="2"> <Name>Peter</Name> <DoB> </DoB> </person> <person xsi:type="longpersontype" phone="5432" friend="0"> <Name>Paul</Name> <DoB> </DoB> <address>manchester</address> </person> this means that a validating XML parser has to manage a schema s type hierarchy to ensure that LongPersonType was really derived by restriction or extension from the type expected for person but it doesn t have to guess an element s type from its properties also: compare they pain & gain of using types to pain & gain of using substitution groups! 113
114 XML Schema: restriction and extension to prevent a type from being instantiated directly, use e.g., <xs:complextype name="strictpersontype" abstract="true"> to prevent a type from being further extended and/or restricted use e.g., <xs:complextype name="strictpersontype" final="#all"> closely related to the mechanism of restriction/extension are substitution groups, i.e., a mechanism to allow to replace one element with a group of others 114
115 XML Schema: summary of complex types we have simple and complex types: simple types for attribute values and text in elements complex types for elements with child elements or attributes we have simple and complex content of elements: simple content: elements with only text between tags and possibly attributes complex content element content (elements only) mixed content (elements and text) empty content (at most attributes) a complex content type can be specified in 3 ways: using element order enforcement constructs (all, sequence, choice) a single child of simplecontent: derive a complex type from a simple or complex type with simple content a single child of complexcontent: derive a complex type from another complex type using restriction or extension 115
116 Comparing XML Schema & DTDs You know one better than the other one is simpler than the other in DTDs, no equivalent to ALL in XML Schema in DTDs, no cool & useful datatypes, lists, unions, in DTDs, no restrictions & extension, no types in a document, an element of a type derived by restriction from Y can be used in place of an element of type Y this can make writing complex schemas easier! but this means that a validating XML parser has to manage a schema s type hierarchy we will see later that both DTDs and XML have additional constraints on content models so that matching a node s childnode sequence against the corresponding content model is easier...will be discussed next week is there a set of XML documents (e.g., your cartoon descriptions) for which we can formulate a DTD but not an XML schema? or the other way round?...more next week 116
117 Let s have a look at this week s coursework 117
COMP60411 Semi-structured Data and the Web A bit of XPath, namespaces, and XML schema
COMP60411 Semi-structured Data and the Web A bit of XPath, namespaces, and XML schema week 2 Bijan Parsia & Uli Sattler University of Manchester 1 .plagiarism again... Work through the COMP60990 Research
More informationCOMP60411 Semi-structured Data and the Web A bit of XPath, namespaces, and XML schema
COMP60411 Semi-structured Data and the Web A bit of XPath, namespaces, and XML schema week 2 Conny Hedeler & Uli Sattler University of Manchester 1 .plagiarism again... Work through the online course available
More informationCOMP60411 Semi-structured Data and the Web A bit of XPath, Namespaces, and XML schema
COMP60411 Semi-structured Data and the Web A bit of XPath, Namespaces, and XML schema week 2 Conny Hedeler & Uli Sattler University of Manchester 1 If you have arrived late... welcome: I hope you have
More informationCOMP60411 Modelling Data on the Web XPath, XML Schema, and XQuery, week 3
COMP60411 Modelling Data on the Web XPath, XML Schema, and XQuery, week 3 Bijan Parsia Uli Sattler University of Manchester 1 Week 1 coursework Mostly graded! Q1, SE1, M1 should be accessible to you CW1
More informationCOMP60411 Modelling Data on the Web XPath, XML Schema, and XQuery. Week 3
COMP60411 Modelling Data on the Web XPath, XML Schema, and XQuery Week 3 Bijan Parsia Uli Sattler University of Manchester Week 1 coursework All graded! Q1, SE1, M1, CW1 In general, Pay attention to the
More informationXML extensible Markup Language
extensible Markup Language Eshcar Hillel Sources: http://www.w3schools.com http://java.sun.com/webservices/jaxp/ learning/tutorial/index.html Tutorial Outline What is? syntax rules Schema Document Object
More informationSoftware Engineering Methods, XML extensible Markup Language. Tutorial Outline. An Example File: Note.xml XML 1
extensible Markup Language Eshcar Hillel Sources: http://www.w3schools.com http://java.sun.com/webservices/jaxp/ learning/tutorial/index.html Tutorial Outline What is? syntax rules Schema Document Object
More informationXML Schema. Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 28
1 / 28 XML Schema Mario Alviano University of Calabria, Italy A.Y. 2017/2018 Outline 2 / 28 1 Introduction 2 Elements 3 Simple and complex types 4 Attributes 5 Groups and built-in 6 Import of other schemes
More informationMarkup Languages. Lecture 4. XML Schema
Markup Languages Lecture 4. XML Schema Introduction to XML Schema XML Schema is an XML-based alternative to DTD. An XML schema describes the structure of an XML document. The XML Schema language is also
More informationSemantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95
ه عا ی Semantic Web XML and XML Schema Morteza Amini Sharif University of Technology Fall 94-95 Outline Markup Languages XML Building Blocks XML Applications Namespaces XML Schema 2 Outline Markup Languages
More informationXML (Extensible Markup Language)
Basics of XML: What is XML? XML (Extensible Markup Language) XML stands for Extensible Markup Language XML was designed to carry data, not to display data XML tags are not predefined. You must define your
More informationCOMP9321 Web Application Engineering. Extensible Markup Language (XML)
COMP9321 Web Application Engineering Extensible Markup Language (XML) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 4 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442
More informationJava EE 7: Back-end Server Application Development 4-2
Java EE 7: Back-end Server Application Development 4-2 XML describes data objects called XML documents that: Are composed of markup language for structuring the document data Support custom tags for data
More informationIntroduction Syntax and Usage XML Databases Java Tutorial XML. November 5, 2008 XML
Introduction Syntax and Usage Databases Java Tutorial November 5, 2008 Introduction Syntax and Usage Databases Java Tutorial Outline 1 Introduction 2 Syntax and Usage Syntax Well Formed and Valid Displaying
More informationBig Data 9. Data Models
Ghislain Fourny Big Data 9. Data Models pinkyone / 123RF Stock Photo 1 Syntax vs. Data Models Physical view Syntax this is text. 2 Syntax vs. Data Models a Logical view
More informationXML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11
!important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... 7:4 @import Directive... 9:11 A Absolute Units of Length... 9:14 Addressing the First Line... 9:6 Assigning Meaning to XML Tags...
More informationModelling XML Applications (part 2)
Modelling XML Applications (part 2) Patryk Czarnik XML and Applications 2014/2015 Lecture 3 20.10.2014 Common design decisions Natural language Which natural language to use? It would be a nonsense not
More informationLast week we saw how to use the DOM parser to read an XML document. The DOM parser can also be used to create and modify nodes.
Distributed Software Development XML Schema Chris Brooks Department of Computer Science University of San Francisco 7-2: Modifying XML programmatically Last week we saw how to use the DOM parser to read
More informationEMERGING TECHNOLOGIES. XML Documents and Schemas for XML documents
EMERGING TECHNOLOGIES XML Documents and Schemas for XML documents Outline 1. Introduction 2. Structure of XML data 3. XML Document Schema 3.1. Document Type Definition (DTD) 3.2. XMLSchema 4. Data Model
More information7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML
7.1 Introduction extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML Lax syntactical rules Many complex features that are rarely used HTML is a markup language,
More informationChapter 1: Getting Started. You will learn:
Chapter 1: Getting Started SGML and SGML document components. What XML is. XML as compared to SGML and HTML. XML format. XML specifications. XML architecture. Data structure namespaces. Data delivery,
More informationXML. Document Type Definitions XML Schema. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta
XML Document Type Definitions XML Schema 1 XML XML stands for extensible Markup Language. XML was designed to describe data. XML has come into common use for the interchange of data over the Internet.
More informationCopyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML
Chapter 7 XML 7.1 Introduction extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML Lax syntactical rules Many complex features that are rarely used HTML
More informationSession [2] Information Modeling with XSD and DTD
Session [2] Information Modeling with XSD and DTD September 12, 2000 Horst Rechner Q&A from Session [1] HTML without XML See Code HDBMS vs. RDBMS What does XDR mean? XML-Data Reduced Utilized in Biztalk
More informationMANAGING INFORMATION (CSCU9T4) LECTURE 2: XML STRUCTURE
MANAGING INFORMATION (CSCU9T4) LECTURE 2: XML STRUCTURE Gabriela Ochoa http://www.cs.stir.ac.uk/~goc/ OUTLINE XML Elements vs. Attributes Well-formed vs. Valid XML documents Document Type Definitions (DTDs)
More informationRestricting complextypes that have mixed content
Restricting complextypes that have mixed content Roger L. Costello October 2012 complextype with mixed content (no attributes) Here is a complextype with mixed content:
More informationMarker s feedback version
Two hours Special instructions: This paper will be taken on-line and this is the paper format which will be available as a back-up UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE Semi-structured Data
More informationCopyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1
Slide 27-1 Chapter 27 XML: Extensible Markup Language Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree) Data Model. XML Documents, DTD, and XML Schema.
More informationSo far, we've discussed the use of XML in creating web services. How does this work? What other things can we do with it?
XML Page 1 XML and web services Monday, March 14, 2011 2:50 PM So far, we've discussed the use of XML in creating web services. How does this work? What other things can we do with it? XML Page 2 Where
More informationmarkup language carry data define your own tags self-descriptive W3C Recommendation
XML intro What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. You must define
More informationXML Schema Element and Attribute Reference
E XML Schema Element and Attribute Reference all This appendix provides a full listing of all elements within the XML Schema Structures Recommendation (found at http://www.w3.org/tr/xmlschema-1/). The
More informationSolution Sheet 5 XML Data Models and XQuery
The Systems Group at ETH Zurich Big Data Fall Semester 2012 Prof. Dr. Donald Kossmann Prof. Dr. Nesime Tatbul Assistants: Martin Kaufmann Besmira Nushi 07.12.2012 Solution Sheet 5 XML Data Models and XQuery
More informationSyntax XML Schema XML Techniques for E-Commerce, Budapest 2004
Mag. iur. Dr. techn. Michael Sonntag Syntax XML Schema XML Techniques for E-Commerce, Budapest 2004 E-Mail: sonntag@fim.uni-linz.ac.at http://www.fim.uni-linz.ac.at/staff/sonntag.htm Michael Sonntag 2004
More informationIntroducing our First Schema
1 di 11 21/05/2006 10.24 Published on XML.com http://www.xml.com/pub/a/2000/11/29/schemas/part1.html See this if you're having trouble printing code examples Using W3C XML By Eric van der Vlist October
More informationDelivery Options: Attend face-to-face in the classroom or remote-live attendance.
XML Programming Duration: 5 Days Price: $2795 *California residents and government employees call for pricing. Discounts: We offer multiple discount options. Click here for more info. Delivery Options:
More informationJeff Offutt. SWE 642 Software Engineering for the World Wide Web
XML Advanced Topics Jeff Offutt http://www.cs.gmu.edu/~offutt/ SWE 642 Software Engineering for the World Wide Web sources: Professional Java Server Programming, Patzer, Wrox, 2 nd edition, Ch 5, 6 Programming
More informationDelivery Options: Attend face-to-face in the classroom or via remote-live attendance.
XML Programming Duration: 5 Days US Price: $2795 UK Price: 1,995 *Prices are subject to VAT CA Price: CDN$3,275 *Prices are subject to GST/HST Delivery Options: Attend face-to-face in the classroom or
More informationIntroduction to Semistructured Data and XML. Overview. How the Web is Today. Based on slides by Dan Suciu University of Washington
Introduction to Semistructured Data and XML Based on slides by Dan Suciu University of Washington CS330 Lecture April 8, 2003 1 Overview From HTML to XML DTDs Querying XML: XPath Transforming XML: XSLT
More informationStructured documents
Structured documents An overview of XML Structured documents Michael Houghton 15/11/2000 Unstructured documents Broadly speaking, text and multimedia document formats can be structured or unstructured.
More informationExtensible Markup Language (XML) Hamid Zarrabi-Zadeh Web Programming Fall 2013
Extensible Markup Language (XML) Hamid Zarrabi-Zadeh Web Programming Fall 2013 2 Outline Introduction XML Structure Document Type Definition (DTD) XHMTL Formatting XML CSS Formatting XSLT Transformations
More informationCOMP9321 Web Application Engineering
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411 1 Extensible
More informationXML. Part II DTD (cont.) and XML Schema
XML Part II DTD (cont.) and XML Schema Attribute Declarations Declare a list of allowable attributes for each element These lists are called ATTLIST declarations Consists of 3 basic parts The ATTLIST keyword
More informationBioinforma)cs Resources XML / Web Access
Bioinforma)cs Resources XML / Web Access Lecture & Exercises Prof. B. Rost, Dr. L. Richter, J. Reeb Ins)tut für Informa)k I12 XML Infusion (in 10 sec) compila)on from hkp://www.w3schools.com/xml/default.asp
More informationThe XQuery Data Model
The XQuery Data Model 9. XQuery Data Model XQuery Type System Like for any other database query language, before we talk about the operators of the language, we have to specify exactly what it is that
More informationAppendix H XML Quick Reference
HTML Appendix H XML Quick Reference What Is XML? Extensible Markup Language (XML) is a subset of the Standard Generalized Markup Language (SGML). XML allows developers to create their own document elements
More informationModelling XML Applications
Modelling XML Applications Patryk Czarnik XML and Applications 2013/2014 Lecture 2 14.10.2013 XML application (recall) XML application (zastosowanie XML) A concrete language with XML syntax Typically defined
More informationBig Data for Engineers Spring Data Models
Ghislain Fourny Big Data for Engineers Spring 2018 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special
More informationXML: Extensible Markup Language
XML: Extensible Markup Language CSC 375, Fall 2015 XML is a classic political compromise: it balances the needs of man and machine by being equally unreadable to both. Matthew Might Slides slightly modified
More informationPart VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153
Part VII Querying XML The XQuery Data Model Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Outline of this part 1 Querying XML Documents Overview 2 The XQuery Data Model The XQuery
More informationCSI 3140 WWW Structures, Techniques and Standards. Representing Web Data: XML
CSI 3140 WWW Structures, Techniques and Standards Representing Web Data: XML XML Example XML document: An XML document is one that follows certain syntax rules (most of which we followed for XHTML) Guy-Vincent
More informationBig Data Exercises. Fall 2018 Week 8 ETH Zurich. XML validation
Big Data Exercises Fall 2018 Week 8 ETH Zurich XML validation Reading: (optional, but useful) XML in a Nutshell, Elliotte Rusty Harold, W. Scott Means, 3rd edition, 2005: Online via ETH Library 1. XML
More informationBig Data Fall Data Models
Ghislain Fourny Big Data Fall 2018 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special Relativity"
More informationPESC Compliant JSON Version /19/2018. A publication of the Technical Advisory Board Postsecondary Electronic Standards Council
Version 0.5.0 10/19/2018 A publication of the Technical Advisory Board Postsecondary Electronic Standards Council 2018. All Rights Reserved. This document may be copied and furnished to others, and derivative
More informationB oth element and attribute declarations can use simple types
Simple types 154 Chapter 9 B oth element and attribute declarations can use simple types to describe the data content of the components. This chapter introduces simple types, and explains how to define
More informationXML Structures. Web Programming. Uta Priss ZELL, Ostfalia University. XML Introduction Syntax: well-formed Semantics: validity Issues
XML Structures Web Programming Uta Priss ZELL, Ostfalia University 2013 Web Programming XML1 Slide 1/32 Outline XML Introduction Syntax: well-formed Semantics: validity Issues Web Programming XML1 Slide
More informationIntroduction to XML. Large Scale Programming, 1DL410, autumn 2009 Cons T Åhs
Introduction to XML Large Scale Programming, 1DL410, autumn 2009 Cons T Åhs XML Input files, i.e., scene descriptions to our ray tracer are written in XML. What is XML? XML - extensible markup language
More informationChapter 11 XML Data Modeling. Recent Development for Data Models 2016 Stefan Deßloch
Chapter 11 XML Data Modeling Recent Development for Data Models 2016 Stefan Deßloch Motivation Traditional data models (e.g., relational data model) primarily support structure data separate DB schema
More informationbut XML goes far beyond HTML: it describes data
The XML Meta-Language 1 Introduction to XML The father of markup languages: XML = EXtensible Markup Language is a simplified version of SGML Originally created to overcome the limitations of HTML the HTML
More informationData Presentation and Markup Languages
Data Presentation and Markup Languages MIE456 Tutorial Acknowledgements Some contents of this presentation are borrowed from a tutorial given at VLDB 2000, Cairo, Agypte (www.vldb.org) by D. Florescu &.
More informationXML. COSC Dr. Ramon Lawrence. An attribute is a name-value pair declared inside an element. Comments. Page 3. COSC Dr.
COSC 304 Introduction to Database Systems XML Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca XML Extensible Markup Language (XML) is a markup language that allows for
More informationXML Format Plug-in User s Guide. Version 10g Release 3 (10.3)
XML Format Plug-in User s Guide Version 10g Release 3 (10.3) XML... 4 TERMINOLOGY... 4 CREATING AN XML FORMAT... 5 CREATING AN XML FORMAT BASED ON AN EXISTING XML MESSAGE FORMAT... 5 CREATING AN EMPTY
More informationCOMP9321 Web Application Engineering
COMP9321 Web Application Engineering Semester 2, 2017 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid= 2465 1
More informationSDPL : XML Basics 2. SDPL : XML Basics 1. SDPL : XML Basics 4. SDPL : XML Basics 3. SDPL : XML Basics 5
2 Basics of XML and XML documents 2.1 XML and XML documents Survivor's Guide to XML, or XML for Computer Scientists / Dummies 2.1 XML and XML documents 2.2 Basics of XML DTDs 2.3 XML Namespaces XML 1.0
More informationSemistructured data, XML, DTDs
Semistructured data, XML, DTDs Introduction to Databases Manos Papagelis Thanks to Ryan Johnson, John Mylopoulos, Arnold Rosenbloom and Renee Miller for material in these slides Structured vs. unstructured
More informationFraming how values are extracted from the data stream. Includes properties for alignment, length, and delimiters.
DFDL Introduction For Beginners Lesson 3: DFDL properties In lesson 2 we learned that in the DFDL language, XML Schema conveys the basic structure of the data format being modeled, and DFDL properties
More informationThe <schema> Element. <?xml version="1.0"?> <xs:schema>... </xs:schema>
DTD: Example
More informationXML DTDs and Namespaces. CS174 Chris Pollett Oct 3, 2007.
XML DTDs and Namespaces CS174 Chris Pollett Oct 3, 2007. Outline Internal versus External DTDs Namespaces XML Schemas Internal versus External DTDs There are two ways to associate a DTD with an XML document:
More informationXML: extensible Markup Language
Datamodels XML: extensible Markup Language Slides are based on slides from Database System Concepts Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use Many examples are from
More informationADT 2005 Lecture 7 Chapter 10: XML
ADT 2005 Lecture 7 Chapter 10: XML Stefan Manegold Stefan.Manegold@cwi.nl http://www.cwi.nl/~manegold/ Database System Concepts Silberschatz, Korth and Sudarshan The Challenge: Comic Strip Finder The Challenge:
More informationFraming how values are extracted from the data stream. Includes properties for alignment, length, and delimiters.
DFDL Introduction For Beginners Lesson 3: DFDL properties Version Author Date Change 1 S Hanson 2011-01-24 Created 2 S Hanson 2011-03-30 Updated 3 S Hanson 2012-09-21 Corrections for errata 4 S Hanson
More informationDOM Interface subset 1/ 2
DOM Interface subset 1/ 2 Document attributes documentelement methods createelement, createtextnode, Node attributes nodename, nodevalue, nodetype, parentnode, childnodes, firstchild, lastchild, previoussibling,
More informationWeb Computing. Revision Notes
Web Computing Revision Notes Exam Format The format of the exam is standard: Answer TWO OUT OF THREE questions Candidates should answer ONLY TWO questions The time allowed is TWO hours Notes: You will
More informationThis book is licensed under a Creative Commons Attribution 3.0 License
6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars
More informationUsing UML To Define XML Document Types
Using UML To Define XML Document Types W. Eliot Kimber ISOGEN International, A DataChannel Company Created On: 10 Dec 1999 Last Revised: 14 Jan 2000 Defines a convention for the use of UML to define XML
More informationXML Extensible Markup Language
XML Extensible Markup Language Generic format for structured representation of data. DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34 XML Extensible Markup Language Generic format for structured
More informationMarkup Languages SGML, HTML, XML, XHTML. CS 431 February 13, 2006 Carl Lagoze Cornell University
Markup Languages SGML, HTML, XML, XHTML CS 431 February 13, 2006 Carl Lagoze Cornell University Problem Richness of text Elements: letters, numbers, symbols, case Structure: words, sentences, paragraphs,
More informationSDMX self-learning package No. 6 Student book. XML Based Technologies Used in SDMX
No. 6 Student book XML Based Technologies Used in SDMX Produced by Eurostat, Directorate B: Statistical Methodologies and Tools Unit B-5: Statistical Information Technologies Last update of content May
More informationXML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9
XML databases Jan Chomicki University at Buffalo Jan Chomicki (University at Buffalo) XML databases 1 / 9 Outline 1 XML data model 2 XPath 3 XQuery Jan Chomicki (University at Buffalo) XML databases 2
More informationBig Data 11. Data Models
Ghislain Fourny Big Data 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special Relativity" 2,Gödel,Kurt,"""Incompleteness""
More informationOn why C# s type system needs an extension
On why C# s type system needs an extension Wolfgang Gehring University of Ulm, Faculty of Computer Science, D-89069 Ulm, Germany wgehring@informatik.uni-ulm.de Abstract. XML Schemas (XSD) are the type
More informationIntroduction to XML. XML: basic elements
Introduction to XML XML: basic elements XML Trying to wrap your brain around XML is sort of like trying to put an octopus in a bottle. Every time you think you have it under control, a new tentacle shows
More informationWhat is XML? XML is designed to transport and store data.
What is XML? XML stands for extensible Markup Language. XML is designed to transport and store data. HTML was designed to display data. XML is a markup language much like HTML XML was designed to carry
More informationH2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views
1. (4 points) Of the following statements, identify all that hold about architecture. A. DoDAF specifies a number of views to capture different aspects of a system being modeled Solution: A is true: B.
More informationXML. extensible Markup Language. ... and its usefulness for linguists
XML extensible Markup Language... and its usefulness for linguists Thomas Mayer thomas.mayer@uni-konstanz.de Fachbereich Sprachwissenschaft, Universität Konstanz Seminar Computerlinguistik II (Miriam Butt)
More informationIntroduction to XML Zdeněk Žabokrtský, Rudolf Rosa
NPFL092 Technology for Natural Language Processing Introduction to XML Zdeněk Žabokrtský, Rudolf Rosa November 28, 2018 Charles Univeristy in Prague Faculty of Mathematics and Physics Institute of Formal
More informationTail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)
CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)
More informationThe concept of DTD. DTD(Document Type Definition) Why we need DTD
Contents Topics The concept of DTD Why we need DTD The basic grammar of DTD The practice which apply DTD in XML document How to write DTD for valid XML document The concept of DTD DTD(Document Type Definition)
More informationextensible Markup Language
extensible Markup Language XML is rapidly becoming a widespread method of creating, controlling and managing data on the Web. XML Orientation XML is a method for putting structured data in a text file.
More informationXML. Presented by : Guerreiro João Thanh Truong Cong
XML Presented by : Guerreiro João Thanh Truong Cong XML : Definitions XML = Extensible Markup Language. Other Markup Language : HTML. XML HTML XML describes a Markup Language. XML is a Meta-Language. Users
More informationXML: Managing with the Java Platform
In order to learn which questions have been answered correctly: 1. Print these pages. 2. Answer the questions. 3. Send this assessment with the answers via: a. FAX to (212) 967-3498. Or b. Mail the answers
More informationSession 23 XML. XML Reading and Reference. Reading. Reference: Session 23 XML. Robert Kelly, 2018
Session 23 XML Reading XML Reading and Reference https://en.wikipedia.org/wiki/xml Reference: XML in a Nutshell (Ch. 1-3), available in Safari On-line 2 1 Lecture Objectives Understand the goal of application
More informationFROM XML SCHEMA TO OBJECT-RELATIONAL DATABASE AN XML SCHEMA-DRIVEN MAPPING ALGORITHM
FROM XML SCHEMA TO OBJECT-RELATIONAL DATABASE AN XML SCHEMA-DRIVEN MAPPING ALGORITHM Irena Mlynkova, Jaroslav Pokorny Charles University, Faculty of Mathematics and Physics, Department of Software Engineering
More informationIntro to XML. Borrowed, with author s permission, from:
Intro to XML Borrowed, with author s permission, from: http://business.unr.edu/faculty/ekedahl/is389/topic3a ndroidintroduction/is389androidbasics.aspx Part 1: XML Basics Why XML Here? You need to understand
More information2006 Martin v. Löwis. Data-centric XML. XML Schema (Part 1)
Data-centric XML XML Schema (Part 1) Schema and DTD Disadvantages of DTD: separate, non-xml syntax very limited constraints on data types (just ID, IDREF, ) no support for sets (i.e. each element type
More information11. EXTENSIBLE MARKUP LANGUAGE (XML)
11. EXTENSIBLE MARKUP LANGUAGE (XML) Introduction Extensible Markup Language is a Meta language that describes the contents of the document. So these tags can be called as self-describing data tags. XML
More informationChapter 3 Brief Overview of XML
Slide 3.1 Web Serv vices: Princ ciples & Te echno ology Chapter 3 Brief Overview of XML Mike P. Papazoglou & mikep@uvt.nl Slide 3.2 Topics XML document structure XML schemas reuse Document navigation and
More informationAltova XMLSpy 2007 Tutorial
Tutorial All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or mechanical, including photocopying, recording, taping, or information storage
More informationM359 Block5 - Lecture12 Eng/ Waleed Omar
Documents and markup languages The term XML stands for extensible Markup Language. Used to label the different parts of documents. Labeling helps in: Displaying the documents in a formatted way Querying
More informationChapter 13 XML: Extensible Markup Language
Chapter 13 XML: Extensible Markup Language - Internet applications provide Web interfaces to databases (data sources) - Three-tier architecture Client V Application Programs Webserver V Database Server
More informationMCS-274 Final Exam Serial #:
MCS-274 Final Exam Serial #: This exam is closed-book and mostly closed-notes. You may, however, use a single 8 1/2 by 11 sheet of paper with hand-written notes for reference. (Both sides of the sheet
More information