-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
166 lines (119 loc) · 4.22 KB
/
readme.txt
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
SXML
by Sterling Stuart Stein
S3 <stein at ir.iit.edu>
http://lingcog.iit.edu/~scubed/
Introduction
SXML is an S-expression based XML processing library
for Bigloo Scheme. It allows you to transform XML
similar to XSLT. It also allows for dynamic XHTML
creation from a database, session management,
and cookie handling like PHP.
Feel free to contact me with any comments that
you have about it.
Benefits
Since there is already XSLT and PHP, why use something else?
XSLT does the built-in XML transformations very well.
However, while Turing complete, it is not very extensible.
For example, it is tricky to get it to do group by.
The syntax for the language is a bit hairy and applying
the transformations can be slow depending on which
tools are used.
Because it is Scheme, list manipulation is very easy.
Quasi-quote ('`') can be used and code fragments can
be inserted into the SXML with the standard syntax.
Because it is an ordinary programming langauge,
new features can easily be added. Bigloo features
compiling into a native executable. On my machine,
a native compiled stylesheet was MUCH faster than using Xalan
to perform the transformation.
PHP can be used very effectively, but typically it
is a series of echo statements that may or may not
result in something that resembles XML. Also, if
an error occurs it can output it to the socket
revealing information about your database layout
and displaying scary messages that don't mean anything
to the users.
As long as the form is correct, SXML will generate
valid XML. Errors can be handled by if statements,
and exception handlers.
It is meant to combine the best features of XSLT and PHP.
Installation
Note: ~> denotes the prompt and should not be typed
To install, do
~> ./configure
This will detect your computer's configuration
and save the settings for compiling.
~> make
This will compile the library and some examples
that use it.
As root,
~> make install
This will install the library and components into your system
directories so your programs may use them.
Note that this must be done as root,
such as preceeding the command by "sudo".
What is SXML?
Here is an example of XML and its SXML counterpart:
XML: (indented for readability)
<file>
<group index="5">
<value type="string" />
</group>
</file>
SXML:
("file" ()
("group" (("index" . 5))
("value" (("type"."string")))
) )
Note that strings are used instead of symbols.
An SXML tag consists of:
1) The node name
2) The list of attributes
3) Zero or more children which can be SXML tags and strings
Strings represent text nodes.
Attributes are lists with each element being a cons
of the attribute's name and its value.
A basic example:
("name" (("attr1" . "val1") ("attr2" . "val2"))
"child1" "child2" ("child3" ()))
which corresponds to: (indented)
<name attr1="val1" attr2="val2">
child1
child2
<child3 />
</name>
More literally, there would be no extra spaces and newlines.
So, it would be: (unindented)
<name attr1="val1" attr2="val2">child1child2<child3/></name>
How to use
In your Bigloo programs
add this line to the module section:
(library sxml)
This will tell Bigloo Scheme to use the sxml library
and to look for the referenced functions there.
Warnings
The XML reader is not strictly XML compliant.
Entities are not treated specially
<? ?>
and
<! >
nodes are removed.
Comments are done by "--" toggling, not naively:
<! -- Comment -- off -- on -- off >
The XML written out may be invalid if characters that aren't
allowed occur in strings. For example:
Text nodes contain '<' or '\"'
Node names contain ' '
Attribute names contain ' '
Copyright
Copyright (C) 2006 Sterling Stuart Stein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.