Class TypedEthereal

java.lang.Object
eu.bandm.tools.tdom.runtime.TypedNode
eu.bandm.tools.tdom.runtime.TypedEthereal
Direct Known Subclasses:
TypedComment, TypedProcessingInstruction

public abstract class TypedEthereal extends TypedNode
Common superclass for free floating, ubiquituous and syntactically unconstrained model components, namels comments and processing instructions. The TypedSubstantials (elements and pcdata) make the skeleton of a tdom model instance and their appearance is constrained by content models. Between these, the ethereals may float freely.
Every substantial can be preceded by ethereals, and ethereals may follow. These are modelled by TypedSubstantial.getPrecedingEthereals(), TypedSubstantial.getFollowingEthereals(), etc.
Generalisation of the case of empty elements leads to the fact that every element and every document may have "leading" and "trailing" ethereals, before the first content component, and after the last. In tdom this is realized by TypedElement.getEtherealContainer().
Neither XML nor Tdom do impose any theory on the relations between substantials and ethereals. It is up to the user to define that e.g. Comments are related to the immediately following substantial, or sim.
Tdom does not impose any preference about storing. Writing out the content of an element is done in this order:
  1. The open tag of the element,
  2. then its leading ethereals;
  3. then for every contained Substantial (element or pcdata) the preceding ethereals, its contents (pcdata or an element, recursively), and then the following ethereals;
  4. finally the trailing ethereals of e, followed by its close tag.

When parsing , the place of storing is undefined. So the following variants are (a priori) totally equivalent:
    [x]
        aComment  --stored-as--> x.leading[0]  or  x.leading[0]   or   y.preceding[0]
        aPI       --stored-as--> x.leading[1]      y.preceding[0]      y.preceding[1]
      [y/]
    [/x]
  
A "normalizing rewriter" can move all Ethereals into some preferred positions. E.g. all can be stored as "preceding" whenever possible, otherweise as "leading". Such a transformation can be defined on UntypedVisitor. FIXME DOIT
  • Constructor Details

    • TypedEthereal

      protected TypedEthereal()
  • Method Details

    • dump

      public abstract void dump(ContentHandler contentHandler, @Opt LexicalHandler lexicalHandler) throws SAXException
      Write this model component to a SAX output stream. Please note that in the SAX architecture, PIs are treated by a ContentHandler, but Comments by a LexicalHandler, so these two handlers must be supplied as a tandem for a method defined with this abstract class.
      Parameters:
      contentHandler - (never null) SAX handler for writing a TypedProcessingInstruction
      lexicalHandler - SAX handler for writing a Comment. If null, then the comments are silently discarded.
      Throws:
      SAXException
    • forAnyExtension

      public final TypedNode<?> forAnyExtension()