SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
XSLT 2.0 und XPath 2.0

»Workshop Technology Days 2008«


Stand: Februar 2008
Version: 1.1




doubleSlash                  Edmund Hierlemann
Net-Business GmbH            Tel.: 07541-70078-0
Otto-Lilienthal-Str. 2       info@doubleSlash.de
D-88046 Friedrichshafen
http://blog.doubleSlash.de




                                                   Folie   1
»Überblick und Inhalt«
Neuerungen zu den Versionen 2.0


 >   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?


                                            Folie   2
»Warum XSLT 2.0 und XPath 2.0«
XSLT 1.0


 
 >   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.

 
 >   …


                                                 Folie   3
»Warum XSLT 2.0 und XPath 2.0«
XPath 1.0



  >•   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,…)

  >•   ….

               EXSLT bietet Workaround-Packages an.

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




                            XSLT 2.0 und XPath 2.0 löst
                            viele Probleme…




                           …aber nicht alle.




                                                          Folie   5
»XSLT 2.0 und XPath 2.0«
Features und Syntax




 Beispiele gefällig?




                           Folie   6
»XSLT 2.0«
Sequenzen


 anstelle der RTF (result tree        <xsl:variable name=quot;sequencequot;
  fragments) werden sequenzen erstellt select=quot;(1,2,3,4,5,6,1,1,2)quot;/>
 Listen aller möglichen typen
                                         Distinct
 direkte Erzeugung mit (...)            <xsl:value-of select=quot;distinct-
                                         values($sequence)quot;/>
<xsl:value-of select=quot;(1,2,3,4,5,6)quot;/>   Reverse
                                         <xsl:value-of select=quot;reverse($sequence)quot;/>

Separator                                RTF
                                         <xsl:value-of
<xsl:value-of select=quot;(1,2,3,4,5,6)quot;
                                         select=quot;/personnel/person/name/givenquot;/>
 separator=quot;, quot;/>
                                         bei value-of select werden aufgrund der
                                         Result-Sequenzen jetzt nicht nur der erste,
                                         sondern alle knoten gefunden.


                                                                                Folie   7
»XSLT 2.0«
Datentypen


 string     Datentypen sicherstellen
 double     <xsl:variable name=quot;test” as=quot;xs:integerquot;>12</xsl:variable>
 integer    <xsl:value-of select=quot;$test instance of xs:integerquot;/>
 Boolean


aber auch:
 dateTime
 gDay
 gMonth
 anyURI
 ... uvm.


                                                                     Folie   8
»XSLT 2.0«
Funktionen


<!-- function addierer -->
<xsl:function name=quot;a:addiererquot;>
 <!-- Datentyp-Unterstützung -->
 <xsl:param name=quot;numberquot; as=quot;xs:integerquot;/>
 <xsl:param name=quot;number2quot; as=quot;xs:integerquot;/>

 <xsl:value-of select=quot;$number + $number2quot;/>
</xsl:function>




                                               Folie   9
»XSLT 2.0«
Gruppen


<xsl:function name=quot;a:groupquot;>
     <xsl:param name=quot;contextquot;></xsl:param>
     <xsl:for-each-group select=quot;$context/personquot; group-by=quot;originquot;>
        <xsl:sort select=quot;current-grouping-key()quot; order=quot;descendingquot; />
        Origin: <xsl:value-of select=quot;current-grouping-key()quot;/><br/>
        <xsl:for-each select=quot;current-group()quot; >
           <xsl:value-of select=quot;name/givenquot;/><xsl:text> </xsl:text><xsl:value-of
 select=quot;name/familyquot;/>
           <xsl:if test=quot;position() != last()quot;>,</xsl:if>
        </xsl:for-each>
        <br/><br/>
     </xsl:for-each-group>
  </xsl:function>



                                                                          Folie   10
»XSLT 2.0«
Analyze String mit Regexp Unterstützung


 <xsl:template match=quot;commentquot;>
     <xsl:analyze-string select=quot;.quot; regex=quot;S.*quot; flags=quot;mquot;>
        <xsl:matching-substring>
           <b><xsl:value-of select=quot;.quot; /></b><br/>
        </xsl:matching-substring>
     </xsl:analyze-string>
   </xsl:template>




                                                              Folie   11
»XPath 2.0«
to-Operator


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

