Markup Languages and Semistructured Data - SS 02



Similar documents
Markup Sprachen und semi-strukturierte Daten

Semistructured data and XML. Institutt for Informatikk INF Ahmet Soylu

Interactive Data Visualization for the Web Scott Murray

DTD Tutorial. About the tutorial. Tutorial

Creating a TEI-Based Website with the exist XML Database

Introduction to XML Applications

XSLT Mapping in SAP PI 7.1

High Performance XML Data Retrieval

XML: extensible Markup Language. Anabel Fraga

Data Integration through XML/XSLT. Presenter: Xin Gu

Extending XSLT with Java and C#

XML Schema Definition Language (XSDL)

Structured vs. unstructured data. Motivation for self describing data. Enter semistructured data. Databases are highly structured

2009 Martin v. Löwis. Data-centric XML. Other Schema Languages

Agents and Web Services

Extensible Markup Language (XML): Essentials for Climatologists

XSLT - A Beginner's Glossary

Exchanger XML Editor - Canonicalization and XML Digital Signatures

BASI DI DATI II 2 modulo Parte II: XML e namespaces. Prof. Riccardo Torlone Università Roma Tre

T Network Application Frameworks and XML Web Services and WSDL Tancred Lindholm

XML and Data Management

WebSphere Business Monitor

Managing XML Documents Versions and Upgrades with XSLT

[MS-ASMS]: Exchange ActiveSync: Short Message Service (SMS) Protocol

Invited Expert on XForms and HTML Working Group

T XML in 2 lessons! %! " #$& $ "#& ) ' */,: -.,0+(. ". "'- (. 1

Application development in XML

Unified XML/relational storage March The IBM approach to unified XML/relational databases

Oracle Database: SQL and PL/SQL Fundamentals

Deferred node-copying scheme for XQuery processors

Concrete uses of XML in software development and data analysis.

Managing large sound databases using Mpeg7

Computer Science E-259

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

Oracle SQL. Course Summary. Duration. Objectives

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

Database & Information Systems Group Prof. Marc H. Scholl. XML & Databases. Tutorial. 11. SQL Compilation, XPath Symmetries

An Approach to Translate XSLT into XQuery

INTRO TO XMLSPY (IXS)

JobScheduler Web Services Executing JobScheduler commands

Session Topic. Session Objectives. Extreme Java G XML Data Processing for Java MOM and POP Applications

Microsoft' Excel & Access Integration

Oracle Database: SQL and PL/SQL Fundamentals NEW

Translating between XML and Relational Databases using XML Schema and Automed

Last Week. XML (extensible Markup Language) HTML Deficiencies. XML Advantages. Syntax of XML DHTML. Applets. Modifying DOM Event bubbling

Consuming and Producing Web Services with WST and JST. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Storing and Querying Ordered XML Using a Relational Database System

10CS73:Web Programming

XML and Data Integration

Presentation / Interface 1.3

Oracle Database: SQL and PL/SQL Fundamentals

Pushing XML Main Memory Databases to their Limits

Translating XQuery expressions to Functional Queries in a Mediator Database System

JSquash: Source Code Analysis of Embedded Database Applications for Determining SQL Statements

Extending the Linked Data API with RDFa

Cleo Communications. CUEScript Training

Rigorous and Automatic Testing of Web Applications

Representation of E-documents in AIDA Project

6. SQL/XML. 6.1 Introduction. 6.1 Introduction. 6.1 Introduction. 6.1 Introduction. XML Databases 6. SQL/XML. Creating XML documents from a database

ABSTRACT 1. INTRODUCTION. Kamil Bajda-Pawlikowski

An XML Based Data Exchange Model for Power System Studies

XML Databases 6. SQL/XML

Address Phone & Fax Internet

By Koji MIYAUCHI* ABSTRACT. XML is spreading quickly as a format for electronic documents and messages. As a consequence,

Web Services Technologies

A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX

Introduction to Web Services

Change Management for XML, in XML

Indexing XML Data in RDBMS using ORDPATH

Discovering SQL. Wiley Publishing, Inc. A HANDS-ON GUIDE FOR BEGINNERS. Alex Kriegel WILEY

A User Interface for XML Document Retrieval

Modern Databases. Database Systems Lecture 18 Natasha Alechina

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

CST6445: Web Services Development with Java and XML Lesson 1 Introduction To Web Services Skilltop Technology Limited. All rights reserved.

EMC Documentum xdb. Installation and Administration Guide P/N A01. Version 9.0

Instant YANG. The Basics. Hakan Millroth, Tail- f Systems ( hakan@tail- f.com)

Smooks Dev Tools Reference Guide. Version: GA

Selenium Automation set up with TestNG and Eclipse- A Beginners Guide

Schematron Validation and Guidance

Authoring for System Center 2012 Operations Manager

XPath Processing in a Nutshell

An XML Schema Extension for Structural Information in Internet and Web-Based Systems

Developer Guide. Christian W. Günther Library version: 1.0 RC7 Revision: 7

Agenda Summary of Previous Session

