Package eu.bandm.tools.xslt.base
Class Transformation
java.lang.Object
eu.bandm.tools.xslt.base.MessageSender
eu.bandm.tools.xslt.base.Transformation
Represents one complete xslt program, which processes any xml
input (for which a tpath interpreter exists), and delivers a bandm tdom result of a
given type (or just plain text, in case of non-xml mode).
It consists of (1) at least ONE(1) xslt file =
Import precedence is considered for
The scope of the following constructs does not extend in a transparaent way, neither to imports nor to includes,
"A subtree rooted at an xsl:stylesheet element does not include any stylesheets imported or included by children of that xsl:stylesheet element."
in CONTRADICTION to [SXLT10:2.6.1]
"The fact that template rules or definitions are included does not affect the way they are processed."
FIXME "growing result" nachhalten, um [comment][attrib][/attrib][/comment] etc. schon STATISCH zu erkennen ?
Templates
,
which is top-level, (2) possibly further files, included or imported,
(3) a library of tpath functions.
Import precedence is considered for
- xsl:strip-space [XSLT10:3.4]
- xsl:apply-templates [XSLT10:5.5 list 1 point 1]
- xsl:apply-import [XSLT10:5.6] not only precedence, but more restricted
- xsl:call-template [XSLT10:5.6] (not clear)
- xsl:namespace-alias [XSLT10:7.1.1]
- xsl:attribute-set [XSLT10:7.1.4] (attribute-wise merging)
- xsl:variable and xsl:param [XSLT10:11.4] (not very clear)
- xsl:key NOT for non-conflicting [XSLT10:12.2] (but else? not clear)
- xsl:namespace-alias [XSLT10:7.1.1]
- xsl:decimal-format NOT for conflicts [XSLT10:12.3]
- xsl:output, attributes except cdata-section-elements [XSLT10:16]
The scope of the following constructs does not extend in a transparaent way, neither to imports nor to includes,
"A subtree rooted at an xsl:stylesheet element does not include any stylesheets imported or included by children of that xsl:stylesheet element."
in CONTRADICTION to [SXLT10:2.6.1]
"The fact that template rules or definitions are included does not affect the way they are processed."
- xsl:exclude-result-prefices [XSLT10:7.1.1]
- xsl:extension-element-preficxes [XSLT10:14.1]
FIXME "growing result" nachhalten, um [comment][attrib][/attrib][/comment] etc. schon STATISCH zu erkennen ?
-
Nested Class Summary
Modifier and TypeClassDescription(package private) class
protected class
Copies top-level definitions from template into its own, structured directories, for named templates, pattern controlled templates, attribute value sets, top-level parameters and variables.static class
Parameters to modify the execution of aTransformation
.static enum
class
Decoding of Xslt Attribute set contents.
ATTENTION interpret specification that attribute's attributes "name" and "namespace" are evaluated in top-level context ONLY ONCE with top-level "current node".class
Decoding of Xslt Output object. -
Field Summary
Modifier and TypeFieldDescriptionfinal Function<TypedSubstantial,
String> (package private) HashSet<eu.bandm.tools.xslt.tdom.Element>
Aux set to detect circular definitions.(package private) final HashSet<Transformation.XslAttributeSet>
(package private) Set<NamespaceName>
All "named attribute set", overlay from this source and all imports.(package private) Map<eu.bandm.tools.xslt.tdom.Element_xsl_call_template,
eu.bandm.tools.xslt.tdom.Element_xsl_template> protected final List<Transformation>
Accumulator for called-by stack, to detect cyclic import.(package private) static final TPathCache.ExprClassified
(package private) static final NamespaceName
(package private) Map<NamespaceName,
DecimalFormatSymbols> (package private) final HashSet<Transformation.XslAttributeSet>
(package private) Set<eu.bandm.tools.xslt.tdom.Element>
(package private) static final Binding<NamespaceName,
eu.bandm.tools.xslt.tdom.Element> (package private) Map<NamespaceName,
eu.bandm.tools.xslt.tdom.Element_xsl_param> (package private) Map<TypedSubstantial,
MultiTypeNodeList.frequency> Is the upper limit of all tpath expressions contained in any (directly or indirected) evaluated attribute value.protected final Function<NamespaceName,
FunctionSignature> (package private) Map<NamespaceName,
eu.bandm.tools.xslt.tdom.Element_xsl_variable> (package private) final List<@Opt Transformation>
(package private) final List<Location<XMLDocumentIdentifier>>
(package private) Multimap<NamespaceName,
eu.bandm.tools.xslt.tdom.Element_xsl_key> "Named attribute set" defined in this module.final Set<eu.bandm.tools.xslt.tdom.Element_xsl_template>
Redundant to templateRegistry.protected Type.XPathProperType
protected Function<NamespaceName,
Type.XPathProperType> protected static Function<NamespaceName,
Type.XPathProperType> protected final Transformation.Modifiers
(package private) Map<NamespaceName,
eu.bandm.tools.xslt.tdom.Element_xsl_template> final Map<TypedSubstantial,
Binding<String, String>> redundant copy, use instead of "origins.get(el).ns_contexts"final Map<TypedSubstantial,
NamespaceName> Some static string objects other than attribute and element names, eg.(package private) Map<String,
XslNumberFormat> (package private) Map<eu.bandm.tools.xslt.tdom.Element_xsl_number,
Transformation.NumberLevel> (package private) final Transformation.XslOutput
(package private) Map<NamespaceName,
Transformation.XslAttributeSet> "Named attribute set" defined in this module.protected Binding<NamespaceName,
eu.bandm.tools.xslt.tdom.Element> Accumulator for top-level definitions.(package private) Map<NamespaceName,
Transformation.XslAttributeSet> All "named attribute set" which are reached from matched templates, and actually contain the calculated attribute values.final Map<eu.bandm.tools.xslt.tdom.Element,
MultiTypeNodeList> Redundant: map union of the values form all templates, because frequently used in Application.protected final ResultContext
Aux coprehension of result dtd features.(package private) final String
(package private) Map<TypedElement,
List<eu.bandm.tools.xslt.tdom.Element_xsl_sort>> List of all xsl:sort commands, by the element they modify.(package private) final DTM.Dtd
(package private) Multimap<eu.bandm.tools.xslt.tdom.Element_xsl_template,
NamespaceName> is redundant w.r.t.(package private) Map<eu.bandm.tools.xslt.tdom.Element_xsl_template,
List<eu.bandm.tools.xslt.tdom.Element_xsl_param>> Sequential order of all parameter definitions, for easy initialization byApplication
.(package private) TemplateRegistry
For retrieval by matching, more elaborated structures and multi-level maps are maintained here:protected final TemplatesCache
Where to ask for included further sources.protected final Templates
(package private) final Collection<DTM.Element>
protected final TransformationCache
Where to ask for imported further sources.protected final TypeInference
(package private) Map<TypedSubstantial,
List<Transformation.XslAttributeSet>> The "named attribute set" which have to be applied when constructing this result element.(package private) final Map<eu.bandm.tools.xslt.tdom.Element,
Type.XPathProperType> The tpath type calculated for vars, parameters, arguments.protected Map<TypedAttribute,
TPathCache.ExprClassified> Map from xslt attributes to tpath expr, iff the attribute (a) is per se and always a tpath expr, or (b) happens to be a value template.Fields inherited from class eu.bandm.tools.xslt.base.MessageSender
msg, trace
-
Constructor Summary
ConstructorDescriptionTransformation
(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, Trace trace, TransformationCache transformationCache, Templates toplevelSource, Transformation.Modifiers modifiers, Function<NamespaceName, FunctionSignature> functionTypes, DTM.Dtd sourceDtm, Collection<DTM.Element> topSourceElements, List<Transformation> calledBy) This constructor is the only external calling point, it creates a new instance and does all type checking, inclusion resolving etc. -
Method Summary
Modifier and TypeMethodDescription(package private) Location<XMLDocumentIdentifier>
(package private) String
(package private) String
static void
checkAttNameNotXmlns
(String name, String[] qname, Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg) static <E extends Enum<E>>
EcheckEnumerationValue
(Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, CDataAttribute attr, String spec, String v, Class<E> enumclass) static boolean
checkEnumerationValue
(Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, CDataAttribute attr, String spec, String v, String... vals) static boolean
checkEnumerationValue
(Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, CDataAttribute attr, String spec, String v, List<String> vals) protected void
checkUnused
(Collection<? extends eu.bandm.tools.xslt.tdom.Element> set, String role, boolean strictmode) (package private) void
(package private) boolean
void
dump
(PrintStream ps) void
dump
(PrintStream ps, ContentHandler p) protected void
duplicateHint
(Location<XMLDocumentIdentifier> loc, NamespaceName name) (package private) URI
Return theTransformation.XslOutput
with the decoded attributes of all reachableElement_xsl_output
in the correct precendence, overwriting and error check.(package private) void
makeDirs()
First (and more important) of only two(2) type check function, which executes all import/inclusion and context check.(package private) @Opt NamespaceName
nonEmptyConstantNamespaceNameAttribute
(CDataAttribute att, TypedElement<?, ?> el, boolean required, String category, String spec) (package private) @Opt NamespaceName
ns_resolve_noDefault
(TypedSubstantial el, String qname) Do not resolve empty prefix to declared default namespace, but to empty uri namespace (no-NS).(package private) @Opt NamespaceName
ns_resolve_noDefault
(TypedSubstantial el, String pref, String localname) called ONLY from TemplateRegistry: tests for names of attributes DO NOT consider default name space!(package private) @Opt NamespaceName
ns_resolve_useDefault
(TypedSubstantial el, String qname) (package private) @Opt NamespaceName
ns_resolve_useDefault
(TypedSubstantial el, String pref, String localname) called ONLY from TemplateRegistry: tests for names of elements DO consider default name space!optionalNonEmptyAttributeValue
(CDataAttribute att, TypedElement<?, ?> el, String category, String spec) Check whether the attribute is defined with the element.void
printFrequenciesAndTypes
(PrintStream ps, MessageLocationFilter filter) requiredNonEmptyAttributeValue
(CDataAttribute att, TypedElement<?, ?> el, String category, String spec) Check whether the attribute is defined with the element, and is a non-empty string.(package private) void
HERE :
(a) reachedAttributeSets contains fresh XslAttributeSet objects for further use, not yet filled with any xsl:attribute etc.
(b) useAttributeSets = the sequence of these, per element generating element/MixedContentContainer.
(c) ownAttributeSets all definitions in this (top-level) Transformation.
(d) allAttributeSets is EMPTY
Each XslAttributeSet must be internally disjoint, so there is no need for a sequential order.protected List<NamespaceName>
splitNamespaceNames
(TypedSubstantial el, String text) static boolean
-
Field Details
-
templatesCache
Where to ask for included further sources. -
transformationCache
Where to ask for imported further sources. -
toplevelSource
-
modifiers
-
functionTypes
-
sourceDtm
-
topSourceElements
-
typeInference
-
resultContext
Aux coprehension of result dtd features. -
calledBy
Accumulator for called-by stack, to detect cyclic import. -
maximalVarType
-
maximalVarTypes
-
minimalVarTypes
-
CONST_NS_text
-
CONST_EXPR_dot
-
includedUris
-
importedUris
-
importedUriLocations
-
importedTransformations
-
outputOwn
-
result_subtrees
Redundant: map union of the values form all templates, because frequently used in Application. -
ns_contexts
redundant copy, use instead of "origins.get(el).ns_contexts" -
ns_names
Some static string objects other than attribute and element names, eg. the NAMES of parameters for template application are also aNamespaceName
. Since these are known statically, but not coded in the tdom model, they are stored here explicitly. For different node types there are different NamespaceNames, but luckily maxmally one(1) each. In detail these are...- apply-templates: resolved value of the mode attribute (OPT NamespaceName !!)
- with-param: r.v. of the name attribute
- param, var (toplevel and local): r.v. of the name attribute
- call-template: r.v. of the (OPT) name attribute
- template: r.v. of the (OPT) name attribute / FIXME what about the "mode" ?
- attribute: r.v. of the attribute's name IFF neither name nor namespace are computed.
- attribute-set: r.v. of the attribute set's name (always a constant).
- element: r.v. of the elements name IFF neither name nor namespace are computed.
- sort: (!containsKey->dynamic, null->erronuous, nsname->data_type)
-
matchingTemplates
Redundant to templateRegistry. Needed for easy accessing all xsl:template with a "match" attribute. (In later version with more control flow analysis, this can be eliminated.) -
namedTemplates
Map<NamespaceName,eu.bandm.tools.xslt.tdom.Element_xsl_template> namedTemplates -
templateRegistry
TemplateRegistry templateRegistryFor retrieval by matching, more elaborated structures and multi-level maps are maintained here: -
externalParameters
Map<NamespaceName,eu.bandm.tools.xslt.tdom.Element_xsl_param> externalParameters -
globalConstants
Map<NamespaceName,eu.bandm.tools.xslt.tdom.Element_xsl_variable> globalConstants -
allAttributeSets
Set<NamespaceName> allAttributeSetsAll "named attribute set", overlay from this source and all imports. -
reachedAttributeSets
Map<NamespaceName,Transformation.XslAttributeSet> reachedAttributeSetsAll "named attribute set" which are reached from matched templates, and actually contain the calculated attribute values. -
usedAttributeSets
Map<TypedSubstantial,List<Transformation.XslAttributeSet>> usedAttributeSetsThe "named attribute set" which have to be applied when constructing this result element. -
ownAttributeSets
Map<NamespaceName,Transformation.XslAttributeSet> ownAttributeSets"Named attribute set" defined in this module. -
sortLists
Map<TypedElement,List<eu.bandm.tools.xslt.tdom.Element_xsl_sort>> sortListsList of all xsl:sort commands, by the element they modify. -
keyDefs
Multimap<NamespaceName,eu.bandm.tools.xslt.tdom.Element_xsl_key> keyDefs"Named attribute set" defined in this module. -
decimalFormats
Map<NamespaceName,DecimalFormatSymbols> decimalFormats -
possibleBindings
Accumulator for top-level definitions. FIXME stimmt das ?? -
xslt_attribute_to_parsed
Map from xslt attributes to tpath expr, iff the attribute (a) is per se and always a tpath expr, or (b) happens to be a value template. NB: The corresponding map for result elements' attributes is in "MultiTypeNodeList -> attCheckResults:AttributeChecks_valueTemplates -> computing:(NamespaceName->ExprClassified)" and has already been calculated when constructingTemplates
(their recognition is necessary to prevent the tdom Element construction). -
frequencies
Map<TypedSubstantial,MultiTypeNodeList.frequency> frequenciesIs the upper limit of all tpath expressions contained in any (directly or indirected) evaluated attribute value. Can be calculated for vars, parameters, arguments, templates and MultiTypeNodeList. (Therefore the domain must be tdom.runtime.TypedSubstantial!) -
varTypes
The tpath type calculated for vars, parameters, arguments. -
activeTopLevel
HashSet<eu.bandm.tools.xslt.tdom.Element> activeTopLevelAux set to detect circular definitions. -
template2paramNames
Multimap<eu.bandm.tools.xslt.tdom.Element_xsl_template,NamespaceName> template2paramNamesis redundant w.r.t.template2params
-
template2params
Map<eu.bandm.tools.xslt.tdom.Element_xsl_template,List<eu.bandm.tools.xslt.tdom.Element_xsl_param>> template2paramsSequential order of all parameter definitions, for easy initialization byApplication
. -
call2template
Map<eu.bandm.tools.xslt.tdom.Element_xsl_call_template,eu.bandm.tools.xslt.tdom.Element_xsl_template> call2template -
numberFormats
Map<String,XslNumberFormat> numberFormats -
numberLevel
Map<eu.bandm.tools.xslt.tdom.Element_xsl_number,Transformation.NumberLevel> numberLevel -
elementHasDoeYes
Set<eu.bandm.tools.xslt.tdom.Element> elementHasDoeYes -
ruler
- See Also:
-
_PRINTNAME
-
emptyBindings
-
activeXas
-
doneXas
-
-
Constructor Details
-
Transformation
public Transformation(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, Trace trace, TransformationCache transformationCache, Templates toplevelSource, Transformation.Modifiers modifiers, Function<NamespaceName, FunctionSignature> functionTypes, DTM.Dtd sourceDtm, Collection<DTM.Element> topSourceElements, List<Transformation> calledBy) This constructor is the only external calling point, it creates a new instance and does all type checking, inclusion resolving etc. by callingmakeDirs()
.- Parameters:
toplevelSource
- source already parsed into aTemplates
object, ie. a bi-coloured graph.transformationCache
- where to look for imported transformations
-
-
Method Details
-
getTopUri
URI getTopUri() -
dump
-
dump
-
printFrequenciesAndTypes
-
_LOCATION
-
_LOCATION_FILENAME_SHORT
-
_LOCATION_SHORT
-
_PRINTNAME
-
checkAttNameNotXmlns
public static void checkAttNameNotXmlns(String name, String[] qname, Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg) -
UriSyntaxCheck
-
checkEnumerationValue
public static <E extends Enum<E>> E checkEnumerationValue(Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, CDataAttribute attr, String spec, String v, Class<E> enumclass) -
checkEnumerationValue
public static boolean checkEnumerationValue(Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, CDataAttribute attr, String spec, String v, String... vals) -
checkEnumerationValue
public static boolean checkEnumerationValue(Location<XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, CDataAttribute attr, String spec, String v, List<String> vals) -
ns_resolve_noDefault
Do not resolve empty prefix to declared default namespace, but to empty uri namespace (no-NS). This is the behaviour for attributes, but also for items embedded in xpath expressions.- Returns:
- null in case of error = undefined ns prefix OR syntax error with colons
-
ns_resolve_useDefault
- Returns:
- null in case of error = undefined ns prefix OR syntax error with colons
-
ns_resolve_useDefault
called ONLY from TemplateRegistry: tests for names of elements DO consider default name space!- Returns:
- null in case of error = undefined ns prefix
-
ns_resolve_noDefault
called ONLY from TemplateRegistry: tests for names of attributes DO NOT consider default name space!- Returns:
- null in case of error = undefined ns prefix
-
requiredNonEmptyAttributeValue
@Opt @Opt String requiredNonEmptyAttributeValue(CDataAttribute att, TypedElement<?, ?> el, String category, String spec) Check whether the attribute is defined with the element, and is a non-empty string. Otherwise generate error message, using "category" String.- Returns:
- null in case of error
-
optionalNonEmptyAttributeValue
@Opt @Opt String optionalNonEmptyAttributeValue(CDataAttribute att, TypedElement<?, ?> el, String category, String spec) Check whether the attribute is defined with the element. Iff so, it must be a non-empty string. For an empty string generate error message, using "category/spec" Strings. -
nonEmptyConstantNamespaceNameAttribute
@Opt @Opt NamespaceName nonEmptyConstantNamespaceNameAttribute(CDataAttribute att, TypedElement<?, ?> el, boolean required, String category, String spec) - Returns:
- null if no such attribute. Error messages may be generated according to "required".
-
duplicateHint
-
splitNamespaceNames
-
checkUnused
protected void checkUnused(Collection<? extends eu.bandm.tools.xslt.tdom.Element> set, String role, boolean strictmode) -
resolveAttributeSets
void resolveAttributeSets()HERE :
(a) reachedAttributeSets contains fresh XslAttributeSet objects for further use, not yet filled with any xsl:attribute etc.
(b) useAttributeSets = the sequence of these, per element generating element/MixedContentContainer.
(c) ownAttributeSets all definitions in this (top-level) Transformation.
(d) allAttributeSets is EMPTY
Each XslAttributeSet must be internally disjoint, so there is no need for a sequential order. We INTERPRET the specification that "merging" in "import precedence" only applies to the explicitly constructed xsl:attribute elements, not to the imported. -
do_ras
-
do_ras
-
makeDirs
void makeDirs()First (and more important) of only two(2) type check function, which executes all import/inclusion and context check.- Calls a
Transformation.Loader
to load all included/imported sub-sources and to collect all definitions in directories. - Calls a
Transformation.ContextChecker
(either in strictCheck==true for all definitions, or only for those reachable by matching templates.)
Missing result elements' attributes may be healed by xsl:useAttributeSet and xsl:Attribute elements. The effect of these can be calculated iff the name attribute is not a AVT. - Calls a
-
getXslOutput
Return theTransformation.XslOutput
with the decoded attributes of all reachableElement_xsl_output
in the correct precendence, overwriting and error check.
-