Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
DTD is a format to describe the structure of XML files. This module not only supports the description of XML but provides also a parser based on this description. More...
Classes | |
class | Exception |
class | Parser |
class | Factory |
class | AbstractAttribute |
class | Content |
class | Optional |
class | Alt |
class | Seq |
class | Repeat |
class | PCDATA |
class | IDAttribute |
class | RefAttribute< T > |
class | Attribute< T > |
Functions | |
Content & | operator* (Content &c) |
Content & | operator! (Content &c) |
Content & | operator+ (Content &c1, Content &c2) |
Content & | operator| (Content &c1, Content &c2) |
Content & | operator, (Content &c1, Content &c2) |
Content & | operator& (Content &c1, Content &c2) |
Variables | |
Content & | EMPTY = _empty |
Content & | ignored = _ignored |
Content & | PCDATA = pcdata |
Content & | ANY = any |
const t::uint32 | STRICT = AbstractAttribute::STRICT |
const t::uint32 | REQUIRED = AbstractAttribute::REQUIRED |
const t::uint32 | FORWARD = AbstractAttribute::FORWARD |
const t::uint32 | CROP = Parser::CROP |
DTD is a format to describe the structure of XML files. This module not only supports the description of XML but provides also a parser based on this description.
Basically, the DTD is made of two types of descriptions:
The content of the elements may be made of simple text or other elements. This content can be described like regular expressions, that is as sequences, alternative, repetitions or optional elements.
Let the DTD below:
The equivalent with the DTD module is:
Then to parse XOM document, one has only to write:
This last example shows the use of another structure named a Factory. A factory is an interface by the user of dtd module to react to the element found in the XML document and to let the application to build a data structure corresponding to the parsed document.
Continuing the example, the factory could be:
As shown in the example above, the function begin() called each time an element is found. Thanks to the element parameter, the corresponding action can be undertaken: build a Training object, recording the name or build a session object.
One can also observe that attributes and PCDATA records the actual value they get at the begin() function call time and this value can be accessed using the "*" operator.
Base classes encompass:
otawa::dtd::Content
- to describe a the content of an element.otawa::dtd::Element
- to describe an element (that is also a dtd::Content).otawa::dtd::Att
- to describe an attribute.dtd module provides also support for identifiers and references with the classes:
To support identifiers, the factory must be able to return a pointer to an object that supports an identifier (function Factory::getRef()). In turn, a reference attribute will store this object pointer when the referenced identifier is resolved.
otawa::dtd::RefAtt<T> supports also forward references (when the flag FORWARD is set). In this case, if the reference cannot be resolved, it will store a memo with an application object to patch obtained by a call to Factory::getPatchRef(). Then when the identifier will be resolved, the parser will automatically call Factory::patch() for each forward reference with the patch object as parameter to let the application to perform the fix.
The content of an element may be made of:
A simpler way to use Seq, Alt and Repeat contents is to use the corresponding operators:
#include <include/elm/xom/dtd.h>
Build an optional content.
c | Optional content. |
References elm::dtd::_gc, and GC::add().
#include <include/elm/xom/dtd.h>
Build a sequence content.
c1 | First content in the sequence. |
c2 | Second content in the sequence. |
References elm::dtd::_gc, and GC::add().
#include <include/elm/xom/dtd.h>
Build a repeated content.
c | Repeated content. |
References elm::dtd::_gc, and GC::add().
#include <include/elm/xom/dtd.h>
Build an alternate content.
c1 | First alternative. |
c2 | Second alternative. |
References elm::dtd::_gc, and GC::add().
#include <include/elm/xom/dtd.h>
Build a sequence content.
c1 | First content in the sequence. |
c2 | Second content in the sequence. |
References elm::dtd::_gc, and GC::add().
#include <include/elm/xom/dtd.h>
Build an alternate content.
c1 | First alternative. |
c2 | Second alternative. |
References elm::dtd::_gc, and GC::add().
#include <include/elm/xom/dtd.h>
Content supporting a sequence of both text and elements.
const t::uint32 CROP = Parser::CROP |
#include <include/elm/xom/dtd.h>
Parser attribute indicating that the blank nodes (text made of spaces) can be ignored.
Referenced by Parser::doesCrop().
#include <include/elm/xom/dtd.h>
Content ensuring that the content of an XML element is empty.
const t::uint32 FORWARD = AbstractAttribute::FORWARD |
#include <include/elm/xom/dtd.h>
Attribute flag marking a reference attribute to enable support for forward references.
Referenced by AbstractAttribute::isForward().
#include <include/elm/xom/dtd.h>
Content ignoring what is exactly in the content: always answer the parsing succeeds.
const t::uint32 REQUIRED = AbstractAttribute::REQUIRED |
#include <include/elm/xom/dtd.h>
Attribute flag marking that the attribute as required its container element.
Referenced by AbstractAttribute::isRequired().
const t::uint32 STRICT = AbstractAttribute::STRICT |
#include <include/elm/xom/dtd.h>
Attribute flag causing parsing failure if there is an error during the attribute parsing.
Referenced by AbstractAttribute::isStrict().