Download presentation
Presentation is loading. Please wait.
Published byBruce Hall Modified over 9 years ago
1
18-Sep-14 CS6795 Semantic Web Techniques 0 Extensible Markup Language
2
18-Sep-14 CS6795 Semantic Web Techniques 1 General Advantages of XML for KR (1) Definition of self-describing data in worldwide standardized, non-proprietary format (2) Structured data and knowledge exchange for enterprises in various industries (3) Integration of information from different sources (into uniform documents) XML offers new general possibilities, from which AI knowledge representation (KR) can profit:
3
18-Sep-14 CS6795 Semantic Web Techniques 2 Specific Advantages of XML for KR XML provides the most suitable infrastructure for knowledge bases on the Web (incl. for W3C languages such as RDF) Additional special KR uses of XML are: Uniform storage of knowledge bases Interchange of knowledge bases between different AI languages Exchange between knowledge bases and databases, application systems, etc. Even transformation/compilation of AI source programs using XML markup and annotations is possible
4
18-Sep-14 CS6795 Semantic Web Techniques 3 Address Example: External to HTML Xaver M. Linde Wikingerufer 7 10555 Berlin Xaver M. Linde Wikingerufer 7 10555 Berlin External Presentation: HTML Markup: HTML tags are still presentation-oriented
5
18-Sep-14 CS6795 Semantic Web Techniques 4 Address Example: HTML to XML Xaver M. Linde Wikingerufer 7 10555 Berlin HTML Markup: XML tags are chosen for content-structuring needs Xaver M. Linde Wikingerufer 7 10555 Berlin XML Markup: While not conveying any formal semanticsany formal semantics:
6
18-Sep-14 CS6795 Semantic Web Techniques 5 Address Example: XML to External Xaver M. Linde Wikingerufer 7 10555 Berlin XML Markup: Xaver M. Linde Wikingerufer 7 10555 Berlin External Presentations: XML stylesheets are, e.g., usable to generate different presentations Xaver M. Linde Wikingerufer 7 10555 Berlin...
7
18-Sep-14 CS6795 Semantic Web Techniques 6 XML to HTML: XSLT Example – Input Xaver M. Linde Wikingerufer 7 10555 Berlin John Doe 42 Gary Cooper Street Stanwyck City
8
18-Sep-14 CS6795 Semantic Web Techniques 7 XML to HTML: XSLT Example – Stylesheet Addresses template for document root (of addresses) template for address elements
9
18-Sep-14 CS6795 Semantic Web Techniques 8 XML to HTML: XSLT Example – Output Addresses Xaver M. Linde Wikingerufer 7 10555 Berlin John Doe 42 Gary Cooper Street Stanwyck City (The HTML code was produced with Apache´s Cocoon in HTML mode, hence became )
10
18-Sep-14 CS6795 Semantic Web Techniques 9 Xaver M. Linde Wikingerufer 7 10555 Berlin Address Example: XML to XML Xaver M. Linde Wikingerufer 7 10555 Berlin XML Markup 1: XML Markup 2: XML stylesheets are also usable to transform XML representations
11
18-Sep-14 CS6795 Semantic Web Techniques 10 Address Example: Some Stylesheets Will Contain Term-(Tree-)Rewriting Rules address N S T namestreettown address name streettown place N S T
12
18-Sep-14 CS6795 Semantic Web Techniques 11 XML to XML: Transformational Semantics via an XSLT Stylesheet Me2XML 96 Hyper Road Boston RDF4All 2001 Broadway New York XML4You 96 Hyper Road Boston % start fact base for addresses address( name("Me2XML"), place( street("96 Hyper Road"), town("Boston") ) ). address( name("RDF4All"), place( street("2001 Broadway"), town("New York") ) ). address( name("XML4You"), place( street("96 Hyper Road"), town("Boston") ) ). % end fact base for addresses Me2XML 96 Hyper Road Boston RDF4All 2001 Broadway New York XML4You 96 Hyper Road Boston XSLTXSLT templates
13
18-Sep-14 CS6795 Semantic Web Techniques 12 XML to XML: XSLT Stylesheet with a Tree-Transforming Template 1 addresses Subtree... addresses... Subtree
14
18-Sep-14 CS6795 Semantic Web Techniques 13 XML to XML: XSLT Stylesheet with a Tree-Transforming Template 2 address PCDATA namestreettown address PCDATA name streettown place
15
18-Sep-14 CS6795 Semantic Web Techniques 14 XML to XML: XSLT Example – Stylesheet
16
18-Sep-14 CS6795 Semantic Web Techniques 15 Address Example: XML Normalization for Recovering Canonical Ordering 10555 Berlin Wikingerufer 7 Xaver M. Linde XML Markups (Non-Normalized): XML Markup (Normalized): Xaver M. Linde Wikingerufer 7 10555 Berlin XSLT transformations can perform XML normalizations Xaver M. Linde 10555 Berlin Wikingerufer 7... etc. find subelements in any position, so earlier stylesheets can be readily adapted for this An address element in normal form has 3 ordered subelements
17
18-Sep-14 CS6795 Semantic Web Techniques 16 Shortlist Example: Irrecoverable Ordering (Used for Ranking) Mary Poppins Xaver M. Linde John Doe XML Markup (Given Positional Information): XML Markup (Lost Positional Information): Mary Poppins John Doe Xaver M. Linde John Doe Xaver M. Linde Mary Poppins... A shortlist element has 3 ordered subelements
18
18-Sep-14 CS6795 Semantic Web Techniques 17 Xaver M. Linde Wikingerufer 7 10555 Berlin WHERE Xaver M. Linde $s $t CONSTRUCT $s $t Address Example: XML Queries XML Markup: XML Query (XML-QL, which influenced XQuery standard):XML-QLXQuery XML queries can select subelements of XML elements elementelement s subelements Wikingerufer 7 10555 Berlin
19
18-Sep-14 CS6795 Semantic Web Techniques 18 address( name("Xaver M. Linde"), street("Wikingerufer 7"), town("10555 Berlin") ) Address Example: Prolog Queries Prolog Term: Prolog Query: Prolog queries can select substructures of Prolog structures S = "Wikingerufer 7" T = "10555 Berlin" structurestructure s substructures address( name("Xaver M. Linde"), street(S), town(T) )
20
18-Sep-14 CS6795 Semantic Web Techniques 19 Address Example: The Element Tree address( name("Xaver M. Linde"), street("Wikingerufer 7"), town("10555 Berlin") ) Prolog Term: structurestructure s substructures Xaver M. Linde Wikingerufer 7 10555 Berlin XML Markup: elementelement s subelements Node-Labeled, (Left-to-Right-)Ordered Element Tree: address Xaver M. LindeWikingerufer 710555 Berlin namestreettown subtreessubtrees tree
21
18-Sep-14 CS6795 Semantic Web Techniques 20 Address Example: Document Type Definition and Tree (1) Document Type Definition (DTD): Document Type Tree: address PCDATA namestreettown address ::=name street town name ::=PCDATA street ::=PCDATA town ::=PCDATA Extended Backus-Naur Form (EBNF):
22
18-Sep-14 CS6795 Semantic Web Techniques 21 Address Example: Document Type Definition and Tree (2) Document Type Tree: Document Type Definition (DTD): address PCDATA name streettown place
23
18-Sep-14 CS6795 Semantic Web Techniques 22 Well-Formedness and Validity Open and close all tags Empty tags end with /> There is a unique root element Elements may not overlap Attribute values are quoted < and & are only used to start tags and entities Only the five predefined entity references are used Match the constraints listed in the DTD (or, generate from DTD as linearized derivation tree, as shown later) XML principles for a document being well- formed: XML principle for a document being valid with respect to (w.r.t.) a DTD : Checked by validators such as http://validator.w3.org/ http://validator.w3.org/
24
18-Sep-14 CS6795 Semantic Web Techniques 23 Mail-Box Example: Address Variant Node-Labeled, (Left-to-Right-)Ordered Element Tree: address( name("Xaver M. Linde"), box("2001"), town("10555 Berlin") ) Prolog Term: Xaver M. Linde 2001 10555 Berlin XML Markup: address Xaver M. Linde 2001 10555 Berlin name box town
25
18-Sep-14 CS6795 Semantic Web Techniques 24 "|" - Disjoined Street/Mail-Box Example: Document Type Definition and Tree Document Type Tree: Document Type Definition (DTD): address PCDATA name street town PCDATA box "|": Choice The above box address and the original street address are valid w.r.t. this "|"-DTD
26
18-Sep-14 CS6795 Semantic Web Techniques 25 Phone & Fax Example: Address Variant Node-Labeled, (Left-to-Right-)Ordered Element Tree: address( name("Xaver M. Linde"), street("Wikingerufer 7"), town("10555 Berlin"), phone("030/1234567"), phone("030/1234568"), fax("030/1234569") ) Prolog Term: Xaver M. Linde Wikingerufer 7 10555 Berlin 030/1234567 030/1234568 030/1234569 XML Markup: address Xaver M. LindeWikingerufer 710555 Berlin name street town 030/1234567030/1234569030/1234568 phone fax
27
18-Sep-14 CS6795 Semantic Web Techniques 26 "+"/"*" - Repetitive-Phone & -Fax Example: Document Type Definition and Tree Document Type Tree: Document Type Definition (DTD): address PCDATA name street town PCDATA phone PCDATA fax "+"/"*": One/Zero or More The above two-phone/one-fax address is valid w.r.t. this "+"/"*"-DTD but the original no-phone/no-fax address is not ( 1 phone!)
28
18-Sep-14 CS6795 Semantic Web Techniques 27 Country Example: Address Variant Node-Labeled, (Left-to-Right-)Ordered Element Tree: address( name("Xaver M. Linde"), street("Wikingerufer 7"), town("10555 Berlin"), country("Germany") ) Xaver M. Linde Wikingerufer 7 10555 Berlin Germany XML Markup: address Xaver M. Linde Wikingerufer 7 10555 Berlin name street town Germany country Prolog Term:
29
18-Sep-14 CS6795 Semantic Web Techniques 28 "?" - Optional-Country Example: Document Type Definition and Tree Document Type Tree: Document Type Definition (DTD): address PCDATA name street town PCDATA country "?": One or Zero The above country address and the original countriless address are valid w.r.t. this "?"-DTD
30
18-Sep-14 CS6795 Semantic Web Techniques 29 Country Address: A Complete XML Document Referring to an External DTD Xaver M. Linde Wikingerufer 7 10555 Berlin Germany The XML declaration uses standalone attribute with "no" value: DTD import The DOCument TYPE declaration names the root element address and, after the SYSTEM keyword, refers to an external DTD at "country-address.dtd" (or, at absolute URL "http://www.cs.unb.ca/~boley/cs6795swt/country-address.dtd" )http://www.cs.unb.ca/~boley/cs6795swt/country-address.dtd XML Instance Document Referring to DTD (via root element):
31
18-Sep-14 CS6795 Semantic Web Techniques 30 "minOccurs" - Optional-Country Example: XML Schema Definition Equivalent XML Schema Definition (XSD):
32
18-Sep-14 CS6795 Semantic Web Techniques 31 "minOccurs" - Optional-Country Example: XML Schema Tree Equivalent Document Schema Tree: address xsd:string name street town xsd:string country
33
18-Sep-14 CS6795 Semantic Web Techniques 32 Country Address: A Complete XML Document Referring to an External XSD <address xsi:noNamespaceSchemaLocation="country-address.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > Xaver M. Linde Wikingerufer 7 10555 Berlin Germany The xsi:noNamespaceSchemaLocation attribute is embedded in the root element address and refers to an external XSD at "country-address.xsd" (or, at absolute URL " http://www.cs.unb.ca/~boley/cs6795swt/country-address.xsd ") http://www.cs.unb.ca/~boley/cs6795swt/country-address.xsd XML Instance Document Referring to XSD (via root element):
34
18-Sep-14 CS6795 Semantic Web Techniques 33 "?" - Optional-Country Example: Relax NG Compact Syntax (RNC) default namespace = "" start = address address = element address { name, street, town, country? } name = element name { xsd:string } street = element street { xsd:string } town = element town { xsd:string } country = element country { xsd:string } Equivalent Relax NG in Compact Syntax (RNC):
35
18-Sep-14 CS6795 Semantic Web Techniques 34 "optional"-Country Example: Relax NG XML Syntax (RNG) Equivalent Relax NG in XML Syntax (RNG):
36
18-Sep-14 CS6795 Semantic Web Techniques 35 Country Address: A Complete XML Document Referring to an External RNG <?xml-model href="country-address.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> Xaver M. Linde Wikingerufer 7 10555 Berlin Germany XML Instance Document Referring to RNG (via xml-model line): The href attribute refers to an external RNG at "country-address.rng" (or, at absolute URL " http://www.cs.unb.ca/~boley/cs6795swt/country-address.rng ") http://www.cs.unb.ca/~boley/cs6795swt/country-address.rng
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.