CITA 330 Section 5 XPath. XSL XSL (Extensible Stylesheet Language) is the standard language for writing stylesheets to transform XML documents among different.

Slides:



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

Dr. Alexandra I. Cristea XPath and Namespaces.
Managing Data Exchange: XPath
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.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
XSL Transformations Lecture 8, 07/08/02. Templates The whole element is a template The match pattern determines where this template applies Result element(s)
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.
XPath Tao Wan March 04, What is XPath? n A language designed to be used by XSL Transformations (XSLT), Xlink, Xpointer and XML Query. n Primary.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
17 Apr 2002 XML Stylesheets Andy Clark. What Is It? Extensible Stylesheet Language (XSL) Language for document transformation – Transformation (XSLT)
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
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.
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.
XP ATH - XML Path Language. W HAT IS XP ATH ? XPath, the XML Path Language, is a query language for selecting nodes from an XML document.query languagenodesXML.
SD2520 Databases using XML and JQuery
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
Chapter 4 Web Pages Using Web Standards Chapter 3 XML – the ‘X’ in Ajax.
Navigating XML. Overview  Xpath is a non-xml syntax to be used with XSLT and Xpointer. Its purpose according to the W3.org is  to address parts of an.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
1/17 ITApplications XML Module Session 7: Introduction to XPath.
XML DOCUMENTS & DATABASES. Summary of Introduction to XML HTML vs. XML HTML vs. XML Types of Data Types of Data Basics of XML Basics of XML XML Syntax,
CSE3201/CSE4500 Information Retrieval Systems
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.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XSLT and XPath, by Dr. Khalil1 XSL, XSLT and XPath Dr. Awad Khalil Computer Science Department AUC.
WORKING WITH XSLT AND XPATH
1 Dr Alexiei Dingli XML Technologies X-Languages.
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.
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.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
1 Displaying XML Document Web and Database Management System.
More on XSLT 07. More on XSLT © Aptech Limited XPath  In this first lesson, XPath, you will learn to:  Define and describe XPath.  Identify nodes according.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 6. XML Path (XPath)
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
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.
Advanced Selenium.  XPath is used to navigate through elements and attributes in a document.  XPath includes over 100 built-in functions.  Functions.
ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method.
XPath Presented by Kushan Athukorala. 2 Agenda XPath XPath Terminology Selecting Nodes Predicates.
1 XML Data Management XPath Principles Werner Nutt.
Lesser Known Injections XML Injections AMol NAik.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
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.
#RefreshCache Effective XSLT Making use of XSLT to better customize your data. Daniel Hazelbaker Information Technology Manager High Desert Church
Advanced Objects. Agenda 2 Working with Websites & Applications ScriptOnce Helpful XPath Tips.
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
ACG 4401 XSLT Extensible Stylesheet Language for Transformations Presenting XML and XBRL.
5 Copyright © 2004, Oracle. All rights reserved. Navigating XML Documents by Using XPath.
XML Schema – XSLT Week 8 Web site:
Beginning XML 4th Edition.
XML and XPath.
{ XML Technologies } BY: DR. M’HAMED MATAOUI
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
XML Path Language Andy Clark 17 Apr 2002.
XML WITH CSS.
XPath 9-May-19.
XML DOCUMENTS & DATABASES
Xpath October 16, 2019 ICS 541: Xpath.
XPath 7-Dec-19.
Presentation transcript:

CITA 330 Section 5 XPath

XSL XSL (Extensible Stylesheet Language) is the standard language for writing stylesheets to transform XML documents among different dialects or into other languages XSL stylesheets are pure XML documents XSL includes three components: –XPath as a standard notation system for specifying subsets of elements in an XML document –XSLT (XSL Transformation) as an XML dialect for specifying XML transformation rules or stylesheets –XSL-FO for formatting XML documents

Example XML Document Gone with the Wind Movie Classic Star Trek TV Series Science fiction

Identifying XML Nodes with XPath Visualize all components in an XML document, including the elements, attributes and text, as graph nodes A node is connected to another node under it if the latter is immediately nested in the former or is an attribute or text value of the former The attribute names have as their prefix The sibling nodes are ordered as they appear in the XML document library dvd title format dvd title format

