File: FleXML.html

package info (click to toggle)
flexml 1.9.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 640 kB
  • ctags: 225
  • sloc: perl: 1,304; makefile: 261; xml: 188; ansic: 117
file content (231 lines) | stat: -rw-r--r-- 8,783 bytes parent folder | download | duplicates (7)
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
  <head>
    <title>FleXML - An XML Processor Generator</title>

    <style type="text/css">
    <!--
        A:link { text-decoration:none }
        A:visited { text-decoration:none }
        A:active { text-decoration:none }
        A:hover { text-decoration:underline; color:#FF0000 }
  
        .tabs { color: #000000; }
        .tabs:visited { color: #000000; }
        .tabs:hover { color:#FF0000; }
    -->
    </style>
  </head>

  <body>



<table>
<tr valign='top'><td>
<p style='font-size:0.8em'><a href="http://sourceforge.net"> 
<img src="http://sourceforge.net/sflogo.php?group_id=34654&amp;type=1" width="88"
                          height="31" alt="SourceForge Logo" /></a><br />
<i>Visit our Sponsor</i></p>

<hr style="height:1px" />
<p style='font-size:0.9em'>
<b><a class='tabs' href="http://sourceforge.net/projects/flexml/">Project Summary</a></b><br />
<!-- <a class='tabs' href="http://flexml.sourceforge.net">Home Page</a><br> -->
<a class='tabs' href="http://sourceforge.net/forum/?group_id=34654">Forums</a><br/>
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654">Tracker</a><br/>
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654&amp;atid=411869">Bugs</a><br/>
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654&amp;atid=411870">Support</a><br/>
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654&amp;atid=411871">Patches</a><br/>
<a class='tabs' href="http://sourceforge.net/mail/?group_id=34654">Lists</a><br/>
<a class='tabs' href="http://sourceforge.net/pm/?group_id=34654">Tasks</a><br/>
<a class='tabs' href="http://sourceforge.net/docman/?group_id=34654">Docs</a><br/>
<a class='tabs' href="http://sourceforge.net/news/?group_id=34654">News</a><br/>
<a class='tabs' href="http://sourceforge.net/cvs/?group_id=34654">CVS</a><br/>
<a class='tabs' href="http://sourceforge.net/project/showfiles.php?group_id=34654">Files</a><br/>
</p>
<hr style="height:1px" /><br/>

</td><td>

    <h1> FleXML - XML Processor Generator </h1>

    <blockquote><p><em>
	See also <a href="flexml.html">the manual page</a>
	and a short <a href="paper.html">white paper</a>.
<!--	and a short <a href="http://sourceforge.net/docman/display_doc.php?docid=6373&amp;group_id=34654">white paper</a>.-->
	Or peek into the 
<a href="http://sourceforge.net/cvs/?group_id=34654">
master source archive</a>.
    </em></p></blockquote>

    <p>
      FleXML reads a DTD (Document Type Definition)
      describing the format of XML (Extensible Markup Language)
      documents; it may be specified as a URI to the DTD on the
      web. From this FleXML produces a validating XML
      processor with an interface to support XML applications.  Proper
      applications can be generated optionally from special action
      files, either for linking or textual combination with the
      processor.
    </p>

    <p>
      FleXML is specifically developed for XML applications
      where a fixed data format suffices in the sense that a single
      DTD is used without individual extensions for a large number of
      documents.  (Specifically it restricts XML rule [28] to
    </p>

<pre>  [28r] doctypedecl ::= '<code>&lt;!DOCTYPE</code>' S Name S ExternalID S? '<code>&gt;</code>'
</pre>

    <p>
      where the ExternalId denotes the used DTD - one might say, in
      fact, that FleXML implements ``non-extensible'' markup. :)
    </p>

    <p>
      With this restriction we can do much better because the possible
      tags and attributes are static: FleXML-generated XML processors
      read the XML document character by character and can immediately
      dispatch the actions associated with each element (or reject the
      document as invalid).  Technically this is done by using the
      Flex scanner generator to produce a deterministic finite
      automaton with an element context stack for the DTD, which means
      that there is almost no overhead for XML processing.
    </p>

    <p>
      Furthermore we have devised a simple extension of the C
      programming language that facilitates the writing of `element
      actions' in C, making it easy to write really fast XML
      applications. In particular we represent XML attribute values
      efficiently in C when this is possible, thus avoiding the
      otherwise ubiquitous conversions between strings and data
      values.
    </p>

    <p>
      Compared to SAX and its XSL-based friends, FleXML immediately
      produces efficient code in that the interdiction of extension
      makes it possible to encode efficiently, FleXML for example uses
      native C `enum' types to implement enumeration attribute
      types. However, the above limitation does prevent uses in more
      complex settings.
    </p>

    <p>
      As an example: the following is all that is needed to produce a
      fast program that prints all href-attributes in
      <code>&lt;a...&gt;</code> tags in XHTML documents (and rejects
      invalid XHTML documents).
    </p>

<pre><code>  &lt;!DOCTYPE actions SYSTEM "flexml-act.dtd"&gt;
  &lt;actions&gt;
  &lt;top&gt;&lt;![CDATA[           #include &lt;stdio.h&gt;                  ]]&gt;&lt;/top&gt;
  &lt;start tag='a'&gt;&lt;![CDATA[ if ({href}) printf("%s\n", {href}); ]]&gt;&lt;/start&gt;
  &lt;/actions&gt;
</code></pre>

    <p>
      In general, action files are themselves XML documents conforming
      to the DTD
    </p>

<pre><code>   &lt;!ELEMENT actions ((top|start|end)*,main?)&gt;
   &lt;!ENTITY % C-code "(#PCDATA)"&gt;
   &lt;!ELEMENT top   %C-code;&gt;
   &lt;!ELEMENT start %C-code;&gt;  &lt;!ATTLIST start tag NMTOKEN #REQUIRED&gt;
   &lt;!ELEMENT end   %C-code;&gt;  &lt;!ATTLIST end   tag NMTOKEN #REQUIRED&gt;
   &lt;!ELEMENT main  %C-code;&gt;
</code></pre>

    <p>
      with <code>%C-code;</code> segments being in C enriched as
      described below.  The elements are used as follows:
    </p>

    <dl>
      <dt>top</dt>
      <dd><p>
	Use for top-level C code such as global declarations, utility
	functions, etc.
	</p></dd>

      <dt>start</dt>
      <dd>
	<p>
	  Attaches the code as an action to the element with the name
	  of the required ``tag'' attribute. The ``%C-code;''
	  component should be C code suitable for inclusion in a C
	  block (i.e., within {...} so it may contain local
	  variables); furthermore the following extensions are
	  available: {attribute} Can be used to access the value of
	  the attribute as set with attribute=value in the start
	  tag. In C, {attribute} will be interpreted depending on the
	  declaration of the attribute. If the attribute is declared
	  as an enumerated type like
	</p>

<pre><code>  &lt;!ATTLIST attrib (alt1 | alt2 |...) ...&gt;
</code></pre>

	<p>
	  then the C attribute value is of an enumerated type with the
	  elements written <code>{attrib=alt1}</code>,
	  <code>{attrib=alt2}</code>, etc.; furthermore an unset
	  attribute has the ``value'' <code>{!attrib}</code>. If the
	  attribute is not an enumeration then <code>{attrib}</code>
	  is a null-terminated C string (of type <code>char*</code>)
	  and <code>{!attrib}</code> is <code>NULL</code>.
	</p>
      </dd>

      <dt>end</dt>
      <dd>
	<p>
	  Similarly attaches the code as an action to the end tag with
	  the name of the required ``tag'' attribute; also here the
	  ``%C-code;'' component should be C code suitable for
	  inclusion in a C block. In case the element has ``Mixed''
	  contents, i.e, was declared to permit <code>#PCDATA</code>,
	  then the special variable <code>{#PCDATA}</code> contains
	  the text (<code>#PCDATA</code>) of the element as a
	  null-terminated C string (of type char*). In case the Mixed
	  contents element actually mixed text and child elements then
	  <code>{#PCDATA}</code> contains the plain concatenation of
	  the text fragments as one string.
	</p>
      </dd>

      <dt>main</dt>
      <dd>
	<p>
	  Finally, an optional ``main'' element can contain the C main
	  function of the XML application. Normally the main function
	  should include (at least) one call of the XML processor
	  <code>yylex</code>.
	</p>
      </dd>

    </dl>
    <p>
      The program is freely redistributable and modifiable (under GNU
      `copyleft').
    </p>
    <hr />
    <address>Copyright (C)
      <a href="mailto:krisrose@debian.org">Kristoffer Rose</a>.
<!-- Created: Thu Dec  9 08:09:41 CET 1999 -->
<!-- hhmts start -->Last modified: Tue Feb 11 18:06:44 EST 2003 <!-- hhmts end -->
    </address>

</td></tr></table>

  <p style='font-size:0.8em'>$Id: FleXML.html,v 1.5 2005/04/06 10:05:15 mquinson Exp $</p>
  </body>
</html>