Package eu.bandm.tools.d2d2.base
Class Udom2Sax
java.lang.Object
eu.bandm.tools.umod.runtime.OptimizingVisitor
eu.bandm.tools.d2d2.rt.MATCH_ONLY_00
eu.bandm.tools.d2d2.rt.SinglePhase_rt
eu.bandm.tools.d2d2.base.Udom2Sax
Generates SAX events in name-space mode.
Create an instance (always anew, no resuage) and then call
An ooption
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 ooption
LexicalHandler
is for comments and PIs.-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.umod.runtime.OptimizingVisitor
OptimizingVisitor.DataByName
-
Field Summary
Modifier and TypeFieldDescriptionstatic final AttributesImpl
protected Set<Definition>
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.protected Method
protected PostProcessor
protected final Locator
protected MessageReceiver<SimpleMessage<?>>
Target of all error messages.static final Set<Definition>
protected static final Class[]
protected ContentHandler
Target of generated write-out.protected LexicalHandler
Target of generated comments and pis.static final String
protected ResultingStructure
Diagnosis only.protected boolean
Indicates that no non-white-space character data has appeared yet, and (if trimming) whitespace is NOT written tows_buffer
.protected boolean
Whether there is any whitespace trimming, as determined by the node type declaration.protected final List<ResultingChars>
Accumulator for whitespace which will be written out iff non-white-space character data follows.Fields inherited from class eu.bandm.tools.d2d2.rt.MATCH_ONLY_00
_visitor_debug_stream, partial
Fields inherited from class eu.bandm.tools.umod.runtime.OptimizingVisitor
affectedClasses, fieldFlags, hasdescend, haspost, haspre, methodname_action, METHODNAME_allFields2codeNumber, METHODNAMEPREFIX_DESCEND, SUFFIX_FILENAME_SCC_DATA
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
action
(ResultingChars chars) 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.void
action
(SubstituteChars chars) applyPostProc
(ResultingStructure input) protected void
checknamespace
(NamespaceName n, boolean isAttribute) Generate an SAX call, iff the namespace uri is not yet mapped to a prefix, and memoize.void
convert
(MessageReceiver<SimpleMessage<?>> msg, ContentHandler sax, ResultingStructure structure, @Opt Map<String, String> namespaceContext) Top-level entry point.void
findPostProc
(Definition def) protected String
protected int
Remember the number of currently mapped name spaces.protected void
protected void
protected void
releasenamespace
(int level) Close all namespaces, as they were at the beginning of the elementprotected void
protected void
wr_simpleElement
(NamespaceName tag, char[] c, int o, int l) protected void
protected void
protected void
writeout_enum
(Enumeration enumT, ResultingStructure res, AttributesImpl att) protected void
writeSimpleElement
(NamespaceName tag, MemString<String> val) protected void
writeSimpleElement_synthetic
(NamespaceName tag, String val) write a text which is synthetic, ie.protected void
Called when writing out any non-whitespace character data, or when starting an "open" tag.Methods inherited from class eu.bandm.tools.d2d2.rt.SinglePhase_rt
action, action, action, action, action, action, action, action, action, action, action, collectFlags, follow_assoc, follow_consumed, follow_obligates, follow_sequ, follow_subs, follow_subs, getKey, getLowestGeneratedClass
Methods inherited from class eu.bandm.tools.d2d2.rt.MATCH_ONLY_00
_visitor_trace, action, action, action, action, action, action, action, action, action, action, action, allFields2codeNumber, compile, followAll_assoc, followAll_consumed, followAll_obligates, followAll_sequ, followAll_subs, followAll_subs, foreignObject, get_class2reachedSccs, get_class2scc, get_field2sccs, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, nomatch
Methods inherited from class eu.bandm.tools.umod.runtime.OptimizingVisitor
calculateFlags, collectFlags_action, collectFlags_actionPreDescendPost, collectFlags_actionRewritefields, collectMethods, readSccData
-
Field Details
-
STRING_defaultNamespacePrefix
- See Also:
-
pp_args
-
foundPostprocMethod
-
foundPostprocObject
-
ATTRIBUTES_EMPTY
-
NO_ATTRIBUTES
-
lastCharsWritten
-
cachedLocation
-
locator
-
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
Target of all error messages. Currently only reflection generated exception (when a post processor cannot be found) or from the sax receiver (SAXException
s) can happen. -
sax
Target of generated write-out. -
saxlex
Target of generated comments and pis. -
toplevelStructure
Diagnosis only. -
ws_buffer
Accumulator for whitespace which will be written out iff non-white-space character data follows. -
trimming
protected boolean trimmingWhether 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 trimfirstIndicates that no non-white-space character data has appeared yet, and (if trimming) whitespace is NOT written tows_buffer
. -
namespacesopen
-
namespacesprefix
-
-
Constructor Details
-
Udom2Sax
public Udom2Sax()
-
-
Method Details
-
findPostProc
-
applyPostProc
-
memoChars
-
memoLoc
-
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. (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
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
Close all namespaces, as they were at the beginning of the element- Throws:
SAXException
-
getCharOnly
-
action
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 classSinglePhase_rt
-
action
- Overrides:
action
in classSinglePhase_rt
-
write
-
wr_simpleElement
-
writeSimpleElement
-
writeSimpleElement_synthetic
write a text which is synthetic, ie. should not influence locator generation! -
writeEmptyElement
-
writeout_enum
protected void writeout_enum(Enumeration enumT, ResultingStructure res, AttributesImpl att) throws SAXException - Throws:
SAXException
-
action
- Overrides:
action
in classSinglePhase_rt
-
action
- Overrides:
action
in classSinglePhase_rt
-