XML Processing Moves Forward XSLT 2.0 and XQuery 1.0 - PowerPoint PPT Presentation

About This Presentation
Title:

XML Processing Moves Forward XSLT 2.0 and XQuery 1.0

Description:

Title: XQuery 1.0 The W3C Standards and the Tamino implementation Author: Software AG Last modified by: Michael Kay Created Date: 3/14/2003 2:02:32 PM – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 22
Provided by: Soft80
Category:

less

Transcript and Presenter's Notes

Title: XML Processing Moves Forward XSLT 2.0 and XQuery 1.0


1
XML Processing Moves Forward XSLT 2.0 and XQuery
1.0
  • Michael Kay
  • Prague 2005

2
About me
  • Database background
  • Started using XML in 1998 for content management
    applications
  • Author of XSLT Programmers Reference
  • Developer of Saxon XSLT processor
  • Member of W3C XSL and XQuery Working Groups
  • Founded SAXONICA March 2004

3
Contents
  • A tour of the new specs
  • Whats significant about XSLT 2.0
  • A quick demo
  • Why XQuery?

4
The QT Specification Family
XSLT 2.0
XQuery 1.0
FunctionsandOperators
XPath 2.0
Data Model
XML Schema
5
Standards maturity
XSLT 1.0XPath 1.0
XMLSchema
XML
Maturity
XQueryXSLT 2.0XPath 2.0
REC
CR
Time
6
A family of standards
XQuery 1.0
XPath 2.0
XSLT 2.0
XPath 1.0
XSLT 1.0
XML Schema
7
XSLT and XQuery
Documents
Data
XSLT
XQuery
8
Whats new in XSLT 2.0
  • New Processing Model
  • Major Features
  • grouping
  • regular expressions
  • functions
  • schema support
  • Many minor features

9
Some minor features
  • XSLT 2.0
  • Temporary trees
  • Multiple Output Files
  • Format date/time
  • Tunnel parameters
  • Declared variable types
  • Multi-mode templates
  • xslnext-match
  • conditional compilation
  • XHTML serialization
  • xslnamespace
  • separator,
  • character maps
  • XPath 2.0
  • Sequences
  • if..then..else
  • for x in X return f(x)
  • some/every
  • except/intersect
  • n is m
  • Function library
  • String functions
  • Regex functions
  • Date/time arithmetic
  • URI handling
  • min(), max(), avg()

10
Handling unstructured text
  • unparsed-text() function
  • reads a text file into a string
  • tokenize() function
  • splits a string into substrings
  • xslanalyze-string
  • parses a string and generates markup

11
Regular expression functions
  • matches()
  • test if a string matches a regex
  • if (matches(in, A-Z30-93)
  • tokenize()
  • split a string into substrings
  • regex matches the separator
  • for s in tokenize(in, ,\s?) ...
  • replace()
  • replace every occurrence of a match
  • replace(in, \s, 20)

12
Grouping
  • Takes any sequence as input
  • Divides the items into groups
  • Applies processing to each group

group-by items with a common value for a
grouping keygroup-adjacent adjacent items with
a common grouping key group-starting-with patter
n to match first item in each group group-ending-w
ith pattern to match last item in each group
13
Grouping by Value
ltxslfor-each-group selectbook
group-bypublishergt
ltxslsort selectcurrent-grouping-key()/gt
lth2gtPublisher ltxslvalue-of
selectcurrent-grouping-key/gt lt/h2gt
ltxslfor-each selectcurrent-group()/gt
ltxslsort selecttitle/gt ltpgtauthor
ltxslvalue-of selectauthor/gtlt/pgt
ltpgttitle ltxslvalue-of selecttitle/gtlt/pgt
lt/xslfor-eachgt lt/xslfor-each-groupgt
14
User-defined Functions
  • Written like named templates
  • Called from XPath
  • Return a result

ltxslfunction namegeddate-to-ISO
asxsdategt ltxslparam namein
asgeddate/gt ltxslsequence selectxsdate(conc
at( substring(in, 8, 4), -
format-number(index-of((JAN, FEB, ...),
substring(in, 4, 3)), 00), -,
substring(in, 1, 2)))/gt lt/xslfunctiongt ltxslso
rt selectgeddate-to-ISO(_at_birth-date)/gt
15
XQuery 1.0
  • Designed to query XML databases
  • Also handles in-memory transformations
  • Well supported by database vendors

16
XQuery ExampleJoin two tables
xquery version 1.0 ltresultsgt for p in doc
("auction.xml")/site/people/person let a
for t in doc("auction.xml")
/site/closed_auctions/closed_auction
where t/buyer/_at_person p/_at_id
return t return ltitem person"p/name"gt
count (a) lt/itemgt lt/resultsgt
XMark Q8
17
XSLT Equivalent
ltresult xslversion"1.0" xmlnsxsl"http//www.w3
.org/1999/XSL/Transform"gt ltxslfor-each
select"/site/people/person"gt ltxslvariable
name"a" select"/site/closed_auctions/clo
sed_auction
buyer/_at_person current()/_at_id"/gt ltitem
person"name"gt ltxslvalue-of
select"count(a)"/gt lt/itemgt
lt/xslfor-eachgt lt/resultgt
XMark Q8
18
Optimization
  • With multi-GB databases, using indexes is
    essential
  • XQuery does not have template rules
  • This makes it possible to do static analysis and
    join optimization

19
XMark Q8 results (msecs)
20
Two can play at that game!
1Mb
XSLT
4Mb
10Mb
Xalan
1503
11006
65855
O(n2)
xt
160
2253
16414
MSXML
33
519
4248
Saxon 8.5
27
26
45
O(n)
XQuery
Saxon 8.5
16
16
31
Qizx
351
711
1813
Galax
1870
6672
16625
caveat this is one query only!
21
Conclusions
  • XSLT 2.0 and XQuery 1.0 are nearly ready
  • XSLT 2.0 has many powerful new features, making
    new applications possible
  • XQuery 1.0 designed for optimization against very
    large databases
Write a Comment
User Comments (0)
About PowerShow.com