SlideShare a Scribd company logo
1 of 27
Download to read offline
FrOSCon



  Bastian Feder, Thomas Weinert
     "The Lumber Mill"
Using XSLT For Your Templates
About Us
●   Application Developer
    –   PHP
    –   XSLT/XPath
    –   (some) JavaScript
●   papaya CMS
    –   PHP based Content Management System
    –   uses XSLT for Templates
About You
●   Who are you?
●   Do you use XSLT?
●   How often do you use XSLT?
●   Do you use other template systems/languages?
●   Smarty?
●   TypoScript?
●   ...?
Template Systems
●   Bind variables
●   Layout logic
       –   Placeholders
       –   Conditions
       –   Loops
       –   Callbacks
               ●   Formatting
               ●   Data loading
XSL
●   XML
       –   Semantic variable tree
●   XPath
       –   Query language for XML trees
●   XSLT
       –   Transforming XML
               ●   Conditions
               ●   Loops
               ●   …
Comparison
●   PHP based                  ●   XSLT
       –   Individual syntax         –   Standardized
       –   Individual tools                syntax
       –   Individual
                                     –   Free and
             documentation                 commercial tools
       –   Different flavors
                                     –   Documentation of
            for different                 the standard and
            purpose                       the
                                          implementations
       –   Easy Syntax?
                                     –   One to rule them
                                          all
