![]() |
Qt 4.8
|
Implements XSL-T's function fn:document()
.
More...
#include <qdocumentfn_p.h>
Implements XSL-T's function fn:document()
.
fn:document()
has no evaluation functions, because it rewrites itself to a set of expressions that is the implementation.
The two-argument version:
document($uris as item()*, $baseURINode as node()) as node()*
is rewritten into:
for $uri in distinct-values($uris) return doc(resolve-uri($uri, base-uri($baseURINode)))
and the single version argument:
document($uris as item()*) as node()*
is rewritten into:
for $uri in distinct-values($uris) return doc($uri)
The distinct-values() call ensures the node deduplication and sorting, although it fails in the case that URIs resolve/directs in some way to the same document. Some of those cases can be solved by wrapping the whole expression with a node deduplication(conceptually the-for-loop/.). One advantage with distinct-values() over generating traditional node sorting/deduplication code is that the latter contains node sorting which is uecessary and can be hard to analyze away. distinct-values() doesn't have this problem due to its narrower task..
This works without problems, assuming XTRE1160 is not raised and that the recover action instead is ignore. In the case XTRE1160 is raised, one must cater for this.
In addition to this, both signatures has its first argument changed to type xs:string*
, in order to generate atomization code.
One notable thing is that the expression for $baseURINode, is moved inside a loop, and will be evaluated repeatedly, unless moved out as part of optimization.
Definition at line 112 of file qdocumentfn_p.h.
|
virtual |
This implementation guarantees to never rewrite away this Expression, but at most rewrite it as a child of another expression(that presumably have a type checking role). It is therefore always safe to override this function and call this implementation and not worry about that this Expression becomes deleted.
Many Expressions override typeCheck() and performs optimizations, as opposed to doing it in the compress() stage. This is due to that the design of those Expressions often are tied to that certain simplifications are done at the typeCheck() stage of the compilation process or that it in some other way is related to what the typeCheck() do. Also, the earlier the AST can be simplified, the better the chances are for subsequent optimizations.
It is important that the super class's typeCheck() is called before doing any custom type checking, since the call can change the children(notably, the childrens' static types). For example, if the Expression, MyExpression in the example, does not match the required type, typeCheck returns the Expression wrapped in for example ItemVerifier, CardinalityVerifier, or both.
typeCheck() may be called many times. typeCheck() must either raise an error if this Expression is an invalid expression. Thus, it is guaranteed that an Expression is valid after typeCheck() is called.
context | supplies information, such as namespace bindings and available function signatures, that can be needed at compilation time. context is guaranteed by the caller to never null. |
reqType | the static type that this Expression must match when evaluated. reqType is guaranteed by the caller to never null. |
reqType
Reimplemented from QPatternist::FunctionCall.
Definition at line 52 of file qdocumentfn.cpp.