Class Def2Xslt3
Every rule for a definition is tranformed into a
"<xslt:template match="XMLTAG">
output fragment. The library code for all reached modules is copied verbatim.
The xslt rules are defined with the "raw" definitions, thus they are the same for their different parametrizations.
Usage is one-shot:
Construct an instance of this class (always anew, no re-usage) and
then call
#extract(String,String,XMLDocumentIdentifier,LocationMap,String, PrintWriter, ResolvedModule...)
.
When parsing any d2d-encoded xslt source, namespace declarations. i.e. mappings from prefix to nsUri, are
- The element structure of the d2d-encoded xslt source is parsed from d2d-tags, which are (possibly context sensitive) wordings, not including any namespace information. These yield elements, which in turn may have a namspaceUri in their xml encoding. This holds for both xslt elements and target elements. It holds for target formats given by a ddf or by a dtd (in that case the Dtd2ddf collects the namespace declarations by the tdom-pi, resolves the prefices into nsUris of the generated Definition and strips them for use as tags.) The target model definition must be addressable by the normal d2d module finding. The d2d xslt source identifies the top-level target model in its headline "d2d xslt producing XY".
- In case of explicitly written, stand alone xslt files, the input xml model is present only in "match" patterns of templates, and in all xpath expressions in attributes of xslt elements and in attribute templates of some xslt elements and all result elements. The namespaces of the input model can NOT be derived from the d2d-data, and the prefix-nsUri-relation must be THE SAME as written/meant in the source text in the contained xpath expressions. Since these are not analysed here, and thus no re-mapping of the prefices is possible, this relation must (a) be declared manually, by a "from"-declaration, must (b) be taken over to the resulting xslt model verbatim, and (c) must not conflict with any other declaration of this kind.
- In case of an xslt source *extracted* from a "docu_to[]" entry in the d2d Module, the input model namespace uris are known, and the prefix COULD be re-mapped for the automatically generated top-level "xsl.template match='...'" attributes. BUT this does not hold for other xpath expressions written explicitly by the user in xslt attributes or result attribute templates, as described for the preceding case.
-
The same holds for third-party documents, inquired explicitly, eg. by
the xpath function "
document(...)
", with different nsUris internally. -
The declarations of the input document in this "extracted" case
are contained completely in the currently
processed d2d module and all its imported modules.
For these, "from" namespace declarations are added automatically, by this code.
The declaration of the target model is completely defined when resolving the key part of the "docu_to_[key]" into a d2d Module and will be identified by the headline of the generated xslt source text. - All third-party namespace mappings must be defined explicitly in the former! HOW ???? FIXME
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Visit all reachable modules and store their namespace declarations. -
Field Summary
Modifier and TypeFieldDescriptionConfiguration parameter: can e overwritten by the init block of an anonymous subclass.Set of all source text paths which have already been written out.protected XMLDocumentIdentifier
The document identifier used for all locations into the generated text.protected int
The current line number written to the output.protected final MessageTee<SimpleMessage<XMLDocumentIdentifier>>
Evidentprotected final MessageCounter
Evident(package private) final Map<String,
ResolvedModule> Only needed to inform about conflicts:Map of all prefices to namspace Uris, as collected byDef2Xslt3.CollectNs
protected PrintWriter
The output channel for the generated xslt-d2d source.protected int
Number of extracted rules, for diagnosis only.Map constructed during output which maps the module source location to the generated output source.protected String
The name of the target format for filtering the rules from the modules.(package private) boolean
Flag to ensure single use.(package private) final int
Evident, seeBatchOptions.Descriptions
Set of all XML tags for which a "<xslt:template match="TAG">
" has been synthesized.protected String
The name of the target format prefixed by "to_
"Fields inherited from class eu.bandm.tools.d2d2.base.Navigate.VisitReachable
done, result, todo
Fields inherited from class eu.bandm.tools.d2d2.model.MATCH_ONLY_00
_visitor_debug_stream, partial
-
Constructor Summary
ConstructorDescriptionDef2Xslt3
(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, int verbosity) Only constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
action
(Definition def) void
void
extract
(String target, @Opt String tdom, @Opt String topElement, XMLDocumentIdentifier docid, LocationMap<XMLDocumentIdentifier, XMLDocumentIdentifier> stringpos2orig, String genComment, PrintWriter printwriter, ResolvedModule... modules) Entry method for conversion.protected void
output
(CheckedList<LocString> docu) Copy the documentaton line block to the output and update the location map.protected void
Write an xslt element "<<xslt:toplevel>
" to the output.Methods inherited from class eu.bandm.tools.d2d2.base.Navigate.VisitReachable
markToDo, markToDo, process, process, processAll, processPublic
Methods inherited from class eu.bandm.tools.d2d2.model.SinglePhase
action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, follow_definitions, follow_defInstances, follow_docu, follow_firsts, follow_globalSubsts, follow_imports, follow_itemDocu, follow_localdefs, follow_localSubsts, follow_modules, follow_namespaces, follow_obligates, follow_on, follow_rawModules, follow_text, follow_weakfirsts, follow_xattributes
Methods inherited from class eu.bandm.tools.d2d2.model.MATCH_ONLY_00
_visitor_trace, action, action, action, action, compile, followAll_definitions, followAll_defInstances, followAll_docu, followAll_firsts, followAll_globalSubsts, followAll_imports, followAll_itemDocu, followAll_localdefs, followAll_localSubsts, followAll_modules, followAll_namespaces, followAll_obligates, followAll_on, followAll_rawModules, followAll_text, followAll_weakfirsts, followAll_xattributes, foreignObject, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, nomatch
-
Field Details
-
defaultXsltLib
Configuration parameter: can e overwritten by the init block of an anonymous subclass. The code of this library will be included in the generated d2d-xslt output. -
used
boolean usedFlag to ensure single use. -
msg
Evident -
msg_c
Evident -
verbosity
final int verbosityEvident, seeBatchOptions.Descriptions
-
target
The name of the target format for filtering the rules from the modules. -
xtarget
The name of the target format prefixed by "to_
" -
printwriter
The output channel for the generated xslt-d2d source. -
generatedDoc
The document identifier used for all locations into the generated text. Is set by the caller. -
linenumber
protected int linenumberThe current line number written to the output. -
rulecount
protected int rulecountNumber of extracted rules, for diagnosis only. -
defsVisited
Set of all source text paths which have already been written out. These are the identifiers of the "static source path" = "raw definitions". -
written
Set of all XML tags for which a "<xslt:template match="TAG">
" has been synthesized. Each XML tag is written at most once. This implies that each raw definition is written at most once.ATTENTION can currently not deal with two different raw definitions with the same XML tag. In this case, one of these is selected without further notice.
(Since the ns-prefices are unique and global, comnparison of qnames stands for comnparison of NamespacesNames.)
-
stringpos2orig
Map constructed during output which maps the module source location to the generated output source. -
namespaces
Map of all prefices to namspace Uris, as collected byDef2Xslt3.CollectNs
-
namespaceOrig
Only needed to inform about conflicts:
-
-
Constructor Details
-
Def2Xslt3
Only constructor. For one use only.- Parameters:
msg
- evidenverbosity
- controls the visibilty of trace outputs, seeBatchOptions.Descriptions
.
-
-
Method Details
-
extract
public void extract(String target, @Opt @Opt String tdom, @Opt @Opt String topElement, XMLDocumentIdentifier docid, LocationMap<XMLDocumentIdentifier, XMLDocumentIdentifier> stringpos2orig, String genComment, PrintWriter printwriter, ResolvedModule... modules) Entry method for conversion. The result is written as a d2d source text to the printwriter.- Parameters:
target
- the name of the target format for filtering the rules stored with the input models.tdom
- from which to get the Dtd for the later inegrated parsing of xslt and target elements. Can be ==null for unstructured targets = non-xml output, or for xslt to be used with another xslt processor. In this case "target" will be the only indication in the extracted code.topElement
- inserted in the "d2d xslt" declaration for later xslt parsing If ==null then it signals unstructured targets = non-xml output.docid
- the identifier to identify the generated linesstringpos2orig
- an OUTPUT parameter which will hold the relation from generated lines in the extracted ".xstl.d2d" source to the to original lines in the ".ddf"-file, for later Location re-translation from error messages.genComment
- generation comment, supplied by the caller, added to the beginning of the ouput (as NON-doc comment).printwriter
- drain for the resulting source text.modules
- list of d2d modules; all of their public definitions shall be translated
-
putSeparator
protected void putSeparator()Write an xslt element "<<xslt:toplevel>
" to the output. This is our extension to xslt and causes the end of a template contents, so that it will not swallow immediately following variables, etc., when parsing it later. -
output
Copy the documentaton line block to the output and update the location map. (Template header and footer are written before and after this method invocation. -
action
- Overrides:
action
in classSinglePhase
-
action
- Overrides:
action
in classSinglePhase
-