45 QObject(parent), m_xmlItem(0)
51 m_query(source.m_query),
52 m_queryText(source.m_queryText),
53 m_focusText(source.m_focusText),
54 m_xmlItem(source.m_xmlItem),
55 m_enableSymbols(false)
70 zDebug() <<
"ZxQuery::setQueryUrl: %s" <<
cStr(url);
82 zDebug() <<
"ZxQuery::setQueryUrl: opening resource file" <<
cStr(url);
86 zWarning() <<
"The XQuery failed. " <<
"Can't open query resource URL: " 98 zDebug() <<
"The XQuery failed for query URL: " << url;
109 zDebug() <<
"The XQuery failed for query URL: " << url;
123 zDebug() <<
"ZxQuery::setFocusUrl: %s" <<
cStr(url);
133 zDebug() <<
"ZxQuery::setFocusUrl: opening resource file" <<
cStr(url);
146 zDebug() <<
"Invalid XQuery focus for resource URL: " << url;
155 zDebug() <<
"Invalid XQuery focus for URL: " << url;
169 zDebug() <<
"ZxQuery::setFocusText";
171 zDebug() <<
"TEXT=" << text;
187 zDebug() <<
"ZxQuery::setFocusItem";
193 const char* className = item->metaObject()->className();
195 zDebug() <<
"The XQuery failed for focus Item: " << className <<
", Item object should be of class Zbl::ZxItem";
221 zDebug() <<
"ZxQuery::setQueryText";
223 zDebug() <<
"QUERY=" << text;
246 void ZxQuery::clearQueryText()
256 qmlRegisterType<ZxQuery>(
"org.zuble.qml", 1, 0,
"ZxQuery");
261 zDebug() <<
"ZxQuery::evaluateToItems";
265 QXmlResultItems result;
283 for(QXmlItem* item =
new QXmlItem(result.next()); !item->isNull();
284 item =
new QXmlItem(result.next()))
286 if (result.hasError())
302 zDebug() <<
"ZxQuery::evaluateToItems found " << items->
m_items.size() <<
" items";
309 zDebug() <<
"ZxQuery::evaluateToStringList";
315 if(!
m_query.evaluateTo(&result))
317 QString msg(
"The XQuery evaluation failed for query URL: %1");
328 zDebug() <<
"ZxQuery::evaluateToXml";
334 if(!
m_query.evaluateTo(&result))
336 zDebug() <<
"The XQuery evaluation failed for query URL: " <<
m_queryUrl.url();
350 return new ZxQuery(*
this, parent());
368 QString resourcePath = m_url.url();
372 m_f->setFileName(resourcePath);
374 zDebug() <<
"ZxQuery::ResourceUrlFile::open setting resource: " << resourcePath;
376 if(!m_f->open(QIODevice::ReadOnly))
378 zWarning() <<
"Resource failed to open: " << resourcePath;
396 if(m_f && m_f->isOpen())
411 if(url != m_url.url())
426 zWarning() <<
"ZxQuery::bindVariable FAILED -- invalid object type: " 427 <<
"xZmlItem parameter must be a ZxItem object.";
453 bool queryOK =
false;
455 zDebug() <<
"ZxQuery::loadQueryText: opening resource file " << fileUri;
459 zWarning() <<
"The XQuery failed. " <<
"Can't open query resource URL: " 460 << fileUri <<
" File error: " << resFile.
errorString();
465 QFile* f = resFile.
m_f;
469 QString b(f->readLine(65535));
471 if(f->error() != QFileDevice::NoError)
473 zWarning() <<
"ZxQuery::loadQueryText error while reading file: " << fileUri;
474 zWarning() <<
"ZxQuery::loadQueryText ABORTING, file error = " << f->errorString();
486 zDebug() <<
"ZxQuery::concatQueryText";
496 zDebug() <<
"ZxQuery::commitQueryText";
509 m_symbols.insert(symbolName, symbolText);
This class allows Javascript programs to access QXmlItem objects.
void setFocusItem(QObject *item)
sets the XQuery focus item
bool m_enableSymbols
Enables query text buffer symbol substitution when true, disables it when false.
static QString getPathScheme(const QString &path)
Obtains the scheme part of a URL path.
void setQueryUrl(const QString &url)
sets the XQuery query url and calls setQuery on the encapsulated QXmlQuery object.
QObject * getFocusItem()
returns the focus URL of the XQuery object
void setFocusUrl(const QString &url)
sets the XQuery focus url and calls setQuery on the encapsulated QXmlQuery object.
Q_INVOKABLE void removeSymbol(const QString &symbolName)
Removes the specified symbol from the symbol substitution map.
ResourceUrlFile m_focusFile
Pointer to a QFile object that will be used as the XQuery focus document.
QString m_focusText
The focus URL.
This class provides access to the QXmlResultItems class from Javascript programs. It accumulates the ...
#define ZBL_REGISTER_LOGGED_OBJECT
const QString getFocusUrl()
returns the focus item the XQuery object
qItemList m_items
A list of QXmlItem objects resulting from an XQuery evaluation.
void setUrl(const QString &url)
Q_INVOKABLE void bindSymbol(const QString &symbolName, const QString &symbolText)
Binds the specified symbol name to the specified text.
void queryUrlChanged(bool queryOK)
Q_INVOKABLE QObject * evaluateToItems()
Evaluates the current XQuery to a ZxResultItems object and returns that object.
QString m_queryText
The source text of the query.
void focusUrlChanged(bool focusOK)
void setSymbolSubstitution(bool enabled)
enables symbol substitution mechanism for query text buffer.
void setFocusText(const QString &text)
sets the XQuery focus url and calls setQuery on the encapsulated QXmlQuery object.
void freeFile()
Frees the QFile if onw exists.
Q_INVOKABLE QString getSymbolText(const QString &symbolName)
obtain the text that will be substituted for the specified symbol when loading text into the query te...
void setQueryText(const QString &text)
Copies the specified text to the query text buffer and calls setQuery on the encapsulated QXmlQuery o...
const bool getSymbolSubstitution()
returns the symbol substituion mode
#define ZBL_DEFINE_LOGGED_OBJECT(class_name)
Q_INVOKABLE void loadQueryText(const QString &fileUri)
Appends the contents of the specified file to the current contents of the query text buffer...
ZxQuery(QObject *parent=0)
Q_INVOKABLE QObject * getCopy()
Returns a ZxQuery object that is a copy of this object.
QXmlNamePool getNamePool() const
Obtains the XML name pool for the encapsulated QXmlQuery object.
QXmlItem m_item
Encapsulated QmlItem object.
Q_INVOKABLE QObject * getNamePoolCopy()
Returns a ZxQuery object that uses the same QXmlNamePool as this object.
QXmlItem m_xmlItem
The focus item.
Q_INVOKABLE void concatQueryText(const QString &text)
Appends the specified text to the current contents of the query text buffer.
QMap< QString, QString > m_symbols
Query text symbol substitution map.
Q_INVOKABLE QStringList evaluateToStringList()
Evaluates the current XQuery to a QStringList object and returns that object.
static bool isResourceScheme(const QString &scheme)
static QString resolvePath(const QString &path, bool includeUrlScheme=true)
Converts relative file paths into canonical file paths. Paths prefixed with prefix are mapped relativ...
static void registerType()
Registers ZxQuery as a QML type.
const QString getQueryUrl()
returns the query URL of the XQuery object
QXmlQuery m_query
The encapsulated QXmlQuery object.
void closeFile()
Closes QFile if one exists.
const QString getFocusText()
returns the focus text of the XQuery object
This class provides access to the QXMLQuery class from Javascript.
ResourceUrlFile m_queryFile
Pointer to a QFile object that will be used as the XQuery query text.
A class for opening XQuery resource files.
void resetFile()
Closes QFile if one exists, otherwise creates a new QFile.
Q_INVOKABLE void commitQueryText()
Sends the current query text buffer to the XQuery processor.
void setValue(const QXmlItem &item, ZxQuery *zQuery)
const QString getQueryText()
returns the text of the query
Q_INVOKABLE QString evaluateToXml()
Evaluates the current XQuery to an XML string.
Q_INVOKABLE void bindVariable(const QString &localName, QObject *zXmlItem)
Binds an XQuery variable with a value.
QUrl m_queryUrl
The URL of the source query file;.