Events Markup
From LMNLWiki
This page describes the markup generated by parse-lmnl.xsl and used by creole-impl.xsl to represent a document as a sequence of events. This page uses RELAX NG Compact syntax to describe the event markup language. The complete RNC schema is also available for download.
Contents |
Basics
The elements in the events markup are in two namespaces: http://lmnl.net/ns/event for the main semantic events and http://lmnl.net/ns/event/syntactic for events that are purely syntactic in nature and that should be ignored by most applications.
default namespace ev = "http://lmnl.net/ns/event" namespace syn = "http://lmnl.net/ns/event/syntactic" datatypes xs = "http://www.w3.org/2001/XMLSchema-datatypes"
The document element is an <events> element, which holds any number of events. It may end in an <ev:error> element to indicate an error in the parsing of the document.
start = events
events = element events { event*, error? }
Every event has certain attributes in common:
common &= hash common &= line common &= col
The hash attribute holds a string that is used to test whether events are equal for the purposes of validation. This is usually a combination of the other attributes on the event. For example, in the events generated by parse-lmnl.xsl, all whitespace-only text has the hash text('true') while non-whitespace text has the hash text('false').
- Note: the characters themselves may be significant once we start testing datatypes, but they aren't at the moment.
hash = attribute hash { xs:string }
The line and col attributes are used to indicate where the event appears, for better error messages.
line = attribute line { xs:integer }
col = attribute col { xs:integer }
Semantic Events
The main set of events are those that deal with the start and end tags of ranges, annotations and atoms. There is an event for the open and close of each start and end tag of the various kinds, except for atoms which only open and close.
event |= element start-tag-open { prefix, ns, name, id, depth, common }
event |= element start-tag-close { prefix, ns, name, id, depth, common }
event |= element end-tag-open { prefix, ns, name, id, depth, common }
event |= element end-tag-close { prefix, ns, name, id, depth, common }
event |= element start-annotation-open { prefix, ns, name, depth, common }
event |= element start-annotation-close { prefix, ns, name, depth, common }
event |= element end-annotation-open { prefix, ns, name, depth, common }
event |= element end-annotation-close { prefix, ns, name, depth, common }
event |= element atom-open { prefix, ns, name, depth, common }
event |= element atom-close { prefix, ns, name, depth, common }
As well as the common attributes, each of these events has a ns attribute which holds the namespace of the range, annotation or atom, and a name attribute which holds its local name. The prefix attribute holds the prefix used for the namespace; this can be used by applications to provide a user-friendly transformation into a different syntax. Ranges can also have IDs, which are held in the id attribute and can be used by applications to match up the start and end of ranges. The depth attribute can be used to match up the open and close events for a given tag: the matching event is the next one of the relevant type with the same depth.
prefix = attribute prefix { xs:NCName }
ns = attribute ns { xs:anyURI }
name = attribute name { xs:NCName }
id = attribute id { xs:NCName }
depth = attribute depth { xs:integer }
The <ev:text> element indicates some text. It is legal for the event stream to have multiple <ev:text> elements in sequence.
event |= element text { chars, ws, common }
The chars attribute holds the content of the text. The ws attribute is true if the text contains only whitespace characters.
chars = attribute chars { xs:string }
ws = attribute ws { 'true' | 'false' }
Syntactic Events
Syntactic events live in the http://lmnl.net/ns/event/syntactic namespace.
The syn:ns-decl event indicates a namespace declaration. The prefix attribute is the prefix that is bound, and the ns attribute is the namespace to which it is bound.
event |= element syn:ns-decl { prefix, ns, common }
The syn:entity-decl event indicates an entity declaration. The prefix, ns and name attributes specify the name of the entity, while the content attribute provides the replacement text for the entity.
event |= element syn:entity-decl { prefix, ns, name, content, common }
content = attribute content { xs:string }
The syn:entities-decl-open and syn:entities-decl-close events mark an entities declaration. The only events between these two events are syn:entity-decl, syn:entities-decl-open and syn:entities-decl-close events. The href attribute holds a URI for the LMNL document that supplied the entity declarations.
event |= element syn:entities-decl-open { href, depth, common }
event |= element syn:entities-decl-close { href, depth, common }
href = attribute href { xs:anyURI }
The syn:entity-open and syn:entity-close events indicate where an entity is referenced in content. The prefix, ns and name attributes specify the name of the entity. The depth attribute can be used to match up the open and close events.
event |= element syn:entity-open { prefix, ns, name, depth, common }
event |= element syn:entity-close { prefix, ns, name, depth, common }
The <syn:comment> element indicates a comment, with a content attribute to hold the content of the comment. As with other syntactic events, these will usually be ignored.
event |= element syn:comment { content, common }
Errors
The <ev:error> element describes a parsing error.
error = element error { parsing, found, message, line, col }
The parsing attribute tells you what the parser was looking for when the error occurred. The found attribute holds the next part of the document to indicate what was found instead. The message gives a general message. Some of these attributes may be empty, but it's bad form for all of them to be empty.
parsing = attribute parsing { xs:string }
found = attribute found { xs:string }
message = attribute message { xs:string }
