Welcome
What's this about?• The Berlin Manifesto constitutes that the transition from v4v6 to Phoenix will be easily possible
• Content Transition is a big part of that
• Last year a GSoC project was initiated for working on that problem
• Therefore: This is for presenting first solutions and inviting some man-power
Warmup Questionnaire• Who of you proably wants to use Phoenix in future?
• Who wants a nice way of reusing her existing content in Phoenix?
• Who knows XSLT?
• Who has development experience with XSLT
• Who thinks i should stop bugging you with silly questions?
OverviewAbout meThe Project
• Lessen the Gap from v4 v6 to Phoenix
• The initial idea
• Google Summer of Code 2011
• Problems & Solutions
Current Status
• A prototypical v4 v6 Extension being able to export contents of pages and tt_content
Shameless self-plug• Nicolas Forgerit
• Student/Freelancer from Karlsruhe
• Love sports & coffee
• Crawl the web for information way too much of my time
github.com/crusoe
@forgerit
• My mentor: Christian Müller
• Core Dev TYPO3/Freelancer from Bonn
• Owner of kitsunet.de
The ProjectLessen the Gap from v4 v6 to Phoenix
• Content Transition
• Export contents of a v4 v6 instance and import to Phoenix
• Use existing interfaces
• Make it flexible and configurable
What again was this GSoC stuff?
• fellowship given out by Google to provide Open Source projects
• TYPO3 had been a sub-project 4 years in a row until 2011
• Unfortunately, TYPO3 hasn't been accepted for 2012 :( (Drupal was, WP not)
The initial idea
• use the well-known SYSEXT:impexp for generating XML data
• make exported data Phoenix-ready
• use XSLT to transform the exported data
• provide generated data as Phoenix packet and/or webservice
Problems & Solutions
• PHPs XSLTProcessor is rather old -> fill missing gaps with PHP+Regex
• Phoenix CTypes were not ready until about 3 weeks ago -> make CTypes configurable as"Snippets"
• XSLTProcessor's debug output is rather "un-verbose" -> no solution yet :( (use Saxon for XSLTdevelopment)
• ...
Current StatusTYPO3 Transition Tool
• A prototypical v4 v6 Extension
• Do the (common) work in just a few clicks
• Make it extendable (via XSLT & PHP)
• Try to make the code looking clean
The Transition Steps
• Step 1: Preparing the data
◦ Set Output Filename
◦ Select to-be-exported Database Tables
◦ Set Initial Page-Subtree Node (usually pid 0 for getting the whole Pagetree)
• Step 2: Transform the data
◦ Provide v4 v6 => Phoenix Content Type configuration
◦ Select to-be-used PHP-Hooks
• Step 3: Export the data
◦ Download Sites.xml
◦ Download packet
◦ Publish generated Data as Webservice
General Transformation Procedure
• have a base stylsheet which does the general procedure
• fetch all the user-chosen snippets and copy them into the base
• execute defined "pre-transformation" PHP-Hooks on the data
• run the XSLT Processor
• execute defined "post-transformation" PHP-Hooks on the xslt-processed data
Code!
view it on T3 Forge or Github.
Base XSLT Stylesheet
• kind of a "base" stylesheet containing several markers
• applies the general rules
• holds several markers which are to be replaced by the right snippets/contents
Code!
view it on T3 Forge or Github.
Content Types XSLT Snippets
• non-valid XSLT scripts (slices of them)
• work just in context of T3TT
• modular and independent from each other
• automagically fetched and traversed by the XSLT Processor
Code!
view it on T3 Forge or Github.
PHP Hooks
• filling gaps of XSLT v1
• kinda "meta-language" for XSLT
• can be easily added to a PHP file
• T3TT splits the to-be-altered Datafile into lines
• ... which can be changed e.g. via PCRE
PHP Hooks (pt. 2)
• needed before as well as after the XSLT transformation
• provide a way to do some quick'n'dirty adjustments
Some example hooks
killIndexColons (pre)
1 <!-- transform -->2 <tablerow index="tt_content:1" type="array">3 <!-- to -->4 <tablerow index="tt_content" id="1" type="array">
since XSLT v1 cannot "regex" attribute values. (v2 can!)
PHP Hooks (pt. 3)unescapeHtmlSpecialCharsOfFlexformValues (pre)
make Flexform transformations XSLT applicable (i.e. undo HSC) (currently not working :[ )
1 <!-- transform -->2 <T3FlexForms>3 <data>4 <sheet index="sDEF">5 ...6 <!-- to -->7 <T3FlexForms>8 <data>9 <sheet index="sDEF">
10 ...
normalizeNodeNames (post)
check that nodeName="{value}" contains Phoenix-compatible characters
!assert that nodeName-value
- is not empty- matches ([-_a-zA-Z0-9])- contains no whitespaces- ...
Code!
view it on T3 Forge or Github.
XSLT Intro• Why XSLT?
• The big pic:
◦ XPath
◦ <xsl:element> and <xsl:value-of>
◦ declarative
◦ pseudo-functional
• Tools
◦ Saxon
◦ XSLTCake
◦ Oxygen Editor (expensive!)
◦ phpStorm can execute XPath expressions
◦ Your Browser!
XSLT Intro (pt. 2)• Resources
◦ en.wikipedia.org on XSLT
◦ Beginning XSLT and XPath - Transforming XML Documents and Data
◦ XSLT (O'Reilly)
◦ XSLT Cookbook
◦ W3C XSLT v1
◦ W3C XSLT v2
XPath on an HTML DOM• Selecting the html node: / (root node)
• Select title node: /head/title
• Axes: child::* (standard), self::* , parent::* and attribute::/@
• Restrict the Selection to a div containing the attribute class="visible" : [@class='visible']
• Link several restrictions logically with and and or
Some built-in XSLT Functions• On currently selected node:
◦ name: name()
◦ value: text()
◦ concatenate strings: concat()
Important XSL TagsOutput
1 <!-- select a node's value -->2 <xsl:value-of select="{nodePath}"/>34 <!-- construct a div with class 'visible' -->5 <xsl:element name="{elementName}">6 <xsl:attribute name="class">visible</xsl:attribute>7 </xsl:element>
Important XSL Tags (pt. 2)(Sub-)Templates (~ Functions)
1 <!-- 'myTemplate' can only be manually called by another function -->2 <xsl:template name="myTemplate"> <!-- do stuff --></xsl:template>34 <!-- 'div' is called whenever a function uses <xsl:apply-templates select="/path/to/div/element" -->5 <xsl:template match="div"> <!-- do stuff --> </xsl:template>67 <!-- apply templates on selected nodes -->8 <xsl:apply-templates select="/path/to/div/element"/>
Important XSL Tags (pt. 3)Some Imperatives
1 <!-- loop over each node of selected node set 'myNodes'-->2 <xsl:for-each select="/path/to/myNodes"><!-- do stuff --></xsl:for-each>34 <!-- switch-case-alike -->5 <xsl:choose>6 <xsl:when test="ContitionA">7 <!-- do stuff when ConditionA is true -->8 </xsl:when>9 <xsl:when test="ConditionB">
10 <!-- do stuff when ConditionB is true -->11 </xsl:when>12 <xsl:otherwise>13 <!-- stuff that is done if neither ConditionA nor ConditionB were true -->14 </xsl:otherwise>15 </xsl:choose>1617 <!-- if -->18 <xsl:if test="someTestCondition"> <!-- do stuff if if is true --> </xsl:if>
Important XSL Tags (pt. 4)Initial Declarations
1 <?xml version="1.0" encoding="UTF-8"?>2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">3 <xsl:output4 method="xml"5 version="1.0"6 encoding="UTF-8"7 omit-xml-declaration="no"8 indent="yes"9 cdata-section-elements="source text"
10 />
Fooling around with XSLTSome possible tasks
• Use XSLTCake.com
• Format your v4 v6 Contents to browsable HTML
• Make a .PDF containing all your v4 v6 Pages
• Look at Phoenix CTypes and how to generate them
We need you!Participation
• Test the T3TT extension and send in bug reports
• Add support for new extensions
Thank you!