-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyslt.en.yhtml2
1069 lines (812 loc) · 33.9 KB
/
yslt.en.yhtml2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
include homepage.en.yhtml2
page "YSLT – XSLT C style" {
h1 id=intro > YSLT – an introduction
p >>
Especially the ¬https://www.w3.org/TR/1999/REC-xslt-19991116 XSLT¬ programmer can benefit from YML.
Usually many attributes of XSLT are annoying in programming praxis:
>>
ul {
li >>
the missing separation of ¬http://en.wikipedia.org/wiki/Indent_style indention¬
of the XSLT program and indention of the output text
>>
li > the complicated syntax
li > the lack of good text escaping mechanisms (< and > are not seldom)
li > ...
}
p > In short, it's ugly ;-)
p >>
Usually the result is, that many programmers are avoiding XSLT as a programming language.
It's a pity, because for processing XML data, it can do much more than “formatting” as
“stylesheets”.
>>
p >>
The idea of YSLT now is to supply a simple language, which programmers want to use, to
make the features of XSLT accessible to a broader base of people.
>>
p >>
YSLT can be used much simpler; it's just a ¬http://fdik.org/yml/index#ylanguages Y Language¬
for XSLT. I'm using it for my blog, here you can ¬http://fdik.org/yblog2.tar.bz2 download YBlog2¬,
a simple blogging software in YSLT.
>>
p > Here you can find the ¬yslt.yml2 YSLT specification¬.
h2 id=hello > Hello, World
p > In YSLT, the hello world program reads like this:
Code ||
include yslt.yml2
textstylesheet template "/" | hello, world
||
p >>
The `a href="http://fdik.org/yml/features#including" code > include` line includes the
YSLT Y Language declarations. The second line generates an XSLT hello world program.
You can generate it using:
>>
Code | % yml2c -o hello.xsl hello.ysl2
p > This results in the following program:
Code ||
<xsl:stylesheet xmlns:func="http://exslt.org/functions"
xmlns:dyn="http://exslt.org/dynamic" xmlns:str="http://exslt.org/strings"
xmlns:math="http://exslt.org/math"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
extension-element-prefixes="exsl func str dyn set math"
xmlns:set="http://exslt.org/sets" version="1.0"
xmlns:exsl="http://exslt.org/common"><xsl:output method="text"/>
<xsl:variable name="space" select="' '"/>
<xsl:param name="autoindent" select="4"/><xsl:template match="/">
<xsl:param name="_indent" select="0"/><xsl:value-of
select="substring($space, 1, $_indent+0*$autoindent)"/>hello, world
</xsl:template></xsl:stylesheet>
||
p >>
You can execute this program with any
¬http://en.wikipedia.org/wiki/XML_template_engine XSL processor¬, for example the Free Software
¬http://xmlsoft.org/XSLT/xsltproc2.html xsltproc¬.
>>
Code ||
% yml2c -o hello.xsl hello.ysl2
% echo '<empty/>' > empty.xml
% xsltproc hello.xsl empty.xml
hello, world
% _
||
p >>
Or you can just use ¬toolchain#processor yml2proc¬:
>>
Code ||
% yml2proc -My hello.ysl2
hello, world
% _
||
h2 id=programming > Programming in YSLT
p >>
Because YSLT is just a ¬index#ylanguages Y Language¬ for XSLT, you can do anything with YSLT
you can do with XSLT in just nicer syntax ;-) To read what XSLT is all about, I recommend
¬https://www.w3.org/TR/1999/REC-xslt-19991116 the official W3C documentation for XSLT¬.
>>
p >>
So this document is just an beginners guide, if you want to understand XSLT completely,
better read the ¬http://www.w3.org W3C¬ stuff.
>>
h3 > Programming YSLT means programming with a pure functional language.
p >>
Lovers of ¬http://en.wikipedia.org/wiki/Lisp_(programming_language) Lisp¬ or
¬http://www.haskell.org/ Haskell¬ will not see any problems. But many programmers are used to
have a programming language with a
¬http://en.wikipedia.org/wiki/Procedural_programming procedural imperative paradigma¬ like
¬http://java.sun.com Java¬,
¬http://en.wikipedia.org/wiki/C_(programming_language) C¬/¬http://en.wikipedia.org/wiki/C++ C++¬
or ¬http://www.python.org Python¬. Why should they use a
¬http://en.wikipedia.org/wiki/Functional_programming functional¬ language?
>>
p >>
Actually, if a functional language is practical or not, depends of what's to do – “the
right tool for the task”, one could say.
>>
p >>
Because processing XML data means traversing a (document) tree,
¬http://en.wikipedia.org/wiki/Recursion recursive¬ algorithms are a clear advantage.
And this is the reason, why choosing a functional language is a good choice for that job.
>>
p >>
It's a little bit like with ¬http://en.wikipedia.org/wiki/SQL SQL¬ – for it's job, it's
excellent, but no-one wants to write a complete application in SQL (and also not in one
of the Turing-complete SQL extension languages like
¬http://www.oracle.com/technology/tech/pl_sql/index.html PL/SQL¬).
>>
h3 id=htmlgen > Generating HTML out of a DSL
p >>
Of course, you can use YSLT as you would use XSLT. Let's say, you have data in XML
documents, and you want to have an excerpt out of this data. This is a common task,
comparable to «SELECT» data out of an SQL database. But we have no database, we have
something like this file customers.yml2:
>>
Code ||
decl customer(*id, *name) { id *id, name *name };
list {
customer 23, "Kurt Meier";
customer 42, "Lieschen Schmidt";
}
||
p >>
Let's say, we want to output this into an ¬http://en.wikipedia.org/wiki/XHTML XHTML¬ document,
where the list is showed as a table. Then we would do the following:
>>
p > The XHTML document should be like the following and include the list in the body:
Code ||
include yslt.yml2
stylesheet {
template "/" html {
head title "Customer List";
body apply "list";
}
||
p >>
In the example above, stylesheet declares the main program. Then we define a template, which
is executed automatically starting reading the root «'/'» of the document tree of the XML
document we're processing.
>>
p > Using the XML document as input, we're creating this HTML tree:
Code ||
<html>
<head>
<title>Customer List</title>
</head>
<body>
<!-- ... ->
</body>
</html>
||
p > How do we create the list? Well, let's use a table with customers:
Code | template "list" table apply "customer";
p >>
What to do per customer? Well, generate a table row with two columns, one for «id» and one
for «name»:
>>
Code ||
template "customer" tr {
td value "id";
td value "name";
}
}
||
p > That was it. We now can run our small program:
Code | % yml2proc -y customer.ysl2 -x customer.xml -o customer.html -P
p > The result looks like this:
Code ||
% cat customer.html
<?xml version="1.0"?>
<html>
<head>
<title>Customer List</title>
</head>
<body>
<table>
<tr>
<td>23</td>
<td>Kurt Meier</td>
</tr>
<tr>
<td>42</td>
<td>Lieschen Schmidt</td>
</tr>
</table>
</body>
</html>
% _
||
p > Here you can download ¬samples/customer.ysl2 the complete program¬.
h3 id=codegen > How to generate code with YSLT
p > Generating code is easy with YSLT, if you follow these steps:
ol {
li > design the software you want to generate using patterns and write that in a DSL
li > write target code once for each pattern
li > deconstruct a compiler for the target code for each pattern
li > fine tune until the diff is empty
}
p >>
Let's test by example. First let's say, we have a pattern of entities we want
to implement as Java beans. The enities in our DSL are:
>>
Code ||
decl entity +name;
decl attr +type +name;
decl aggregates +entity;
structure {
entity Customer {
attr String name;
attr int creditLimit;
aggregates Order;
}
entity Order {
attr String no;
attr String description;
attr int amount;
}
}
||
p >>
How to write that in a Java Program? Well, following the second step, we're
writing our target code manually; for this simple sample, let's be naive and
save the following into a file named Customer.java.target:
>>
Code ||
import java.util.Vector;
import java.util.Collections;
import base.Entity;
class Customer extends Entity {
Customer {
id = genId();
}
// attribute name
private String name;
public String getName() {
return name;
}
public void setName(String value) {
name = value;
}
// attribute creditLimit
private int creditLimit;
public int getCreditLimit() {
return creditLimit;
}
public void setCreditLimit(int value) {
creditLimit = value;
}
// Order aggregation
protected Vector orderList = new Vector();
void addOrder(Order entity) {
orderList.add(entity);
}
void removeOrder(Order entity) {
orderList.remove(entity);
}
Iterator orderIterator() {
return orderList.iterator();
}
}
||
p >>
The third step does most of the work. First we cite this code
into gen_entity.ysl2 and create the basic form of an YSLT script:
>>
Code ||
include yslt.yml2
tstylesheet {
template "/" {
| import java.util.Vector;
| import java.util.Collections;
| import base.Entity;
|
| class Customer extends Entity {
| Customer {
| id = genId();
| }
|
| // attribute name
|
| private String name;
| public String getName() {
| return name;
| }
| public void setName(String value) {
| name = value;
| }
|
| // attribute creditLimit
|
| private int creditLimit;
| public int getCreditLimit() {
| return creditLimit;
| }
| public void setCreditLimit(int value) {
| creditLimit = value;
| }
|
| // Order aggregation
|
| protected Vector orderList = new Vector();
| void addOrder(Order entity) {
| orderList.add(entity);
| }
| void removeOrder(Order entity) {
| orderList.remove(entity);
| }
| Iterator orderIterator() {
| return orderList.iterator();
| }
| }
}
}
||
p >>
Now for the deconstruction. I think, it'll be best, if we
¬#edocument create a .java file for each entity¬.
So we're moving the whole thing into a template for each entity
creating a file, and we're applying this for each entity using the name of each
Entity as parameter. We're adding some distinction of cases, too.
>>
p >>
When we apply, the indention system of YSLT will add an indention level, so we can
take out rendundant whitespace; for the first apply we don't want this, so we're
giving the number 0 as the indention level.
>>
p >>
In attributes, braces «{…}» let us insert the value of an XPath expression into our
DSL, while inside quoted text the same is done by the ¬#angledouble angle double quotes¬
`] <code>«…»</code>`:
>>
Code ||
include yslt.yml2
tstylesheet {
template "/structure" apply "Entity", 0;
template "Entity" document "{@name}.java" {
if "aggregates" {
| import java.util.Vector;
| import java.util.Collections;
}
| import base.Entity;
|
| class `] «`@name`] »` extends Entity {
| `] «`@name`] »` {
| id = genId();
| }
|
[...]
| orderList.remove(entity);
| }
| Iterator orderIterator() {
| return orderList.iterator();
| }
| }
}
}
||
p >>
Well, not bad. Now for the pattern of an attribute and an aggregation, respectively.
>>
Code ||
include yslt.yml2
tstylesheet {
template "/structure" apply "Entity";
template "Entity" document "{@name}.java" {
if "aggregates" {
| import java.util.Vector;
| import java.util.Collections;
}
| import base.Entity;
|
| class `] «`@name`] »` extends Entity {
| `] «`@name`] »` {
| id = genId();
| }
|
apply "attr|aggregates";
| }
}
template "attr" {
|
| // attribute `] «`@name`] »`
|
| private `] «`@type`] »` `] «`@name`] »`;
| public `] «`@type`] »` get`] «`@name`] »`() {
| return `] «`@name`] »`;
| }
| public void set`] «`@name`] »`(`] «`@type`] »` value) {
| `] «`@name`] »` = value;
| }
}
template "aggregates" {
|
| // `] «`@entity`] »` aggregation
|
| protected Vector `] «`@entity`] »`List = new Vector();
| void add`] «`@entity`] »`(`] «`@entity`] »` entity) {
| `] «`@entity`] »`List.add(entity);
| }
| void remove`] «`@entity`] »`(`] «`@entity`] »` entity) {
| `] «`@entity`] »`List.remove(entity);
| }
| Iterator `] «`@entity`] »`Iterator() {
| return `] «`@entity`] »`List.iterator();
| }
}
}
||
p >>
As you can see, we're deconstructing step by step. This is a good idea to get
into code generation with YSLT, but it remains a good idea even for the advanced
programmer: it keeps a clear view on what's happening.
>>
p >>
In the last step, test it out and make a diff to your target code. You will see
that our example needs some beautifying: in Java, camel case is important and
makes you some work to revert characters to uppercase or lowercase, respectively.
For that work you'll see that ¬http://www.w3.org/TR/xpath/#function-translate XPath's translate() function¬ is a little bit ugly ;-)
So we're defining an ¬features#userop operator¬ for that at the top of the file:
>>
Code ||
define operator "“(.*?)”" as call "ucase" with "text", "%1";
||
p >>
Inside the template, we're defining the ucase function:
>>
Code ||
function "ucase" {
param "text";
value "translate(substring($text,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')";
value "substring($text, 2)";
}
}
||
p >>
Now we can replace one quoting with another; have a look at the getter and setter
methods:
>>
Code ||
include yslt.yml2
define operator "“(.*?)”" as call "ucase" with "text", "%1";
tstylesheet {
template "/structure" apply "Entity";
[...]
template "attr" {
|
| // attribute `] «`@name`] »`
|
| private `] «`@type`] »` `] «`@name`] »`;
| public `] «`@type`] »` get“@name”() {
| return `] «`@name`] »`;
| }
| public void set“@name”(`] «`@type`] »` value) {
| `] «`@name`] »` = value;
| }
}
[...]
function "ucase" {
param "text";
value "translate(substring($text,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')";
value "substring($text, 2)";
}
}
||
p >>
Well, the rest is a pure laborious task ;-) Feel free to complete. And: use diff!
>>
h3 id=ddlgen > A more advanced example: generating SQL DDL out of an UML diagram
p >>
Well, now for something real ;-) This is a very common task: somebody models
with an ¬http://en.wikipedia.org/wiki/Class_diagram UML class diagram¬, and you want
to have SQL ¬http://en.wikipedia.org/wiki/Data_Definition_Language DDL¬, which generates
a matching database structure.
>>
p > Let's go:
p >>
First, lets use a stylesheet, which declares the needed
¬http://www.w3.org/TR/REC-xml-names/ XMI namespaces¬:
>>
Code ||
include yslt.yml2
tstylesheet xmlns:uml="http://schema.omg.org/spec/UML/2.1",
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" {
||
p > Now, search the Model for all content:
Code | template "/" apply "xmi:XMI/uml:Model/packagedElement", 0;
p >>
We're translating ¬http://en.wikipedia.org/wiki/Package_(UML) UML Packages¬ into
underscore separated prefixes:
>>
Code ||
template "packagedElement[@xmi:type='uml:Package']" {
param "name", "''";
if "$name=''" apply "packagedElement", 0 { with "name", "@name"; }
if "$name!=''" apply "packagedElement", 0 { with "name", "concat($name, '_', @name)"; }
}
||
p > Each Class is represented by a table in the database:
Code ||
template "packagedElement[@xmi:type='uml:Class']" {
param "name";
| CREATE TABLE «$name»_«@name» (
apply "ownedAttribute";
| );
}
||
p >>
Finally, for each different data type for an attribute we're outputting different fields
with different types:
>>
Code ||
template "ownedAttribute[@xmi:type='uml:Property' and type/@xmi:type='uml:PrimitiveType']" {
0> «@name»
choose {
when "type/@href='http://schema.omg.org/spec/UML/2.1/uml.xml#String'"
> VARCHAR
// [...] for other types, extend when clauses
}
if "position()!=last()" > ,
text "\\n";
}
}
||
p > Our little sample only supports «VARCHAR», but it is an easy game to play to complete that.
p >>
Here you can download the ¬samples/xmi2ddl.ysl2 XMI 2 DDL compiler sample¬. I used
¬http://bouml.free.fr/ BOUML¬ to create a small ¬samples/demo.xmi UML sample file¬
as ¬http://www.omg.org/spec/XMI/ XMI 2.1¬.
>>
p > To compile that, use:
Code ||
% yml2proc -y xmi2ddl.ysl2 -x demo.xmi
CREATE TABLE demo_Customer (
id VARCHAR,
name VARCHAR
);
% _
||
p >>
In the samples directory you'll find
¬samples/xmi2ddl.uml2 a prettier solution¬ using ¬samples/uml.yml2 some declares to prettify¬.
>>
h1 id=features > Features of YSLT
p >>
Because YSLT just generates XSLT programs, it will be a good idea to read the
¬https://www.w3.org/TR/1999/REC-xslt-19991116 XSLT Documentation¬ as well as the
¬http://www.w3.org/TR/xpath XPath Documentation¬.
>>
p >>
In the following, you find a ¬#functionlist List of YSLT Functions¬ and a
¬#operatorlist List of YSLT Operators¬.
>>
h2 id=functionlist > List of YSLT Functions
h3 > apply(select, *indent=1)
p >>
Generates the «<xsl:apply-templates />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Applying-Template-Rules tag¬. The «*indent» pointer gives
the number of indention levels to add (default: 1) for the Indention System.
>>
p i > Example:
Code | apply "attr|aggregation", mode=define;
h3 id=assert > assert(test, msg)
p >>
Generates «<xsl:value-of select="yml:assert(test, msg)"». See the ¬#ymlassert yml:assert() XPath extension¬.
This function does not generate anything when not being called by ¬toolchain#processor ysltproc¬
with the --debug switch.
>>
h3 > attrib(name, namespace)
p > Generates the «<xsl:attribute />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#creating-attributes tag¬.
h3 > call(name)
p >>
Generates the «<call-template />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#named-templates tag¬.
Used to call a «function()».
>>
p i > Example:
Code | call "ucase" with "text", "$name";
h3 > choose()
p >>
Generates the «<xsl:choose />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Conditional-Processing-with-xsl:choose tag¬.
Use in a «choose() ... when()... otherwise()...» structure.
>>
p i > Example:
Code ||
choose {
when "$id=1"
> yes
when "$id=2"
> no
otherwise
error "invalid id";
}
||
h3 > comment()
p > Generates the «<xsl:comment />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Creating-Comments tag¬.
p i > Example:
Code | comment "this comment will remain in XML";
h3 > const(name, select)
p > Generates the «<xsl:variable />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#variables tag¬.
p i > Example:
Code | const "pi", 3.14;
h3 > copy(select)
p > Generates the «<xsl:copy-of />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#copy-of tag¬.
p i > Example:
Code | copy ".";
h3 id=debug > debug(msg)
p >>
Generates «<xsl:value-of select="yml:debug(msg)"». See the ¬#ymldebug yml:debug() XPath extension¬.
This function does not generate anything when not being called by ¬toolchain#processor ysltproc¬
with the --debug switch.
>>
h3 > def(name)
p >>
Generates the ¬http://www.exslt.org EXSLT¬ «<func:funcion />»
¬http://www.exslt.org/func/elements/function/ tag¬.
>>
h3 id=edocument > document(href, method)
p >>
Generates the ¬http://www.exslt.org EXSLT¬ «<exsl:document />»
¬http://www.exslt.org/exsl/elements/document/ tag¬.
>>
p i > Example:
Code ||
template "entity" document "{@name}.java" {
[…]
}
||
h3 > element(name, namespace)
p >>
Generates the «<xsl:element />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Creating-Elements-with-xsl:element tag¬.
>>
h3 > error()
p >>
Generates the «<xsl:message />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#message tag¬
with attribute «terminate» set to "yes".
>>
h3 > estylesheet(*output="xml")
p >>
Does the same as «stylesheet()», but additionally declares the ¬http://www.exslt.org/ EXSLT¬
functions of the groups «exsl», «func», «str», «dyn», «set» and «math» and declares the
corresponding name spaces.
>>
h3 > for(select)
p > Generates the «<xsl:for-each />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#for-each tag¬.
p i > Example:
Code | for "../structure[@name='hello'" > «@type»
h3 > foreach(select)
p > Same as «for()».
h3 > function(name)
p >>
Generates the «<xsl:template />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#named-templates tag¬.
Used by calling with «call()».
>>
p i > Example:
Code ||
function "ucase" {
param "text";
value "translate(substring($text,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')";
value "substring($text, 2)";
}
||
h3 > if(test)
p >>
Generates the «<xsl:if />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Conditional-Processing-with-xsl:if tag¬.
>>
p i > Example:
Code | if "position()<last()" > ,
h3 > import(href)
p > Generates the «<xsl:import />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#import tag¬.
h3 > key(name, match, use)
p > Generates the «<xsl:key />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#key tag¬.
h3 > message()
p > Generates the «<xsl:message />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#message tag¬.
h3 > otherwise()
p >>
Generates the «<xsl:otherwise />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Conditional-Processing-with-xsl:choose tag¬.
Use in a «choose() ... when()... otherwise()...» structure.
>>
h3 > output(method)
p > Generates the «<xsl:output />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#output tag¬.
h3 > param(name, select)
p > Generates the «<xsl:param />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#variables tag¬.
p i > Example:
Code | param "x", 42;
h3 > processing(name)
p >>
Generates the «<xsl:processing-instruction />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Creating-Processing-Instructions tag¬.
>>
h3 > raw()
p >>
Generates the «<xsl:text />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Creating-Text tag¬.
Sets the attribute «disable-output-escaping» to "yes".
>>
h3 > result(select)
p >>
Generates the ¬http://www.exslt.org EXSLT¬ «<func:result />»
¬http://www.exslt.org/func/elements/result/ tag¬.
>>
h3 > stylesheet(*output="xml")
p >>
Generates the XSLT «<stylesheet />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#stylesheet-element tag¬.
Additionally generates an «<output />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#output tag¬
in the body, with attribute «method» set to the value of the pointer «*output» (default: "xml").
>>
p > The content you're giving is placed in the body after the «<output />» tag.
p > The «version» attribute is set to "1.0" and XML namespace «xsl» is correctly defined.
p >>
In short: use for a stylesheet, just give the output type as parameter, if you don't want to
to generate XML but HTML ("html") oder plain text ("text").
>>
p > «stylesheet()» additionally generates tags for the Indention System.
h3 > template(match)
p >>
Generates the «<xsl:template />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Defining-Template-Rules tag¬.
Additionally generates tags for the Indention System.
>>
p i > Example:
Code ||
template "attr", mode=declare
| attribute `] «@type»` `] «@name»`;
||
h3 > text()
p > Generate the «<xsl:text />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Creating-Text tag¬.
h3 > textstylesheet()
p > Same as «estylesheet()», but «*output» is now "text", that means the stylesheet outputs plain text.
h3 > tstylesheet()
p > Same as «textstylesheet()».
h3 > value(select)
p > Generates the «<xsl:value-of />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#value-of tag¬.
p i > Example:
Code | value "@name";
h3 > warning()
p >>
Generates the «<xsl:message />» ¬https://www.w3.org/TR/1999/REC-xslt-19991116#message tag¬
with attribute «terminate» set to "no".
>>
h3 > when()
p >>
Generates the «<xsl:when />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Conditional-Processing-with-xsl:choose tag¬.
Use in a «choose() ... when()... otherwise()...» structure.
>>
h3 > with(name, select)
p >>
Generates the «<xsl:with-param />»
¬https://www.w3.org/TR/1999/REC-xslt-19991116#section-Passing-Parameters-to-Templates tag¬.
>>
p i > Example:
Code | call "ucase" with "text", "$name";
h2 id=operatorlist > List of YSLT Text Operators
h3 id="angledouble" > Operator `] <code>«…»</code>`
p > Generate YSLT Function Call «value('…')».