SlideShare a Scribd company logo
1 of 20
Download to read offline
Tech Talk
BIBFRAME Working Group
17 November 2015
XPath, XSLT, and XQuery
Notes from the Library Juice Academy courses,“Introduction to XML” and
“Transforming and Querying XML with XSLT and XQuery”
Allison Jai O’Dell | AJODELL@ufl.edu || Hikaru Nakano | hnakano@mail.ufl.edu
Douglas Smith | dougsmith@uflib.ufl.edu || Gerald Langford | gerlang@uflib.ufl.edu
XML
“The Extensible Markup Language (XML) is a simple text-based format for
representing structured information: documents, data, configuration, books,
transactions, invoices, and much more. ” -- http://www.w3.org/standards/xml/core
XML Example
<?xml version="1.0" encoding="UTF-8"?>
<bunnies xmlns:food=“http://www.example.com/food”>
<bunny>
<name>Frances</name>
<breed>mini lop</breed>
<gender>female</gender>
<color>white with brown spots</color>
<birth>January 10, 2009</birth>
<food:fave>strawberries, parsley,
cilantro, carrots</food:fave>
</bunny>
<bunny status="RBB">
<name>Howard</name>
<breed>mixed, dwarf</breed>
<gender>male</gender>
<color>light brown agouti</color>
<birth>March 15, 2009</birth>
<death>September 1, 2012</death>
</bunny>
</bunnies>
• opening and closing tag
• case sensitive
• properly nested
• quoted attribute values
• opening XML declaration
• character encoding
• root element
• namespace declaration
XPath
Selects nodes from an XML document
http://www.w3schools.com/xsl/xpath_intro.asp
XPath Examples
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
Select all the title nodes:
/bookstore/book/title
Select all the year nodes, regardless of path:
//year
Select the title of the first book:
/bookstore/book[1]/title
Select price nodes with price>35:
/bookstore/book[price>35]/price
Select the attribute category "WEB" within book node; return titles
/bookstore/book[@category=“WEB”]/title
And you can use regular expressions!
http://www.w3schools.com/xsl/xpath_examples.asp
XSLT
eXtensible Stylesheet Language Transformations
Transforms XML documents into other documents
http://www.w3schools.com/xsl/default.asp
XSLT Overview
XSLT is used to transform an XML document into various types of documents, such as another
XML document, a web recognizable document (for example, HTML, XHTML, HTML5), and even
plain text documents.
How it works: The XSLT process utilizes XPath to navigate through the source tree and to identify
nodes in the source tree. The process then checks to see if the nodes that the XPath identifies
match a template that the user has defined. If a node matches a template, the transformation
defined in the template is performed.
Transformations using XSL
“A transformation in the XSLT language is expressed in the form of a stylesheet, whose syntax is
well-formed XML …
“The term stylesheet reflects the fact that one of the important roles of XSLT is to add styling
information to an XML source document, by transforming it into a document consisting of XSL
formatting objects (see [Extensible Stylesheet Language (XSL)]), or into another presentation-
oriented format such as HTML, XHTML, or SVG. However, XSLT is used for a wide range of
transformation tasks, not exclusively for formatting and presentation applications.”
-- http://www.w3.org/TR/xslt20/#what-is-xslt
How is XSLT used?
“If you make a purchase on eBay, or buy a book at Amazon, chances are that pretty much everything
you see on everyWeb page has been processed with XSLT. Use XSLT to process multiple XML
documents and to produce any combination of text, HTML and XML output. XSLT support is
shipped with all major computer operating systems today, as well as being built in to all majorWeb
browsers.”
-- http://www.w3.org/standards/xml/transformation
XSLT Example: XML to XML
Input:
ad.ufl.eduuflibdeptdataCatalogingAuthorities_&_Metadata_QualityBibFrameMeeting20151117pubmed_sample_xml_rev.docx
Output:
ad.ufl.eduuflibdeptdataCatalogingAuthorities_&_Metadata_QualityBibFrameMeeting20151117pubmed_sample_xslt_out.docx
XSLT Example: XML to XML
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/ArticleSet">
<xsl:element name="ArticleSet">
<xsl:for-each select="Article">
<xsl:element name="title"><xsl:value-of select="ArticleTitle"/></xsl:element>
<xsl:copy-of select="AuthorList"/>
<xsl:element name="pages"><xsl:text>pages </xsl:text><xsl:value-of select="FirstPage"/><xsl:text>-
</xsl:text><xsl:value-of select="LastPage"/></xsl:element>
<xsl:element name="link"><xsl:if
test="ArticleIdList/ArticleId[@IdType='doi']"><xsl:text>http://dx.doi.org/</xsl:text><xsl:value-of
select="ArticleIdList/ArticleId[@IdType='doi']"/></xsl:if></xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
XSLT Example: XML to HTML
Input:
<?xml-stylesheet type="text/xsl" href="quiz1.xsl"?>
<catalog>
<type>Image Catalog</type>
<image>
<id>entry.0001</id>
<preview>http://upload.wikimedia.org/wikipedia/commons/9/93/Waterhouse-sleep_and_his_half-
brother_death-1874.jpg</preview>
<title>Hypnos and Thanatos</title>
<artist>John Willian Waterhouse</artist>
<country>UK</country>
<medium>Painting</medium>
<year>1874</year>
<subject>Greek Mythology</subject>
</image>
</catalog>
XSLT Example: XML to HTML
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="catalog"/>
</xsl:template>
<xsl:template match="catalog">
<html>
<head>
<title>Quiz 1</title>
<style>
body {background-color: #000000}
h1 {color: #ffffff;
font-family: verdana}
h2 {color: #F6CEEC;
font-family: verdana}
p {color: #F6CEEC;
font-family: verdana}
</style>
</head>
<body>
<xsl:for-each select="image">
<p>
<xsl:variable name="preview" select="preview"></xsl:variable>
<img src="{$preview}" width="400px"/>
</p>
<h1>
<xsl:value-of select="title"/>
</h1>
<h2>
<b><xsl:value-of select="artist"/></b>
</h2>
<p>
Country: <xsl:value-of select="country" /><br />
Medium: <xsl:value-of select="medium" /><br />
Date: <xsl:value-of select="year" /><br />
Subject: <xsl:value-of select="subject" /><br />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XSLT Example: XML to HTML
Output:
http://allisonjai.com/lja/quiz1.xml
XQuery
Queries XML data
http://www.w3schools.com/xsl/xquery_intro.asp
XQuery Overview
There are a myriad of uses for XQuery including:
• querying XML documents and data sources that can output XML documents
• combining data from multiple sources
• transforming data
• generating reports from XML data
• building web and application services over XML data
There is some overlap in utility between XSLT and XQuery, but in general XQuery is more effective
in querying large structured and unstructured data sets and deriving data from large data sets.
FLWOR
XQuery works by combining the use of path expressions (XPaths) to access parts or fragments of
XML data and the use of FLWOR ("for", "let", "where", "order by", "return") expressions to process,
join, and return data.
http://www.w3ctutorial.com/xquery-basic/xquery-flwor
XQuery Example
Input:
XQuery Example
Query:
XQuery Example
Output:

More Related Content

What's hot

An Overview of the Biodiversity Heritage Library
An Overview of the Biodiversity Heritage LibraryAn Overview of the Biodiversity Heritage Library
An Overview of the Biodiversity Heritage LibraryMartin Kalfatovic
 
Lice on the Web: A workshop on the new Phthiraptera website
Lice on the Web: A workshop on the new Phthiraptera websiteLice on the Web: A workshop on the new Phthiraptera website
Lice on the Web: A workshop on the new Phthiraptera websiteVince Smith
 
Multilingual presentation ifla 2013 08-19
Multilingual presentation ifla 2013 08-19Multilingual presentation ifla 2013 08-19
Multilingual presentation ifla 2013 08-19Janifer Gatenby
 
The library in the life of the user
The library in the life of the userThe library in the life of the user
The library in the life of the userlisld
 
Library futures: converging and diverging directions for public and academic ...
Library futures: converging and diverging directions for public and academic ...Library futures: converging and diverging directions for public and academic ...
Library futures: converging and diverging directions for public and academic ...lisld
 
Linked Data for African Libraries
Linked Data for African LibrariesLinked Data for African Libraries
Linked Data for African LibrariesGetaneh Alemu
 
What ami searching_hollis+articlestab
What ami searching_hollis+articlestabWhat ami searching_hollis+articlestab
What ami searching_hollis+articlestabEmily Singley
 
Linked Data Implementations—Who, What and Why?
Linked Data Implementations—Who, What and Why?Linked Data Implementations—Who, What and Why?
Linked Data Implementations—Who, What and Why?OCLC
 
Metadata for researchers
Metadata for researchers Metadata for researchers
Metadata for researchers Getaneh Alemu
 
Data Designed for Discovery
Data Designed for DiscoveryData Designed for Discovery
Data Designed for DiscoveryOCLC
 
VuFind @ Illinois #1 VuFind at the University of Illinois
VuFind @ Illinois #1 VuFind at the University of IllinoisVuFind @ Illinois #1 VuFind at the University of Illinois
VuFind @ Illinois #1 VuFind at the University of IllinoisJenny Emanuel
 
The role of metadata for discovery: tips for content providers
The role of metadata for discovery: tips for content providersThe role of metadata for discovery: tips for content providers
The role of metadata for discovery: tips for content providersGetaneh Alemu
 
How to access online catalogue, e resources etc @ TISS
How to access online catalogue, e resources etc @ TISSHow to access online catalogue, e resources etc @ TISS
How to access online catalogue, e resources etc @ TISSVeeresh Hanchinal
 
From the principle of sufficiency and necessity to metadata enriching
From the principle of sufficiency and necessity to metadata enrichingFrom the principle of sufficiency and necessity to metadata enriching
From the principle of sufficiency and necessity to metadata enrichingGetaneh Alemu
 

What's hot (20)

An Overview of the Biodiversity Heritage Library
An Overview of the Biodiversity Heritage LibraryAn Overview of the Biodiversity Heritage Library
An Overview of the Biodiversity Heritage Library
 
Lice on the Web: A workshop on the new Phthiraptera website
Lice on the Web: A workshop on the new Phthiraptera websiteLice on the Web: A workshop on the new Phthiraptera website
Lice on the Web: A workshop on the new Phthiraptera website
 
Multilingual presentation ifla 2013 08-19
Multilingual presentation ifla 2013 08-19Multilingual presentation ifla 2013 08-19
Multilingual presentation ifla 2013 08-19
 
The library in the life of the user
The library in the life of the userThe library in the life of the user
The library in the life of the user
 
Library futures: converging and diverging directions for public and academic ...
Library futures: converging and diverging directions for public and academic ...Library futures: converging and diverging directions for public and academic ...
Library futures: converging and diverging directions for public and academic ...
 
Linked Data for African Libraries
Linked Data for African LibrariesLinked Data for African Libraries
Linked Data for African Libraries
 
Social Work Subject Guide
Social Work Subject GuideSocial Work Subject Guide
Social Work Subject Guide
 
BIMM July 2021
BIMM July 2021BIMM July 2021
BIMM July 2021
 
Library tutorial
Library tutorial Library tutorial
Library tutorial
 
What ami searching_hollis+articlestab
What ami searching_hollis+articlestabWhat ami searching_hollis+articlestab
What ami searching_hollis+articlestab
 
Linked Data Implementations—Who, What and Why?
Linked Data Implementations—Who, What and Why?Linked Data Implementations—Who, What and Why?
Linked Data Implementations—Who, What and Why?
 
Metadata for researchers
Metadata for researchers Metadata for researchers
Metadata for researchers
 
A theory of Metadata enriching & filtering
A theory of  Metadata enriching & filteringA theory of  Metadata enriching & filtering
A theory of Metadata enriching & filtering
 
Data Designed for Discovery
Data Designed for DiscoveryData Designed for Discovery
Data Designed for Discovery
 
Get me my data !
Get me my data !Get me my data !
Get me my data !
 
VuFind @ Illinois #1 VuFind at the University of Illinois
VuFind @ Illinois #1 VuFind at the University of IllinoisVuFind @ Illinois #1 VuFind at the University of Illinois
VuFind @ Illinois #1 VuFind at the University of Illinois
 
How to access databases
How to access databasesHow to access databases
How to access databases
 
The role of metadata for discovery: tips for content providers
The role of metadata for discovery: tips for content providersThe role of metadata for discovery: tips for content providers
The role of metadata for discovery: tips for content providers
 
How to access online catalogue, e resources etc @ TISS
How to access online catalogue, e resources etc @ TISSHow to access online catalogue, e resources etc @ TISS
How to access online catalogue, e resources etc @ TISS
 
From the principle of sufficiency and necessity to metadata enriching
From the principle of sufficiency and necessity to metadata enrichingFrom the principle of sufficiency and necessity to metadata enriching
From the principle of sufficiency and necessity to metadata enriching
 

Viewers also liked

SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...
SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...
SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...Allison Jai O'Dell
 
JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...
JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...
JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...Allison Jai O'Dell
 
Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...
Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...
Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...Allison Jai O'Dell
 
Introducing the Artists' Books Thesaurus
Introducing the Artists' Books ThesaurusIntroducing the Artists' Books Thesaurus
Introducing the Artists' Books ThesaurusAllison Jai O'Dell
 
Understanding Regular expressions: Programming Historian Study Group, Univers...
Understanding Regular expressions: Programming Historian Study Group, Univers...Understanding Regular expressions: Programming Historian Study Group, Univers...
Understanding Regular expressions: Programming Historian Study Group, Univers...Allison Jai O'Dell
 
Big Metadata: Mining Special Collections Catalogs for New Knowledge
Big Metadata: Mining Special Collections Catalogs for New KnowledgeBig Metadata: Mining Special Collections Catalogs for New Knowledge
Big Metadata: Mining Special Collections Catalogs for New KnowledgeAllison Jai O'Dell
 
Cataloging Zines in an RDA Environment
Cataloging Zines in an RDA EnvironmentCataloging Zines in an RDA Environment
Cataloging Zines in an RDA EnvironmentAllison Jai O'Dell
 
Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...
Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...
Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...Allison Jai O'Dell
 
Teaching Linked Data to Librarians: A Discussion of Pedagogical Methods
Teaching Linked Data to Librarians: A Discussion of Pedagogical MethodsTeaching Linked Data to Librarians: A Discussion of Pedagogical Methods
Teaching Linked Data to Librarians: A Discussion of Pedagogical MethodsAllison Jai O'Dell
 
Defining Usefulness and Facilitating Access Based on Research Applications
Defining Usefulness and Facilitating Access Based on Research ApplicationsDefining Usefulness and Facilitating Access Based on Research Applications
Defining Usefulness and Facilitating Access Based on Research ApplicationsAllison Jai O'Dell
 
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...Allison Jai O'Dell
 
'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget
'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget
'I need help and FAST!': Immediate Guided Search with the assignFAST GadgetAllison Jai O'Dell
 
Cataloger 3.0: Competencies and Education for the BIBFRAME Catalog
Cataloger 3.0: Competencies and Education for the BIBFRAME CatalogCataloger 3.0: Competencies and Education for the BIBFRAME Catalog
Cataloger 3.0: Competencies and Education for the BIBFRAME CatalogAllison Jai O'Dell
 
Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...
Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...
Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...Allison Jai O'Dell
 
Descriptive Cataloging for Special Collections, University of Miami Libraries
Descriptive Cataloging for Special Collections, University of Miami LibrariesDescriptive Cataloging for Special Collections, University of Miami Libraries
Descriptive Cataloging for Special Collections, University of Miami LibrariesAllison Jai O'Dell
 
Studying the book arts in the 21st century: using Linked Data to enhance know...
Studying the book arts in the 21st century: using Linked Data to enhance know...Studying the book arts in the 21st century: using Linked Data to enhance know...
Studying the book arts in the 21st century: using Linked Data to enhance know...Allison Jai O'Dell
 
Designing Metadata to Meet User Needs for Special Collections
Designing Metadata to Meet User Needs for Special CollectionsDesigning Metadata to Meet User Needs for Special Collections
Designing Metadata to Meet User Needs for Special CollectionsAllison Jai O'Dell
 
Religions in Russia
Religions in RussiaReligions in Russia
Religions in RussiaSanechka1991
 

Viewers also liked (20)

SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...
SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...
SQL: University of Florida Libraries, Linked Data Working Group, Tech Talk 20...
 
JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...
JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...
JSON and Microdata: University of Florida Libraries, BIBFRAME Working Group, ...
 
Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...
Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...
Linked Data Principles and RDF: University of Florida Libraries, BIBFRAME Wor...
 
Introducing the Artists' Books Thesaurus
Introducing the Artists' Books ThesaurusIntroducing the Artists' Books Thesaurus
Introducing the Artists' Books Thesaurus
 
Understanding Regular expressions: Programming Historian Study Group, Univers...
Understanding Regular expressions: Programming Historian Study Group, Univers...Understanding Regular expressions: Programming Historian Study Group, Univers...
Understanding Regular expressions: Programming Historian Study Group, Univers...
 
Big Metadata: Mining Special Collections Catalogs for New Knowledge
Big Metadata: Mining Special Collections Catalogs for New KnowledgeBig Metadata: Mining Special Collections Catalogs for New Knowledge
Big Metadata: Mining Special Collections Catalogs for New Knowledge
 
Cataloging Zines in an RDA Environment
Cataloging Zines in an RDA EnvironmentCataloging Zines in an RDA Environment
Cataloging Zines in an RDA Environment
 
Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...
Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...
Towards a Framework for Linked Rare Materials Metadata: An Overview of the Ta...
 
Teaching Linked Data to Librarians: A Discussion of Pedagogical Methods
Teaching Linked Data to Librarians: A Discussion of Pedagogical MethodsTeaching Linked Data to Librarians: A Discussion of Pedagogical Methods
Teaching Linked Data to Librarians: A Discussion of Pedagogical Methods
 
Defining Usefulness and Facilitating Access Based on Research Applications
Defining Usefulness and Facilitating Access Based on Research ApplicationsDefining Usefulness and Facilitating Access Based on Research Applications
Defining Usefulness and Facilitating Access Based on Research Applications
 
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: Univer...
 
'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget
'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget
'I need help and FAST!': Immediate Guided Search with the assignFAST Gadget
 
Cataloger 3.0: Competencies and Education for the BIBFRAME Catalog
Cataloger 3.0: Competencies and Education for the BIBFRAME CatalogCataloger 3.0: Competencies and Education for the BIBFRAME Catalog
Cataloger 3.0: Competencies and Education for the BIBFRAME Catalog
 
Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...
Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...
Special Collections, Special Thesauri: Managing and Publishing Local Vocabula...
 
Using EAC-CPF
Using EAC-CPFUsing EAC-CPF
Using EAC-CPF
 
Descriptive Cataloging for Special Collections, University of Miami Libraries
Descriptive Cataloging for Special Collections, University of Miami LibrariesDescriptive Cataloging for Special Collections, University of Miami Libraries
Descriptive Cataloging for Special Collections, University of Miami Libraries
 
Studying the book arts in the 21st century: using Linked Data to enhance know...
Studying the book arts in the 21st century: using Linked Data to enhance know...Studying the book arts in the 21st century: using Linked Data to enhance know...
Studying the book arts in the 21st century: using Linked Data to enhance know...
 
Designing Metadata to Meet User Needs for Special Collections
Designing Metadata to Meet User Needs for Special CollectionsDesigning Metadata to Meet User Needs for Special Collections
Designing Metadata to Meet User Needs for Special Collections
 
Act 6
Act 6Act 6
Act 6
 
Religions in Russia
Religions in RussiaReligions in Russia
Religions in Russia
 

Similar to Transform XML with XSLT and XQuery

Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriyaIntegrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriyaVijiPriya Jeyamani
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xsltTUSHAR VARSHNEY
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slidesRussell Ward
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIRoselin Mary S
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLTMahmoud Allam
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld BookNet Canada
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)Serhii Kartashov
 
IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT IWMW
 
Xml transformation language
Xml transformation languageXml transformation language
Xml transformation languagereshmavasudev
 
Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet LanguageJussi Pohjolainen
 

Similar to Transform XML with XSLT and XQuery (20)

Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriyaIntegrative Programming and Technology Chapter 4- Dr. J. VijiPriya
Integrative Programming and Technology Chapter 4- Dr. J. VijiPriya
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xslt
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides
 
Xslt
XsltXslt
Xslt
 
Service Oriented Architecture - Unit II
Service Oriented Architecture - Unit IIService Oriented Architecture - Unit II
Service Oriented Architecture - Unit II
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
 
eXtensible Markup Language (XML)
eXtensible Markup Language (XML)eXtensible Markup Language (XML)
eXtensible Markup Language (XML)
 
Xsl xslt
Xsl  xsltXsl  xslt
Xsl xslt
 
IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT IWMW 2001: XML and XSLT
IWMW 2001: XML and XSLT
 
Xslt
XsltXslt
Xslt
 
Xslt
XsltXslt
Xslt
 
Xslt
XsltXslt
Xslt
 
Xml transformation language
Xml transformation languageXml transformation language
Xml transformation language
 
XML XSLT
XML XSLTXML XSLT
XML XSLT
 
Xml p5 Lecture Notes
Xml p5 Lecture NotesXml p5 Lecture Notes
Xml p5 Lecture Notes
 
XSL - XML STYLE SHEET
XSL - XML STYLE SHEETXSL - XML STYLE SHEET
XSL - XML STYLE SHEET
 
XSLT for Web Developers
XSLT for Web DevelopersXSLT for Web Developers
XSLT for Web Developers
 
Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet Language
 
Xml PPT
Xml PPTXml PPT
Xml PPT
 

Recently uploaded

Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 

Recently uploaded (20)

Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 

Transform XML with XSLT and XQuery

  • 1. Tech Talk BIBFRAME Working Group 17 November 2015 XPath, XSLT, and XQuery Notes from the Library Juice Academy courses,“Introduction to XML” and “Transforming and Querying XML with XSLT and XQuery” Allison Jai O’Dell | AJODELL@ufl.edu || Hikaru Nakano | hnakano@mail.ufl.edu Douglas Smith | dougsmith@uflib.ufl.edu || Gerald Langford | gerlang@uflib.ufl.edu
  • 2. XML “The Extensible Markup Language (XML) is a simple text-based format for representing structured information: documents, data, configuration, books, transactions, invoices, and much more. ” -- http://www.w3.org/standards/xml/core
  • 3. XML Example <?xml version="1.0" encoding="UTF-8"?> <bunnies xmlns:food=“http://www.example.com/food”> <bunny> <name>Frances</name> <breed>mini lop</breed> <gender>female</gender> <color>white with brown spots</color> <birth>January 10, 2009</birth> <food:fave>strawberries, parsley, cilantro, carrots</food:fave> </bunny> <bunny status="RBB"> <name>Howard</name> <breed>mixed, dwarf</breed> <gender>male</gender> <color>light brown agouti</color> <birth>March 15, 2009</birth> <death>September 1, 2012</death> </bunny> </bunnies> • opening and closing tag • case sensitive • properly nested • quoted attribute values • opening XML declaration • character encoding • root element • namespace declaration
  • 4. XPath Selects nodes from an XML document http://www.w3schools.com/xsl/xpath_intro.asp
  • 5. XPath Examples <?xml version="1.0" encoding="UTF-8"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="WEB"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore> Select all the title nodes: /bookstore/book/title Select all the year nodes, regardless of path: //year Select the title of the first book: /bookstore/book[1]/title Select price nodes with price>35: /bookstore/book[price>35]/price Select the attribute category "WEB" within book node; return titles /bookstore/book[@category=“WEB”]/title And you can use regular expressions! http://www.w3schools.com/xsl/xpath_examples.asp
  • 6. XSLT eXtensible Stylesheet Language Transformations Transforms XML documents into other documents http://www.w3schools.com/xsl/default.asp
  • 7. XSLT Overview XSLT is used to transform an XML document into various types of documents, such as another XML document, a web recognizable document (for example, HTML, XHTML, HTML5), and even plain text documents. How it works: The XSLT process utilizes XPath to navigate through the source tree and to identify nodes in the source tree. The process then checks to see if the nodes that the XPath identifies match a template that the user has defined. If a node matches a template, the transformation defined in the template is performed.
  • 8. Transformations using XSL “A transformation in the XSLT language is expressed in the form of a stylesheet, whose syntax is well-formed XML … “The term stylesheet reflects the fact that one of the important roles of XSLT is to add styling information to an XML source document, by transforming it into a document consisting of XSL formatting objects (see [Extensible Stylesheet Language (XSL)]), or into another presentation- oriented format such as HTML, XHTML, or SVG. However, XSLT is used for a wide range of transformation tasks, not exclusively for formatting and presentation applications.” -- http://www.w3.org/TR/xslt20/#what-is-xslt
  • 9. How is XSLT used? “If you make a purchase on eBay, or buy a book at Amazon, chances are that pretty much everything you see on everyWeb page has been processed with XSLT. Use XSLT to process multiple XML documents and to produce any combination of text, HTML and XML output. XSLT support is shipped with all major computer operating systems today, as well as being built in to all majorWeb browsers.” -- http://www.w3.org/standards/xml/transformation
  • 10. XSLT Example: XML to XML Input: ad.ufl.eduuflibdeptdataCatalogingAuthorities_&_Metadata_QualityBibFrameMeeting20151117pubmed_sample_xml_rev.docx Output: ad.ufl.eduuflibdeptdataCatalogingAuthorities_&_Metadata_QualityBibFrameMeeting20151117pubmed_sample_xslt_out.docx
  • 11. XSLT Example: XML to XML XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output method="xml" indent="yes" encoding="utf-8"/> <xsl:template match="/ArticleSet"> <xsl:element name="ArticleSet"> <xsl:for-each select="Article"> <xsl:element name="title"><xsl:value-of select="ArticleTitle"/></xsl:element> <xsl:copy-of select="AuthorList"/> <xsl:element name="pages"><xsl:text>pages </xsl:text><xsl:value-of select="FirstPage"/><xsl:text>- </xsl:text><xsl:value-of select="LastPage"/></xsl:element> <xsl:element name="link"><xsl:if test="ArticleIdList/ArticleId[@IdType='doi']"><xsl:text>http://dx.doi.org/</xsl:text><xsl:value-of select="ArticleIdList/ArticleId[@IdType='doi']"/></xsl:if></xsl:element> </xsl:for-each> </xsl:element> </xsl:template> </xsl:stylesheet>
  • 12. XSLT Example: XML to HTML Input: <?xml-stylesheet type="text/xsl" href="quiz1.xsl"?> <catalog> <type>Image Catalog</type> <image> <id>entry.0001</id> <preview>http://upload.wikimedia.org/wikipedia/commons/9/93/Waterhouse-sleep_and_his_half- brother_death-1874.jpg</preview> <title>Hypnos and Thanatos</title> <artist>John Willian Waterhouse</artist> <country>UK</country> <medium>Painting</medium> <year>1874</year> <subject>Greek Mythology</subject> </image> </catalog>
  • 13. XSLT Example: XML to HTML XSLT: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:apply-templates select="catalog"/> </xsl:template> <xsl:template match="catalog"> <html> <head> <title>Quiz 1</title> <style> body {background-color: #000000} h1 {color: #ffffff; font-family: verdana} h2 {color: #F6CEEC; font-family: verdana} p {color: #F6CEEC; font-family: verdana} </style> </head> <body> <xsl:for-each select="image"> <p> <xsl:variable name="preview" select="preview"></xsl:variable> <img src="{$preview}" width="400px"/> </p> <h1> <xsl:value-of select="title"/> </h1> <h2> <b><xsl:value-of select="artist"/></b> </h2> <p> Country: <xsl:value-of select="country" /><br /> Medium: <xsl:value-of select="medium" /><br /> Date: <xsl:value-of select="year" /><br /> Subject: <xsl:value-of select="subject" /><br /> </p> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
  • 14. XSLT Example: XML to HTML Output: http://allisonjai.com/lja/quiz1.xml
  • 16. XQuery Overview There are a myriad of uses for XQuery including: • querying XML documents and data sources that can output XML documents • combining data from multiple sources • transforming data • generating reports from XML data • building web and application services over XML data There is some overlap in utility between XSLT and XQuery, but in general XQuery is more effective in querying large structured and unstructured data sets and deriving data from large data sets.
  • 17. FLWOR XQuery works by combining the use of path expressions (XPaths) to access parts or fragments of XML data and the use of FLWOR ("for", "let", "where", "order by", "return") expressions to process, join, and return data. http://www.w3ctutorial.com/xquery-basic/xquery-flwor