This commit is contained in:
King_DuckZ 2020-02-17 22:13:50 +01:00
parent 8c48174b5b
commit 9341942014
1702 changed files with 33300 additions and 17345 deletions

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001-2007
* Copyright (c) 2001-2008
* DecisionSoft Limited. All rights reserved.
* Copyright (c) 2004-2007
* Copyright (c) 2004-2008
* Oracle. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -16,14 +16,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: xmark.cpp,v 1.3 2007/11/29 16:53:03 jpcs Exp $
* $Id: xmark.cpp,v 1.7 2008/03/07 17:46:47 jpcs Exp $
*/
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#include <time.h>
#else
#include <sys/time.h>
#endif
#include <sys/time.h>
#include <iostream>
#include <fstream>
#include <vector>
@ -33,6 +35,7 @@
#include <xercesc/util/XMLEntityResolver.hpp>
#include <xercesc/framework/MemBufFormatTarget.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xqilla/xqilla-simple.hpp>
#include <xqilla/context/VariableStore.hpp>
@ -49,7 +52,7 @@ XERCES_CPP_NAMESPACE_USE
using namespace std;
#define MAXIMUM_TIME_FOR_QUERIES 0.2
#define MSECS_IN_SECS 1000000
#define MILLISECS_IN_SECS 1000
Sequence query(XQilla &xqilla, DynamicContext *context, const Item::Ptr &ci, string query)
{
@ -74,21 +77,21 @@ string timestamp(string &dateTime)
char szDate[256];
sprintf(szDate,"%04d-%02d-%02dT%02d:%02d:%02dZ",
tm.tm_year+1900,
tm.tm_mon+1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec);
tm_p->tm_year+1900,
tm_p->tm_mon+1,
tm_p->tm_mday,
tm_p->tm_hour,
tm_p->tm_min,
tm_p->tm_sec);
dateTime = szDate;
sprintf(szDate,"%04d%02d%02d%02d%02d%02d",
tm.tm_year+1900,
tm.tm_mon+1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec);
tm_p->tm_year+1900,
tm_p->tm_mon+1,
tm_p->tm_mday,
tm_p->tm_hour,
tm_p->tm_min,
tm_p->tm_sec);
return szDate;
}
@ -116,16 +119,13 @@ public:
double durationInSeconds() const
{
return ((double)duration_ / MSECS_IN_SECS);
return ((double)duration_ / MILLISECS_IN_SECS);
}
private:
static unsigned long getTime()
{
struct timeval timev;
gettimeofday(&timev, 0);
return (timev.tv_sec * MSECS_IN_SECS) + timev.tv_usec;
return XMLPlatformUtils::getCurrentMillis();
}
unsigned long start_;
@ -284,45 +284,49 @@ public:
}
return true;
}
virtual bool putDocument(const Node::Ptr &document, const XMLCh *uri, DynamicContext *context)
{
return false;
}
};
void queryBenchmarkData(XQilla &xqilla, DynamicContext *config_context, const Item::Ptr &config, string &dataPath,
XQillaConfiguration *conf, Stats &stats, StatsReporter &reporter)
{
// Find the files
// Find the files
XMarkResolver resolver;
Result files = query(xqilla, config_context, config, "for $a in /benchmark_data/data_type[@name = '" + stats.data
+ "']/size[@name = '" + stats.size + "']/file/@name return data($a)");
Item::Ptr file;
while((file = files->next(config_context)).notNull()) {
string fullpath = dataPath + stats.data + "/" + stats.size + "/" + UTF8(file->asString(config_context));
Result files = query(xqilla, config_context, config, "for $a in /benchmark_data/data_type[@name = '" + stats.data
+ "']/size[@name = '" + stats.size + "']/file/@name return data($a)");
Item::Ptr file;
while((file = files->next(config_context)).notNull()) {
string fullpath = dataPath + stats.data + "/" + stats.size + "/" + UTF8(file->asString(config_context));
resolver.defaultCollection.push_back(fullpath);
}
}
// Find the queries
Result queries = query(xqilla, config_context, config, "for $a at $pos in /benchmark_data/data_type[@name = '" + stats.data
+ "']/query return (data($a/description), data($a/action), $pos)");
// Find the queries
Result queries = query(xqilla, config_context, config, "for $a at $pos in /benchmark_data/data_type[@name = '" + stats.data
+ "']/query return (data($a/description), data($a/action), $pos)");
Item::Ptr query;
while((query = queries->next(config_context)).notNull()) {
stats.reset();
Item::Ptr query;
while((query = queries->next(config_context)).notNull()) {
stats.reset();
stats.info["description"] = UTF8(query->asString(config_context));
query = queries->next(config_context);
string action = UTF8(query->asString(config_context));
query = queries->next(config_context);
stats.info["query_index"] = UTF8(query->asString(config_context));
stats.info["description"] = UTF8(query->asString(config_context));
query = queries->next(config_context);
string action = UTF8(query->asString(config_context));
query = queries->next(config_context);
stats.info["query_index"] = UTF8(query->asString(config_context));
// Replace "input()" with the correct "collection()" function call
string::size_type pos = action.find("input()");
while(pos != string::npos) {
action = action.replace(pos, 7, "collection()");
pos = action.find("input()");
}
stats.info["action"] = "<![CDATA[" + action + "]]>";
// Replace "input()" with the correct "collection()" function call
string::size_type pos = action.find("input()");
while(pos != string::npos) {
action = action.replace(pos, 7, "collection()");
pos = action.find("input()");
}
stats.info["action"] = "<![CDATA[" + action + "]]>";
try {
try {
AutoDelete<DynamicContext> context(xqilla.createContext(XQilla::XQUERY, conf));
context->registerURIResolver(&resolver, /*adopt*/false);
@ -340,7 +344,7 @@ void queryBenchmarkData(XQilla &xqilla, DynamicContext *config_context, const It
stats.timer.stop();
++stats.count;
}
}
}
catch(XQException& e) {
cerr << UTF8(e.getError()) << endl;
cerr << "at " << UTF8(e.getXQueryFile()) << ":" << e.getXQueryLine() << ":" << e.getXQueryColumn() << endl;
@ -356,9 +360,9 @@ void queryBenchmarkData(XQilla &xqilla, DynamicContext *config_context, const It
exit(-1);
}
stats.name = "query";
reporter.reportStats(stats);
}
stats.name = "query";
reporter.reportStats(stats);
}
}
void usage(const char *progname)
@ -409,10 +413,10 @@ int main(int argc, char *argv[])
else if(configPath.empty()) {
configPath = argv[i];
string::size_type pos = configPath.rfind("/");
if(pos != string::npos) {
dataPath = configPath.substr(0, pos + 1);
}
string::size_type pos = configPath.rfind("/");
if(pos != string::npos) {
dataPath = configPath.substr(0, pos + 1);
}
}
else {
cerr << "Too many parameters" << endl;

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001-2007
* Copyright (c) 2001-2008
* DecisionSoft Limited. All rights reserved.
* Copyright (c) 2004-2007
* Copyright (c) 2004-2008
* Oracle. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: runner.cpp,v 1.39 2007/11/29 16:53:04 jpcs Exp $
* $Id: runner.cpp,v 1.43 2008/03/07 17:46:47 jpcs Exp $
*/
#ifdef _MSC_VER
@ -39,15 +39,9 @@
#include <xqilla/xqilla-simple.hpp>
#include <xqilla/context/VariableStore.hpp>
#include <xqilla/context/ModuleResolver.hpp>
#include <xqilla/context/URIResolver.hpp>
#include <xqilla/functions/FunctionConstructor.hpp>
#include <xqilla/utils/XQillaPlatformUtils.hpp>
#include <xqilla/xerces/XercesConfiguration.hpp>
#include <xqilla/fastxdm/FastXDMConfiguration.hpp>
#include <xqilla/events/ContentSequenceFilter.hpp>
#include <xqilla/events/EventSerializer.hpp>
#include <xqilla/events/NSFixupFilter.hpp>
#if defined(XERCES_HAS_CPP_NAMESPACE)
XERCES_CPP_NAMESPACE_USE
@ -76,6 +70,7 @@ private:
virtual bool resolveDocument(Sequence &result, const XMLCh* uri, DynamicContext* context, const QueryPathNode *projection);
virtual bool resolveCollection(Sequence &result, const XMLCh* uri, DynamicContext* context, const QueryPathNode *projection);
virtual bool resolveDefaultCollection(Sequence &result, DynamicContext* context, const QueryPathNode *projection);
virtual bool putDocument(const Node::Ptr &document, const XMLCh *uri, DynamicContext *context) { return false; }
private:
XQillaConfiguration *m_conf;
@ -201,26 +196,32 @@ int main(int argc, char *argv[])
if(xmlResults) {
results.reset(new XMLReportResultListener());
XMLReportResultListener *xmlreport = (XMLReportResultListener*)results.get();
xmlreport->setImplementation("XQilla", "1.0");
xmlreport->setImplementation("XQilla", "2.0");
xmlreport->setOrganization("XQilla", "http://xqilla.sourceforge.net");
xmlreport->addImplementationDefinedItem("expressionUnicode", "UTF-16");
xmlreport->addImplementationDefinedItem("implicitTimezone", "Defined by the system clock");
xmlreport->addImplementationDefinedItem("XMLVersion", "1.1");
xmlreport->addImplementationDefinedItem("axes", "Full axis support");
xmlreport->addImplementationDefinedItem("defaultOrderEmpty", "empty least");
xmlreport->addImplementationDefinedItem("normalizationForms", "NFC, NFD, NFKC, NFKD");
xmlreport->addImplementationDefinedItem("docProcessing", "schema validation");
if(!update) {
xmlreport->addImplementationDefinedItem("expressionUnicode", "UTF-16");
xmlreport->addImplementationDefinedItem("implicitTimezone", "Defined by the system clock");
xmlreport->addImplementationDefinedItem("XMLVersion", "1.1");
xmlreport->addImplementationDefinedItem("axes", "Full axis support");
xmlreport->addImplementationDefinedItem("defaultOrderEmpty", "empty least");
xmlreport->addImplementationDefinedItem("normalizationForms", "NFC, NFD, NFKC, NFKD");
xmlreport->addImplementationDefinedItem("docProcessing", "schema validation");
}
xmlreport->addFeature("Minimal Conformance", true);
xmlreport->addFeature("Schema Import", true);
xmlreport->addFeature("Schema Validation", true);
xmlreport->addFeature("Static Typing", false);
xmlreport->addFeature("Static Typing Extensions", false);
xmlreport->addFeature("Full Axis", true);
xmlreport->addFeature("Module", true);
xmlreport->addFeature("Serialization", false);
xmlreport->addFeature("Trivial XML Embedding", false);
if(!update) {
xmlreport->addFeature("Schema Import", true);
xmlreport->addFeature("Schema Validation", true);
xmlreport->addFeature("Static Typing", false);
xmlreport->addFeature("Static Typing Extensions", false);
xmlreport->addFeature("Full Axis", true);
xmlreport->addFeature("Module", true);
xmlreport->addFeature("Serialization", false);
xmlreport->addFeature("Trivial XML Embedding", false);
}
xmlreport->setSubmittor("John Snelson", "john.snelson@oracle.com");
}
else {
results.reset(new ConsoleResultListener());
@ -352,7 +353,7 @@ void XQillaTestSuiteRunner::runTestCase(const TestCase &testCase)
map<string, string>::const_iterator v;
for(v=testCase.extraVars.begin();v!=testCase.extraVars.end();v++) {
XQQuery* pInnerQuery = xqilla.parseFromURI(X(v->second.c_str()), context.get());
Janitor<XQQuery> pInnerQuery(xqilla.parseFromURI(X(v->second.c_str()), context.get(), XQilla::NO_ADOPT_CONTEXT));
Sequence doc=pInnerQuery->execute(context.get())->toSequence(context.get());
context->setExternalVariable(X(v->first.c_str()), doc);
}

View file

@ -4,6 +4,7 @@
<error id="Constr-inscope-3" reason="inspect" action="pass"/>
<error id="Constr-inscope-4" reason="inspect" action="pass"/>
<error id="Constr-namespace-13" reason="result failure"/>
<error id="K-FunctionCallExpr-12" reason="error failure" comment="XQilla provides the fn:unparsed-text() function from XSLT 2.0"/>
<error id="K-FunctionProlog-12" reason="no error failure"/>
<error id="K-InternalVariablesWith-21" reason="error failure"/>
<error id="K-InternalVariablesWith-22" reason="error failure"/>
@ -127,4 +128,5 @@
<error id="fn-resolve-uri-4" reason="no error failure"/>
<error id="fn-resolve-uri-9" reason="result failure"/>
<error id="normalization-1" reason="no error failure"/>
<error id="validateexpr-26" reason="error failure" action="pass" comment="&quot;Element {}a is not defined as a global element [err:XQDY0084]&quot; returned instead"/>
</errors>