Class Udom2Sax


public class Udom2Sax extends SinglePhase_rt
Generates SAX events in name-space mode. FIXME MOVE PARAMETERS TO CONSTRUCTOR Create an instance (always anew, no resuage) and then call convert(eu.bandm.tools.message.MessageReceiver<eu.bandm.tools.message.SimpleMessage<?>>,org.xml.sax.ContentHandler,eu.bandm.tools.d2d2.rt.ResultingStructure,@eu.bandm.tools.annotations.Opt java.util.Map<java.lang.String,java.lang.String>)- Has to be piped into a consuming ContentHandler in name-space mode, like NamespaceEmbedder.
An optional LexicalHandler is for comments and PIs.
  • Field Details

    • STRING_defaultNamespacePrefix

      public static final String STRING_defaultNamespacePrefix
      See Also:
    • pp_args

      protected static final Class[] pp_args
    • foundPostprocMethod

      protected Method foundPostprocMethod
    • foundPostprocObject

      protected PostProcessor foundPostprocObject
    • ATTRIBUTES_EMPTY

      public static final AttributesImpl ATTRIBUTES_EMPTY
    • NO_ATTRIBUTES

      public static final Set<Definition> NO_ATTRIBUTES
    • lastCharsWritten

      protected MemString<String> lastCharsWritten
    • cachedLocation

      protected Location<String> cachedLocation
    • locator

      protected final Locator locator
    • attributesDone

      protected Set<Definition> attributesDone
      All those definitions the content of which (under the currently written node) have already been written out as attributes, and therefore do not need further processing.
    • msg

      protected MessageReceiver<SimpleMessage<?>> msg
      Target of all error messages. Currently only reflection generated exception (when a post processor cannot be found) or from the sax receiver (SAXExceptions) can happen.
    • sax

      protected ContentHandler sax
      Target of generated write-out.
    • saxlex

      protected LexicalHandler saxlex
      Target of generated comments and pis.
    • toplevelStructure

      protected ResultingStructure toplevelStructure
      Diagnosis only.
    • ws_buffer

      protected final List<ResultingChars> ws_buffer
      Accumulator for whitespace which will be written out iff non-white-space character data follows.
    • trimming

      protected boolean trimming
      Whether there is any whitespace trimming, as determined by the node type declaration. If true, then whitespace character data will at most be put into the intermediate buffer, and written out only when non-white-space data follows.
    • trimfirst

      protected boolean trimfirst
      Indicates that no non-white-space character data has appeared yet, and (if trimming) whitespace is NOT written to ws_buffer.
    • namespacesopen

      protected Stack<String> namespacesopen
    • namespacesprefix

      protected Stack<String> namespacesprefix
  • Constructor Details

    • Udom2Sax

      public Udom2Sax()
  • Method Details

    • findPostProc

      public void findPostProc(Definition def)
    • applyPostProc

      public ResultingStructure applyPostProc(ResultingStructure input)
    • memoChars

      protected void memoChars(MemString<String> chars)
    • memoLoc

      protected void memoLoc(ResultingStructure res)
    • updateCache

      protected void updateCache()
    • convert

      public void convert(MessageReceiver<SimpleMessage<?>> msg, ContentHandler sax, ResultingStructure structure, @Opt @Opt Map<String,String> namespaceContext)
      Top-level entry point. No special constructor required! All uris in namespaceContext are added to the output context, the prefix therein is used iff (1) uri not yet defined, (2) if prefix used, it will be mangled. Used primely for xslt source namespaces, which are present only in xpath expressions! THEREFORE IT CAN FAIL BECAUSE MANGLING OF PREFIXES DOES NOT CARRY OVER as long as xslt/xpath is external/unparsed!
      Parameters:
      msg - target for error messages when trying to write the SAX event. // STIMMT NICHT MEHR, denn getCharOnly() würde gerne senden! (All these messages are due to technical reasons and do not carry a location information.)
      sax - target for the SAX events.
      structure - what to write out.
      namespaceContext - map of prefices to uris, output at first, may be ==null.
    • ws_buffer_flush

      protected void ws_buffer_flush()
      Called when writing out any non-whitespace character data, or when starting an "open" tag.
    • checknamespace

      protected void checknamespace(NamespaceName n, boolean isAttribute) throws SAXException
      Generate an SAX call, iff the namespace uri is not yet mapped to a prefix, and memoize. Otherwise do nothing, so that the current (second) prefix (=synonym) will be ignored and the oldest assigned prefix continued to be used.
      Throws:
      SAXException
    • marknamespace

      protected int marknamespace()
      Remember the number of currently mapped name spaces.
    • releasenamespace

      protected void releasenamespace(int level) throws SAXException
      Close all namespaces, as they were at the beginning of the element
      Throws:
      SAXException
    • getCharOnly

      protected String getCharOnly(Definition x, ResultContainer c)
    • action

      public void action(ResultingStructure res_pre)
      If argument is not yet written out as attribute, then (1) apply postproc, (2) collect all attributes, (3) emit an "open element" sax event, (4) visit sub-structure, (5) emit a "close element" sax event.
      Overrides:
      action in class SinglePhase_rt
    • action

      public void action(PermutationGroup pg)
      Overrides:
      action in class SinglePhase_rt
    • write

      protected void write(MemString<String> mem)
    • wr_simpleElement

      protected void wr_simpleElement(NamespaceName tag, char[] c, int o, int l)
    • writeSimpleElement

      protected void writeSimpleElement(NamespaceName tag, MemString<String> val)
    • writeSimpleElement_synthetic

      protected void writeSimpleElement_synthetic(NamespaceName tag, String val)
      write a text which is synthetic, ie. should not influence locator generation!
    • writeEmptyElement

      protected void writeEmptyElement(NamespaceName tag)
    • writeout_enum

      protected void writeout_enum(Enumeration enumT, ResultingStructure res, AttributesImpl att) throws SAXException
      Throws:
      SAXException
    • action

      public void action(ResultingChars chars)
      Overrides:
      action in class SinglePhase_rt
    • action

      public void action(SubstituteChars chars)
      Overrides:
      action in class SinglePhase_rt