SlideShare une entreprise Scribd logo
1  sur  19
Velocity vs. XSLTVelocity vs. XSLT
Alvin Chao – James Madison UniversityAlvin Chao – James Madison University
Jason Aller – University of California Davis – School of LawJason Aller – University of California Davis – School of Law
The Eternal debate…The Eternal debate…
http://www.hannonhill.com
/news/blog/2011/the-eternal-debate-velocity-or-xslt.html
Common Elements - XMLCommon Elements - XML
Traversal MethodsTraversal Methods
XSLTXSLT
<xsl:apply-templates select=“/path/to/node[conditional]”/><xsl:apply-templates select=“/path/to/node[conditional]”/>
<xsl:template match=“node”/><xsl:template match=“node”/>
VelocityVelocity
$_XPathTool.selectNodes($contentRoot, “/path/to/node”)$_XPathTool.selectNodes($contentRoot, “/path/to/node”)
$_XPathTool.selectSingleNode($contentRoot,$_XPathTool.selectSingleNode($contentRoot,
“/path/to/node”)“/path/to/node”)
$contentRoot.getChild(“path”).getChild(“to”).getChild(“node”$contentRoot.getChild(“path”).getChild(“to”).getChild(“node”
))
$contentRoot.getChildren()$contentRoot.getChildren()
Common Elements -Common Elements -
Syntax/FunctionalitySyntax/Functionality
VariablesVariables
#set ($myVar = “content value”)#set ($myVar = “content value”)
<xsl:variable name=“<xsl:variable name=“myVarmyVar”” select=select=““content valuecontent value””>>
LoopsLoops
#foreach ($item in $items) Output Content #end#foreach ($item in $items) Output Content #end
<xsl:for-each>Output Content</xsl:for-each><xsl:for-each>Output Content</xsl:for-each>
Conditional StatementsConditional Statements
#if ($value == “value”) Output Content #end#if ($value == “value”) Output Content #end
<xsl:if test=“$value = ‘value’”> Output Content </xsl:if><xsl:if test=“$value = ‘value’”> Output Content </xsl:if>
DatesDates
Velocity BenefitsVelocity Benefits
Based on Java – can leverage Java commands like .contains,Based on Java – can leverage Java commands like .contains,
and .replaceand .replace
Doesn’t need Xalan JavaScript extension to format dates /Doesn’t need Xalan JavaScript extension to format dates /
Date difference calculation easierDate difference calculation easier
Conditional closing tagsConditional closing tags
Extended Math /Array /real variablesExtended Math /Array /real variables
Ability to break out of loops #breakAbility to break out of loops #break
Script like syntax(php, JavaScript familiar)Script like syntax(php, JavaScript familiar)
XSLT BenefitsXSLT Benefits
Widespread use outside of Cascade(wealth of tutorials andWidespread use outside of Cascade(wealth of tutorials and
books available)books available)
Easier null checkingEasier null checking
Easy recursive callsEasy recursive calls
Not as many $signs and _sNot as many $signs and _s
Render SpeedRender Speed
Testing code outside of Cascade ServerTesting code outside of Cascade Server
Advanced editors outside of Cascade Server - OxygenXMLAdvanced editors outside of Cascade Server - OxygenXML
Head to Head ComparisonHead to Head Comparison
Attribute Velocity XSLT
Offline
Development/Testing
Hard to do this, but you
can setup some basic
offline testing (Eclipse
install of Velocity Tools)
Easy to do this may
require some external
tools (Oxygen XML,
XML Spear)
Familiarity of Language Script language, like
JavaScript, php, etc…
XSLT, may be a
learning curve
Flow Logical structured
language flow from top
to bottom
Template based
structure, requires
knowledge of the data
Including within formats Now available in
Cascade Server 7.6!
Easily done with
imports
Location of Xpath Harder to understand if
not familiar with
XPATH(Chrome XML
View plugin)
Those familiar with
XML will know Xpath,
Tools like Oxygen
XML or XML Spear
can help with this
Battlefield for TimingsBattlefield for Timings
(Server specs)(Server specs)
Physical machine = Dell Optiplex 745 2.4ghz Intel Core 2Physical machine = Dell Optiplex 745 2.4ghz Intel Core 2
Duo w /4GB RAM running Windows 2008 ServerDuo w /4GB RAM running Windows 2008 Server
Cascade 7.6Cascade 7.6
JVM Max heap 1024, Min 768JVM Max heap 1024, Min 768
Cascade Total ram = 742MBCascade Total ram = 742MB
Restarted server, ran all 3 Velocity rounds, then retested forRestarted server, ran all 3 Velocity rounds, then retested for
cached timing, restarted again and ran all 3 XSLT roundscached timing, restarted again and ran all 3 XSLT rounds
then retested for cached timingsthen retested for cached timings
Round 1 – Large Tabular DataRound 1 – Large Tabular Data
During this round contestants were asked to take a large setDuring this round contestants were asked to take a large set
of person data and sort this data into four equal lengthof person data and sort this data into four equal length
column listings by first name.column listings by first name.
The dataset is an XML block with 1000 entries. Columns areThe dataset is an XML block with 1000 entries. Columns are
created via YUI Grid .css versus tables to produce validcreated via YUI Grid .css versus tables to produce valid
XHTML and not use tables for layout. Data was generatedXHTML and not use tables for layout. Data was generated
using the Vulcano tool:using the Vulcano tool: http://http://www.datagenerator.orgwww.datagenerator.org
Data format: ID, Name, email, phone, date, websiteData format: ID, Name, email, phone, date, website
Round 1 TimingsRound 1 Timings
Velocity XSLT
Initial Runtime (ms) 3635ms 5957ms
Cached Runtime 2032ms 3873ms
Round 2 – Search Speed – LargeRound 2 – Search Speed – Large
DataData
Contestants were asked to search the works of ShakespeareContestants were asked to search the works of Shakespeare
in XML format for the provided search term of pirate.in XML format for the provided search term of pirate.
Tragically for Alvin it was determined that the bard neverTragically for Alvin it was determined that the bard never
made mention of Ninjas, while Pirates were mentioned in amade mention of Ninjas, while Pirates were mentioned in a
number of plays.number of plays.
Round 2 - TimingsRound 2 - Timings
Velocity XSLT
Initial Runtime 8409ms 7644ms
Cached Runtime 2135ms 1928ms
Final Round (3) – Tumblr RSSFinal Round (3) – Tumblr RSS
FeedFeed
Contestants were asked to render an external RSS feed fromContestants were asked to render an external RSS feed from
a Tumblr account –a Tumblr account – http://velocityversusxslt.tumlbr.comhttp://velocityversusxslt.tumlbr.com
Round 3 TimingsRound 3 Timings
Velocity XSLT
Initial Runtime 350ms 401ms
Cached Runtime 215ms 200ms
Velocity ResourcesVelocity Resources
Only 2 book on Velocity:Only 2 book on Velocity:
Pro Jakarta Velocity -Pro Jakarta Velocity -
http://www.amazon.com/Pro-Jakarta-Velocity-Professional-Expert/dp/159059410X/ref=sr_1_1?ie=http://www.amazon.com/Pro-Jakarta-Velocity-Professional-Expert/dp/159059410X/ref=sr_1_1?ie=
jakartajakarta
Matering Apache VelocityMatering Apache Velocity httphttp://www.amazon.com/exec/obidos/ASIN/0471457949://www.amazon.com/exec/obidos/ASIN/0471457949//
Velocity User’s Guide:Velocity User’s Guide: http://velocity.apache.org/engine/devel/user-http://velocity.apache.org/engine/devel/user-guide.htmlguide.html
Velocity Cookbook on github:Velocity Cookbook on github: httpshttps://github.com/hannonhill/Velocity-://github.com/hannonhill/Velocity-CookbookCookbook
Presentations:Presentations:
2010 User’s Conference -2010 User’s Conference -
http://www.hannonhill.com/news/conference/2010/videos/Velocity-vs-http://www.hannonhill.com/news/conference/2010/videos/Velocity-vs-XSLT.htmlXSLT.html
HH Blog posting -HH Blog posting - httphttp
://www.hannonhill.com/news/blog/2011/the-eternal-debate-velocity-or-://www.hannonhill.com/news/blog/2011/the-eternal-debate-velocity-or-
xslt.htmlxslt.html
Velocity Webinar http://www.hannonhill.com/products/demos/velocity-Velocity Webinar http://www.hannonhill.com/products/demos/velocity-
functionality-overview-webinar-video.htmlfunctionality-overview-webinar-video.html
XSLT ResourcesXSLT Resources
Hannon Hill XSLT Workbook on githubHannon Hill XSLT Workbook on github
https://github.com/hannonhill/XSLT-Workbookhttps://github.com/hannonhill/XSLT-Workbook
XSLT by Doug Tidwell and published by O’ReillyXSLT by Doug Tidwell and published by O’Reilly
XSLT Cookbook, 2nd Edition by Sal Mangano andXSLT Cookbook, 2nd Edition by Sal Mangano and
published by O’Reillypublished by O’Reilly
OxygenXML http://www.oxygenxml.com/OxygenXML http://www.oxygenxml.com/
And the winner is…And the winner is…
The clear winner is you, because you get to choose whichThe clear winner is you, because you get to choose which
language to use by default, but you retain the option tolanguage to use by default, but you retain the option to
switch when doing so makes sense.switch when doing so makes sense.
But, for those who need a victor – go take our poll – VelocityBut, for those who need a victor – go take our poll – Velocity
or XSLT here:or XSLT here:

