104 initialTemplateName);
112 const QUrl &queryURI,
113 const QXmlName &initialTemplateName)
125 return createExpression(tokenizer, context, lang, requiredType, queryURI, initialTemplateName);
132 const QUrl &queryURI,
133 const QXmlName &initialTemplateName)
140 #ifdef Patternist_DEBUG 147 info->initialTemplateName = initialTemplateName;
149 effectiveTokenizer->setParserContext(info);
154 "We shouldn't be able to get an error, because we throw exceptions.");
162 context->error(QtXmlPatterns::tr(
"A library module cannot be evaluated " 163 "directly. It must be imported from a " 180 const bool hasExternalFocus = context->contextItemType();
192 for(
int i = 0; i < info->templateCalls.count(); ++i)
196 const Template::Ptr t(info->namedTemplates.value(targetName));
202 context->error(QtXmlPatterns::tr(
"No template by name %1 exists.").arg(
formatKeyword(context->namePool(), targetName)),
225 effectiveContext = context;
229 pDebug() <<
"----- User Function Typecheck -----";
236 const Expression::Ptr typeCheck((*it)->body()->typeCheck(effectiveContext,
237 (*it)->signature()->returnType()));
241 pDebug() <<
"------------------------------";
243 pDebug() <<
"----- User Function Compress -----";
245 (*it)->setBody(comp);
247 pDebug() <<
"------------------------------";
255 for(; vit != vend; ++vit)
265 pDebug() <<
"----- Global Variable Typecheck -----";
273 pDebug() <<
"------------------------------";
282 pDebug() <<
"Have " << info->namedTemplates.count() <<
"named templates";
284 QMutableHashIterator<QXmlName, Template::Ptr>
it(info->namedTemplates);
294 it.value()->body = it.value()->body->compress(context);
297 it.value()->compileParameters(context);
303 QHashIterator<QXmlName, TemplateMode::Ptr>
it(info->templateRules);
313 patternContext = context;
322 const int len = mode->templatePatterns.count();
324 bool hasDoneItOnce =
false;
327 for(
int i = 0; i < len; ++i)
338 matchPattern = matchPattern->compress(patternContext);
339 pattern->setMatchPattern(matchPattern);
341 if(currentTemplateID == -1 && hasDoneItOnce)
343 currentTemplateID = pattern->id();
346 else if(currentTemplateID == pattern->id() && hasDoneItOnce)
348 hasDoneItOnce =
false;
352 hasDoneItOnce =
true;
353 currentTemplateID = pattern->id();
365 pattern->templateTarget()->compileParameters(focusContext);
370 body = body->compress(context);
372 pattern->templateTarget()->body = body;
391 "We should at least have the builtin templates.");
392 QHashIterator<QXmlName, TemplateMode::Ptr>
it(info->templateRules);
399 if(it.key() == nameModeAll)
402 it.value()->addMode(modeAll);
409 pDebug() <<
"----- Initial AST build. -----";
411 pDebug() <<
"------------------------------";
413 pDebug() <<
"----- Type Check -----";
415 result->rewrite(result, result->typeCheck(context, requiredType), context);
417 pDebug() <<
"------------------------------";
419 pDebug() <<
"----- Compress -----";
420 result->rewrite(result, result->compress(context), context);
422 pDebug() <<
"------------------------------";
437 next->as<
Path>()->setLast();
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
A StaticContext that carries a specified static type for the context item, but otherwise delegates to...
bool isReadable() const
Returns true if data can be read from the device; otherwise returns false.
Delegates another Tokenizer, and while doing so prints the tokens it delivers to stderr.
QString formatKeyword(const QString &keyword)
static const SequenceType::Ptr ZeroOrMoreItems
#define it(className, varName)
QueryLanguage
Specifies whether you want QXmlQuery to interpret the input to setQuery() as an XQuery or as an XSLT ...
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
The QByteArray class provides an array of bytes.
Implements the path expression, containing two steps, such as in html/body.
Tokenizes XSL-T 2.0 documents.
Contains macros for debugging.
The QBuffer class provides a QIODevice interface for a QByteArray.
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
Expression::Ptr next()
Returns the current Expression and advances the iterator.
void setTemplate(const Template::Ptr &templ)
friend class const_iterator
T * data() const
Returns a pointer to the shared data object.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
The namespace for the internal API of QtXmlPatterns.
The QSourceLocation class identifies a location in a resource by URI, line, and column.
A hand-written tokenizer which tokenizes XQuery 1.0 & XPath 2.0, and delivers tokens to the Bison gen...
Contains data used when parsing and tokenizing.
static const AnyNodeType::Ptr node
Expression::Ptr skipOperands()
#define Q_ASSERT_X(cond, where, what)
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
virtual void processTreePass(const Expression::Ptr &tree, const CompilationStage stage)
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
virtual Expression::Ptr createExpression(QIODevice *const device, const StaticContext::Ptr &context, const QXmlQuery::QueryLanguage lang, const SequenceType::Ptr &requiredType, const QUrl &queryURI, const QXmlName &initialTemplateName)
const T * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
QExplicitlySharedDataPointer< Tokenizer > Ptr
QExplicitlySharedDataPointer< StaticContext > Ptr
int XPathparse(QPatternist::ParserContext *const info)
The entry point to the parser.
static const KeyPair *const end
The QIODevice class is the base interface class of all I/O devices in Qt.
virtual void processTemplateRule(const Expression::Ptr &body, const TemplatePattern::Ptr &pattern, const QXmlName &mode, const TemplateCompilationStage stage)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static void registerLastPath(const Expression::Ptr &operand)
Implements xsl:call-template.
virtual void processNamedTemplate(const QXmlName &name, const Expression::Ptr &tree, const TemplateCompilationStage stage)
A helper class that iterates a tree of Expression instances. It is not a sub-class of QAbstractXmlFor...
virtual Expression::Ptr createExpression(const QString &expr, const StaticContext::Ptr &context, const QXmlQuery::QueryLanguage lang, const SequenceType::Ptr &requiredType, const QUrl &queryURI, const QXmlName &initialTemplateName)