XQuery and XSLT http w 3 orgPeoplefsasakiqttutorial ppt

  • Slides: 86
Download presentation
XQuery and XSLT http: //w 3. org/People/fsasaki/qt-tutorial. ppt Felix Sasaki World Wide Web Consortium

XQuery and XSLT http: //w 3. org/People/fsasaki/qt-tutorial. ppt Felix Sasaki World Wide Web Consortium 1

Purpose General overview of XSLT 2. 0 and XQuery 1. 0: Common features, differences,

Purpose General overview of XSLT 2. 0 and XQuery 1. 0: Common features, differences, future perspectives 2

Background: Who am I? • Topic 1: Japanese and Linguistics: 私 は 鰻 です

Background: Who am I? • Topic 1: Japanese and Linguistics: 私 は 鰻 です 。。 ワタシ 私 名詞-代名詞-一般 ハ は 助詞-係助詞 ウナギ 鰻 名詞-一般 デス です 助動詞 特殊・デス 基本形 。 記号-句点 • Topic 2: Representation and processing of multilingual data based on standard technologies & formats: <s> <w type="名詞-代名詞-一般">私</w>. . . </s> 3

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 4

Introduction • 17 (!) specifications about "XQuery" and "XSLT", abbreviated as "QT" • A

Introduction • 17 (!) specifications about "XQuery" and "XSLT", abbreviated as "QT" • A complex architecture • QT describes input, processing and output of XML data 5

The different pieces of the cake 1. The common underpinning of XQuery and XSLT:

The different pieces of the cake 1. The common underpinning of XQuery and XSLT: XPath 2. 0 data model & formal semantics 2. How to select information in XML documents: XPath 2. 0 3. Manipulating information: XPath functions and operators 4. Generating output: Serialization 5. The XQuery 1. 0 and XSLT 2. 0 specifications, which deploy 1 -4 6

The different pieces of the cake FLWOR Expressions XML Constructors Query Prolog User-Defined Functions

The different pieces of the cake FLWOR Expressions XML Constructors Query Prolog User-Defined Functions Conditional Expressions Arithmetic Expressions Quantified Expressions Built-In Functions and Operators Data Model XPath 2. 0 XQuery 1. 0 XSLT 2. 0 Stylesheets Templates Formatting XPath 1. 0 Path Expressions Comparison Expressions Some Built-In Functions 7 Graphic based on XQuery tutorial from Priscilla Walmsley (Datypic)

Attention! Basis of this presentation: A set of WORKING DRAFTS! Things might still change!

Attention! Basis of this presentation: A set of WORKING DRAFTS! Things might still change! 8

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 9

Information processed by XQuery / XSLT Input: XML documents, XML database, XML Schema QT-Processing

Information processed by XQuery / XSLT Input: XML documents, XML database, XML Schema QT-Processing QT processing: defined in terms of XPath 2. 0 data model 10 Serialization: XML documents, XML database, …

Information processed by XQuery / XSLT • Input: XML documents: <my. Doc>. . .

Information processed by XQuery / XSLT • Input: XML documents: <my. Doc>. . . </my. Doc> • Input: XML Schema documents <xs: element name="my. Doc"> … </xs: element> 11

Information processed by XQuery / XSLT • Input: Type information based on user defined

Information processed by XQuery / XSLT • Input: Type information based on user defined XML Schema data types: <xs: element name="my. Doc" type="myns: my. Type"> … </xs: element> • Type information can be deployed for XQuery / XSLT processing: element(*, myns: my. Type) 12

Information processed by XQuery / XSLT • Predefined XML Schema data types • Examples:

Information processed by XQuery / XSLT • Predefined XML Schema data types • Examples: built in primitive data types like any. URI, date. Time, g. Year. Month, g. Year, … • Specially for XPath 2. 0: xdt: day. Time. Duration • Good for: URI processing, time related processing • Type casting for built in data types: xs: date("2005 -07 -12+07: 00") 13

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 14

XPath 2. 0 data model: • sequences of items, i. e. nodes … –

XPath 2. 0 data model: • sequences of items, i. e. nodes … – document node – element nodes: <my. Doc>…</my. Doc> – attribute nodes: <my. El my. Attr="my. Val 1"/> – namespace nodes: <myns: my. El>…</myns: my. El> – text nodes: <p>My <em>yellow</em> (and small) flower. </p> – comment node: <!-- my comment --> – processing instruction: <? my-pi … ? > • and / or atomic values (see below) 15

