Debian Codegraph @

NOTES

raw
1 # FleXML fast XML scanner framework
2 # Copyright (c) 1999 Kristoffer Rose. All rights reserved.
3 #
4 # Description: Notes for FleXML scanner generator
5 # Author: Kristoffer Rose
6 # Created: August 1999
7 # License: NTSys proprietary
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 # $Id: NOTES,v 1.3 2006/07/18 18:21:13 mquinson Exp $
24
25
26 GUIDELINES FOR WRITING A flex(1) SCANNER FOR SIMPLE XML FORMATS.
27
28
29 We know how to handle the following DTD element declarations.
30
31
32 1. "Leaf" elements with the declarations
33
34 <!ELEMENT tag EMPTY>
35 <!ELEMENT tag (#PCDATA)>
36
37 Start conditions:
38
39 %x AL_tag
40
41 Rules:
42
43 "<tag"{s}"/>" STag(tag), ETag(tag);
44 "<tag"{s}">" STag(tag), ENTER(PCDATA);
45 "<tag"{S} STag(tag), ENTER(AL_tag);
46 <AL_tag>"/>" LEAVE, Etag(tag);
47 <AL_tag>">" LEAVE, ENTER(PCDATA);
48 <PCDATA>"</tag"{s}">" Etag(tag), LEAVE;
49
50 Handlers:
51
52 STag_tag(void) {...}
53 ETag_tag(char* pcdata) {...}
54
55
56 2. "Logical" elements with unordered element contents using the declaration
57
58 <!ELEMENT tag (tag1|tag2|...|tagn)*>
59
60 Start conditions:
61
62 %x AL_tag
63 %x IN_tag
64
65 Rules:
66
67 "<tag"{s}"/>" STag(tag), ETag(tag);
68 "<tag"{s}">" STag(tag), ENTER(IN_tag);
69 "<tag"{S} STag(tag), ENTER(AL_tag);
70 <AL_tag>"/>" LEAVE, Etag(tag);
71 <AL_tag>">" BEGIN(IN_tag);
72 <IN_tag>"</tag"{s}">" Etag(tag);
73
74 Handlers:
75
76 STag_tag(void) {...}
77 ETag_tag(char* pcdata) {...}
78
79
80 3. "Attribute" declarations of the form
81
82 <!ATTLIST tag attribute CDATA>
83
84 Rule:
85
86 <AL_tag>"attribute"{Eq}{Q} Attribute(tag,attribute);
87
88 Handler:
89
90 Attribute_tag_attribute(char* value) {...}
91
92 That's all, for the moment.
93
94 Note: the scanner can be made (more) validating by using the <IN_tag>
95 condition in front of all the rules in tag1...tagn and give the
96 top-level rules the start condition INITIAL.