Structured vs. unstructured data. Semistructured data, XML, DTDs. Motivation for self-describing data

17 March 2013 NIEM Web Services API Version 1.0 URI:

BIRT: A Field Guide to Reporting

Grandstream XML Application Guide Three XML Applications

metaengine DataConnect For SharePoint 2007 Configuration Guide

Chapter 3: XML Namespaces

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Java and XML parsing. EH2745 Lecture #8 Spring

Interaction Translation Methods for XML/SNMP Gateway Using XML Technologies

Internationalization Tag Set 1.0 A New Standard for Internationalization and Localization of XML

Introduction to XML. Data Integration. Structure in Data Representation. Yanlei Diao UMass Amherst Nov 15, 2007

Quiz! Database Indexes. Index. Quiz! Disc and main memory. Quiz! How costly is this operation (naive solution)?

In this chapter, we lay the foundation for all our further discussions. We start

What's new in 3.0 (XSLT/XPath/XQuery) (plus XML Schema 1.1) Michael Kay Saxonica

estatistik.core: COLLECTING RAW DATA FROM ERP SYSTEMS

Transcription:

Markup Languages and Semistructured Data - SS 02 http://www.pms.informatik.uni-muenchen.de/lehre/markupsemistrukt/02ss/ XPath 1.0 Tutorial 28th of May, 2002 Dan Olteanu

XPath 1.0 - W3C Recommendation language for addressing and matching parts of an XML document. designed to be used standalone, but also by XPointer, XSLT, XQuery. uses a compact, non-xml format to facilitate use within URIs and attribute values. provides basic facilities for string, number and boolean manipulation. supports namespaces.

XPath 1.0 Data Model can be derived from XML InfoSet. XML document is viewed as a tree, containing different kinds of nodes. kinds of nodes: root, element, text, attribute, namespace, processing instruction, comment nodes. imposes a document order defined on all nodes except attribute and namespace nodes (order of occurence of element start-tags). the root node is the first node. the namespace nodes are defined to occur before the attribute nodes. root and element nodes have an ordered list of children. an element node is the parent of the associated set of attribute/namespace nodes, the attributes/namespaces are not children of the associated element node.

<?xml version="1.0" encoding="iso-8859-1"?> <book> <chapter> <title>various Fruits</title> <para> The next chapters introduce different kinds of fruits, like <fruit figref="fr_virg">strawberries</fruit> or <fruit figref="apple">apples</fruit>. </para> </chapter> <chapter> <title>strawberries</title> <para> stre[a]w berige; stre[a]w straw + berie berry; perhaps from the resemblance of the runners of the plant to straws. </para> <para> A fragrant edible berry, of a delicious taste and commonly of a red colour. </para> <para> The common American strawberry is <figure caption="fragaria virginiana" data="fr_virg.jpg" id="fr_virg">fragaria virginiana</figure>, the European is <figure caption="fragaria vesca" data="fr_vesca.jpg" id="fr_vesca">fragaria vesca</figure>. </para> </chapter> </book>

root book Kinds of Nodes element chapter chapter Text attribute title para title para para para root "... " "... " "... " "... " "... " "... " "... " "... " fruit fruit figure figure figref "... " figref "... " caption data id "... " caption data id "... " "... " "... " "... " "... " "... " "... " "... " "... " Tree Representation for the XML fragment example, cf. XPath 1.0 Data Model

XPath Expressions: Syntactic Building Blocks primary expressions: strings, numbers, booleans, location paths, predicates, function calls, variable reference. complex expressions: unions, filters, relational expressions. basic expression types: string, number, boolean, node-set. expression evaluation done in a context, consisting of: the context node. the context position and size. a set of variable bindings. a function library. a set of namespace declarations in expression scope. examples Markup-Sprachen und semi-strukturierte Daten ($x + $y) 2 > 10.7 //lecture[@name = Markup and contains(author, Bry )]

Location Paths: The MOST Important Constructs A path is constructed from steps, which have: an axis, which specifies the tree relationship between the nodes. a node test, which specifies the name of the selected nodes. zero or more predicates, which refine the set of nodes selected by the location step. Examples: child::para child::figure[attribute::id= fr vesca ] child::*[position()=last()] Abbreviated syntax: @name for attribute::name para[1] for child::para[position()=1].//para for self::node()/descendant-or-self::node()/child::para. for self::node()../para for parent::node()/child::para

AXES IN XPATH 1.0 ANCESTOR ANCESTOR OR SELF PRECEDING SIBLING PARENT SELF FOLLOWING SIBLING CURRENT NODE ATTRIBUTE NAMESPACE PRECEDING FOLLOWING DESCENDANT CHILD DESCENDANT OR SELF

Example Break (1) - Testing Location Paths We use: a graphical test environment for XPath expressions, named XPath Tester. Command line for XPath Tester 1.1: java -jar xpathtester_1_1.jar. downloadable from 5Sight: http://www.fivesight.com/downloads/xpathtester.asp. Prerequisites: Java Virtual Machine, e.g. jdk 1.2 or higher. a Java-based XPath evaluator, e.g. Xalan, Saxon, XT. a Java-based XML parser, e.g. Xerces, XML4Java, Alfred.

