Class ToHtml

All Implemented Interfaces:
PCDataVisitor

public class ToHtml extends Visitor
Generate from a collection of lablog entries an interactive HTML representation. Visit the lablog tdom model and create an xhtml tdom model.

The text structure of lablog is imported from d2d_gp.basic. One central issue is the difference in content models for the xhtml containers Element_p, Element_li, Element_td, etc., and the compositional modifiers Element_em, Element_span, etc. E.g. a visited PCData on the input side will be translated into very different of these target contexts, and thus wrapped into different TypedContent classes. For this the ToHtml.DeliveryContext is introduced.

A special problem is the "hierarchy rotation" between "p" on one side and "list" and "table" on the other. In d2d_gp.basic the "p" element is the central means for organizing text (e.g. the attributes "language", "style", "accessRights"), and all other elements containing text (even images) are subordinated. In xhtml its different and not so consistent:

          d2d_gp.basic:             xhtml:

          |                        |---------+--------+
          p                        p       list       p
          |--------+-----+         |                  |
          PCData  list PCData      PCData          PCData
  
  
  
  The xhtml Tdom defines some abstract classes which make this sorting easier:

  
         Element_body      Element_p              Element_li                E_span    Element_div
         Element_td                                                         E_em etc. _inline
  contains..
         E_block_content   E_p.Content            E_li.Content              E_span.Content  
                         wraps..
                           E_misc_inline|E_inline E_block_content|E_inline  E_misc_inline|_inline
                         which are..
                                        |_a|_phrase  |_fonstyle
                                           |_em|_kbd |_b|_big|_i|_tt
  which are..                                          
         E_form | E_form_content
                  E_block      | E_misc
                               | E_misc_inline|_noscript 
                               | _del|_ins|_script
                  E_div|_p|E_table
                  E_heading|E_blocktext
                  _h1|_h2..|hr pre address
  
