Top Banner
doubleSlash Net-Business GmbH Otto-Lilienthal-Str. 2 D-88046 Friedrichshafen http://blog.doubleSlash.de Edmund Hierlemann Tel.: 07541-70078-0 [email protected] »Workshop Technology Days 2008« Stand: Februar 2008 Version: 1.1 XSLT 2.0 und XPath 2.0
17

Neues von XSLT 2.0 und XPath 2.0

Dec 18, 2014

Download

Business

Oliver Belikan

Was tut sich neues in XSLT und XPATH 2.0?
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Neues von XSLT 2.0 und XPath 2.0

Folie 1

doubleSlash

Net-Business GmbH

Otto-Lilienthal-Str. 2

D-88046 Friedrichshafen

http://blog.doubleSlash.de

Edmund Hierlemann

Tel.: 07541-70078-0

[email protected]

»Workshop Technology Days 2008«

Stand: Februar 2008Version: 1.1

XSLT 2.0 und XPath 2.0

Page 2: Neues von XSLT 2.0 und XPath 2.0

Folie 2

Warum XSLT 2.0 und XPath 2.0?

XSLT 2.0 Features und Syntax.

Beispiel-Code.

XPath 2.0 Features und Syntax.

Beispiele-Code.

Welche XSLT-Prozessoren existieren?

Fragen?

»Überblick und Inhalt«Neuerungen zu den Versionen 2.0

>

>

>

>

>

Page 3: Neues von XSLT 2.0 und XPath 2.0

Folie 3

Spezifikationen 1.0 ist über 8 Jahre alt.

Verarbeitung erfolgt immer über Trees

(RTFs).

Rekursive Aufrufe als Workaround für

Schleifen.

Funktionen mit Rückgabe nicht möglich.

»Warum XSLT 2.0 und XPath 2.0«XSLT 1.0

>

>

>

>

>

Page 4: Neues von XSLT 2.0 und XPath 2.0

Folie

• Spezifikation ist über 8 Jahre alt.

• Typsicherheit.

• Keine Schleifen in XPath möglich.

• Keine if-then-else Möglichkeit in XPath.

• Stark eingeschränkte Anzahl an

Funktionen (Search-replace,…)

• ….

>

>

>

>

4

»Warum XSLT 2.0 und XPath 2.0«XPath 1.0

EXSLT bietet Workaround-Packages an.

>

>

Page 5: Neues von XSLT 2.0 und XPath 2.0

Folie 5

XSLT 2.0 und XPath 2.0 löst

viele Probleme…

…aber nicht alle.

»XSLT 2.0 und XPath 2.0«...da war doch noch was

Page 6: Neues von XSLT 2.0 und XPath 2.0

Folie

Beispiele gefällig?

6

»XSLT 2.0 und XPath 2.0«Features und Syntax

Page 7: Neues von XSLT 2.0 und XPath 2.0

Folie 7

»XSLT 2.0«Sequenzen

anstelle der RTF (result tree fragments) werden sequenzen erstellt

Listen aller möglichen typen

direkte Erzeugung mit (...)

<xsl:value-of select="(1,2,3,4,5,6)"/>

Separator

<xsl:value-of select="(1,2,3,4,5,6)" separator=", "/>

<xsl:variable name="sequence" select="(1,2,3,4,5,6,1,1,2)"/>

Distinct

<xsl:value-of select="distinct-

values($sequence)"/>

Reverse

<xsl:value-of select="reverse($sequence)"/>

RTF

<xsl:value-of

select="/personnel/person/name/given"/>

bei value-of select werden aufgrund der

Result-Sequenzen jetzt nicht nur der erste,

sondern alle knoten gefunden.

Page 8: Neues von XSLT 2.0 und XPath 2.0

Folie 8

»XSLT 2.0«Datentypen

string

double

integer

Boolean

aber auch:

dateTime

gDay

gMonth

anyURI

... uvm.

Datentypen sicherstellen

<xsl:variable name="test” as="xs:integer">12</xsl:variable>

<xsl:value-of select="$test instance of xs:integer"/>

Page 9: Neues von XSLT 2.0 und XPath 2.0

Folie 9

»XSLT 2.0«Funktionen

<!-- function addierer -->

<xsl:function name="a:addierer">

<!-- Datentyp-Unterstützung -->

<xsl:param name="number" as="xs:integer"/>