Contenu connexe

Plus de hannonhill

Data Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JSData Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JShannonhill
 
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...hannonhill
 
Fun with Cascade Server!
Fun with Cascade Server!Fun with Cascade Server!
Fun with Cascade Server!hannonhill
 
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
Accessibility in Practice:  Integrating Web Accessibility into Cascade TrainingAccessibility in Practice:  Integrating Web Accessibility into Cascade Training
Accessibility in Practice: Integrating Web Accessibility into Cascade Traininghannonhill
 
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade ServerCrowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Serverhannonhill
 
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...hannonhill
 
Climbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground UpClimbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground Uphannonhill
 
In Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified TemplateIn Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified Templatehannonhill
 
Cusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding PlatformCusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding Platformhannonhill
 
Web Services: Encapsulation, Reusability, and Simplicity
Web Services: Encapsulation, Reusability, and SimplicityWeb Services: Encapsulation, Reusability, and Simplicity
Web Services: Encapsulation, Reusability, and Simplicityhannonhill
 
Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!hannonhill
 
Web Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web ServicesWeb Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web Serviceshannonhill
 
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...hannonhill
 
Redesign in Cascade Server
Redesign in Cascade ServerRedesign in Cascade Server
Redesign in Cascade Serverhannonhill
 
Building Org Charts Using Cascade Server
Building Org Charts Using Cascade Server Building Org Charts Using Cascade Server
Building Org Charts Using Cascade Server hannonhill
 