keine rekursionen mehr
<xsl:for-each select=quot;personnel/personquot;>
 <xsl:value-of select=quot;name/givenquot;/><xsl:text> </xsl:text><xsl:value-of
 select=quot;name/familyquot;/>: Importance factor:
 <xsl:for-each select=quot;(1 to count(email))quot;>
    *
 </xsl:for-each>
 <br/>
</xsl:for-each>




                                                                          Folie   12
»XPath 2.0«
Schleife und Bedingung



Schleife -> spart rekursive aufrufe
<xsl:value-of select=quot;for $i in (1 to 6) return $i*2[$i > 2]quot;/>


If then else -> spart choose when
<xsl:variable name=quot;testquot; as=quot;xs:integerquot;>100</xsl:variable>
<xsl:value-of select=quot;if ($test ge 100) then 'gross' else 'klein'quot;/>




                                                                       Folie   13
»XPath 2.0«
Suche und Datumsfunktionen


search-replace
<xsl:variable name=quot;testquot; as=quot;xs:stringquot;>doubleSlash ist super super Super
 toll.</xsl:variable>
<xsl:value-of select=quot;replace($test,'super','ganz')quot;/>
mit regexp
<xsl:value-of select=quot;replace($test,'W','&lt;br&gt;')quot; disable-output-
 escaping=quot;yesquot;/>

Datumsfunktionen
<xsl:variable name=quot;heutequot; select=quot;current-date()quot; as=quot;xs:datequot;/>
normal
<xsl:value-of select=quot;$heutequot;/>
formatiert
<xsl:value-of select=quot;format-date($heute,'[D01].[M01].[Y0001]')quot;/>



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


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)


                                                    Folie   15
»XSLT 2.0 und XPath 2.0«
Referenzen


  >   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/


                                                     Folie   16
Vielen Dank!

Für mehr Informationen
und weitere Fragen:
»Kontaktiern Sie uns unter
07541-70078-0 oder info@doubleSlash.de«




