| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 3 |
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 4 |
<html> |
| 5 |
<head> |
| 6 |
<title>FleXML - An XML Processor Generator</title> |
| 7 |
|
| 8 |
<style type="text/css"> |
| 9 |
<!-- |
| 10 |
A:link { text-decoration:none } |
| 11 |
A:visited { text-decoration:none } |
| 12 |
A:active { text-decoration:none } |
| 13 |
A:hover { text-decoration:underline; color:#FF0000 } |
| 14 |
|
| 15 |
.tabs { color: #000000; } |
| 16 |
.tabs:visited { color: #000000; } |
| 17 |
.tabs:hover { color:#FF0000; } |
| 18 |
--> |
| 19 |
</style> |
| 20 |
</head> |
| 21 |
|
| 22 |
<body> |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
<table> |
| 27 |
<tr valign='top'><td> |
| •28 |
<p style='font-size:0.8em'><a href="http://sourceforge.net">SourceForge</a><br /> |
| 29 |
<i>Visit our Sponsor</i></p> |
| 30 |
|
| 31 |
<hr style="height:1px" /> |
| 32 |
<p style='font-size:0.9em'> |
| 33 |
<b><a class='tabs' href="http://sourceforge.net/projects/flexml/">Project Summary</a></b><br /> |
| 34 |
<!-- <a class='tabs' href="http://flexml.sourceforge.net">Home Page</a><br> --> |
| 35 |
<a class='tabs' href="http://sourceforge.net/forum/?group_id=34654">Forums</a><br/> |
| 36 |
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654">Tracker</a><br/> |
| 37 |
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654&atid=411869">Bugs</a><br/> |
| 38 |
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654&atid=411870">Support</a><br/> |
| 39 |
<a class='tabs' href="http://sourceforge.net/tracker/?group_id=34654&atid=411871">Patches</a><br/> |
| 40 |
<a class='tabs' href="http://sourceforge.net/mail/?group_id=34654">Lists</a><br/> |
| 41 |
<a class='tabs' href="http://sourceforge.net/pm/?group_id=34654">Tasks</a><br/> |
| 42 |
<a class='tabs' href="http://sourceforge.net/docman/?group_id=34654">Docs</a><br/> |
| 43 |
<a class='tabs' href="http://sourceforge.net/news/?group_id=34654">News</a><br/> |
| 44 |
<a class='tabs' href="http://sourceforge.net/cvs/?group_id=34654">CVS</a><br/> |
| 45 |
<a class='tabs' href="http://sourceforge.net/project/showfiles.php?group_id=34654">Files</a><br/> |
| 46 |
</p> |
| 47 |
<hr style="height:1px" /><br/> |
| 48 |
|
| 49 |
</td><td> |
| 50 |
|
| 51 |
<h1> FleXML - XML Processor Generator </h1> |
| 52 |
|
| 53 |
<blockquote><p><em> |
| 54 |
See also <a href="flexml.html">the manual page</a> |
| 55 |
and a short <a href="paper.html">white paper</a>. |
| 56 |
<!-- and a short <a href="http://sourceforge.net/docman/display_doc.php?docid=6373&group_id=34654">white paper</a>.--> |
| 57 |
Or peek into the |
| 58 |
<a href="http://sourceforge.net/cvs/?group_id=34654"> |
| 59 |
master source archive</a>. |
| 60 |
</em></p></blockquote> |
| 61 |
|
| 62 |
<p> |
| 63 |
FleXML reads a DTD (Document Type Definition) |
| 64 |
describing the format of XML (Extensible Markup Language) |
| 65 |
documents; it may be specified as a URI to the DTD on the |
| 66 |
web. From this FleXML produces a validating XML |
| 67 |
processor with an interface to support XML applications. Proper |
| 68 |
applications can be generated optionally from special action |
| 69 |
files, either for linking or textual combination with the |
| 70 |
processor. |
| 71 |
</p> |
| 72 |
|
| 73 |
<p> |
| 74 |
FleXML is specifically developed for XML applications |
| 75 |
where a fixed data format suffices in the sense that a single |
| 76 |
DTD is used without individual extensions for a large number of |
| 77 |
documents. (Specifically it restricts XML rule [28] to |
| 78 |
</p> |
| 79 |
|
| 80 |
<pre> [28r] doctypedecl ::= '<code><!DOCTYPE</code>' S Name S ExternalID S? '<code>></code>' |
| 81 |
</pre> |
| 82 |
|
| 83 |
<p> |
| 84 |
where the ExternalId denotes the used DTD - one might say, in |
| 85 |
fact, that FleXML implements ``non-extensible'' markup. :) |
| 86 |
</p> |
| 87 |
|
| 88 |
<p> |
| 89 |
With this restriction we can do much better because the possible |
| 90 |
tags and attributes are static: FleXML-generated XML processors |
| 91 |
read the XML document character by character and can immediately |
| 92 |
dispatch the actions associated with each element (or reject the |
| 93 |
document as invalid). Technically this is done by using the |
| 94 |
Flex scanner generator to produce a deterministic finite |
| 95 |
automaton with an element context stack for the DTD, which means |
| 96 |
that there is almost no overhead for XML processing. |
| 97 |
</p> |
| 98 |
|
| 99 |
<p> |
| 100 |
Furthermore we have devised a simple extension of the C |
| 101 |
programming language that facilitates the writing of `element |
| 102 |
actions' in C, making it easy to write really fast XML |
| 103 |
applications. In particular we represent XML attribute values |
| 104 |
efficiently in C when this is possible, thus avoiding the |
| 105 |
otherwise ubiquitous conversions between strings and data |
| 106 |
values. |
| 107 |
</p> |
| 108 |
|
| 109 |
<p> |
| 110 |
Compared to SAX and its XSL-based friends, FleXML immediately |
| 111 |
produces efficient code in that the interdiction of extension |
| 112 |
makes it possible to encode efficiently, FleXML for example uses |
| 113 |
native C `enum' types to implement enumeration attribute |
| 114 |
types. However, the above limitation does prevent uses in more |
| 115 |
complex settings. |
| 116 |
</p> |
| 117 |
|
| 118 |
<p> |
| 119 |
As an example: the following is all that is needed to produce a |
| 120 |
fast program that prints all href-attributes in |
| 121 |
<code><a...></code> tags in XHTML documents (and rejects |
| 122 |
invalid XHTML documents). |
| 123 |
</p> |
| 124 |
|
| 125 |
<pre><code> <!DOCTYPE actions SYSTEM "flexml-act.dtd"> |
| 126 |
<actions> |
| 127 |
<top><![CDATA[ #include <stdio.h> ]]></top> |
| 128 |
<start tag='a'><![CDATA[ if ({href}) printf("%s\n", {href}); ]]></start> |
| 129 |
</actions> |
| 130 |
</code></pre> |
| 131 |
|
| 132 |
<p> |
| 133 |
In general, action files are themselves XML documents conforming |
| 134 |
to the DTD |
| 135 |
</p> |
| 136 |
|
| 137 |
<pre><code> <!ELEMENT actions ((top|start|end)*,main?)> |
| 138 |
<!ENTITY % C-code "(#PCDATA)"> |
| 139 |
<!ELEMENT top %C-code;> |
| 140 |
<!ELEMENT start %C-code;> <!ATTLIST start tag NMTOKEN #REQUIRED> |
| 141 |
<!ELEMENT end %C-code;> <!ATTLIST end tag NMTOKEN #REQUIRED> |
| 142 |
<!ELEMENT main %C-code;> |
| 143 |
</code></pre> |
| 144 |
|
| 145 |
<p> |
| 146 |
with <code>%C-code;</code> segments being in C enriched as |
| 147 |
described below. The elements are used as follows: |
| 148 |
</p> |
| 149 |
|
| 150 |
<dl> |
| 151 |
<dt>top</dt> |
| 152 |
<dd><p> |
| 153 |
Use for top-level C code such as global declarations, utility |
| 154 |
functions, etc. |
| 155 |
</p></dd> |
| 156 |
|
| 157 |
<dt>start</dt> |
| 158 |
<dd> |
| 159 |
<p> |
| 160 |
Attaches the code as an action to the element with the name |
| 161 |
of the required ``tag'' attribute. The ``%C-code;'' |
| 162 |
component should be C code suitable for inclusion in a C |
| 163 |
block (i.e., within {...} so it may contain local |
| 164 |
variables); furthermore the following extensions are |
| 165 |
available: {attribute} Can be used to access the value of |
| 166 |
the attribute as set with attribute=value in the start |
| 167 |
tag. In C, {attribute} will be interpreted depending on the |
| 168 |
declaration of the attribute. If the attribute is declared |
| 169 |
as an enumerated type like |
| 170 |
</p> |
| 171 |
|
| 172 |
<pre><code> <!ATTLIST attrib (alt1 | alt2 |...) ...> |
| 173 |
</code></pre> |
| 174 |
|
| 175 |
<p> |
| 176 |
then the C attribute value is of an enumerated type with the |
| 177 |
elements written <code>{attrib=alt1}</code>, |
| 178 |
<code>{attrib=alt2}</code>, etc.; furthermore an unset |
| 179 |
attribute has the ``value'' <code>{!attrib}</code>. If the |
| 180 |
attribute is not an enumeration then <code>{attrib}</code> |
| 181 |
is a null-terminated C string (of type <code>char*</code>) |
| 182 |
and <code>{!attrib}</code> is <code>NULL</code>. |
| 183 |
</p> |
| 184 |
</dd> |
| 185 |
|
| 186 |
<dt>end</dt> |
| 187 |
<dd> |
| 188 |
<p> |
| 189 |
Similarly attaches the code as an action to the end tag with |
| 190 |
the name of the required ``tag'' attribute; also here the |
| 191 |
``%C-code;'' component should be C code suitable for |
| 192 |
inclusion in a C block. In case the element has ``Mixed'' |
| 193 |
contents, i.e, was declared to permit <code>#PCDATA</code>, |
| 194 |
then the special variable <code>{#PCDATA}</code> contains |
| 195 |
the text (<code>#PCDATA</code>) of the element as a |
| 196 |
null-terminated C string (of type char*). In case the Mixed |
| 197 |
contents element actually mixed text and child elements then |
| 198 |
<code>{#PCDATA}</code> contains the plain concatenation of |
| 199 |
the text fragments as one string. |
| 200 |
</p> |
| 201 |
</dd> |
| 202 |
|
| 203 |
<dt>main</dt> |
| 204 |
<dd> |
| 205 |
<p> |
| 206 |
Finally, an optional ``main'' element can contain the C main |
| 207 |
function of the XML application. Normally the main function |
| 208 |
should include (at least) one call of the XML processor |
| 209 |
<code>yylex</code>. |
| 210 |
</p> |
| 211 |
</dd> |
| 212 |
|
| 213 |
</dl> |
| 214 |
<p> |
| 215 |
The program is freely redistributable and modifiable (under GNU |
| 216 |
`copyleft'). |
| 217 |
</p> |
| 218 |
<hr /> |
| 219 |
<address>Copyright (C) |
| 220 |
<a href="mailto:[email protected]">Kristoffer Rose</a>. |
| 221 |
<!-- Created: Thu Dec 9 08:09:41 CET 1999 --> |
| 222 |
<!-- hhmts start -->Last modified: Tue Feb 11 18:06:44 EST 2003 <!-- hhmts end --> |
| 223 |
</address> |
| 224 |
|
| 225 |
</td></tr></table> |
| 226 |
|
| 227 |
<p style='font-size:0.8em'>$Id: FleXML.html,v 1.5 2005/04/06 10:05:15 mquinson Exp $</p> |
| 228 |
</body> |
| 229 |
</html> |