Core Function Library: Node-Set Functions number last() returns the context size from the expression evaluation context. number position() returns the context position from the expression evaluation context. number count(node-set) returns the number of nodes in the argument node-set. node-set id(object) selects elements by their unique ID, as declared in DTD. string name(node-set?), string local-name(node-set?), string namespace-uri(node-set?) returns the expanded/local name/namespace URI of the node in the argument node-set that is first in document order.

Example Break (2) - Testing Node-Set Functions We use: a graphical test environment for XPath expressions, named XPath Tester. Command line for XPath Tester 1.1: java -jar xpathtester_1_1.jar. downloadable from 5Sight: http://www.fivesight.com/downloads/xpathtester.asp. Prerequisites: Java Virtual Machine, e.g. jdk 1.2 or higher. a Java-based XPath evaluator, e.g. Xalan, Saxon, XT. a Java-based XML parser, e.g. Xerces, XML4Java, Alfred.

Core Function Library: String Functions string string(object?) string concat(string, string, string*) boolean start-with(string, string) boolean contains(string, string) string substring-before(string, string) string substring-after(string, string) string substring(string, number, number?) number string-length(string?) string normalize-space(string?) string translate(string, string, string)

Example Break (3) - Testing String Functions We use: a graphical test environment for XPath expressions, named XPath Tester. Command line for XPath Tester 1.1: java -jar xpathtester_1_1.jar. downloadable from 5Sight: http://www.fivesight.com/downloads/xpathtester.asp. Prerequisites: Java Virtual Machine, e.g. jdk 1.2 or higher. a Java-based XPath evaluator, e.g. Xalan, Saxon, XT. a Java-based XML parser, e.g. Xerces, XML4Java, Alfred.

Core Function Library: Boolean & Number Functions Boolean Functions boolean boolean(object) boolean not(boolean) boolean true() boolean false() Number Functions number number(object?) number sum(node-set?) number floor(number) number ceiling(number) number round(number)

Example Break (4) - Testing Boolean & Number Functions We use: a graphical test environment for XPath expressions, named XPath Tester. Command line for XPath Tester 1.1: java -jar xpathtester_1_1.jar. downloadable from 5Sight: http://www.fivesight.com/downloads/xpathtester.asp. Prerequisites: Java Virtual Machine, e.g. jdk 1.2 or higher. a Java-based XPath evaluator, e.g. Xalan, Saxon, XT. a Java-based XML parser, e.g. Xerces, XML4Java, Alfred.

More Examples (1) Select the figure elements without attributes: //figure[not(@*)] Select the chapter s having three paragraphs: //chapter[count(.//para) = 3] Select the first paragraph of each chapter: //chapter//para[1] Select the first paragraph of all chapter s: (//chapter//para)[1] Select the figures with an attribute caption Fragaria virginiana from the second chapter: //chapter[2]//figure[@caption = Fragaria virginiana ] Select the figures in chapters 2 through 5: //chapter[position() >= 2 and position() <= 5]//figure Select captions of figures that are referenced by figref attributes of fruit elements in the first chapter: id(//chapter[1]//fruit/@figref)[self::figure]/caption

More Examples (2) Select chapter s in which the word Strawberry is mentioned in at least one paragraph: //chapter[.//para[contains(., Strawberry )]] Select chapter s in which the word Strawberry is mentioned in every paragraph: //chapter[count(.//para) = count(.//para[contains(., Strawberry )]) and.//para] OR //chapter[not(.//para[not(contains(., Strawberry ))]) and.//para] List the names of the second-level manager s of all employees whose rating is Good : id(id(/emp[rating = Good ]/@mgr)[self::emp]/@mgr)[self::emp]/name List all distinct employees from a company: (//company//employee)[not(.=preceding::employee)] Prepare a critical sequence report consisting of all elements that occur between the first and second incision: (//incision[2]/preceding::*) [count(. (//incision[1]/following::*)) = count (//incision[1]/following::*)]

What s coming with XPath 2.0? support for XML Schema primitive datatypes. explicit For Any and For All quantifiers (some and every). FR construct from XQuery FLoWeR expression (for-return). extended set of aggregation functions (e.g. min, max, avg...). conditional expressions (if-then-else). node-set intersection and difference functions (intersect, except). string matching using regular expressions.

Useful links W3C XPath Recommendation: http://www.w3.org/tr/xpath. XPath Tutorial from Zvon: http://www.zvon.org/xxl/xpathtutorial/general/examples.html. XPath Tester from 5Sight: http://www.fivesight.com/downloads/xpathtester.asp. XPath Tester from PhPXML: http://www.phpxml.org/scripts/testsuite/. XPath Tutorial from Resin: http://www.caucho.com/products/resin/ref/xpath.xtp. XPath Implementation from Xalan: http://xml.apache.org/xalan-j/index.html.