Path Expressions Path expressions are used to select nodes in an XML document An absolute location path starts with a slash / and has the general form of /step/step/… A relative location path does not start with a slash / and has the general form of step/step/… In both cases, the path expression is evaluated from left to right, and each step is evaluated in the current node set to refine it

Path Expressions Each step has the following general form: [axisName::]nodeTest[predicate] –the optional axis name specifies the tree- relationship between the selected nodes and the current node –the node test identifies a node type within an axis –zero or more predicates are for further refining the selected node set

Path Expressions ExpressionDescription nodeNameSelects all child nodes of the named node /Selects from the root node //Selects nodes in the document from the current node that match the selection no matter where they are.Selects the current node..Selects the parent of the current attributes text()Selects the text value of the current element *Selects any element any attribute node node()Selects any node of any kind (elements, attributes, …)

Path Expressions library: all the library elements in the current node set /library: the root element library library/dvd: all dvd elements that are children of library elements in the current node set //dvd: all dvd elements no matter where they are in the document (no matter how many levels they are nested in other elements) relative to the current node set library//title: all title elements that are descendants of the library elements in the current node set no matter where they are under the library elements all attributes that are named “id” relative to the current node set

Path Expressions /library/dvd/title/text(): the text values of all the title elements of the dvd elements /library/dvd[1]: the first dvd child element of library /library/dvd[last()]: the last dvd child element of library /library/dvd[last()-1]: the last but one dvd child element of library /library/dvd[position()<3]: the first two dvd child elements of library all dvd elements that have an id attribute the dvd element that has an id attribute with value 2

Path Expressions /library/dvd[genre='Classic']: all dvd child elements of library that have “Classic” as their genre value /library/dvd[genre='Classic']/title: all title elements of dvd elements of library that have “Classic” as their genre value /library/*: all the child nodes of the library element //*: all elements in the document all dvd elements that have any attribute //title | //genre: all title and genre elements in the document

Popular Axis Names Axis NameResult ancestorSelects all ancestors (parent, grandparent, etc.) of the current node ancestor-or-selfSelects all ancestors (parent, grandparent, etc.) of the current node and the current node itself attributeSelects all attributes of the current node childSelects all children of the current node descendantSelects all descendants (children, grandchildren, etc.) of the current node descendant-or-selfSelects all descendants (children, grandchildren, etc.) of the current node and the current node itself followingSelects everything in the document after the end tag of the current node following-siblingSelects all siblings after the current node namespaceSelects all namespace nodes of the current node parentSelects the parent of the current node precedingSelects everything in the document that is before the start tag of the current node preceding-siblingSelects all siblings before the current node selfSelects the current node

Path Expressions child::dvd: all dvd nodes that are children of the current node attribute::id: the id attribute of the current node child::*: all children of the current node attribute::*: all attributes of the current node child::text(): all text child nodes of the current node child::node(): all child nodes of the current node descendant::dvd: all dvd descendants of the current node ancestor::dvd: all dvd ancestors of the current node child::*/child::title: all title grandchildren of the current node

Arithmetic Expressions + add - subtract * multiply div (not / ) divide mod modulo (remainder)

Boolean Operators = means “equal to”(Notice it’s not == ) != means “not equal to” and (infix operator) or (infix operator) not() (function) The following are used for numerical comparisons only: < “less than” <= “less than or equal to” > “greater than” >= “greater than or equal to”

XPath Functions XPath contains a number of functions on node sets, numbers, and strings; here are a few of them: –count( elem ) counts the number of selected elements Example: //chapter[count(section)=2] selects chapter s with exactly two section children –name() returns the name of the element Example: //*[name()='section'] is the same as //section –starts-with( arg1, arg2 ) tests if arg1 starts with arg2 Example: //*[starts-with(name(), 'sec'] –contains( arg1, arg2 ) tests if arg1 contains arg2 Example: //*[contains(name(), 'ect')]

XPath Boolean Functions boolean() false() lang() not() true()

XPath Node-Set Functions count() id() last() local-name() name() namespace-uri() position()

XPath Numeric Functions ceiling() floor() number() round() sum()

XPath String Functions concat() contains() normalize-space() starts-with() string() string-length() substring() substring-after() substring-before() translate()