Beginner Tutorial - 09
Beginner Tutorial - 09
2
00:00:03,060 --> 00:00:06,939
welcome to another video about and XML that
3
00:00:06,940 --> 00:00:10,990
editorials and this video I'm gonna talk about
4
00:00:10,990 --> 00:00:14,490
axe SLT or I
5
00:00:14,490 --> 00:00:18,690
extensible stylesheet
6
00:00:18,690 --> 00:00:22,429
language transformation okay the
7
00:00:22,429 --> 00:00:28,309
so first the ball I I want you guys to know that access
8
00:00:28,309 --> 00:00:31,759
L I am is language
9
00:00:31,760 --> 00:00:35,679
a is the extensible stealth sheet language
10
00:00:35,679 --> 00:00:39,320
okay I so is the language that was created
11
00:00:39,320 --> 00:00:43,329
to you I'm like CSS was created for
12
00:00:43,329 --> 00:00:47,280
HTML XSL it was created for
13
00:00:47,280 --> 00:00:50,308
XML documents okay so we can a
14
00:00:50,308 --> 00:00:53,839
style a.m. the XML documents as
15
00:00:53,840 --> 00:00:57,270
we want with XSL I am
16
00:00:57,270 --> 00:01:00,350
but now a and you the
17
00:01:00,350 --> 00:01:04,760
a map that appear and is the XSLT
18
00:01:04,760 --> 00:01:09,299
which means XSL a.m. extensible stylesheet
19
00:01:09,299 --> 00:01:12,540
language transformation okay a
20
00:01:12,540 --> 00:01:16,590
so what it does its transforms a.m.
21
00:01:16,590 --> 00:01:20,469
the the style to whatever
22
00:01:20,469 --> 00:01:23,670
a.m. type of document we want okay
23
00:01:23,670 --> 00:01:26,829
a so i'm good show you just
24
00:01:26,829 --> 00:01:30,060
a little and example okay
25
00:01:30,060 --> 00:01:34,290
how to take a simple XML file and how to transform it
26
00:01:34,290 --> 00:01:37,409
to another type of file okay so
27
00:01:37,409 --> 00:01:41,930
before I am we start or
28
00:01:41,930 --> 00:01:44,979
from okay let's just do the XML for
29
00:01:44,978 --> 00:01:49,009
first XML file so the first thing we have to do is create let's create some
30
00:01:49,009 --> 00:01:49,750
mom
31
00:01:49,750 --> 00:01:52,969
list of albums as we did in the let and
32
00:01:52,969 --> 00:01:56,750
previous videos so a normal
33
00:01:56,750 --> 00:02:00,000
XML okay so to start we have to declare
34
00:02:00,000 --> 00:02:03,009
the XML I am version
35
00:02:03,009 --> 00:02:06,040
so
36
00:02:06,040 --> 00:02:10,250
XML version
37
00:02:10,250 --> 00:02:15,120
equals 1.0 and encoding
38
00:02:15,120 --> 00:02:18,700
weekend type yes so
39
00:02:18,699 --> 00:02:23,589
antoine
40
00:02:23,590 --> 00:02:28,030
which is the code this is the code for the general
41
00:02:28,030 --> 00:02:31,620
or the American English arm
42
00:02:31,620 --> 00:02:35,420
type data and here
43
00:02:35,419 --> 00:02:39,809
catalog and here
44
00:02:39,810 --> 00:02:46,239
course catalog K
45
00:02:46,239 --> 00:02:49,239
and here will start is
46
00:02:49,239 --> 00:02:53,500
to put album and close
47
00:02:53,500 --> 00:02:56,759
album K
48
00:02:56,759 --> 00:03:00,658
so in here I'm going to title
49
00:03:00,658 --> 00:03:05,459
and close title and artist
50
00:03:05,459 --> 00:03:09,408
and close artist
51
00:03:09,408 --> 00:03:12,509
and country
52
00:03:12,509 --> 00:03:16,158
thank all those country
53
00:03:16,158 --> 00:03:19,829
and it's a
54
00:03:19,830 --> 00:03:23,480
price and close
55
00:03:23,479 --> 00:03:26,818
price okay
56
00:03:26,818 --> 00:03:31,119
and I am so let's continue
57
00:03:31,120 --> 00:03:35,430
let's go up with this p
58
00:03:35,430 --> 00:03:38,580
based
59
00:03:38,580 --> 00:03:42,830
and let's do one more and paste
60
00:03:42,830 --> 00:03:48,459
so we would have three different albums now it's a Bob Marley
61
00:03:48,459 --> 00:03:51,670
apps sorry
62
00:03:51,669 --> 00:03:58,669
exodus Bob Marley
63
00:03:59,060 --> 00:04:04,170
country Jamaica price
64
00:04:04,169 --> 00:04:08,818
1989 I'm here title
65
00:04:08,818 --> 00:04:15,818
black album
66
00:04:16,339 --> 00:04:19,448
like a country
67
00:04:19,449 --> 00:04:22,530
say priced anti
68
00:04:22,529 --> 00:04:26,878
and here style title
69
00:04:26,879 --> 00:04:30,330
a nevermind
70
00:04:30,329 --> 00:04:33,459
arianna
71
00:04:33,459 --> 00:04:37,209
country you say and price
72
00:04:37,209 --> 00:04:40,278
20 to you okay
73
00:04:40,278 --> 00:04:45,310
I am so we have now said three different albums
74
00:04:45,310 --> 00:04:49,589
and our catalog perfect
75
00:04:49,589 --> 00:04:54,369
sick this and knowing when to do
76
00:04:54,370 --> 00:04:57,399
is arm open
77
00:04:57,399 --> 00:05:01,579
and you file and in this new file
78
00:05:01,579 --> 00:05:06,579
I just hacked type year am
79
00:05:06,579 --> 00:05:13,069
that's a XML
80
00:05:13,069 --> 00:05:17,189
XML version equals
81
00:05:17,189 --> 00:05:24,189
on .0
82
00:05:27,430 --> 00:05:30,810
code and because the s so
83
00:05:30,810 --> 00:05:33,990
and 88 and I'm
84
00:05:33,990 --> 00:05:40,100
on grows
85
00:05:40,100 --> 00:05:45,669
now access I'll I'll
86
00:05:45,668 --> 00:05:50,049
sheet version
87
00:05:50,050 --> 00:05:53,230
equals 1.0
88
00:05:53,230 --> 00:05:57,280
and the XML
89
00:05:57,279 --> 00:06:02,689
on namespace is going to be a XSL
90
00:06:02,689 --> 00:06:06,740
equals two HTTP
91
00:06:06,740 --> 00:06:11,439
blue
92
00:06:11,439 --> 00:06:14,660
and W 3
93
00:06:14,660 --> 00:06:19,110
or and I'm
94
00:06:19,110 --> 00:06:24,030
XSL Tran
95
00:06:24,029 --> 00:06:27,259
for okay so this is the namespace
96
00:06:27,259 --> 00:06:31,360
for the I'm as the healthy
97
00:06:31,360 --> 00:06:34,449
I'll or XSL file okay
98
00:06:34,449 --> 00:06:39,610
that we are created now now XSL here
99
00:06:39,610 --> 00:06:43,610
prefix SSL template
100
00:06:43,610 --> 00:06:50,610
match equals
101
00:06:51,860 --> 00:06:54,930
thus a backslash and now here
102
00:06:54,930 --> 00:06:58,590
at what I'm going to do you is
103
00:06:58,589 --> 00:07:03,009
type HTML and here
104
00:07:03,009 --> 00:07:06,829
body so as you might figured out right now
105
00:07:06,829 --> 00:07:12,939
I'm going to transform the basically did this
106
00:07:12,939 --> 00:07:17,800
XML file to I am an XHTML
107
00:07:17,800 --> 00:07:22,290
okay with all the tax I am
108
00:07:22,290 --> 00:07:27,230
dad an exceptional should have and then present
109
00:07:27,230 --> 00:07:31,390
the this a albums and annexes shamelle
110
00:07:31,389 --> 00:07:34,759
a.m. typeof output okay
111
00:07:34,759 --> 00:07:38,750
in our web in the in a web page okay so you'll see the result
112
00:07:38,750 --> 00:07:42,490
in a minute so h2
113
00:07:42,490 --> 00:07:46,250
en hue my catalog
114
00:07:46,250 --> 00:07:50,279
and close h2
115
00:07:50,279 --> 00:07:53,949
and I camp but table now
116
00:07:53,949 --> 00:07:57,310
table border equals
117
00:07:57,310 --> 00:08:01,829
1 and here
118
00:08:01,829 --> 00:08:07,180
TR and tiara PGE
119
00:08:07,180 --> 00:08:11,610
growler apps sorry BG color
120
00:08:11,610 --> 00:08:14,830
equals to you
121
00:08:14,829 --> 00:08:18,750
C-nine I
122
00:08:18,750 --> 00:08:22,100
a 9 a she the
123
00:08:22,100 --> 00:08:25,520
32 you close this
124
00:08:25,519 --> 00:08:28,979
and now th
125
00:08:28,980 --> 00:08:32,418
cause th
126
00:08:32,418 --> 00:08:35,449
sided
127
00:08:35,450 --> 00:08:38,750
title and
128
00:08:38,750 --> 00:08:42,659
th artist
129
00:08:42,659 --> 00:08:45,779
misty
130
00:08:45,779 --> 00:08:52,029
title artist country and price artist
131
00:08:52,029 --> 00:08:55,230
and now just set
132
00:08:55,230 --> 00:08:58,759
typing year closed
133
00:08:58,759 --> 00:09:02,759
are and now
134
00:09:02,759 --> 00:09:09,759
type a X cell and for
135
00:09:10,360 --> 00:09:15,029
each solak
136
00:09:15,029 --> 00:09:18,049
and
137
00:09:18,049 --> 00:09:24,389
catalog apps catalog CD
138
00:09:24,389 --> 00:09:27,960
and
139
00:09:27,960 --> 00:09:33,530
here type TR and here
140
00:09:33,529 --> 00:09:36,850
TD and
141
00:09:36,850 --> 00:09:42,159
access lol value
142
00:09:42,159 --> 00:09:45,480
of
143
00:09:45,480 --> 00:09:49,250
select equals
144
00:09:49,250 --> 00:09:56,230
and title
145
00:09:56,230 --> 00:09:59,470
and close to D and
146
00:09:59,470 --> 00:10:06,470
year copy this
147
00:10:07,059 --> 00:10:09,708
pasted
148
00:10:09,708 --> 00:10:16,708
and Christy are
149
00:10:17,919 --> 00:10:22,558
title title not title here is artist
150
00:10:22,558 --> 00:10:26,058
K I'm here
151
00:10:26,058 --> 00:10:29,509
just have to type
152
00:10:29,509 --> 00:10:34,318
access cell for
153
00:10:34,318 --> 00:10:38,139
each and
154
00:10:38,139 --> 00:10:44,068
table
155
00:10:44,068 --> 00:10:48,528
and body and HTML
156
00:10:48,528 --> 00:10:51,708
and I am
157
00:10:51,708 --> 00:10:56,368
ok close
158
00:10:56,369 --> 00:11:00,160
access so template
159
00:11:00,159 --> 00:11:03,698
and some
160
00:11:03,698 --> 00:11:08,109
XSL
161
00:11:08,110 --> 00:11:11,330
style she finally
162
00:11:11,330 --> 00:11:15,690
okay a so it takes a little bit of work but arm
163
00:11:15,690 --> 00:11:18,980
it's good for your coat practice
164
00:11:18,980 --> 00:11:22,279
okay so style sheet
165
00:11:22,279 --> 00:11:27,629
now let's save this as an XSL file
166
00:11:27,629 --> 00:11:31,559
so I'm going to
167
00:11:31,559 --> 00:11:35,579
save this s catalog dot
168
00:11:35,580 --> 00:11:39,639
XSL a
169
00:11:39,639 --> 00:11:42,779
say this held
170
00:11:42,779 --> 00:11:45,949
catalog XSL now we have to do you
171
00:11:45,950 --> 00:11:50,400
is to make here a.m. declaration to relate
172
00:11:50,399 --> 00:11:54,360
to the cattle except XSL K arm
173
00:11:54,360 --> 00:11:58,060
so to do that its pretty easy to set to come up
174
00:11:58,059 --> 00:12:01,159
here and pics and now
175
00:12:01,159 --> 00:12:06,059
style sheet
176
00:12:06,059 --> 00:12:09,079
type equals
177
00:12:09,080 --> 00:12:13,690
a text cell
178
00:12:13,690 --> 00:12:17,520
apps backs Texas
179
00:12:17,519 --> 00:12:21,519
I'll and a traffic will
180
00:12:21,519 --> 00:12:25,990
um catalog
181
00:12:25,990 --> 00:12:30,960
access cell K so that's pretty much it
182
00:12:30,960 --> 00:12:34,910
let's hope this and
183
00:12:34,909 --> 00:12:39,360
to open I am the file
184
00:12:39,360 --> 00:12:42,460
albums XML and see how
185
00:12:42,460 --> 00:12:48,450
XSL comforts this I am this fire presentation we just have to run this
186
00:12:48,450 --> 00:12:55,450
chrome and let's see the result
187
00:12:57,549 --> 00:13:03,808
okay we don't get map and the problem is okay the problem is that
188
00:13:03,808 --> 00:13:06,818
instead a problem as data sorry
189
00:13:06,818 --> 00:13:10,178
here instead over the city we have to put here
190
00:13:10,178 --> 00:13:13,549
album sorry so catalog album
191
00:13:13,549 --> 00:13:17,378
catalog our home save this
192
00:13:17,379 --> 00:13:20,490
okay so
193
00:13:20,490 --> 00:13:23,649
I found a an error here which is I
194
00:13:23,649 --> 00:13:26,818
you have to put the declaration XML at that
195
00:13:26,818 --> 00:13:30,578
first-line okay at top page you have always to do that
196
00:13:30,578 --> 00:13:33,628
I had this and my second line
197
00:13:33,629 --> 00:13:38,339
so you have to put it this always at the top as well as your XML
198
00:13:38,339 --> 00:13:42,699
okay and down here as well I had
199
00:13:42,698 --> 00:13:46,419
a.m. a little space year and template
200
00:13:46,419 --> 00:13:50,389
so you don't you mustn't have any space there
201
00:13:50,389 --> 00:13:54,438
either & Style Sheets okay so safe that
202
00:13:54,438 --> 00:13:58,899
okay so now we are ready to try
203
00:13:58,899 --> 00:14:02,458
a the XML file and transform it
204
00:14:02,458 --> 00:14:05,469
and to you exhibition of file to do that
205
00:14:05,470 --> 00:14:08,499
just simply open the XML file
206
00:14:08,499 --> 00:14:15,428
and I'm Firefox or chrome or whatever browser you have normally have to
207
00:14:15,428 --> 00:14:18,678
I have a browser that supports excess a.m.
208
00:14:18,678 --> 00:14:21,928
X SLT okay I'm
209
00:14:21,928 --> 00:14:25,649
in this case I'm gonna use I tried Chrome but my chrome
210
00:14:25,649 --> 00:14:30,659
as the not a.m. updated so I had to use Firefox
211
00:14:30,659 --> 00:14:34,759
and if you use the and upgraded version of Firefox
212
00:14:34,759 --> 00:14:38,778
that supports XLT the result up this
213
00:14:38,778 --> 00:14:41,838
transformation that we did with XSL
214
00:14:41,839 --> 00:14:45,069
is going to be a
215
00:14:45,068 --> 00:14:48,289
this one here okay so the code
216
00:14:48,289 --> 00:14:53,208
this is the code and if you see here at the bar
217
00:14:53,208 --> 00:14:56,558
at the top you see the
218
00:14:56,558 --> 00:15:00,600
file that we opened is albums dot XML
219
00:15:00,600 --> 00:15:06,360
but I am we did some transformation use in XSL
220
00:15:06,360 --> 00:15:10,778
an or XSLT and this is the output
221
00:15:10,778 --> 00:15:13,798
that we have from our XML okay
222
00:15:13,798 --> 00:15:16,798
it's more presentable an
223
00:15:16,798 --> 00:15:19,980
we have some little
224
00:15:19,980 --> 00:15:24,079
background-color: here and I'm our
225
00:15:24,078 --> 00:15:27,969
two columns with the artist and the title at the album
226
00:15:27,970 --> 00:15:31,540
okay guys so this a pretty a simple example
227
00:15:31,539 --> 00:15:35,838
a how we can transform files with XSLT
228
00:15:35,839 --> 00:15:39,290
and hair you can go to a
229
00:15:39,289 --> 00:15:43,278
you can go to preschools or
230
00:15:43,278 --> 00:15:47,778
search for some tutorials a if you want to go deeper
231
00:15:47,778 --> 00:15:51,499
and with XSLT okay see you guys later
232
00:15:51,499 --> 00:15:52,870
and don't forget this track by