Visualization of nodes <my. Doc> <my. El my. Attr="my. Val 1"/> <my. El my.

Visualization of nodes <my. Doc> <my. El my. Attr="my. Val 1"/> <my. El my. Attr="my. Val 2"/> </my. Doc> 1 document() mydoc. xml 2 4 attribute() my. Attr order of nodes is defined by document order: 1 -6 element() my. Doc 5 3 element() my. El 16 6 attribute() my. Attr

Atomic values • Nodes in XPath 2. 0 have string values and typed values,

Atomic values • Nodes in XPath 2. 0 have string values and typed values, i. e. a sequence of atomic values • "string" function: returns a string value, e. g. – string(doc("mydoc. xml")) 17

Deployment of types: Example for time related types • Extracting the timezone from a

Deployment of types: Example for time related types • Extracting the timezone from a date value: timezone-from-date (xs: date("2005 -07 -12+07: 00")) • output: PT 7 H 18

Not in the data model • . . . is: – Character encoding schema

Not in the data model • . . . is: – Character encoding schema – CDATA section boundaries – entity references – DOCTYPE declaration and internal DTD subset • All this information might get lost during XQuery / XSLT processing • Mainly XSLT allows the user to parameterize the output, i. e. the serialization of the data model 19

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 20

Path expressions <xsl: template match="my. Doc"> <your. Doc> <xsl: apply-templates/> </your. Doc> </xsl: template>

