summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-25 11:55:29 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-25 11:55:29 +0100
commitafa273865b7f2697c6e28fb1511486d2f9ce6bfe (patch)
tree0f33dd43a368f5c9bd4399eed67763b1e9e74032
parentfabf557bb8390a94ff4b5d8688a91ffe4abd17ec (diff)
parent82c5cc6532ac5d0323ecda94b6767e1fdaef2639 (diff)
downloadqtxmlpatterns-afa273865b7f2697c6e28fb1511486d2f9ce6bfe.tar.gz
Merge remote-tracking branch 'origin/5.8' into devv5.9.0-alpha1
Conflicts: .qmake.conf Change-Id: I1e57330ccf8e964fa41637849b4958dea64360fd
-rw-r--r--configure.json5
-rw-r--r--examples/xmlpatterns/xmlpatterns.pro4
-rw-r--r--src/xmlpatterns/api/api.pri3
-rw-r--r--src/xmlpatterns/configure.json20
-rw-r--r--src/xmlpatterns/expr/qexpressionvariablereference.cpp4
-rw-r--r--src/xmlpatterns/expr/qexpressionvariablereference_p.h8
-rw-r--r--src/xmlpatterns/expr/qtemplateparameterreference.cpp2
-rw-r--r--src/xmlpatterns/expr/qtemplateparameterreference_p.h8
-rw-r--r--src/xmlpatterns/parser/qquerytransformparser.cpp4
-rw-r--r--src/xmlpatterns/parser/querytransformparser.ypp4
-rw-r--r--src/xmlpatterns/qtokenautomaton/README12
-rwxr-xr-xsrc/xmlpatterns/qtokenautomaton/regenerate.sh38
-rw-r--r--src/xmlpatterns/schema/qxsdtypechecker.cpp13
-rw-r--r--src/xmlpatterns/xmlpatterns.pro3
-rw-r--r--sync.profile10
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/xmlpatternsvalidator/files/fractiondigits.xml4
-rw-r--r--tests/auto/xmlpatternsvalidator/files/fractiondigits.xsd15
-rw-r--r--tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp5
-rw-r--r--tools/tools.pro4
20 files changed, 127 insertions, 43 deletions
diff --git a/configure.json b/configure.json
new file mode 100644
index 0000000..b725f49
--- /dev/null
+++ b/configure.json
@@ -0,0 +1,5 @@
+{
+ "subconfigs": [
+ "src/xmlpatterns"
+ ]
+}
diff --git a/examples/xmlpatterns/xmlpatterns.pro b/examples/xmlpatterns/xmlpatterns.pro
index bfc3a3e..b7c65d8 100644
--- a/examples/xmlpatterns/xmlpatterns.pro
+++ b/examples/xmlpatterns/xmlpatterns.pro
@@ -1,10 +1,10 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += xmlpatterns-private
SUBDIRS += xquery
qtHaveModule(widgets) {
SUBDIRS += recipes
- load(qfeatures)
- !contains(QT_DISABLED_FEATURES, xmlschema): SUBDIRS += filetree schema
+ qtConfig(xml-schema): SUBDIRS += filetree schema
}
EXAMPLE_FILES = \
diff --git a/src/xmlpatterns/api/api.pri b/src/xmlpatterns/api/api.pri
index 2192d82..fec6499 100644
--- a/src/xmlpatterns/api/api.pri
+++ b/src/xmlpatterns/api/api.pri
@@ -50,8 +50,7 @@ SOURCES += $$PWD/qvariableloader.cpp \
$$PWD/qcoloringmessagehandler.cpp \
$$PWD/qcoloroutput.cpp
-load(qfeatures)
-!contains(QT_DISABLED_FEATURES, xmlschema) {
+qtConfig(xml-schema) {
HEADERS += $$PWD/qxmlschema.h \
$$PWD/qxmlschema_p.h \
$$PWD/qxmlschemavalidator.h \
diff --git a/src/xmlpatterns/configure.json b/src/xmlpatterns/configure.json
new file mode 100644
index 0000000..851ebf8
--- /dev/null
+++ b/src/xmlpatterns/configure.json
@@ -0,0 +1,20 @@
+{
+ "module": "xmlpatterns",
+
+ "features": {
+ "xml-schema": {
+ "label": "XML schema support",
+ "purpose": "Support for XML schema validation",
+ "output": [ "privateFeature" ]
+ }
+ },
+
+ "summary": [
+ {
+ "section": "QtXmlPatterns",
+ "entries": [
+ "xml-schema"
+ ]
+ }
+ ]
+}
diff --git a/src/xmlpatterns/expr/qexpressionvariablereference.cpp b/src/xmlpatterns/expr/qexpressionvariablereference.cpp
index 67d43f8..ffd5e88 100644
--- a/src/xmlpatterns/expr/qexpressionvariablereference.cpp
+++ b/src/xmlpatterns/expr/qexpressionvariablereference.cpp
@@ -45,8 +45,8 @@ QT_BEGIN_NAMESPACE
using namespace QPatternist;
ExpressionVariableReference::ExpressionVariableReference(const VariableSlotID slotP,
- const VariableDeclaration::Ptr &varDecl) : VariableReference(slotP)
- , m_varDecl(varDecl)
+ const VariableDeclaration *varDecl) : VariableReference(slotP)
+ , m_varDecl(varDecl)
{
}
diff --git a/src/xmlpatterns/expr/qexpressionvariablereference_p.h b/src/xmlpatterns/expr/qexpressionvariablereference_p.h
index b0d2bb8..ed4047b 100644
--- a/src/xmlpatterns/expr/qexpressionvariablereference_p.h
+++ b/src/xmlpatterns/expr/qexpressionvariablereference_p.h
@@ -73,7 +73,7 @@ namespace QPatternist
{
public:
ExpressionVariableReference(const VariableSlotID slot,
- const VariableDeclaration::Ptr &varDecl);
+ const VariableDeclaration *varDecl);
virtual bool evaluateEBV(const DynamicContext::Ptr &context) const;
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
@@ -86,9 +86,9 @@ namespace QPatternist
virtual ExpressionVisitorResult::Ptr accept(const ExpressionVisitor::Ptr &visitor) const;
inline const Expression::Ptr &sourceExpression() const;
- inline const VariableDeclaration::Ptr &variableDeclaration() const;
+ inline const VariableDeclaration *variableDeclaration() const;
private:
- const VariableDeclaration::Ptr m_varDecl;
+ const VariableDeclaration *m_varDecl;
};
inline const Expression::Ptr &ExpressionVariableReference::sourceExpression() const
@@ -96,7 +96,7 @@ namespace QPatternist
return m_varDecl->expression();
}
- inline const VariableDeclaration::Ptr &ExpressionVariableReference::variableDeclaration() const
+ inline const VariableDeclaration *ExpressionVariableReference::variableDeclaration() const
{
return m_varDecl;
}
diff --git a/src/xmlpatterns/expr/qtemplateparameterreference.cpp b/src/xmlpatterns/expr/qtemplateparameterreference.cpp
index 61501e8..441f9e3 100644
--- a/src/xmlpatterns/expr/qtemplateparameterreference.cpp
+++ b/src/xmlpatterns/expr/qtemplateparameterreference.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
using namespace QPatternist;
-TemplateParameterReference::TemplateParameterReference(const VariableDeclaration::Ptr &varDecl) : m_varDecl(varDecl)
+TemplateParameterReference::TemplateParameterReference(const VariableDeclaration *varDecl) : m_varDecl(varDecl)
{
}
diff --git a/src/xmlpatterns/expr/qtemplateparameterreference_p.h b/src/xmlpatterns/expr/qtemplateparameterreference_p.h
index 61707b0..d9e1722 100644
--- a/src/xmlpatterns/expr/qtemplateparameterreference_p.h
+++ b/src/xmlpatterns/expr/qtemplateparameterreference_p.h
@@ -67,7 +67,7 @@ namespace QPatternist
class TemplateParameterReference : public EmptyContainer
{
public:
- TemplateParameterReference(const VariableDeclaration::Ptr &varDecl);
+ TemplateParameterReference(const VariableDeclaration *varDecl);
virtual bool evaluateEBV(const DynamicContext::Ptr &context) const;
virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
@@ -78,10 +78,10 @@ namespace QPatternist
virtual Properties properties() const;
inline const Expression::Ptr &sourceExpression() const;
- inline const VariableDeclaration::Ptr &variableDeclaration() const;
+ inline const VariableDeclaration *variableDeclaration() const;
private:
- const VariableDeclaration::Ptr m_varDecl;
+ const VariableDeclaration *m_varDecl;
};
inline const Expression::Ptr &TemplateParameterReference::sourceExpression() const
@@ -89,7 +89,7 @@ namespace QPatternist
return m_varDecl->expression();
}
- inline const VariableDeclaration::Ptr &TemplateParameterReference::variableDeclaration() const
+ inline const VariableDeclaration *TemplateParameterReference::variableDeclaration() const
{
return m_varDecl;
}
diff --git a/src/xmlpatterns/parser/qquerytransformparser.cpp b/src/xmlpatterns/parser/qquerytransformparser.cpp
index 93c7d15..73a3560 100644
--- a/src/xmlpatterns/parser/qquerytransformparser.cpp
+++ b/src/xmlpatterns/parser/qquerytransformparser.cpp
@@ -1098,7 +1098,7 @@ static Expression::Ptr resolveVariable(const QXmlName &name,
* mechanism must. */
case VariableDeclaration::ExpressionVariable:
{
- retval = create(new ExpressionVariableReference(var->slot, var), sourceLocator, parseInfo);
+ retval = create(new ExpressionVariableReference(var->slot, var.data()), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::FunctionArgument:
@@ -1113,7 +1113,7 @@ static Expression::Ptr resolveVariable(const QXmlName &name,
}
case VariableDeclaration::TemplateParameter:
{
- retval = create(new TemplateParameterReference(var), sourceLocator, parseInfo);
+ retval = create(new TemplateParameterReference(var.data()), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::ExternalVariable:
diff --git a/src/xmlpatterns/parser/querytransformparser.ypp b/src/xmlpatterns/parser/querytransformparser.ypp
index c1f5302..338bfe4 100644
--- a/src/xmlpatterns/parser/querytransformparser.ypp
+++ b/src/xmlpatterns/parser/querytransformparser.ypp
@@ -1027,7 +1027,7 @@ static Expression::Ptr resolveVariable(const QXmlName &name,
* mechanism must. */
case VariableDeclaration::ExpressionVariable:
{
- retval = create(new ExpressionVariableReference(var->slot, var), sourceLocator, parseInfo);
+ retval = create(new ExpressionVariableReference(var->slot, var.data()), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::FunctionArgument:
@@ -1042,7 +1042,7 @@ static Expression::Ptr resolveVariable(const QXmlName &name,
}
case VariableDeclaration::TemplateParameter:
{
- retval = create(new TemplateParameterReference(var), sourceLocator, parseInfo);
+ retval = create(new TemplateParameterReference(var.data()), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::ExternalVariable:
diff --git a/src/xmlpatterns/qtokenautomaton/README b/src/xmlpatterns/qtokenautomaton/README
index 8c5e552..32c348f 100644
--- a/src/xmlpatterns/qtokenautomaton/README
+++ b/src/xmlpatterns/qtokenautomaton/README
@@ -56,8 +56,16 @@ Using it is approached as follows:
--schema qtokenautomaton.xsd yourFile.xml`
3. Produce the C++ files by invoking the stylesheet with an XSL-T 2.0
- processor[1]. For instance, with the implementation Saxon, this would be:
- `java net.sf.saxon.Transform -xsl:qautomaton2cpp.xsl yourFile.xml`
+ processor[1], for example Saxon.
+
+ If the Java SDK is installed, it can be invoked by:
+ java net.sf.saxon.Transform -xsl:qautomaton2cpp.xsl yourFile.xml
+
+ Debian provides a command line utility saxonb-xslt for this:
+ sudo apt-get install libsaxonb-java
+ saxonb-xslt -ext:on -xsl:qautomaton2cpp.xsl -s:yourFile.xml
+
+ The script regenerate.sh is provided to do this.
4. Include the produced C++ files with your build system.
diff --git a/src/xmlpatterns/qtokenautomaton/regenerate.sh b/src/xmlpatterns/qtokenautomaton/regenerate.sh
new file mode 100755
index 0000000..23b49b1
--- /dev/null
+++ b/src/xmlpatterns/qtokenautomaton/regenerate.sh
@@ -0,0 +1,38 @@
+#/bin/sh -x
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the build tools of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL21$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see http://www.qt.io/terms-conditions. For further
+## information use the contact form at http://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 2.1 or version 3 as published by the Free
+## Software Foundation and appearing in the file LICENSE.LGPLv21 and
+## LICENSE.LGPLv3 included in the packaging of this file. Please review the
+## following information to ensure the GNU Lesser General Public License
+## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+##
+## As a special exception, The Qt Company gives you certain additional
+## rights. These rights are described in The Qt Company LGPL Exception
+## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+cd $(dirname "$0")/..
+saxonb-xslt -ext:on -xsl:qtokenautomaton/qautomaton2cpp.xsl -s:schema/tokens.xml -o:schema/qxsdschematoken.cpp
+saxonb-xslt -ext:on -xsl:qtokenautomaton/qautomaton2cpp.xsl -s:parser/qxslttokenlookup.xml -o:parser/qxslttokenlookup.cpp
diff --git a/src/xmlpatterns/schema/qxsdtypechecker.cpp b/src/xmlpatterns/schema/qxsdtypechecker.cpp
index 2e4ce8e..d6b224f 100644
--- a/src/xmlpatterns/schema/qxsdtypechecker.cpp
+++ b/src/xmlpatterns/schema/qxsdtypechecker.cpp
@@ -37,6 +37,8 @@
**
****************************************************************************/
+#include <QtMath>
+
#include "qxsdtypechecker_p.h"
#include "qabstractdatetime_p.h"
@@ -150,13 +152,12 @@ static int fractionDigitsForDecimal(const QString &lexicalValue)
{
// we use the lexical value here, as the conversion to double might strip
// away decimal positions
-
- QString trimmedValue(lexicalValue.trimmed());
- const int pos = trimmedValue.indexOf(QLatin1Char('.'));
- if (pos == -1) // no '.' -> 0 fraction digits
+ bool ok = false;
+ double dbl = lexicalValue.toDouble(&ok);
+ if (!ok)
return 0;
- else
- return (trimmedValue.length() - pos - 1);
+ dbl = dbl - qFloor(dbl);
+ return QString::number(dbl).length() - 2;
}
XsdTypeChecker::XsdTypeChecker(const XsdSchemaContext::Ptr &context, const QVector<QXmlName> &namespaceBindings, const QSourceLocation &location)
diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro
index 1b53673..5244bb1 100644
--- a/src/xmlpatterns/xmlpatterns.pro
+++ b/src/xmlpatterns/xmlpatterns.pro
@@ -19,8 +19,7 @@ include($$PWD/janitors/janitors.pri)
include($$PWD/parser/parser.pri)
include($$PWD/projection/projection.pri)
-load(qfeatures)
-!contains(QT_DISABLED_FEATURES, xmlschema) {
+qtConfig(xml-schema) {
include($$PWD/schema/schema.pri)
}
include($$PWD/type/type.pri)
diff --git a/sync.profile b/sync.profile
index 675c687..45a2b44 100644
--- a/sync.profile
+++ b/sync.profile
@@ -3,13 +3,3 @@
);
%moduleheaders = ( # restrict the module headers to those found in relative path
);
-# Module dependencies.
-# Every module that is required to build this module should have one entry.
-# Each of the module version specifiers can take one of the following values:
-# - A specific Git revision.
-# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
-# - an empty string to use the same branch under test (dependencies will become "refs/heads/master" if we are in the master branch)
-#
-%dependencies = (
- "qtbase" => "",
-);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index df80f80..aba49b6 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,4 +1,5 @@
TEMPLATE=subdirs
+QT_FOR_CONFIG += xmlpatterns-private
SUBDIRS=\
checkxmlfiles \
cmake \
@@ -30,8 +31,7 @@ SUBDIRS=\
xmlpatternsxqts \
xmlpatternsxslts \
-load(qfeatures)
-!contains(QT_DISABLED_FEATURES, xmlschema) {
+qtConfig(xml-schema) {
SUBDIRS += qxmlschema \
qxmlschemavalidator \
xmlpatternsschema \
diff --git a/tests/auto/xmlpatternsvalidator/files/fractiondigits.xml b/tests/auto/xmlpatternsvalidator/files/fractiondigits.xml
new file mode 100644
index 0000000..55c2ee8
--- /dev/null
+++ b/tests/auto/xmlpatternsvalidator/files/fractiondigits.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:number xmlns:tns="http://www.example.org/FractionDigitsTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/FractionDigitsTest FractionDigitsTest.xsd">
+ <tns:value>1234.560000</tns:value>
+</tns:number>
diff --git a/tests/auto/xmlpatternsvalidator/files/fractiondigits.xsd b/tests/auto/xmlpatternsvalidator/files/fractiondigits.xsd
new file mode 100644
index 0000000..b8f266a
--- /dev/null
+++ b/tests/auto/xmlpatternsvalidator/files/fractiondigits.xsd
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/FractionDigitsTest" xmlns:tns="http://www.example.org/FractionDigitsTest" elementFormDefault="qualified">
+ <element name="number" type="tns:NumberType" />
+ <complexType name="NumberType">
+ <sequence>
+ <element name="value">
+ <simpleType>
+ <restriction base="decimal">
+ <fractionDigits value="2"/>
+ </restriction>
+ </simpleType>
+ </element>
+ </sequence>
+ </complexType>
+</schema>
diff --git a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp
index 8e86dd9..8a11418 100644
--- a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp
+++ b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp
@@ -227,6 +227,11 @@ void tst_XmlPatternsValidator::xsdSupport_data() const
<< (QStringList() << path + QLatin1String("substitution-group-invalid.xml")
<< path + QLatin1String("substitution-group.xsd"))
<< QString();
+ QTest::newRow("QTBUG-58245 fraction digits shouldn't take trailing 0 into account")
+ << 0
+ << (QStringList() << path + QLatin1String("fractiondigits.xml")
+ << path + QLatin1String("fractiondigits.xsd"))
+ << QString();
}
QTEST_MAIN(tst_XmlPatternsValidator)
diff --git a/tools/tools.pro b/tools/tools.pro
index 92bbaca..df3f095 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -1,9 +1,9 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += xmlpatterns-private
-load(qfeatures)
!android|android_app {
SUBDIRS += xmlpatterns
- !contains(QT_DISABLED_FEATURES, xmlschema) {
+ qtConfig(xml-schema) {
SUBDIRS += xmlpatternsvalidator
}
}