Element_misc_inline (del, ins, script, noscript) is not in a full copositional way.
  • Field Details

  • Constructor Details

    • ToHtml

      Only constructor.
      Parameters:
      msg - Message receiver for the tool's own messages. D2d parser errors from the files will not be printed but included at the beginning of the rendered result.
  • Method Details

    • ERROR

      void ERROR(String m)
    • WARNING

      void WARNING(Location<XMLDocumentIdentifier> loc, String m)
    • addToSurvey

      void addToSurvey(Map<String,EnumMap<ToHtml.State,List<Integer>>> map, String key, ToHtml.State state, int issueNumber)
      Add the issue (given by number) into a survey map. Finally the follwing html tables are generated:
                    OPEN   ACCEPTED WONTFIX ...   SUMME
         OPENED BY
         author1    [13 ]  [ 4 ]    [ 2 ]         [ 19 ]  <--- show the numbers and are clickable
         author2
         
         ACCEPTED BY
         author1           [ 1 ]                  [  1 ] 
         author2           [ 3 ]                  [  3 ]
         
         package1   [ 7 ]  [ 1 ]    [ 2 ]         [ 10 ]
         package2   [ 6 ]  [ 3 ]                  [  9 ]
      
        [a]switch all visible:[/a]
        [a]packagename1:issue1[/a][br/]   <--- become visible or invisible according to the
        [a]packagename1:issue2[/a][br/]             clicks in the html tables above
        [a]packagename1:issue3[/a][br/]
        ...
        
      Parameters:
      map -
      key - the author or the packagename, depends on the map
      state - in which the issue currently is
      issueNumber -
    • dumpDelivery

      void dumpDelivery(String s)
      Auxiliary debugging procedure which dumps the current stack of accepting contexts.
    • dumpDelivery

      void dumpDelivery(@Opt @Opt ToHtml.DeliveryContext d)
      Auxiliary debugging procedure which dumps the current stack of accepting contexts.
    • visit

      public void visit(TypedPCData data)
      Description copied from class: BaseVisitor
      To be overridden. This default implementation does nothing.
      Specified by:
      visit in interface PCDataVisitor
      Overrides:
      visit in class Visitor
    • flushP

      void flushP()
      Is called when an accumulated xhtml paragraph contents must be written out, because the next input element cannot be contained in an xhtml paragraph.
    • visit

      public void visit(Element_a_list el)
      Construct an xhtml list from a d2d list. For this, a currently growing xhtml paragraph must be closed and re-opened afterwards. ATTENTION: correspondig to d2d_gp toXhtml, a list without "symbol" entry is rendered by arabic numbers.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_listitem el)
      Description copied from class: Visitor
      Can be overridden by the user to define particular semantic operations. Will be called whenever the default model instance traversal (as implemented by the methods in this class) reaches such an element.
      This default implementation descends into the element by calling visit(..) in turn for all PCData and all Elements in its contents.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_table el)
      Construct an xhtml table from a d2d table. For this, a currently growing xhtml paragraph must be closed and re-opened afterwards.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_tr el)
      Construct an xhtml tr from a d2d tr.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_td el)
      Construct an xhtml td from a d2d td.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_p el)
      Construct an xhtml p from a d2d p.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_SRC el)
      Construct an xhtml PRE from a d2d SRC. Flush an open p iff we are the first in a "desc"
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_nl el)
      Construct an xhtml br from a d2d nl.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_hh el)
      Insert character data hashmark.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_src el)
      Construct an xhtml tt from a d2d src. Can only contain "#hh".
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_link el)
      Construct an xhtml link from a d2d link.
      ATTENTION renders from the "text" input only un-decorated text. Starting "0" is replaced by "http:/" and "1" by "https:/", for ease of writing.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_emph el)
      Construct an xhtml em from a d2d emph. FIXME CHECK d2d emph NUR CHARACTER DATA wird benommen ?!?!
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_a_xemph el)
      Construct an xhtml b from a d2d xemph. FIXME CHECK d2d emph NUR CHARACTER DATA wird benommen ?!?!
      Overrides:
      visit in class Visitor
    • extractAuthors

      protected String extractAuthors(Element el)
      Visit an subtree of the d2d input and extract a list of author names.
    • visit

      public void visit(Element_note el)
      Make the xhtml rendering of a note = a text aappended to an Issue.
      Overrides:
      visit in class Visitor
    • visit

      public void visit(Element_desc el)
      Make the xhtml rendering of a d2d "desc" element, which occurs is the main sub-element of an issue. Open a paragraph context in case that the "@p" alternative of its content model is chosen, and flushP() it on return, if necessary. If the "p*" alternative is chosen, this first (empty) paragraph will be flushed and the explicit/contained paragraph will also be flushed by its visitor code (thus inP==false).
      Overrides:
      visit in class Visitor
    • renderDocmat

      protected void renderDocmat(String packageName, String issueName, Element_docmat data)
      Make the xhtml rendering of a d2d "docMat" element, which appears independent from an issue.
    • renderIssue

      protected void renderIssue(String packageName, String issueName, Element_issue data)
      Make the xhtml rendering of a d2d "issue" element.
    • renderPackage

      protected void renderPackage(String packagename, @Opt @Opt List<Element_issue> issues, @Opt @Opt List<Element_docmat> docmats)
      Make the xhtml rendering of a package header, i.e. a package name for which issues or docmats or both have been collected.
    • makeSurveyTable

      Make rendering of one survey table, i.e. a clickable xhtml table with figures of issues by key (author or package) and state. When clicked, the following list of links to these xhtml issue entries will collapse and expand accordingly.
      Parameters:
      title - to be printed above the table
      map - title of the row -> states (= headers of the columns) -> list of indexes
    • makeHtml

      public Element_html makeHtml(SortedMap<String,List<Element_issue>> issuesByPackage, SortedMap<String,List<Element_docmat>> docmatsByPackage, Map<Element,File> elements2file, Map<File,@Opt MessageStore<SimpleMessage<XMLDocumentIdentifier>>> files2error)
      Make the complete html rendering.