Extensible Markup Language - PowerPoint PPT Presentation

Loading...

PPT – Extensible Markup Language PowerPoint presentation | free to download - id: 789f58-NTMyN



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Extensible Markup Language

Description:

Extensible Markup Language * CS6795 Semantic Web Techniques 18-Sep-14 – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 37
Provided by: Harol102
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Extensible Markup Language


1
Extensible Markup Language
XML
XML
2
General Advantages of XML for KR
XML offers new general possibilities, from
which AI knowledge representation (KR) can profit
(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
3
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.

XML
Even transformation/compilation of AI source
programs using XML markup and annotations is
possible
4
Address Example External to HTML
External Presentation
Xaver M. Linde Wikingerufer 7 10555 Berlin
HTML tags are still presentation-oriented
XML
HTML Markup
ltemgtXaver M. Lindelt/emgt ltbrgt Wikingerufer
7 ltbrgt ltstronggt10555 Berlinlt/stronggt
5
Address Example HTML to XML
HTML Markup
While not conveying any formal semantics
ltemgtXaver M. Lindelt/emgt ltbrgt Wikingerufer
7 ltbrgt ltstronggt10555 Berlinlt/stronggt
XML tags are chosen for content-structuring needs
XML
XML Markup
ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt lt/addressgt
6
Address Example XML to External
XML Markup
ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt lt/addressgt
XML
XML stylesheets are, e.g., usable to
generate different presentations
External Presentations
Xaver M. Linde Wikingerufer 7 10555 Berlin
Xaver M. Linde Wikingerufer 7 10555 Berlin
. . .
7
XML to HTML XSLT Example Input
ltaddressesgt ltaddressgt ltnamegtXaver M.
Lindelt/namegt ltstreetgtWikingerufer 7lt/streetgt
lttowngt10555 Berlinlt/towngt lt/addressgt
ltaddressgt ltnamegtJohn Doelt/namegt
ltstreetgt42 Gary Cooper Streetlt/streetgt
lttowngtStanwyck Citylt/towngt lt/addressgt lt/address
esgt
XSLT
8
XML to HTML XSLT Example Stylesheet
ltxslstylesheet version"1.0" xmlnsxsl"http//ww
w.w3.org/1999/XSL/Transform"gt ltxsltemplate
match"/addresses"gt lthtmlgt
ltheadgtlttitlegtAddresseslt/titlegtlt/headgt ltbody
bgcolor"white"gt ltxslapply-templates/gt
lt/bodygt lt/htmlgt lt/xsltemplategt
ltxsltemplate match"address"gt ltpgt
ltigtltxslvalue-of select"name"/gtlt/igtltbr/gt
ltxslvalue-of select"street"/gtltbr/gt
ltbgtltxslvalue-of select"town"/gtlt/bgt lt/pgt
lt/xsltemplategt lt/xslstylesheetgt
template for document root (of addresses)
XSLT
template for address elements
9
XML to HTML XSLT Example Output
lt!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http//www.w3.org/TR/REC-html40/strict.dtd"gt lth
tmlgt ltheadgtlttitlegtAddresseslt/titlegtlt/headgt
ltbody bgcolor"white"gt ltpgtltigtXaver M.
Lindelt/igtltbrgt Wikingerufer 7ltbrgt
ltbgt10555 Berlinlt/bgt lt/pgt ltpgtltigtJohn
Doelt/igtltbrgt 42 Gary Cooper Streetltbrgt
ltbgtStanwyck Citylt/bgt lt/pgt
lt/bodygt lt/htmlgt (The HTML code was produced with
Apaches Cocoon in HTML mode, hence ltbr/gt became
ltbrgt)
XSLT
10
Address Example XML to XML
XML Markup 1
ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt lt/addressgt
XML stylesheets are also usable to transform XML
representations
XML
XML Markup 2
ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltplacegt ltstreetgtWikingerufer 7lt/streetgt
lttowngt10555 Berlinlt/towngt
lt/placegt lt/addressgt
11
Address Example Some Stylesheets Will Contain
Term-(Tree-)Rewriting Rules
address
name
street
town
T
S
N
XML
address
name
place
street
town
N
T
S
12
XML to XML Transformational Semantics via an
XSLT Stylesheet
ltaddressesgt ltaddressgt ltnamegtMe2XMLlt/namegt
ltstreetgt96 Hyper Roadlt/streetgt
lttowngtBostonlt/towngt lt/addressgt ltaddressgt
ltnamegtRDF4Alllt/namegt ltstreetgt2001
Broadwaylt/streetgt lttowngtNew Yorklt/towngt
lt/addressgt ltaddressgt ltnamegtXML4Yoult/namegt
ltstreetgt96 Hyper Roadlt/streetgt
lttowngtBostonlt/towngt lt/addressgt lt/addressesgt
XSLT
13
XML to XML XSLT Stylesheet with a
Tree-Transforming Template 1
lt!-- process addresses and position address
nester --gt ltxsltemplate match"/addresses"gt
ltaddressesgt ltxslapply-templates/gt
lt/addressesgt lt/xsltemplategt
XSLT
14
XML to XML XSLT Stylesheet with a
Tree-Transforming Template 2
lt!-- apply address nester to each flat address
--gt ltxsltemplate match"address"gt
ltaddressgt ltnamegtltxslvalue-of
select"name"/gtlt/namegt ltplacegt
ltstreetgtltxslvalue-of select"street"/gtlt/streetgt
lttowngtltxslvalue-of select"town"/gtlt/towngt
lt/placegt lt/addressgt lt/xsltemplategt
XSLT
15
XML to XML XSLT Example Stylesheet
ltxslstylesheet version"1.0" xmlnsxsl"http//ww
w.w3.org/1999/XSL/Transform"gt lt!-- process
addresses and position address nester --gt
ltxsltemplate match"/addresses"gt
ltaddressesgt ltxslapply-templates/gt
lt/addressesgt lt/xsltemplategt lt!-- apply
address nester to each flat address --gt
ltxsltemplate match"address"gt ltaddressgt
ltnamegtltxslvalue-of select"name"/gtlt/namegt
ltplacegt ltstreetgtltxslvalue-of
select"street"/gtlt/streetgt
lttowngtltxslvalue-of select"town"/gtlt/towngt
lt/placegt lt/addressgt lt/xsltemplategt lt/xsls
tylesheetgt
XSLT
16
Address Example XML Normalization for Recovering
Canonical Ordering
XML Markups (Non-Normalized)
ltaddressgt lttowngt10555 Berlinlt/towngt
ltstreetgtWikingerufer 7lt/streetgt ltnamegtXaver
M. Lindelt/namegt lt/addressgt
ltaddressgt ltnamegtXaver M. Lindelt/namegt
lttowngt10555 Berlinlt/towngt ltstreetgtWikingerufer
7lt/streetgt lt/addressgt
. . .
XSLT transformations can perform XML
normalizations
XSLT
XML Markup (Normalized)
ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt lt/addressgt
ltxslvalue-of select"name"/gt 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
Shortlist Example Irrecoverable Ordering (Used
for Ranking)
XML Markup (Given Positional Information)
ltshortlistgt ltnamegtMary Poppinslt/namegt
ltnamegtXaver M. Lindelt/namegt ltnamegtJohn
Doelt/namegt lt/shortlistgt
A shortlist element has 3 ordered subelements
XML
XML Markup (Lost Positional Information)
ltshortlistgt ltnamegtMary Poppinslt/namegt
ltnamegtJohn Doelt/namegt ltnamegtXaver M.
Lindelt/namegt lt/shortlistgt
ltshortlistgt ltnamegtJohn Doelt/namegt
ltnamegtXaver M. Lindelt/namegt ltnamegtMary
Poppinslt/namegt lt/shortlistgt
. . .
18
Address Example XML Queries
XML Markup
subelements
element
ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt lt/addressgt
s
XML Query (XML-QL, which influenced XQuery
standard)
WHERE ltaddressgt ltnamegtXaver M.
Lindelt/namegt ltstreetgtslt/streetgt
lttowngttlt/towngt lt/addressgt CONSTRUCT
ltbindinggt ltsgtslt/sgt lttgttlt/tgt
lt/bindinggt
XML
XML queries can select subelements of XML elements
ltbindinggt ltsgtWikingerufer 7lt/sgt
lttgt10555 Berlinlt/tgt lt/bindinggt
19
Address Example Prolog Queries
Prolog Term
substructures
address( name("Xaver M. Linde"),
street("Wikingerufer 7"), town("10555
Berlin") )
s
structure
XML
Prolog Query
Prolog queries can select substructures of Prolog
structures
address( name("Xaver M. Linde"),
street(S), town(T) )
S "Wikingerufer 7" T "10555 Berlin"
20
Address Example The Element Tree
XML
21
Address Example Document Type Definition and
Tree (1)
Document Type Definition (DTD)
Extended Backus-Naur Form (EBNF)
lt!ELEMENT address (name, street, town)
gt lt!ELEMENT name (PCDATA) gt lt!ELEMENT
street (PCDATA) gt lt!ELEMENT town (PCDATA) gt
address name street town name
PCDATA street PCDATA town PCDATA
XML
22
Address Example Document Type Definition and
Tree (2)
Document Type Definition (DTD)
lt!ELEMENT address (name, place) gt lt!ELEMENT place
(street, town) gt lt!ELEMENT name (PCDATA)
gt lt!ELEMENT street (PCDATA) gt lt!ELEMENT
town (PCDATA) gt
Document Type Tree
XML
address
name
place
street
town
PCDATA
PCDATA
PCDATA
23
Well-Formedness and Validity
XML principles for a document being
well-formed
XML principle for a document
being valid with respect to (w.r.t.) a DTD
  • Open and close all tags
  • Empty tags end with /gt
  • There is a unique root element
  • Elements may not overlap
  • Attribute values are quoted
  • lt 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
Checked by validators such as http//validator.w3.
org/
24
Mail-Box Example Address Variant
XML
Node-Labeled, (Left-to-Right-)Ordered Element
Tree
25
""-Disjoined Street/Mail-Box Example Document
Type Definition and Tree
Document Type Definition (DTD)
lt!ELEMENT address (name, (street box), town)
gt lt!ELEMENT name (PCDATA) gt lt!ELEMENT
street (PCDATA) gt lt!ELEMENT box (PCDATA)
gt lt!ELEMENT town (PCDATA) gt
"" Choice The above box address and the
original street address are valid w.r.t. this
""-DTD
XML
Document Type Tree
address
name
street
town
box
PCDATA
PCDATA
PCDATA
PCDATA
26
Phone Fax Example Address Variant
Prolog Term
address( name("Xaver M. Linde"),
street("Wikingerufer 7"), town("10555
Berlin"), phone("030/1234567"),
phone("030/1234568"), fax("030/1234569") )
XML
Node-Labeled, (Left-to-Right-)Ordered Element
Tree
address
town
name
fax
phone
phone
street
Xaver M. Linde
Wikingerufer 7
10555 Berlin
030/1234567
030/1234569
030/1234568
27
""/""-Repetitive-Phone -Fax Example Document
Type Definition and Tree
Document Type Definition (DTD)
lt!ELEMENT address (name, street, town, phone,
fax) gt lt!ELEMENT name (PCDATA) gt lt!ELEMENT
street (PCDATA) gt lt!ELEMENT town (PCDATA)
gt lt!ELEMENT phone (PCDATA) gt lt!ELEMENT
fax (PCDATA) gt
""/"" 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!)
XML
Document Type Tree
address
name
street
phone
fax
town
PCDATA
PCDATA
PCDATA
PCDATA
PCDATA
28
Country Example Address Variant
Prolog Term
address( name("Xaver M. Linde"),
street("Wikingerufer 7"), town("10555
Berlin"), country("Germany") )
XML
Node-Labeled, (Left-to-Right-)Ordered Element
Tree
address
name
street
town
country
Xaver M. Linde
Wikingerufer 7
10555 Berlin
Germany
29
"?"-Optional-Country Example Document Type
Definition and Tree
Document Type Definition (DTD)
lt!ELEMENT address (name, street, town, country?)
gt lt!ELEMENT name (PCDATA) gt lt!ELEMENT
street (PCDATA) gt lt!ELEMENT town (PCDATA)
gt lt!ELEMENT country (PCDATA) gt
"?" One or Zero The above country address and
the original countriless address are valid
w.r.t. this "?"-DTD
XML
Document Type Tree
address
country
name
street
town
PCDATA
PCDATA
PCDATA
PCDATA
30
Country Address A Complete XML Document
Referring to an External DTD
XML Instance Document Referring to DTD (via root
element)
lt?xml version"1.0" standalone"no"?gt lt!DOCTYPE
address SYSTEM "country-address.dtd"gt ltaddressgt
ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt ltcountrygtGermanylt/countrygt lt/addr
essgt
XML
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/cs6795sw
t/country-address.dtd")
31
"minOccurs"-Optional-Country Example XML Schema
Definition
Equivalent XML Schema Definition (XSD)
lt?xml version"1.0"?gt ltxsdschema
xmlnsxsd"http//www.w3.org/2001/XMLSchema"gt
ltxsdelement name"address"gt
ltxsdcomplexTypegt ltxsdsequencegt
ltxsdelement name"name" type"xsdstring"/gt
ltxsdelement name"street" type"xsdstring"/gt
ltxsdelement name"town"
type"xsdstring"/gt ltxsdelement
name"country" type"xsdstring" minOccurs"0"/gt
lt/xsdsequencegt lt/xsdcomplexTypegt
lt/xsdelementgt lt/xsdschemagt
XML
32
"minOccurs"-Optional-Country Example XML Schema
Tree
Equivalent Document Schema Tree
XML
33
Country Address A Complete XML Document
Referring to an External XSD
XML Instance Document Referring to XSD (via root
element)
lt?xml version"1.0"?gt ltaddress
xsinoNamespaceSchemaLocation"country-address.xsd
" xmlnsxsi"http//www.w3.org/2001/XMLSchema
-instance" gt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt ltcountrygtGermanylt/countrygt lt/addr
essgt
XML
The xsinoNamespaceSchemaLocation 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/cs679
5swt/country-address.xsd")
34
"?"-Optional-Country Example Relax NG Compact
Syntax (RNC)
Equivalent Relax NG in Compact Syntax (RNC)
default namespace "" start address address
element address name, street, town, country?
name element name xsdstring street
element street xsdstring town element town
xsdstring country element country
xsdstring
XML
35
"optional"-Country Example Relax NG XML Syntax
(RNG)
Equivalent Relax NG in XML Syntax (RNG)
lt?xml version"1.0"?gt ltgrammar xmlns"http//relax
ng.org/ns/structure/1.0"gt ltstartgt ltref
name"address"/gt lt/startgt ltdefine
name"address"gt ltelement name"address"
ns""gt ltgroupgt ltref name"name"/gt
ltref name"street"/gt ltref
name"town"/gt ltoptionalgt ltref
name"country"/gt lt/optionalgt
lt/groupgt lt/elementgt lt/definegt
ltdefine name"name"gt ltelement name"name"
ns""gt ltdata type"string"
datatypeLibrary"http//www.w3.org/2001/XMLSchema-
datatypes"/gt lt/elementgt lt/definegt ltdefine
name"street"gt ltelement name"street" ns""gt
ltdata type"string" datatypeLibrary"http//w
ww.w3.org/2001/XMLSchema-datatypes"/gt
lt/elementgt lt/definegt ltdefine name"town"gt
ltelement name"town" ns""gt ltdata
type"string" datatypeLibrary"http//www.w3.org/2
001/XMLSchema-datatypes"/gt lt/elementgt
lt/definegt ltdefine name"country"gt ltelement
name"country" ns""gt ltdata type"string"
datatypeLibrary"http//www.w3.org/2001/XMLSchema-
datatypes"/gt lt/elementgt lt/definegt lt/grammargt
XML
36
Country Address A Complete XML Document
Referring to an External RNG
XML Instance Document Referring to RNG (via
xml-model line)
lt?xml version"1.0"?gt lt?xml-model
href"country-address.rng"
type"application/xml"
schematypens"http//relaxng.org/ns/structure/1.0"
?gt ltaddressgt ltnamegtXaver M. Lindelt/namegt
ltstreetgtWikingerufer 7lt/streetgt lttowngt10555
Berlinlt/towngt ltcountrygtGermanylt/countrygt lt/addr
essgt
XML
The href attribute refers to an external RNG at
"country-address.rng" (or, at absolute URL
"http//www.cs.unb.ca/boley/cs6795swt/country-add
ress.rng")
About PowerShow.com