<xsl:param name="number2" as="xs:integer"/>

<xsl:value-of select="$number + $number2"/>

</xsl:function>

Page 10: Neues von XSLT 2.0 und XPath 2.0

Folie 10

»XSLT 2.0«Gruppen

<xsl:function name="a:group">

<xsl:param name="context"></xsl:param>

<xsl:for-each-group select="$context/person" group-by="origin">

<xsl:sort select="current-grouping-key()" order="descending" />

Origin: <xsl:value-of select="current-grouping-key()"/><br/>

<xsl:for-each select="current-group()" >

<xsl:value-of select="name/given"/><xsl:text> </xsl:text><xsl:value-of

select="name/family"/>

<xsl:if test="position() != last()">,</xsl:if>

</xsl:for-each>

<br/><br/>

</xsl:for-each-group>

</xsl:function>

Page 11: Neues von XSLT 2.0 und XPath 2.0

Folie 11

»XSLT 2.0«Analyze String mit Regexp Unterstützung

<xsl:template match="comment">

<xsl:analyze-string select="." regex="\S.*" flags="m">

<xsl:matching-substring>

<b><xsl:value-of select="." /></b><br/>

</xsl:matching-substring>

</xsl:analyze-string>

</xsl:template>

Page 12: Neues von XSLT 2.0 und XPath 2.0

Folie 12

»XPath 2.0«to-Operator

<xsl:value-of select="1 to 6"/>

keine rekursionen mehr

<xsl:for-each select="personnel/person">

<xsl:value-of select="name/given"/><xsl:text> </xsl:text><xsl:value-of

select="name/family"/>: Importance factor:

<xsl:for-each select="(1 to count(email))">

*

</xsl:for-each>

<br/>

</xsl:for-each>

Page 13: Neues von XSLT 2.0 und XPath 2.0

Folie 13

»XPath 2.0«Schleife und Bedingung

Schleife -> spart rekursive aufrufe

<xsl:value-of select="for $i in (1 to 6) return $i*2[$i > 2]"/>

If then else -> spart choose when

<xsl:variable name="test" as="xs:integer">100</xsl:variable>

<xsl:value-of select="if ($test ge 100) then 'gross' else 'klein'"/>

Page 14: Neues von XSLT 2.0 und XPath 2.0

Folie 14

»XPath 2.0«Suche und Datumsfunktionen

search-replace

<xsl:variable name="test" as="xs:string">doubleSlash ist super super Super

toll.</xsl:variable>

<xsl:value-of select="replace($test,'super','ganz')"/>

mit regexp

<xsl:value-of select="replace($test,'\W','&lt;br&gt;')" disable-output-

escaping="yes"/>

Datumsfunktionen

<xsl:variable name="heute" select="current-date()" as="xs:date"/>

normal

<xsl:value-of select="$heute"/>

formatiert

<xsl:value-of select="format-date($heute,'[D01].[M01].[Y0001]')"/>

Page 15: Neues von XSLT 2.0 und XPath 2.0

Folie 15

Folgende XSLT Prozessoren unterstützen die 2.0 Features

bislang:

Saxon 9b.

Altova XML 2008.

Keine konkreten Angaben,

ob und wann 2.0 eingeführt wird bei:

Xalan

Microsoft MSXML (.NET)

»XSLT 2.0 und XPath 2.0«Wann kann ich das jetzt nutzen?

Page 16: Neues von XSLT 2.0 und XPath 2.0

Folie 16

Thomas Meinike

http://www.iks.hs-merseburg.de/~meinike/

D. Pawson

http://www.dpawson.co.uk/xsl/rev2/rev2.html

Jeni Tennison

http://www.jenitennison.com/xslt/

W3C

http://www.w3.org/TR/xslt20/

http://www.w3.org/TR/xpath20/

»XSLT 2.0 und XPath 2.0«Referenzen

>

>

>

>

Page 17: Neues von XSLT 2.0 und XPath 2.0

Folie 17

doubleSlash

Net-Business GmbH

Otto-Lilienthal-Str. 2

D-88046 Friedrichshafen

http://blog.doubleSlash.de

»Kontaktiern Sie uns unter 07541-70078-0 oder [email protected]«

Vielen Dank!

Für mehr Informationen und weitere Fragen:

Edmund Hierlemann

Tel.: 07541-70078-0

[email protected]