Nodes
●   texts/text[@ident='foo']/*
●   texts/text[@ident='foo']/text()
●   texts/text[@ident='foo']/node()
●   texts/text[@ident='foo']/@value

     Elements            Text nodes   Attributes
         *                  text()        @*
                node()
Template call/apply
●   <xsl:call-template/>
        –   Call templates by name
●   <xsl:apply-templates/>
        –   Template matching
        –   Most exact pattern wins
●   Current node
●   Parameters
●   Modes
Static Templates Files
●   Template files should not be writable by the
    web server
        –   Security
        –   Tools
●   Template files should not be generated from
    PHP
        –   Same reasons
        –   Context
Collecting Output
              Page (HTML)


              Page (XML)




             Part 1 (HTML)   Part 2 (HTML)


Main (XML)    Part 1 (XML)   Part 2 (XML)
Caching Output
                Page (HTML)


                 Page (XML)


                   Cache

                Part 1 (HTML)   Part 2 (HTML)


Main (XML)       Part 1 (XML)   Part 2 (XML)
Embedding Output
●   Escaping and CDATA-Sections
        –   CDATA is for readability and whitespaces
●   <xsl:copy-of select=“...“/>
●   disable-output-escaping=“yes“
●   Dangers
        –   HTML Injection
Import templates
●   Generic
●   Reusable
●   Encapsulation
●   Inheritance
Multiple Columns Template
●   Group items
        –   Calculate positions
●   Call item group templates
●   Call item generic template
●   Use itemType parameter to identify item
    template
●   Call type specific template for item
XML Data Files
●   Wellformed XML
●   XPath: document()
●   URI
          –   Single loading
Language Templates
●   Phrases
       –   "layout texts"
●   Numbers
●   Date and Time
EXSLT
●   Community initiative to provide extensions to
    XSLT
        –   Common
        –   Functions
        –   Math, Random
        –   Strings, Regular Expressions
        –   Dates and Times
        –   Sets
        –   Dynamic
EXSLT: functions module
●   Make templates to functions
       –   func:function
       –   func:result
●   Namespace required
       –   func
       –   Own
PHP
●   Streamwrapper
       –   return XML data for document()
●   Callbacks
       –   call php source
Streamwrapper
●   PHP file functions use stream wrappers
       –   Internal: http, ftp, phar, …
●   Register own stream wrappers
       –   PHP class
       –   Basic functions
                ●   stream_open(), stream_read(), stream_tell(),
                      stream_seek(), stream_eof(),
       –   url_stat()
●   No php source!
Callbacks
●   Register PHP functions for xsl
        –   registerPHPFunctions($restrict)
        –   php::function('function', parameter, ...)
        –   php::functionString('function', ...)
RTF Problem
●   Result Tree Fragment
       –   XML created in XSL
       –   No CDATA
       –   No node set
●   XSLT 2.0
●   EXSLT
       –   node-set()
Other Templates
●   Repeat String
●   JavaScript Escaping
ext/xslcache
●   Process cache
●   Performance increase
●   Still evaluating
        –   Only some checks in php requests
●   Only static XSLT
●   Same library like ext/xsl
        –   eXSLT
        –   PHP callbacks
Administration


        ●   Single template
        ●   About 25% saved
Output


   ●   Several template
   ●   About 90% saved
Links
●   http://www.a-basketful-of-papayas.net/

●   http://www.w3.org/TR/xpath
●   http://www.w3.org/TR/xslt
●   http://www.dpawson.co.uk/xsl/sect2/sect21.html

●   http://code.nytimes.com/projects/xslcache/

More Related Content

What's hot (20)

Understanding XML DOM
Understanding XML DOMUnderstanding XML DOM
Understanding XML DOM
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!
 
Querring xml with xpath
Querring xml with xpath Querring xml with xpath
Querring xml with xpath
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Dom parser
Dom parserDom parser
Dom parser
 
Programming the Semantic Web
Programming the Semantic WebProgramming the Semantic Web
Programming the Semantic Web
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
DOM-XML
DOM-XMLDOM-XML
DOM-XML
 
Xml
XmlXml
Xml
 
XML - SAX
XML - SAXXML - SAX
XML - SAX
 
Xml databases
Xml databasesXml databases
Xml databases
 
Xml
XmlXml
Xml
 
Persentation on c language
Persentation on c languagePersentation on c language
Persentation on c language
 
XSL - XML STYLE SHEET
XSL - XML STYLE SHEETXSL - XML STYLE SHEET
XSL - XML STYLE SHEET
 
Data exchange over internet (XML vs JSON)
Data exchange over internet (XML vs JSON)Data exchange over internet (XML vs JSON)
Data exchange over internet (XML vs JSON)
 
Slide
SlideSlide
Slide
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
SMWCon Fall 2015 FForms
SMWCon Fall 2015 FFormsSMWCon Fall 2015 FForms
SMWCon Fall 2015 FForms
 
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
 
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft ...
 

Similar to The Lumber Mill - XSLT For Your Templates

Find it, possibly also near you!
Find it, possibly also near you!Find it, possibly also near you!
Find it, possibly also near you!Paul Borgermans
 
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation LanguagesSyntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation LanguagesTara Athan
 
Get the most out of Solr search with PHP
Get the most out of Solr search with PHPGet the most out of Solr search with PHP
Get the most out of Solr search with PHPPaul Borgermans
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for PerlGeir Aalberg
 
Java Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsJava Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsAnton Keks
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyOlivier Bourgeois
 
The XML Forms Architecture
The XML Forms ArchitectureThe XML Forms Architecture
The XML Forms ArchitectureiText Group nv
 
Papyrus for Real Time at the OMG TC
Papyrus for Real Time  at the OMG TCPapyrus for Real Time  at the OMG TC
Papyrus for Real Time at the OMG TCCharles Rivet
 
Formal machines for Streaming XML Querying
Formal machines for Streaming XML QueryingFormal machines for Streaming XML Querying
Formal machines for Streaming XML QueryingJustAnotherAbstraction
 
XML-athon with Don and Dean
XML-athon with Don and DeanXML-athon with Don and Dean
XML-athon with Don and DeanSafe Software
 
Balisage - EXPath - A practical introduction
Balisage - EXPath - A practical introductionBalisage - EXPath - A practical introduction
Balisage - EXPath - A practical introductionFlorent Georges
 
Developing web apps using Erlang-Web
Developing web apps using Erlang-WebDeveloping web apps using Erlang-Web
Developing web apps using Erlang-Webfanqstefan
 
Extensible stylesheet language (Transformation) or XSLT
Extensible stylesheet language (Transformation) or XSLTExtensible stylesheet language (Transformation) or XSLT
Extensible stylesheet language (Transformation) or XSLTAshikur Rahman
 

Similar to The Lumber Mill - XSLT For Your Templates (20)

Find it, possibly also near you!
Find it, possibly also near you!Find it, possibly also near you!
Find it, possibly also near you!
 
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation LanguagesSyntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages
 
Get the most out of Solr search with PHP
Get the most out of Solr search with PHPGet the most out of Solr search with PHP
Get the most out of Solr search with PHP
 
XML Tools for Perl
XML Tools for PerlXML Tools for Perl
XML Tools for Perl
 
Java Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsJava Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & Servlets
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development Efficiency
 
The XML Forms Architecture
The XML Forms ArchitectureThe XML Forms Architecture
The XML Forms Architecture
 
Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
 
Papyrus for Real Time at the OMG TC
Papyrus for Real Time  at the OMG TCPapyrus for Real Time  at the OMG TC
Papyrus for Real Time at the OMG TC
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
 
Formal machines for Streaming XML Querying
Formal machines for Streaming XML QueryingFormal machines for Streaming XML Querying
Formal machines for Streaming XML Querying
 
Cmsc 100 (web content)
Cmsc 100  (web content)Cmsc 100  (web content)
Cmsc 100 (web content)
 
XML-athon with Don and Dean
XML-athon with Don and DeanXML-athon with Don and Dean
XML-athon with Don and Dean
 
Balisage - EXPath - A practical introduction
Balisage - EXPath - A practical introductionBalisage - EXPath - A practical introduction
Balisage - EXPath - A practical introduction
 
Developing web apps using Erlang-Web
Developing web apps using Erlang-WebDeveloping web apps using Erlang-Web
Developing web apps using Erlang-Web
 
Lightweight web frameworks
Lightweight web frameworksLightweight web frameworks
Lightweight web frameworks
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Extensible stylesheet language (Transformation) or XSLT
Extensible stylesheet language (Transformation) or XSLTExtensible stylesheet language (Transformation) or XSLT
Extensible stylesheet language (Transformation) or XSLT
 

More from Thomas Weinert

PHPUG CGN: Controlling Arduino With PHP
PHPUG CGN: Controlling Arduino With PHPPHPUG CGN: Controlling Arduino With PHP
PHPUG CGN: Controlling Arduino With PHPThomas Weinert
 
Controlling Arduino With PHP
Controlling Arduino With PHPControlling Arduino With PHP
Controlling Arduino With PHPThomas Weinert
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesThomas Weinert
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend PerformanceThomas Weinert
 
Experiences With Pre Commit Hooks
Experiences With Pre Commit HooksExperiences With Pre Commit Hooks
Experiences With Pre Commit HooksThomas Weinert
 
Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHPThomas Weinert
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend PerformanceThomas Weinert
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend PerformanceThomas Weinert
 

More from Thomas Weinert (13)

PHPUG CGN: Controlling Arduino With PHP
PHPUG CGN: Controlling Arduino With PHPPHPUG CGN: Controlling Arduino With PHP
PHPUG CGN: Controlling Arduino With PHP
 
Controlling Arduino With PHP
Controlling Arduino With PHPControlling Arduino With PHP
Controlling Arduino With PHP
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard Interfaces
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
Lumberjack XPath 101
Lumberjack XPath 101Lumberjack XPath 101
Lumberjack XPath 101
 
FluentDom
FluentDomFluentDom
FluentDom
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
Experiences With Pre Commit Hooks
Experiences With Pre Commit HooksExperiences With Pre Commit Hooks
Experiences With Pre Commit Hooks
 
SVN Hook
SVN HookSVN Hook
SVN Hook
 
Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHP
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
PHP 5.3/6
PHP 5.3/6PHP 5.3/6
PHP 5.3/6
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 

Recently uploaded

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

The Lumber Mill - XSLT For Your Templates

  • 1. FrOSCon Bastian Feder, Thomas Weinert "The Lumber Mill" Using XSLT For Your Templates
  • 2. About Us ● Application Developer – PHP – XSLT/XPath – (some) JavaScript ● papaya CMS – PHP based Content Management System – uses XSLT for Templates
  • 3. About You ● Who are you? ● Do you use XSLT? ● How often do you use XSLT? ● Do you use other template systems/languages? ● Smarty? ● TypoScript? ● ...?
  • 4. Template Systems ● Bind variables ● Layout logic – Placeholders – Conditions – Loops – Callbacks ● Formatting ● Data loading
  • 5. XSL ● XML – Semantic variable tree ● XPath – Query language for XML trees ● XSLT – Transforming XML ● Conditions ● Loops ● …
  • 6. Comparison ● PHP based ● XSLT – Individual syntax – Standardized – Individual tools syntax – Individual – Free and documentation commercial tools – Different flavors – Documentation of for different the standard and purpose the implementations – Easy Syntax? – One to rule them all
  • 7. Nodes ● texts/text[@ident='foo']/* ● texts/text[@ident='foo']/text() ● texts/text[@ident='foo']/node() ● texts/text[@ident='foo']/@value Elements Text nodes Attributes * text() @* node()
  • 8. Template call/apply ● <xsl:call-template/> – Call templates by name ● <xsl:apply-templates/> – Template matching – Most exact pattern wins ● Current node ● Parameters ● Modes
  • 9. Static Templates Files ● Template files should not be writable by the web server – Security – Tools ● Template files should not be generated from PHP – Same reasons – Context
  • 10. Collecting Output Page (HTML) Page (XML) Part 1 (HTML) Part 2 (HTML) Main (XML) Part 1 (XML) Part 2 (XML)
  • 11. Caching Output Page (HTML) Page (XML) Cache Part 1 (HTML) Part 2 (HTML) Main (XML) Part 1 (XML) Part 2 (XML)
  • 12. Embedding Output ● Escaping and CDATA-Sections – CDATA is for readability and whitespaces ● <xsl:copy-of select=“...“/> ● disable-output-escaping=“yes“ ● Dangers – HTML Injection
  • 13. Import templates ● Generic ● Reusable ● Encapsulation ● Inheritance
  • 14. Multiple Columns Template ● Group items – Calculate positions ● Call item group templates ● Call item generic template ● Use itemType parameter to identify item template ● Call type specific template for item
  • 15. XML Data Files ● Wellformed XML ● XPath: document() ● URI – Single loading
  • 16. Language Templates ● Phrases – "layout texts" ● Numbers ● Date and Time
  • 17. EXSLT ● Community initiative to provide extensions to XSLT – Common – Functions – Math, Random – Strings, Regular Expressions – Dates and Times – Sets – Dynamic
  • 18. EXSLT: functions module ● Make templates to functions – func:function – func:result ● Namespace required – func – Own
  • 19. PHP ● Streamwrapper – return XML data for document() ● Callbacks – call php source
  • 20. Streamwrapper ● PHP file functions use stream wrappers – Internal: http, ftp, phar, … ● Register own stream wrappers – PHP class – Basic functions ● stream_open(), stream_read(), stream_tell(), stream_seek(), stream_eof(), – url_stat() ● No php source!
  • 21. Callbacks ● Register PHP functions for xsl – registerPHPFunctions($restrict) – php::function('function', parameter, ...) – php::functionString('function', ...)
  • 22. RTF Problem ● Result Tree Fragment – XML created in XSL – No CDATA – No node set ● XSLT 2.0 ● EXSLT – node-set()
  • 23. Other Templates ● Repeat String ● JavaScript Escaping
  • 24. ext/xslcache ● Process cache ● Performance increase ● Still evaluating – Only some checks in php requests ● Only static XSLT ● Same library like ext/xsl – eXSLT – PHP callbacks
  • 25. Administration ● Single template ● About 25% saved
  • 26. Output ● Several template ● About 90% saved
  • 27. Links ● http://www.a-basketful-of-papayas.net/ ● http://www.w3.org/TR/xpath ● http://www.w3.org/TR/xslt ● http://www.dpawson.co.uk/xsl/sect2/sect21.html ● http://code.nytimes.com/projects/xslcache/