doubleSlash                  Edmund Hierlemann
Net-Business GmbH            Tel.: 07541-70078-0
Otto-Lilienthal-Str. 2       info@doubleSlash.de
D-88046 Friedrichshafen
http://blog.doubleSlash.de




                                                   Folie 17

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Neues von XSLT 2.0 und XPath 2.0

  • 1. XSLT 2.0 und XPath 2.0 »Workshop Technology Days 2008« Stand: Februar 2008 Version: 1.1 doubleSlash Edmund Hierlemann Net-Business GmbH Tel.: 07541-70078-0 Otto-Lilienthal-Str. 2 info@doubleSlash.de D-88046 Friedrichshafen http://blog.doubleSlash.de Folie 1
  • 2. »Überblick und Inhalt« Neuerungen zu den Versionen 2.0 > 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? Folie 2
  • 3. »Warum XSLT 2.0 und XPath 2.0« XSLT 1.0  > 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.  > … Folie 3
  • 4. »Warum XSLT 2.0 und XPath 2.0« XPath 1.0 >• 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,…) >• …. EXSLT bietet Workaround-Packages an. Folie 4
  • 5. »XSLT 2.0 und XPath 2.0« ...da war doch noch was XSLT 2.0 und XPath 2.0 löst viele Probleme… …aber nicht alle. Folie 5
  • 6. »XSLT 2.0 und XPath 2.0« Features und Syntax  Beispiele gefällig? Folie 6
  • 7. »XSLT 2.0« Sequenzen  anstelle der RTF (result tree <xsl:variable name=quot;sequencequot; fragments) werden sequenzen erstellt select=quot;(1,2,3,4,5,6,1,1,2)quot;/>  Listen aller möglichen typen Distinct  direkte Erzeugung mit (...) <xsl:value-of select=quot;distinct- values($sequence)quot;/> <xsl:value-of select=quot;(1,2,3,4,5,6)quot;/> Reverse <xsl:value-of select=quot;reverse($sequence)quot;/> Separator RTF <xsl:value-of <xsl:value-of select=quot;(1,2,3,4,5,6)quot; select=quot;/personnel/person/name/givenquot;/> separator=quot;, quot;/> bei value-of select werden aufgrund der Result-Sequenzen jetzt nicht nur der erste, sondern alle knoten gefunden. Folie 7
  • 8. »XSLT 2.0« Datentypen  string Datentypen sicherstellen  double <xsl:variable name=quot;test” as=quot;xs:integerquot;>12</xsl:variable>  integer <xsl:value-of select=quot;$test instance of xs:integerquot;/>  Boolean aber auch:  dateTime  gDay  gMonth  anyURI  ... uvm. Folie 8
  • 9. »XSLT 2.0« Funktionen <!-- function addierer --> <xsl:function name=quot;a:addiererquot;> <!-- Datentyp-Unterstützung --> <xsl:param name=quot;numberquot; as=quot;xs:integerquot;/> <xsl:param name=quot;number2quot; as=quot;xs:integerquot;/> <xsl:value-of select=quot;$number + $number2quot;/> </xsl:function> Folie 9
  • 10. »XSLT 2.0« Gruppen <xsl:function name=quot;a:groupquot;> <xsl:param name=quot;contextquot;></xsl:param> <xsl:for-each-group select=quot;$context/personquot; group-by=quot;originquot;> <xsl:sort select=quot;current-grouping-key()quot; order=quot;descendingquot; /> Origin: <xsl:value-of select=quot;current-grouping-key()quot;/><br/> <xsl:for-each select=quot;current-group()quot; > <xsl:value-of select=quot;name/givenquot;/><xsl:text> </xsl:text><xsl:value-of select=quot;name/familyquot;/> <xsl:if test=quot;position() != last()quot;>,</xsl:if> </xsl:for-each> <br/><br/> </xsl:for-each-group> </xsl:function> Folie 10
  • 11. »XSLT 2.0« Analyze String mit Regexp Unterstützung <xsl:template match=quot;commentquot;> <xsl:analyze-string select=quot;.quot; regex=quot;S.*quot; flags=quot;mquot;> <xsl:matching-substring> <b><xsl:value-of select=quot;.quot; /></b><br/> </xsl:matching-substring> </xsl:analyze-string> </xsl:template> Folie 11
  • 12. »XPath 2.0« to-Operator <xsl:value-of select=quot;1 to 6quot;/> keine rekursionen mehr <xsl:for-each select=quot;personnel/personquot;> <xsl:value-of select=quot;name/givenquot;/><xsl:text> </xsl:text><xsl:value-of select=quot;name/familyquot;/>: Importance factor: <xsl:for-each select=quot;(1 to count(email))quot;> * </xsl:for-each> <br/> </xsl:for-each> Folie 12
  • 13. »XPath 2.0« Schleife und Bedingung Schleife -> spart rekursive aufrufe <xsl:value-of select=quot;for $i in (1 to 6) return $i*2[$i > 2]quot;/> If then else -> spart choose when <xsl:variable name=quot;testquot; as=quot;xs:integerquot;>100</xsl:variable> <xsl:value-of select=quot;if ($test ge 100) then 'gross' else 'klein'quot;/> Folie 13
  • 14. »XPath 2.0« Suche und Datumsfunktionen search-replace <xsl:variable name=quot;testquot; as=quot;xs:stringquot;>doubleSlash ist super super Super toll.</xsl:variable> <xsl:value-of select=quot;replace($test,'super','ganz')quot;/> mit regexp <xsl:value-of select=quot;replace($test,'W','&lt;br&gt;')quot; disable-output- escaping=quot;yesquot;/> Datumsfunktionen <xsl:variable name=quot;heutequot; select=quot;current-date()quot; as=quot;xs:datequot;/> normal <xsl:value-of select=quot;$heutequot;/> formatiert <xsl:value-of select=quot;format-date($heute,'[D01].[M01].[Y0001]')quot;/> Folie 14
  • 15. »XSLT 2.0 und XPath 2.0« Wann kann ich das jetzt nutzen? 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) Folie 15
  • 16. »XSLT 2.0 und XPath 2.0« Referenzen > 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/ Folie 16
  • 17. Vielen Dank! Für mehr Informationen und weitere Fragen: »Kontaktiern Sie uns unter 07541-70078-0 oder info@doubleSlash.de« doubleSlash Edmund Hierlemann Net-Business GmbH Tel.: 07541-70078-0 Otto-Lilienthal-Str. 2 info@doubleSlash.de D-88046 Friedrichshafen http://blog.doubleSlash.de Folie 17