1 Typing XQuery WANG Zhen (Selina) 2006.4.6. 2 Something about the Internship Group Name: PROTHEO, Inria, France Research: Rewriting and strategies, Constraints,

Slides:



Advertisements
Similar presentations
Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
RDF Tutorial.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
1 XQuery Web and Database Management System. 2 XQuery XQuery is to XML what SQL is to database tables XQuery is designed to query XML data What is XQuery?
1 Conditional XPath, the first order complete XPath dialect Maarten Marx Presented by: Einav Bar-Ner.
NaLIX: A Generic Natural Language Search Environment for XML Data Presented by: Erik Mathisen 02/12/2008.
Dr. Alexandra I. Cristea RDF.
Static Typing in XQuery Mary Fernández, Jérôme Siméon, Philip Wadler Επιμέλεια Παρουσίασης: Μαγδαληνός Παναγής.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
CIS 375—Web App Dev II XPath. 2 XPath IntroductionIntroduction What is XPath? XPath is a syntax for defining parts of an _____ document XPath uses paths.
Introduce of XML Xiaoling Song CS157A. What is XML? XML stands for EXtensible Markup Language XML stands for EXtensible Markup Language XML is a markup.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
XSLT XSLT: eXtensible Stylesheet Language for Transformations - a language for transforming XML documents into any text- based format (e.g. HTML, plain.
Aalborg University – Department of Production XML Extensible Markup Language Kaj A. Jørgensen Aalborg University, Department of Production XML – Extensible.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Lecture 21 XML querying. 2 XSL (eXtensible Stylesheet Language) In HTML, default styling is built into browsers as tag set for HTML is predefined and.
Dr. Azeddine Chikh IS446: Internet Software Development.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
1 XPath XPath became a W3C Recommendation 16. November 1999 XPath is a language for finding information in an XML document XPath is used to navigate through.
IBM Almaden Research Center © 2006 IBM Corporation On the Path to Efficient XML Queries Andrey Balmin, Kevin Beyer, Fatma Özcan IBM Almaden Research Center.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
1 T RANSFORMING XSLT 2.0 T O XQ UERY 1.0 Advanced Database SystemsCOSC282 G OWRI S HANKAR D ARA T EAM M EMBERS D ARREL M AZZARI A LBIN L AGA A DITYA T.
Li Tak Sing COMPS311F. XPath XPath is a simple language that allows you to write expressions to refer to different parts of an XML document. We will learn.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
RELATIONAL FAULT TOLERANT INTERFACE TO HETEROGENEOUS DISTRIBUTED DATABASES Prof. Osama Abulnaja Afraa Khalifah
Lesson 3 CDT301 – Compiler Theory, Spring 2011 Teacher: Linus Källberg.
Optimization in XSLT and XQuery Michael Kay. 2 Challenges XSLT/XQuery are high-level declarative languages: performance depends on good optimization Performance.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Chapter 2. Design of a Simple Compiler J. H. Wang Sep. 21, 2015.
Tutorial 13 Validating Documents with Schemas
Types in programming languages1 What are types, and why do we need them?
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. Ambiguity in Grammars A grammar is ambiguous if and only if it generates a sentential form that has.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
Introduction XML stands for eXtensible Markup Language. Designed to transport and store data; not to display it XML is similar to HTML, but tags are not.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
Compiler Construction By: Muhammad Nadeem Edited By: M. Bilal Qureshi.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
1 A Simple Syntax-Directed Translator CS308 Compiler Theory.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
Formal Semantics of Programming Languages 虞慧群 Topic 2: Operational Semantics.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
XML Schema – XSLT Week 8 Web site:
1 XML and XML in DLESE Katy Ginger November 2003.
Propositional Calculus: Boolean Functions and Expressions
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
XQuery Leonidas Fegaras.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Presentation transcript:

1 Typing XQuery WANG Zhen (Selina)

2 Something about the Internship Group Name: PROTHEO, Inria, France Research: Rewriting and strategies, Constraints, Automated Deduction A member in REWERSE (Reasoning on the Web with Rules and Semantics), a research network within EU Aim: develop reasoning languages for Web applications. In progress: Xcerpt A deductive, rule-based query language for graph-structured data, including XML data. More suitable for reasoning, compared to XQuery. Still working on Xcerpt and its the typing system. Question: How to build a type system for Xcerpt? Refer to the typing system of other query languages. My Internship: analyze the typing system of XQuery

3 Outline Background Related Work XQuery Typing System Conclusion and Future Work

4 Background XQuery An XML query language E.g.: A simple path expression doc("Catalogue.xml")/catalogue/cdCatalogue.xml Path expressions with predicate doc("Catalogue.xml")/catalogue/cd[ 1 ]/title doc("Catalogue.xml")/catalogue/cd[ price>=30 ] /title doc("Catalogue.xml")/catalogue/cd[ keyword ] /title

Predicate [pre] serves to filter a sequence, retaining some items and discarding others.  For …/x[pre]…  Compute the predicate truth value of pre for each item x.  If true, the item x is retained, else, the item x is discarded  Three Typical Predicates [pre] :  pre is numeric → predicate truth value = if position is pre doc("Catalogue.xml")/catalogue/cd[1]/title  pre is boolean → predicate truth value = pre doc("Catalogue.xml")/catalogue/cd[price>30]/title  pre is a typed path → predicate truth value = if pre exit doc("Catalogue.xml")/catalogue/cd[keyword]/title Background

6 Typing XQuery An important aspect of XQuery formal semantics E.g.: Given: Catalogue.xml A query: extract the title of the CD's, with price equal to or more than 30 XQuery expression: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Result

7 Background Problem, if no type information for the XML data The queries and Different ResultsDifferent Results Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query3: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title >= price“30.0” incorrect=30 correct>30 or <30 ResultPrice Not only compare the number, but also compare the length in some cases Possible Reason:

8 Background However, there is no error message or warning. The mistake is too subtle to be located easily. If we provide type information (E.g.: define price as a float) and type checking, we may find the mistake during compilation: >= numeric (numeric: decimal, float, double etc) price>="30.0" Typing error!

9 Related Work XQuery 1.0 and XPath 2.0 Formal Semantics A W3C Candidate Recommendation, including Describes the formal semantics, including some details in static analysis phase and dynamic evaluation phase Provides some generic typing rules Too general to guide the implementation of the detailed typing procedure E.g.: only a single rule for typing path expressions Some inconsistency between the summarized formal semantics and the rules E.g.: Formal SemanticsRules Three kinds of Predicate: (Numeric, Boolean, Typed path) ---

10 Related Work Besides numeric/boolean/typed path, for the other possible expressions pre for Predicates [pre] If pre is a string or a sequence, the predicate truth value is true if pre is not empty, and is false otherwise. In all other cases, a typing error is raised. Problem: any expression can be used in a predicate. Some of them, can pass compilation, but does not give reasonable results doc("Catalogue.xml")/catalogue/cd[ “1” ] doc("Catalogue.xml")/catalogue/cd[ “price>=30” ] doc("Catalogue.xml")/catalogue/cd[ “keyword” ]

11 XQuery Typing System This system includes the typing rules which describes the detailed typing procedure for XQuery. Extension on W3C work Adopt and modify some basic notations to focus on typing Try to solve the inconsistency problem Up to now, we mainly extend the typing rules for path expression including predicates.  Definitions and Notations  Typing Rules  Example  Implementation

12 Definitions and Notations A Basic Type The built-in datatypes defined in XML Schema, including the primitive and the derived datatypes. E.g.: string, integer etc. A user defined simple type. E.g.: “myInteger” defines the integer with value between 1000 and 2000 :

13 Definitions and Notations A type is: 1.A type constant, e.g.: DocumentType, predicate 2.A basic type, or 3.A type symbol (E.g., a type called “CD”), or 4.A functional type with the form (n ≥ 0) where {…} are types for attributes, τi are types for children 5. A disjunction type is of the form (whereτi are types, and n ≥ 0): 6. A type with occurrence indicator, in the form of

14 Definitions and Notations A typing judgement exp:τ exp is an typed expression, τis a type. if exp’s type is τ, the typing judgement is true The conclusion is true, given that all the premises are true, All the premises and the conclusion are typing judgements. If there is no premise, the conclusion is always true. A typing rule

15 Definitions and Notations Notations

16 Typing Rules Typing rules used for Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title Typing doc(f) doc(f) is a document function, which is used to extract data from XML file f. Typing rule suppose that the type of the root element of XML file f isτ

Typing Paths

Typing Predicate ( numeric, boolean, typed path ) τ1<: τ2 means type τ1 is the subtype of type τ2 If exp: τ1, and τ1<: τ2, then exp: τ2 Use a type called “numeric” where: (W3C) Typing rules

Example Typing Query 1 with a schema: doc("Catalogue.xml")/catalogue/cd[price>=30]/titleschema

Typing Query 1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Example

Typing Query 2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Predicate (numeric, boolean, typed path) see whether price>=“30.0”: boolean Typing Rule (from W3C) for operator “>=”, while τis numeric Example A typing error is generated

23 Implementation In order to apply those typing rules, we need to: parse an XQuery expression into an abstract syntax tree apply those rules by navigating through the tree, add type information on the nodes Our implementation: XQueryX – XML expression of XQuery syntax TOM -- An extension of Java designed to manipulate tree structures and XML documents, by using pattern matching facilities. Framework Example: Query 1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title

<module xmlns:xqx=" xmlns:xsi=" xsi:schemaLocation=" doc Catalogue.xml XQueryX expression

child catalogue child cd price 30 XQueryX expression

child title XQueryX expression

Apply the Rules by Using TOM Rules for typing Doc(f) Rules for typing each step in a path expression

28 Conclusion and Future Work Conclusion We analyze the related work in typing XQuery, and solve some inconsistency by extends the typing rules. A prototype of XQuery Typing System is implemented, including the detailed typing rules for the path expressions in XQuery. Future Work Implementation of all the typing rules in W3C work, find and solve the potential inconsistency problem Design typing system for Xcerpt Find a polymorphic typing system for Web query languages.

29 Thank You

Catalogue.xml "Empire Burlesque" Bob Dylan Empire Bob Hide your heart Bonnie Tyler Stop Sam Brown Result Hide your heart Stop Query: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Source: Catalogue.xml

Result Hide your heart Stop Source: Catalogue.xml Query 1 Query 2 Query 3 Result Stop 30 Incorrect Correct Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query3: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title

Catalogue.xml "Empire Burlesque" Bob Dylan Empire Bob Hide your heart Bonnie Tyler Stop Sam Brown

Result Hide your heart Stop Source: Catalogue.xml Query 1 Query 2 Query 3 Result Stop 30 Incorrect Correct Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query3: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title

Result Hide your heart Stop Source: Catalogue.xml Query 1 Query 2 Query 3 Result Stop Incorrect Correct 30.0 Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query3: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title

Catalogue.xml "Empire Burlesque" Bob Dylan Empire Bob Hide your heart Bonnie Tyler Stop Sam Brown

Result Hide your heart Stop Source: Catalogue.xml Query 1 Query 2 Query 3 Result Stop 30 Incorrect Correct Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query3: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title

Result Hide your heart Stop Source: Catalogue.xml Query 1 Query 2 Query 3 Correct Query1: doc("Catalogue.xml")/catalogue/cd[price>=30]/title Query2: doc("Catalogue.xml")/catalogue/cd[price>="30.0"]/title Query3: doc("Catalogue.xml")/catalogue/cd[price>="30.00"]/title

Example: Schema file “Catalogue.xsd”