Leveraging Administrative Tasks with Webservices
Leveraging Administrative Tasks with WebservicesLeveraging Administrative Tasks with Webservices
Leveraging Administrative Tasks with Webserviceshannonhill
 
Making the grade without Clippy – Use of automatic readability scoring
Making the grade without Clippy – Use of automatic readability scoringMaking the grade without Clippy – Use of automatic readability scoring
Making the grade without Clippy – Use of automatic readability scoringhannonhill
 
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...hannonhill
 
Preparing for Emergency Communications
Preparing for Emergency CommunicationsPreparing for Emergency Communications
Preparing for Emergency Communicationshannonhill
 
A Groovy Way to Interface With Cascade Server
A Groovy Way to Interface With Cascade ServerA Groovy Way to Interface With Cascade Server
A Groovy Way to Interface With Cascade Serverhannonhill
 

Plus de hannonhill (20)

Data Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JSData Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JS
 
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
 
Fun with Cascade Server!
Fun with Cascade Server!Fun with Cascade Server!
Fun with Cascade Server!
 
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
Accessibility in Practice:  Integrating Web Accessibility into Cascade TrainingAccessibility in Practice:  Integrating Web Accessibility into Cascade Training
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
 
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade ServerCrowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
 
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
 
Climbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground UpClimbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground Up
 
In Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified TemplateIn Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified Template
 
Cusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding PlatformCusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding Platform
 
Web Services: Encapsulation, Reusability, and Simplicity
Web Services: Encapsulation, Reusability, and SimplicityWeb Services: Encapsulation, Reusability, and Simplicity
Web Services: Encapsulation, Reusability, and Simplicity
 
Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!
 
Web Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web ServicesWeb Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web Services
 
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
 
Redesign in Cascade Server
Redesign in Cascade ServerRedesign in Cascade Server
Redesign in Cascade Server
 
Building Org Charts Using Cascade Server
Building Org Charts Using Cascade Server Building Org Charts Using Cascade Server
Building Org Charts Using Cascade Server
 
Leveraging Administrative Tasks with Webservices
Leveraging Administrative Tasks with WebservicesLeveraging Administrative Tasks with Webservices
Leveraging Administrative Tasks with Webservices
 
Making the grade without Clippy – Use of automatic readability scoring
Making the grade without Clippy – Use of automatic readability scoringMaking the grade without Clippy – Use of automatic readability scoring
Making the grade without Clippy – Use of automatic readability scoring
 
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
Ingesting Banner output Schedule Classes into Cascade Server (In Java - Web S...
 
Preparing for Emergency Communications
Preparing for Emergency CommunicationsPreparing for Emergency Communications
Preparing for Emergency Communications
 
A Groovy Way to Interface With Cascade Server
A Groovy Way to Interface With Cascade ServerA Groovy Way to Interface With Cascade Server
A Groovy Way to Interface With Cascade Server
 

Dernier

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
 
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
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
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
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Dernier (20)

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
 
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
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
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
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
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
 
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...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Velocity vs. XSLT by Jason Aller and Alvin Chao

  • 1. Velocity vs. XSLTVelocity vs. XSLT Alvin Chao – James Madison UniversityAlvin Chao – James Madison University Jason Aller – University of California Davis – School of LawJason Aller – University of California Davis – School of Law
  • 2. The Eternal debate…The Eternal debate… http://www.hannonhill.com /news/blog/2011/the-eternal-debate-velocity-or-xslt.html
  • 3. Common Elements - XMLCommon Elements - XML Traversal MethodsTraversal Methods XSLTXSLT <xsl:apply-templates select=“/path/to/node[conditional]”/><xsl:apply-templates select=“/path/to/node[conditional]”/> <xsl:template match=“node”/><xsl:template match=“node”/> VelocityVelocity $_XPathTool.selectNodes($contentRoot, “/path/to/node”)$_XPathTool.selectNodes($contentRoot, “/path/to/node”) $_XPathTool.selectSingleNode($contentRoot,$_XPathTool.selectSingleNode($contentRoot, “/path/to/node”)“/path/to/node”) $contentRoot.getChild(“path”).getChild(“to”).getChild(“node”$contentRoot.getChild(“path”).getChild(“to”).getChild(“node” )) $contentRoot.getChildren()$contentRoot.getChildren()
  • 4. Common Elements -Common Elements - Syntax/FunctionalitySyntax/Functionality VariablesVariables #set ($myVar = “content value”)#set ($myVar = “content value”) <xsl:variable name=“<xsl:variable name=“myVarmyVar”” select=select=““content valuecontent value””>> LoopsLoops #foreach ($item in $items) Output Content #end#foreach ($item in $items) Output Content #end <xsl:for-each>Output Content</xsl:for-each><xsl:for-each>Output Content</xsl:for-each> Conditional StatementsConditional Statements #if ($value == “value”) Output Content #end#if ($value == “value”) Output Content #end <xsl:if test=“$value = ‘value’”> Output Content </xsl:if><xsl:if test=“$value = ‘value’”> Output Content </xsl:if> DatesDates
  • 5. Velocity BenefitsVelocity Benefits Based on Java – can leverage Java commands like .contains,Based on Java – can leverage Java commands like .contains, and .replaceand .replace Doesn’t need Xalan JavaScript extension to format dates /Doesn’t need Xalan JavaScript extension to format dates / Date difference calculation easierDate difference calculation easier Conditional closing tagsConditional closing tags Extended Math /Array /real variablesExtended Math /Array /real variables Ability to break out of loops #breakAbility to break out of loops #break Script like syntax(php, JavaScript familiar)Script like syntax(php, JavaScript familiar)
  • 6. XSLT BenefitsXSLT Benefits Widespread use outside of Cascade(wealth of tutorials andWidespread use outside of Cascade(wealth of tutorials and books available)books available) Easier null checkingEasier null checking Easy recursive callsEasy recursive calls Not as many $signs and _sNot as many $signs and _s Render SpeedRender Speed Testing code outside of Cascade ServerTesting code outside of Cascade Server Advanced editors outside of Cascade Server - OxygenXMLAdvanced editors outside of Cascade Server - OxygenXML
  • 7. Head to Head ComparisonHead to Head Comparison Attribute Velocity XSLT Offline Development/Testing Hard to do this, but you can setup some basic offline testing (Eclipse install of Velocity Tools) Easy to do this may require some external tools (Oxygen XML, XML Spear) Familiarity of Language Script language, like JavaScript, php, etc… XSLT, may be a learning curve Flow Logical structured language flow from top to bottom Template based structure, requires knowledge of the data Including within formats Now available in Cascade Server 7.6! Easily done with imports Location of Xpath Harder to understand if not familiar with XPATH(Chrome XML View plugin) Those familiar with XML will know Xpath, Tools like Oxygen XML or XML Spear can help with this
  • 8. Battlefield for TimingsBattlefield for Timings (Server specs)(Server specs) Physical machine = Dell Optiplex 745 2.4ghz Intel Core 2Physical machine = Dell Optiplex 745 2.4ghz Intel Core 2 Duo w /4GB RAM running Windows 2008 ServerDuo w /4GB RAM running Windows 2008 Server Cascade 7.6Cascade 7.6 JVM Max heap 1024, Min 768JVM Max heap 1024, Min 768 Cascade Total ram = 742MBCascade Total ram = 742MB Restarted server, ran all 3 Velocity rounds, then retested forRestarted server, ran all 3 Velocity rounds, then retested for cached timing, restarted again and ran all 3 XSLT roundscached timing, restarted again and ran all 3 XSLT rounds then retested for cached timingsthen retested for cached timings
  • 9. Round 1 – Large Tabular DataRound 1 – Large Tabular Data During this round contestants were asked to take a large setDuring this round contestants were asked to take a large set of person data and sort this data into four equal lengthof person data and sort this data into four equal length column listings by first name.column listings by first name. The dataset is an XML block with 1000 entries. Columns areThe dataset is an XML block with 1000 entries. Columns are created via YUI Grid .css versus tables to produce validcreated via YUI Grid .css versus tables to produce valid XHTML and not use tables for layout. Data was generatedXHTML and not use tables for layout. Data was generated using the Vulcano tool:using the Vulcano tool: http://http://www.datagenerator.orgwww.datagenerator.org Data format: ID, Name, email, phone, date, websiteData format: ID, Name, email, phone, date, website
  • 10. Round 1 TimingsRound 1 Timings Velocity XSLT Initial Runtime (ms) 3635ms 5957ms Cached Runtime 2032ms 3873ms
  • 11. Round 2 – Search Speed – LargeRound 2 – Search Speed – Large DataData Contestants were asked to search the works of ShakespeareContestants were asked to search the works of Shakespeare in XML format for the provided search term of pirate.in XML format for the provided search term of pirate. Tragically for Alvin it was determined that the bard neverTragically for Alvin it was determined that the bard never made mention of Ninjas, while Pirates were mentioned in amade mention of Ninjas, while Pirates were mentioned in a number of plays.number of plays.
  • 12.
  • 13. Round 2 - TimingsRound 2 - Timings Velocity XSLT Initial Runtime 8409ms 7644ms Cached Runtime 2135ms 1928ms
  • 14. Final Round (3) – Tumblr RSSFinal Round (3) – Tumblr RSS FeedFeed Contestants were asked to render an external RSS feed fromContestants were asked to render an external RSS feed from a Tumblr account –a Tumblr account – http://velocityversusxslt.tumlbr.comhttp://velocityversusxslt.tumlbr.com
  • 15.
  • 16. Round 3 TimingsRound 3 Timings Velocity XSLT Initial Runtime 350ms 401ms Cached Runtime 215ms 200ms
  • 17. Velocity ResourcesVelocity Resources Only 2 book on Velocity:Only 2 book on Velocity: Pro Jakarta Velocity -Pro Jakarta Velocity - http://www.amazon.com/Pro-Jakarta-Velocity-Professional-Expert/dp/159059410X/ref=sr_1_1?ie=http://www.amazon.com/Pro-Jakarta-Velocity-Professional-Expert/dp/159059410X/ref=sr_1_1?ie= jakartajakarta Matering Apache VelocityMatering Apache Velocity httphttp://www.amazon.com/exec/obidos/ASIN/0471457949://www.amazon.com/exec/obidos/ASIN/0471457949// Velocity User’s Guide:Velocity User’s Guide: http://velocity.apache.org/engine/devel/user-http://velocity.apache.org/engine/devel/user-guide.htmlguide.html Velocity Cookbook on github:Velocity Cookbook on github: httpshttps://github.com/hannonhill/Velocity-://github.com/hannonhill/Velocity-CookbookCookbook Presentations:Presentations: 2010 User’s Conference -2010 User’s Conference - http://www.hannonhill.com/news/conference/2010/videos/Velocity-vs-http://www.hannonhill.com/news/conference/2010/videos/Velocity-vs-XSLT.htmlXSLT.html HH Blog posting -HH Blog posting - httphttp ://www.hannonhill.com/news/blog/2011/the-eternal-debate-velocity-or-://www.hannonhill.com/news/blog/2011/the-eternal-debate-velocity-or- xslt.htmlxslt.html Velocity Webinar http://www.hannonhill.com/products/demos/velocity-Velocity Webinar http://www.hannonhill.com/products/demos/velocity- functionality-overview-webinar-video.htmlfunctionality-overview-webinar-video.html
  • 18. XSLT ResourcesXSLT Resources Hannon Hill XSLT Workbook on githubHannon Hill XSLT Workbook on github https://github.com/hannonhill/XSLT-Workbookhttps://github.com/hannonhill/XSLT-Workbook XSLT by Doug Tidwell and published by O’ReillyXSLT by Doug Tidwell and published by O’Reilly XSLT Cookbook, 2nd Edition by Sal Mangano andXSLT Cookbook, 2nd Edition by Sal Mangano and published by O’Reillypublished by O’Reilly OxygenXML http://www.oxygenxml.com/OxygenXML http://www.oxygenxml.com/
  • 19. And the winner is…And the winner is… The clear winner is you, because you get to choose whichThe clear winner is you, because you get to choose which language to use by default, but you retain the option tolanguage to use by default, but you retain the option to switch when doing so makes sense.switch when doing so makes sense. But, for those who need a victor – go take our poll – VelocityBut, for those who need a victor – go take our poll – Velocity or XSLT here:or XSLT here: