47. XSL:if content has #something
<replace
css:theme=”#theme1”
css:content=”#content1”
css:if-content=”#something”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
48. XSL:if content has #something
XSL: pull in #content1
<replace
css:theme=”#theme1”
css:content=”#content1”
css:if-content=”#something”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
49. XSL:if content has #something
XSL: pull in #content1
XSL:else
<replace
css:theme=”#theme1”
css:content=”#content1”
css:if-content=”#something”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
50. XSL:if content has #something
XSL: pull in #content1
XSL:else
<div id=”theme1”>
Theme1 Stuff
</div>
<replace
css:theme=”#theme1”
css:content=”#content1”
css:if-content=”#something”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
51. <before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
52. XSL: pull in #cbefore
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
53. XSL: pull in #cbefore
<div id=”theme1”>
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
54. XSL: pull in #cbefore
<div id=”theme1”>
XSL: pull in #cbefore-children
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
55. XSL: pull in #cbefore
<div id=”theme1”>
XSL: pull in #cbefore-children
Theme 1 Stuff
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
56. XSL: pull in #cbefore
<div id=”theme1”>
XSL: pull in #cbefore-children
Theme 1 Stuff
XSL: pull in #cafter-children
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
57. XSL: pull in #cbefore
<div id=”theme1”>
XSL: pull in #cbefore-children
Theme 1 Stuff
XSL: pull in #cafter-children
</div>
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
58. XSL: pull in #cbefore
<div id=”theme1”>
XSL: pull in #cbefore-children
Theme 1 Stuff
XSL: pull in #cafter-children
</div>
XSL: pull in #cafter
<before theme=”#theme1” … />
<before theme-children”#theme1” …/>
<after theme-children=”theme1” … />
<after theme=”theme1” … />
R
U
L
E
S
X
S
L
Thursday, October 3, 13
59. <after theme-children=”theme1” … />
<before theme-children”#theme1” …/>
<after theme=”theme1” … />
<before theme=”#theme1” … />
XSL: pull in #cbefore
<div id=”theme1”>
XSL: pull in #cbefore-children
Theme 1 Stuff
XSL: pull in #cafter-children
</div>
XSL: pull in #cafter
R
U
L
E
S
X
S
L
Thursday, October 3, 13
63. XSL: pull in #content1
<replace
css:theme=”#theme1”
css:content=”#content1”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
64. XSL: pull in #content1
XSL: process what just got
pulled in
<replace
css:theme=”#theme1”
css:content=”#content1”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
65. XSL: pull in #content1
XSL: process what just got
pulled in
“content” drops / replaces
<replace
css:theme=”#theme1”
css:content=”#content1”
/>
R
U
L
E
X
S
L
Thursday, October 3, 13
66. <before css:theme=”#theme1” … />
<after css:theme=”#theme1” … />
<drop css:content=”#nastytag” />
XSL: pull in #cbefore
<div id=”theme1”>
Theme 1 Stuff
</div>
XSL: pull in #cafter
R
U
L
E
S
X
S
L
Thursday, October 3, 13
67. <before css:theme=”#theme1” … />
<after css:theme=”#theme1” … />
<drop css:content=”#nastytag” />
XSL: pull in #cbefore
<div id=”theme1”>
Theme 1 Stuff
</div>
XSL: pull in #cafter
R
U
L
E
S
X
S
L
— do content drop
— do content drop
Thursday, October 3, 13
68. <drop css:content=”#nastytag” />
<before css:theme=”#theme1” … />
<after css:theme=”#theme1” … />
XSL: pull in #cbefore
<div id=”theme1”>
Theme 1 Stuff
</div>
XSL: pull in #cafter
R
U
L
E
S
X
S
L
— do content drop
— do content drop
Thursday, October 3, 13
71. T
H
E
M
E
<body>
...
<div id=”#newsslot” />
...
<div id=”#rightcol” />
...
</body>
<replace
css:theme-children=”#newsslot”
css:content=”.portletNews”
/>
<drop css:content=”.portletNews” />
<replace
css:theme-children=”#rightcol”
css:content-children=”#col3”/>
R
U
L
E
Thursday, October 3, 13
72. T
H
E
M
E
<body>
...
<div id=”#newsslot” />
...
<div id=”#rightcol” />
...
</body>
<replace
css:theme-children=”#newsslot”
css:content=”.portletNews”
/>
<drop css:content=”.portletNews” />
<replace
css:theme-children=”#rightcol”
css:content-children=”#col3”/>
R
U
L
E
mode=”raw” />
Thursday, October 3, 13
75. X
S
L
XSL: pull in #col3
XSL: do “content” drops and
replaces on what was
inserted
<replace
css:theme-children=”#rightcol”
css:content-children=”#col3”
/>
R
U
L
E
Thursday, October 3, 13
76. X
S
L
XSL: pull in #col3
XSL: do “content” drops and
replaces on what was
inserted
<replace
css:theme-children=”#rightcol”
css:content-children=”#col3”
/>
R
U
L
E mode=”raw” />
do routine cleanup,
but no content drops /
replaces
Thursday, October 3, 13
87. Where Diazo
breaks down:
Manipulating content beyond drop/replace
Manipulating attributes/text
Require XSLT
And we’re not
doing that today!
Thursday, October 3, 13
An interpreter reads the rules file as a list of instructions.Starts with copy of theme, applies rules, one at a time, transforming theme at each stage. Output in one step is input in the next.
Two parts: Part one: Rules are used to analyze and transform theme to produce an XSL template. Content is not involved in part one. Part two: template applied to content. Original theme is not involved. Variety of transformation engines available.
Let’s look back at part one of the processing. The important thing to realize is that the mapping of the rules onto the theme is much more like CSS than Python. The ordering of your rules makes a difference in the same way it does with CSS - as a tie-breaker.
Back to part two XSL template is applied to transform content. An XSLT engine is basically a node processor - a recursive one.
Let’s watch this in action for a simple replace. No, that’s not real XSL -- all you’ll see today is pseudo code
Let’s just elaborate the previous example to see how “children” specs are applied. Note that the outer div survives the transform.
Let’s add a conditional and see how that works
And, some before and after rules. Order doesn’t matter! Generated XSL stays the same.
What about content drop / replace rules? Here’s where the recursive character of XSL transformation comes in.
Let’s return to our replace example. This is a regular theme replacement. But there’s a step we didn’t show before: continued processing - content drop replaces
content drops/replaces are done with each pull from content, on what’s been pulled. Rule order doesn’t matter! All content rules are applied during this processing
First, a simple attempt at a move; move news portlet to a box of its own; leave rest of portlets. This would depend on the order of the rules; it will not work; .portletNews content will be missing from the final page. More advanced diazo users know how to fix this: with a mode directive. But note where it goes!
“ Cooking” is what we’ve been doing all along, executing content drops and replaces automatically. Adding mode=”raw” changes the XSLT processing after the insert.