Path expressions <xsl: template match="my. Doc"> <your. Doc> <xsl: apply-templates/> </your. Doc> </xsl: template> … <xsl: template match="my. El"> <your. El your. Attr="{@my. Attr}"> </xsl: template>. . . xquery version "1. 0"; <your. Doc> { let $input : = doc("mydoc. xml") for $elements in $input//my. El return <your. El your. Attr= "$elements/@my. Attr"/> }</your. Doc> In both languages: selection of nodes in single or multiple documents. In XSLT: "patterns" as subset of XPath for template matching rules 21

Path steps: child axis child: : * document() mydoc. xml or child: : my.

Path steps: child axis child: : * document() mydoc. xml or child: : my. El attribute() my. Attr element() my. Doc element() my. El 22 element() my. El attribute() my. Attr

Path steps: parent axis parent: : document -node() document() mydoc. xml element() my. Doc

Path steps: parent axis parent: : document -node() document() mydoc. xml element() my. Doc attribute() my. Attr element() my. El 23 element() my. El attribute() my. Attr

Path steps: sibling axis preceding-sibling: : my. El document() mydoc. xml element() my. Doc

Path steps: sibling axis preceding-sibling: : my. El document() mydoc. xml element() my. Doc attribute() my. Attr element() my. El 24 element() my. El attribute() my. Attr

predicate expressions child: : * [position()>1] document() mydoc. xml element() my. Doc attribute() my.

predicate expressions child: : * [position()>1] document() mydoc. xml element() my. Doc attribute() my. Attr element() my. El 25 element() my. El attribute() my. Attr

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 26

General processing of XQuery / XSLT • XQuery: – Input: zero or more source

General processing of XQuery / XSLT • XQuery: – Input: zero or more source documents – Output: zero or more result documents • XSLT: – Input: zero or more source documents – Output: zero or more result documents • What is the difference? 27

An example • Processing input "mydoc. xml": <my. Doc> <my. El my. Attr="my. Val

An example • Processing input "mydoc. xml": <my. Doc> <my. El my. Attr="my. Val 1"/> <my. El my. Attr="my. Val 2"/> </my. Doc> • Desired processing output "yourdoc. xml": <your. Doc> <your. El your. Attr="my. Val 1"/> <your. El your. Attr="my. Val 2"/> </your. Doc> 28

XSLT <xsl: stylesheet …> <xsl: template match="/"> <xsl: apply-templates/>. . . </xsl: template> <xsl:

XSLT <xsl: stylesheet …> <xsl: template match="/"> <xsl: apply-templates/>. . . </xsl: template> <xsl: template match="my. El"> <your. El your. Attr="{@my. Attr}"> </xsl: template> <xsl: template match="my. Doc"> <your. Doc> <xsl: apply-templates/> </your. Doc> </xsl: template> </xsl: stylesheet> 29 • Template based processing • Traversal of input document, match of templates • "Push processing": Nodes from the input are pushed to matching templates

Templates and matching nodes document() a 1 mydoc. xml b 2 4 attribute() my.

Templates and matching nodes document() a 1 mydoc. xml b 2 4 attribute() my. Attr element() my. Doc c 3 6 c 5 element() my. El attribute() my. Attr b <xsl: template match="my. Doc"> <xsl: template match="/"> a <xsl: apply-templates/> </xsl: template> c <xsl: template match="my. El"> <your. El your. Attr="{@my. Attr}"> </xsl: template> <your. Doc> <xsl: apply-templates/> </your. Doc> </xsl: template> 30

XQuery xquery version "1. 0"; <your. Doc> { let $input : = doc("mydoc. xml")

XQuery xquery version "1. 0"; <your. Doc> { let $input : = doc("mydoc. xml") for $elements in $input//my. El return <your. El your. Attr="{$elements/@my. Attr}"/> } </your. Doc> 31 • "Pull processing": XPath expressions pull information out of document(s)

XQuery 1 document() mydoc. xml 2 4 5 3 attribute() my. Attr 1 element()

XQuery 1 document() mydoc. xml 2 4 5 3 attribute() my. Attr 1 element() my. Doc element() my. El xquery version "1. 0"; <your. Doc> { let $input : = doc("mydoc. xml") for $elements in $input//my. El 3 5 element() my. El 4 6 attribute() my. Attr return <your. El 6 your. Attr="{$elements/@my. Attr}"/> } </your. Doc> 32

When to use XSLT • Good for processing of mixed content, e. g. text

When to use XSLT • Good for processing of mixed content, e. g. text with markup. Example task: <para>My <emph>yellow</emph> <note>and small</note> flower. </para> should become <p>My <em>yellow</em> (and small) flower. </p> Solution: push processing of the <para> content: <xsl: template match="para"> <p><xsl: apply-templates/></p> </xsl: template> <xsl: template match="emph">…</xsl: template> … 33

When to use XQuery • Good for processing of multiple data sources in a

When to use XQuery • Good for processing of multiple data sources in a single or multiple documents via For Let Where Order -by Return (FLWOR) expressions • Example: creation of a citation index for $mybibl in doc("my-bibl. xml")//entry for $citations in doc("mytext. xml") //cite where $citations/@ref =$mybibl/@id return <citation section="{$citations/ancestor: : section/@id}"/> 34

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 35

Full Text Search: Objectives • Search for phrases, not substrings • Language based search

Full Text Search: Objectives • Search for phrases, not substrings • Language based search (e. g. using morphological information) • Token-based search • Application of stemming / thesauri 36

Full Text Search: Basics • "Word": character, n-gram, or sequence of characters returned by

Full Text Search: Basics • "Word": character, n-gram, or sequence of characters returned by a tokenizer • "Phrase": Sequence of words • "Sentence" and "Paragraph": Defined by the tokenizer 37

Full Text Search: Example • Applying stemming in a Query: for $b in /books/book

Full Text Search: Example • Applying stemming in a Query: for $b in /books/book where $b/title ftcontains ("dog" with stemming) && "cat" return $b/author 38

Full Text Search: Example • Language specification: /book[@number="1"]//editor ftcontains "salon de the" with default

Full Text Search: Example • Language specification: /book[@number="1"]//editor ftcontains "salon de the" with default stop words language "fr" 39

Full Text Search: Example • Score specification: for $b score $s in /books/book[content ftcontains

Full Text Search: Example • Score specification: for $b score $s in /books/book[content ftcontains "web site" && "usability"] where $s > 0. 5 order by $s descending return <result>…</result> 40

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2.

Topics • • • Introduction Interplay between the components The common underpinning: XPath 2. 0 Path expressions General processing of XQuery / XSLT Future: Full text search 41

XQuery and XSLT http: //w 3. org/People/fsasaki/qt-tutorial. ppt Felix Sasaki World Wide Web Consortium

XQuery and XSLT http: //w 3. org/People/fsasaki/qt-tutorial. ppt Felix Sasaki World Wide Web Consortium 42

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General processing of XQuery / XSLT • String and number processing • IRI processing • Dates, timezones, language information • Generating output: serialization 43

Aspects of string processing • • What is the scope: characters (code points) String

Aspects of string processing • • What is the scope: characters (code points) String counting Codepoint conversion String comparison: collations String comparison: regular expressions Normalization The role of schemas e. g. in the case of white space handling 44

Scope of string processing • Basic operation: Counting 'characters' • Good message: QT counts

Scope of string processing • Basic operation: Counting 'characters' • Good message: QT counts code points, not bytes or code units • Attention: All string processing uses string values, not typed values! 45

String values versus typed values string-length($my. Doc/my. El/revision-date@) string-length(xs: string($my. Doc/my. El/revisiondate@)) • With

String values versus typed values string-length($my. Doc/my. El/revision-date@) string-length(xs: string($my. Doc/my. El/revisiondate@)) • With a schema: type of @revision-date = xs: date • Works not works 46

String values versus typed values • Difference: second example uses adequate type casting •

String values versus typed values • Difference: second example uses adequate type casting • Type casting is not always possible: http: //www. w 3. org/TR/xpathfunctions/#casting-from-primitive-to-primitive 47

Codepoints versus strings: XQuery <text>{"string to code points: su&#x. E 7; on becomes ",

Codepoints versus strings: XQuery <text>{"string to code points: su&#x. E 7; on becomes ", string-to-codepoints("su&#x. E 7; on"), "code points to string: 115 117 231 110 becomes ", codepoints-to-string((115, 117, 231, 110)) }</text> <text> string to code points: suçon becomes 115 117 231 110. code points to string: 115 117 231 110 becomes suçon </text> 48

Codepoints versus strings: XSLT <text> <xsl: text>string to code points: su&#x. E 7; on

Codepoints versus strings: XSLT <text> <xsl: text>string to code points: su&#x. E 7; on becomes </xsl: text> <xsl: value-of select=" string-to-codepoints('su&#x. E 7; on')"/> <xsl: text>. code points to string: 115 117 231 110 becomes </xsl: text> <xsl: value-of select=" codepoints-to-string((115, 117, 231, 110))"/> </text> 49

Collation functions: compare() • Returns "0": <xsl: value-of select="compare('abc', 'abc')"/> compare("abc", "abc") • Returns

Collation functions: compare() • Returns "0": <xsl: value-of select="compare('abc', 'abc')"/> compare("abc", "abc") • Returns "-1": <xsl: value-of select="compare('abc', 'bbc')"/> • Returns "1": <xsl: value-of select="compare('bbc', 'abc')"/> 50

Collation based function compare() • Identification of collation via an URI. • Example: returns

Collation based function compare() • Identification of collation via an URI. • Example: returns "1" if 'my. Collation' describes the order respectively: <xsl: value-of select"compare('Strasse', 'Straße', 'my. Collation')"/> compare("Strasse", "Straße", "my. Collation") 51

Collation identification • Identification via an URI. Codepoint-based collation: http: //www. w 3. org/2005/04/xpathfunctions/collation/codepoint

Collation identification • Identification via an URI. Codepoint-based collation: http: //www. w 3. org/2005/04/xpathfunctions/collation/codepoint • Parameterization via an URI: http: //my. Qt. Processor. com/collation? lang=de; strength=primary 52

String comparison: regular expressions • Based on regular expressions for XML Schema datatypes, with

String comparison: regular expressions • Based on regular expressions for XML Schema datatypes, with some additions • Flags for case mapping based on Unicode case mapping tables: <xsl: value-of select=" matches('my. Love', 'mylove', 'i')"/> 53

Normalization • XML documents: not always with early unicode normalization • Unicode collation algorithm

Normalization • XML documents: not always with early unicode normalization • Unicode collation algorithm ensures equivalent results • Normalization can be ensured for NCF, NFD, NFKC, NFKD: <xsl: value-of select=" unicode-normalize('suc&#x 0327; on', 'NFC')"/> • Output: su&#x. E 7; on 54

White space and typed values • Assuming a type for @lastname: <person lastname="Dr. &#x

White space and typed values • Assuming a type for @lastname: <person lastname="Dr. &#x 20; No"/> • Comparison of typed values via eq <xsl: value-of select=" string($my. Doc/person/@lastname) eq 'Dr. &#x 20; No' "/> • Collation might also affect white space handling 55

White space and typed values • Result: "false" or "true": – "false" if type

White space and typed values • Result: "false" or "true": – "false" if type of @lastname collapses whitespace – "true" if type of @lastname does not collapse whitespace 56

Number processing: rounding • number / currency formatting: round(2. 5) returns 3. round(2. 4999)

Number processing: rounding • number / currency formatting: round(2. 5) returns 3. round(2. 4999) returns 2. round(-2. 5) returns -2 • does not deploy culture specific rounding conventions, e. g. – round 3 rd digit less than 3 to 0 or drop it (Argentina) 57

XSLT-specific: Numbering • Conversion of numbers into a string, controlled by various attributes: <xsl:

XSLT-specific: Numbering • Conversion of numbers into a string, controlled by various attributes: <xsl: number value="position()" format="Ww" lang="de" ordinal="-e" /> <xsl: number value="position()" format="&#x 30 A 2; "/> <!-- &#x 30 A 2; is ア--> <xsl: number value="position()" format="๑"/> <!– ๑ is &#x 30 A 2; --> 58

XSLT-specific: Numbering • Output for a sequence of three items: Ersteア๑ Zweiteイ๒ Dritteウ๓ 59

XSLT-specific: Numbering • Output for a sequence of three items: Ersteア๑ Zweiteイ๒ Dritteウ๓ 59

XSLT-specific: Numbering • format-number(): designed for numeric quantities (not necessarily whole numbers) 60

XSLT-specific: Numbering • format-number(): designed for numeric quantities (not necessarily whole numbers) 60

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General processing of XQuery / XSLT • String and number processing • IRI processing • Dates, timezones, language information • Generating output: serialization 61

Status of IRI in QT • In the data model: Support for IRI will

Status of IRI in QT • In the data model: Support for IRI will be normative. • data type xs: any. URI: relies on xml schema any. URI, still defined in terms of URI 62

Functions for IRI / URI processing • casting to xs: any. URI: from untyped

Functions for IRI / URI processing • casting to xs: any. URI: from untyped values or string: xs: any. URI("http: //example. mü ller. com") 63

Functions for IRI / URI processing • escaping URI via escape-uri, escapedreserved="false" escape-uri ("http:

Functions for IRI / URI processing • escaping URI via escape-uri, escapedreserved="false" escape-uri ("http: //example. dü rst. com", false()) • output: http: //example. d%C 3%BCrst. com 64

Functions for IRI / URI processing • output with escaped-reserved="true": http%3 A%2 F%2 Fexample.

Functions for IRI / URI processing • output with escaped-reserved="true": http%3 A%2 F%2 Fexample. d%C 3%BCrst. com 65

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General processing of XQuery / XSLT • String and number processing • IRI processing • Dates, timezones, language information • Generating output: serialization 66

Dates and time types • Basis: – date and time types from XML Schema

Dates and time types • Basis: – date and time types from XML Schema – QT specific extensions: xdt: year. Month. Duration, xdt: day. Time. Duration • Operations: time comparison, time adjustment, timezone sensitive operations 67

Comparison of date types • Comparison of date types: xdt: year. Month. Duration("P 1

Comparison of date types • Comparison of date types: xdt: year. Month. Duration("P 1 Y 6 M") eq xdt: year. Month. Duration("P 1 Y 7 M") • output: false 68

Component extraction • Extracting the timezone from a date value: timezone-from-date (xs: date("2005 -07

Component extraction • Extracting the timezone from a date value: timezone-from-date (xs: date("2005 -07 -12+07: 00")) • output: PT 7 H 69

Arithmetic functions on dates and times • Subtract day. Time. Durations: xdt: day. Time.

Arithmetic functions on dates and times • Subtract day. Time. Durations: xdt: day. Time. Duration("P 2 DT 12 H") xdt: day. Time. Duration("P 2 DT 12 H 30 M") • output: -PT 30 M 70

XSLT: Formatting Dates / Times • Some parameters formatting conventions: picture string with [components];

XSLT: Formatting Dates / Times • Some parameters formatting conventions: picture string with [components]; presentation modifier; language <xsl: value-of select="format-date(xs: date('200509 -07'), '[MNn] [D 1 o] [Y]', 'en', ())"/> <xsl: value-of select="format-date(xs: date('200509 -07'), '[D 1 o] [MNn] [Y]', 'de', ())"/> 71

XSLT: Formatting Dates / Times • Output: September 7 th 2005 7. September 2005

XSLT: Formatting Dates / Times • Output: September 7 th 2005 7. September 2005 72

Processing of language information • function lang: /my. Root/my. El/text()[lang("de")] • returns the content

Processing of language information • function lang: /my. Root/my. El/text()[lang("de")] • returns the content of <my. El>, assuming the document: <my. Root xml: lang="de"> <my. El>Some german text. </my. El> </my. Root>} 73

Processing of language information • no value for xml: lang("de") returns "false" 74

Processing of language information • no value for xml: lang("de") returns "false" 74

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General

Topics • Introduction • The common underpinning: XPath 2. 0 data model • General processing of XQuery / XSLT • String and number processing • IRI processing • Dates, timezones, language information • Generating output: serialization 75

Serialization – basic concept • XQuery / XSLT: process XML in terms of the

Serialization – basic concept • XQuery / XSLT: process XML in terms of the XPath 2. 0 data model • Output: described in terms of serialization parameters 76

Some serialization parameters • • byte-order-mark cdata-section-elements encoding escape-uri-attributes media-type normalization-form use-character-maps 77

Some serialization parameters • • byte-order-mark cdata-section-elements encoding escape-uri-attributes media-type normalization-form use-character-maps 77

Output methods • Pre-configuration of various serialization parameters for: – XML – XHTML –

Output methods • Pre-configuration of various serialization parameters for: – XML – XHTML – Text • XQuery: – Mandatory output method: XML, version="1. 0" – No need for implementations to support further serialization parameters 78

Output methods in XSLT • Provides support for serialization parameters and output methods via

Output methods in XSLT • Provides support for serialization parameters and output methods via – xsl: output • Support also not mandatory 79

XSLT character maps • Mapping characters to other characters • Desired output: <jsp: set.

XSLT character maps • Mapping characters to other characters • Desired output: <jsp: set. Property name="user" property="id" value='<%= "id" + id. Value %>'/> 80

XSLT character maps • Character map: <xsl: character-map name="jsp"> <xsl: output-character=" «" string="< %"/>

XSLT character maps • Character map: <xsl: character-map name="jsp"> <xsl: output-character=" «" string="< %"/> <xsl: output-character="» " string="%> "/> <xsl: output-character="§" string='"'/> </xsl: character-map> 81

Regular expressions with XSLT <xsl: template match="text()"> <xsl: analyze-string select=". " regex="&#x. E 001;

Regular expressions with XSLT <xsl: template match="text()"> <xsl: analyze-string select=". " regex="&#x. E 001; "> <xsl: matching-substring> <my. Char type="E 001"/> </xsl: matching-substring> <xsl: non-matching-substring> <xsl: value-of select=". "/> </xsl: non-matching-substring> </xsl: analyze-string> </xsl: template> 82

Regular expressions with XQuery xquery version "1. 0"; declare function local: expand. PUAChar($string as

Regular expressions with XQuery xquery version "1. 0"; declare function local: expand. PUAChar($string as xs: string, $char as xs: string) as item()* { if (contains($string, $char)) then (substring-before($string, $char), element my. Char { attribute code {string-tocodepoints($char)} }, local: expand. PUAChar(substring-after($string, $char)) else $string }; for $input in doc("replace-characters. xml")//text() return local: expand. PUAChar($input, "&#x. E 001; ") 83

Topics – finally! • Introduction • The common underpinning: XPath 2. 0 data model

Topics – finally! • Introduction • The common underpinning: XPath 2. 0 data model • General processing of XQuery / XSLT • String and number processing • IRI processing • Dates, timezones, language information • Generating output: serialization 84

Wrap up: Is it useful? Yes! • QT: a power tool for i 18

Wrap up: Is it useful? Yes! • QT: a power tool for i 18 n sensitive XML processing • Quite hard to digest, but very tasty • Some aspects of i 18 n related processing might be improved • Remember: It's still a set of working drafts. . . 85

I 18 n Sensitive Processing with XQuery and XSLT Felix Sasaki World Wide Web

I 18 n Sensitive Processing with XQuery and XSLT Felix Sasaki World Wide Web Consortium 86