Package eu.bandm.tools.xslt.base
Class TemplateRegistry.Finder<N>
java.lang.Object
eu.bandm.tools.xslt.base.TemplateRegistry.Finder<N>
- Enclosing class:
- TemplateRegistry
Realizes the finding of templates according to [Xslt 1.0:5.2].
The template infos have been collected and pre-organized
acoordingly in a
The executive method is
TemplateRegistry
,
e.g. when constructing a Transformation
.
This class is reusable; it could be unified with TemplateRegistry,
but it has a type parameter N giving the node implementation to match.
and TemplateRegistry doesn't.
The executive method is
find(Object, NamespaceName)
.-
Field Summary
Modifier and TypeFieldDescription(package private) final Application<N>
Needed for namespace context, tpathInterpreter, documentClient (getParent() getAncestorsAndSelf()?? FIXME RAUS ??), etc.(package private) final DocumentClient<N>
(package private) N
final Function<NamespaceName,
Function<N>> final Function<NamespaceName,
Value<N>> (package private) String
(package private) Collection<Rt.TemplateEntry>
(package private) final SimpleInterpreter<N>
Used for tpath-expr which serve as "xslt patterns", i.e.(package private) boolean
List of all ancestors of the node to match, for instant access. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) void
(package private) void
find
(N n, NamespaceName mode) Central worker method, find set of matching templates for one given node.protected boolean
matchNotStep
(N node, TPathCache.PatternPart pp, Context ns) (package private) boolean
patternMatches
(List<N> upward, TPathCache.PatternPart pp, Context nsDefs, boolean lowestTagHasBeenTested) This is just a tuned entry, when the list of ancestors is cached by the caller because more than one PatternParts are going to be tested (as the case when searching templates.)boolean
patternMatches
(N node, TPathCache.ExprClassified exp, Context tpathContext) Called by Application for realizing "xsl:number".protected boolean
patternMatches
(N node, TPathCache.PatternPart pp, Context ns) (package private) void
testAllTemplatePrefices
(@Opt Set<Rt.TemplateEntry> entries) (package private) void
Step through one priority level.(package private) void
(package private) boolean
testPredicates
(N node, TPath.Step step, Context nsDefs) Test the predicate of the givenTPath.Step
in a context of node "and the siblings of the context node that match the NodeTest as the context node list" [XSLT 1.0:5.2](package private) boolean
testStepTag
(N node, TPath.Step expr, Context<N> nsDefs) In case of template finding: called only on non-bottom levels, so node must be element (or document).(package private) void
By the table look-up, which has led to this call, it holds that:
(1) te.pattern.expr is at least one TPath.Step element (not mere "id()" or "key()" or "Root") (2) the kind and name of the lowest-level node has already been verified.(package private) boolean
testUpward
(List<N> upward, TPathCache.PatternPart pp, TPath.Step step, Context nsDefs, int nodeIndex, int patternIndex, int doubleSlashes, boolean lowestTagHasBeenTested) Test bottom up for a pattern match.
Case 1) the pattern is un-rooted and the top node is existentially quantified.
Case 2) the pattern has a UNIQUE root (either document element or some element identified by id() or key()): then this element is at the end of the shortened "upward" parameter.tmpContext
(N node, Function<String, String> ns)
-
Field Details
-
tpathInterpreter
Used for tpath-expr which serve as "xslt patterns", i.e. as "match" attributs of templates.
Variable bindings for the "global" vars are NOT needed, see [XSLT 1.0:5.3] "It is an error for the value of the match attribute to contain a VariableReference" -
documentClient
-
application
Needed for namespace context, tpathInterpreter, documentClient (getParent() getAncestorsAndSelf()?? FIXME RAUS ??), etc. -
node
N node -
result
Collection<Rt.TemplateEntry> result -
upCached
boolean upCached -
upwardCache
List of all ancestors of the node to match, for instant access. -
pi_target
String pi_target -
noVars
-
noFuns
-
-
Constructor Details
-
Finder
Finder(DocumentClient<N> documentClient, Application<N> application)
-
-
Method Details
-
addNotNull
-
cacheUpward
void cacheUpward() -
find
Central worker method, find set of matching templates for one given node. Not containing exactly one member indicates an xslt programming error. The top-level look-up is deterministic, for the given MODE. The next level steps through decreasing priorities, until something matches. -
testAllTemplates
Step through one priority level. First decision is per category of the visited node. -
testAllTemplatePrefices
-
testOptTemplatePrefix
-
testTemplatePrefix
By the table look-up, which has led to this call, it holds that:
(1) te.pattern.expr is at least one TPath.Step element (not mere "id()" or "key()" or "Root") (2) the kind and name of the lowest-level node has already been verified. -
patternMatches
Called by Application for realizing "xsl:number". -
patternMatches
-
tmpContext
-
matchNotStep
-
patternMatches
boolean patternMatches(List<N> upward, TPathCache.PatternPart pp, Context nsDefs, boolean lowestTagHasBeenTested) This is just a tuned entry, when the list of ancestors is cached by the caller because more than one PatternParts are going to be tested (as the case when searching templates.) -
testUpward
boolean testUpward(List<N> upward, TPathCache.PatternPart pp, TPath.Step step, Context nsDefs, int nodeIndex, int patternIndex, int doubleSlashes, boolean lowestTagHasBeenTested) Test bottom up for a pattern match.
Case 1) the pattern is un-rooted and the top node is existentially quantified.
Case 2) the pattern has a UNIQUE root (either document element or some element identified by id() or key()): then this element is at the end of the shortened "upward" parameter.
"upward" is the list of ancestors (in descending order). "nodeIndex" is the index of the currently tested node in "upward". "patternIndex" is the number of step objects still to test.
Check goes bottom up and is short cut by length constraints.0 0 1 1 doubleSlashes 1 2 3 4 patternIndex (1-based !) pattern a / b // c / X nodeIndex 7 6 5 4 3 2 1 0 [doc] x / x / a / b/x/x/ c / X (<--- valid solution iff root==null) 5 4 3 2 1 0 or [doc]/ a / b/x/x/ c / X (<--- valid solution iff root==null or ==Root) 4 3 2 1 0 or a / b/x/b/ c / X ^ tested in advance iff rooted (a="/" or a="id()" or a="key()" ^ kind/tag (possibly) already verified predicates "[..]" not yet tested
ALL THE OFF BY ONE BUGS NOT YET CHECKED FIXME!! -
testPredicates
Test the predicate of the givenTPath.Step
in a context of node "and the siblings of the context node that match the NodeTest as the context node list" [XSLT 1.0:5.2] -
testStepTag
In case of template finding: called only on non-bottom levels, so node must be element (or document). In general case: can be any kind of node <==> also lowest level must be tested.
-