Подход к реализации XQuery Паращенко Олег Санкт-Петербургский Государственный Университет Обнинск, 2004.

Slides:



Advertisements
Similar presentations
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XPath, NameSpaces.
Advertisements

Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.
Dr. Alexandra I. Cristea XPath and Namespaces.
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
XQuery John Annechino Steven Pow. Agenda What is XQuery? Uses of XQuery XQuery vs. XSLT Syntax –Built-In Functions –FLWOR –if-then-else –User-Defined.
XQuery Or, what about REAL databases?. XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer.
XQUERY. What is XQuery? XQuery is the language for querying XML data The best way to explain XQuery is to say that XQuery is to XML what SQL is to database.
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?
XPath XML Path Language. Outline XML Path Language (XPath) Data Model Description Node values XPath expressions Relative expressions Simple subset of.
Transforming XML Part I Document Navigation with XPath John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel:
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
XML 6.6 XPath 6. What is XPath? XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements is similar to.
2-Jun-15 XPath. 2 What is XPath? XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements is similar to.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
XSLT XML DBs, and Schemas Week 18 DSA. The Whisky Case study XSLT can be applied in the client. –Add a xml processing instruction to the xml to bind to.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
QSX (LN 3)1 Query Languages for XML XPath XQuery XSLT (not being covered today!) (Slides courtesy Wenfei Fan, Univ Edinburgh and Bell Labs)
1 Overview of XPath. 2 XPATH XPath expressions are used to locate nodes in XML documents The list of nodes located by an XPath expression is called a.
A note on generating text with the xsl:value-of instruction.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Реализация XPath над S-выражениями 2007 Миленин Евгений, гр. 544 Кафедра Системного Программирования Математико-Механический ф-т, СПбГУ Научный руководитель:
XPATH neral/examples.html.
XPath Carissa Mills Jill Kerschbaum. What is XPath? n A language designed to be used by both XSL Transformations (XSLT) and XPointer. n Provides common.
Lecture 12. Default Processing in XSLT The default processing in XSLT is to process the XPath root node The default processing for various node types.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
Xpath Sources:
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
XPath XPath is used to navigate through elements and attributes in an XML document. XPath is a major element in W3C's XSLT standard - and XQuery and XPointer.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
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.
Sofia, Bulgaria | 9-10 October Using XQuery to Query and Manipulate XML Data Stephen Forte CTO, Corzen Inc Microsoft Regional Director NY/NJ (USA) Stephen.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
XPath Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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.
Nikos dimitrakas – IS4/2i1242/2i4042 spring XML Query Languages Database Systems (4th edition) Chapter 30.5, , Articles & Excerpts.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer.
Information Management XML and Databases hussein suleman uct cs
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
Database Systems Part VII: XML Querying Software School of Hunan University
XPath Aug ’10 – Dec ‘10. XPath   XML Path Language   Technology that allows to select a part or parts of an XML document to process   XPath was.
XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello January 29, 2014.
XQuery Leah Andrews. Overview  Queries data stored in XML trees  Declarative  High-level  Functional (no side effects)  Strongly typed  Nodes 
WPI, MOHAMED ELTABAKH PROCESSING AND QUERYING XML 1.
1 XML Data Management XPath Principles Werner Nutt.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
Designing Streamable XPath Expressions Roger L. Costello January 5,
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
© 2013 The MITRE Corporation. All rights reserved. XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello, February 3, 2014.
SDPL 2005Notes 7: XQuery1 7 Querying XML n How to access different sources (DBs, docs) as XML? n XQuery, W3C XML Query Language –"work in progress", (last.
XML Query languages--XPath. Objectives Understand XPath, and be able to use XPath expressions to find fragments of an XML document Understand tree patterns,
Dongwon Lee, Ph.D. IST 516 Fall 2011
Querying and Transforming XML Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Querying XML XQuery.
Querying XML XQuery.
XML Path Language Andy Clark 17 Apr 2002.
Querying XML XPath.
Querying XML XPath.
Modified Slides from Dr. Sagiv
Modified Slides from Dr. Sagiv
Presentation transcript:

Подход к реализации XQuery Паращенко Олег Санкт-Петербургский Государственный Университет Обнинск, 2004

XML Hello Hello, World ! article / ”“!” “World”

… … Простой XPath Похож на путь к файлу /usr/bin/xmllint

Простой XPath Результат — множество узлов /AAA/CCC

// Поиск по всему поддереву //DDD/BBB

* Любое имя /AAA/*/*/BBB

@ Атрибут

Оси навигации child::ename descendant::enam e parent::node() attribute::aname self::node() ancestor following-sibling preceding-sibling … ename

Фильтрация (/AAA/BBB)[1](/AAA/BBB)[last()]

Фильтрация, функции //bin[vim] //bin/*[contains(name(), 'vi')]

Запросы не для XPath Обратные ссылки /... /xxx//... /yyy//... [..?xxx..?yyy...] Создание элементов, переименование

Пример XQuery Here is a query. doc("books.xml")//book[1]/title Here is the result of the above query. { doc("books.xml")//book[1]/title } Here is a query. doc("books.xml")//book[1]/title Here is the result of the above query. TCP/IP Illustrated

FLWOR (“flower”) expressions for—let—where—order by—return for $i in (1, 2, 3) return { $i } 1 2 3

define function toc($book-or-section as element()) as element()* { for $section in $book-or-section/section return { $section/title, toc($section) } } { for $s in doc("xquery-book.xml")/book return toc($s) } Функции

Ресурсы Спецификации А.Валиков “Технология XSLT” “XQuery from the Experts: A Guide to the W3C XML Query Language” by Howard Katz, D. D. Chamberlin

Подход к реализации XQuery Паращенко Олег Санкт-Петербургский Государственный Университет Обнинск, 2004 (продолжение)

XPath vs “вручную” get_elem("elemname[i]") vs /** * Returns child element at given position. Position can be * negative. In this case nodes are counting from end. * Last node position is '-1'. node parent node name name of node, null if not important pos position of node starting from zero, can be negative */ public static Element getChildElement (Element node, String name, int s) { // // Update position to be always positive. // boolean fromEnd = pos < 0; if (fromEnd) { pos = -(pos + 1); } // // Initialize // Node cur_node = fromEnd ? node.getLastChild(): node.getFirstChild(); int cur_pos = -1; // // Walk on children // for (; cur_node != null; cur_node = (fromEnd ? cur_node.getPreviousSibling() : cur_node.getNextSibling ())) { // // Check that current node is of type 'element' // if (cur_node.getNodeType() != Node.ELEMENT_NODE) { continue; } // // Get element, check its name and position // Element cur_elem = (Element)cur_node; if ((name != null) && (! name.equals (cur_elem.getTagName()))) { continue; } cur_pos++; if (cur_pos == pos) { return cur_elem; } // // If node was found, it was returned from inside loop // return null; }

XPath vs “вручную” наглядность меньше кода – меньше ошибок и дополнительных расходов менее 1 минуты vs более 2 часов

Программы с деревьями find текстовые процессоры компиляторы, интерпретаторы встроенный xpath/xquery — “серебрянная пуля”

Единая реализация Библиотеки C vs Java vs.NET vs … Виртуальная машина ● Реализация XQuery на удобном языке программирования ● Байт-код ВМ ● Интерпретатор ВМ

Готовые реализации ● CL-XML ● SXML/SXPath/SXQuery Удобный язык ● Common Lisp или Scheme

SXML Hello Hello, World ! (*TOP* (article (id "hw")) (title "Hello") (para "Hello, " (object "World") "!"))) S-exp: XML:

SXPath ((txpath document) ((sxpath '(// TAF TRange *text*)) document) ((node-join (node-closure (node-typeof? 'TAF)) (select-kids (node-typeof? 'VALID)) (select-kids (node-typeof? (select-kids (node-typeof? 'TRange)) (select-kids (node-typeof? '*text*))) document)

Части системы SXQuery XQuery VM макрораскрытие, компиляция В программе: Интерпретатор ВМ Привязка (bindings) Парсер XML, XPath, XQuery

Этапы развития Сейчас – проверка идеи v.0.1: Python AST v.1.0: Docbook XSLT

Похожие системы Частично – любая реализация XPath/XQuery XSLTC от Oracle

Оптимизация (//ename)[1]

ВМ как исходный код e1 := _X(doc, “AAA//BBB/CCC”) e2 := _X(doc, “AAA//BBB/DDD”) t1 := child(doc, “AAA”) t2 := descendant(t1, “BBB”) e1 := child(t2, “CCC”) t3 := child(doc, “AAA”) t4 := descendant(t3, “BBB”) e2 := child(t4, “DDD”) t1 := child(doc, “AAA”) t2 := descendant(t1, “BBB”) e1 := child(t2, “CCC”) e2 := child(t2, “DDD”)

Другие ВМ Java VM.NET VM LLVM

Подход к реализации XQuery Паращенко Олег Санкт-Петербургский Государственный Университет Обнинск, 2004