summaryrefslogtreecommitdiffstats
path: root/tests/auto/xmlpatterns
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:34:13 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:34:13 (GMT)
commit67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch)
tree1dbf50b3dff8d5ca7e9344733968c72704eb15ff /tests/auto/xmlpatterns
downloadQt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2
Long live Qt!
Diffstat (limited to 'tests/auto/xmlpatterns')
-rw-r--r--tests/auto/xmlpatterns/.gitattributes3
-rw-r--r--tests/auto/xmlpatterns/.gitignore5
-rw-r--r--tests/auto/xmlpatterns/XSLTTODO1450
-rw-r--r--tests/auto/xmlpatterns/baselines/globals.xml12
-rw-r--r--tests/auto/xmlpatterns/queries/README4
-rw-r--r--tests/auto/xmlpatterns/queries/allAtomics.xq50
-rw-r--r--tests/auto/xmlpatterns/queries/allAtomicsExternally.xq33
-rw-r--r--tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq0
-rw-r--r--tests/auto/xmlpatterns/queries/concat.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/emptySequence.xq2
-rw-r--r--tests/auto/xmlpatterns/queries/errorFunction.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/externalStringVariable.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/externalVariable.xq2
-rw-r--r--tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/flwor.xq4
-rw-r--r--tests/auto/xmlpatterns/queries/globals.gccxml33
-rw-r--r--tests/auto/xmlpatterns/queries/invalidRegexp.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/nodeSequence.xq31
-rw-r--r--tests/auto/xmlpatterns/queries/nonexistingCollection.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/oneElement.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/onePlusOne.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/onlyDocumentNode.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/openDocument.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/reportGlobals.xq101
-rw-r--r--tests/auto/xmlpatterns/queries/simpleDocument.xml1
-rw-r--r--tests/auto/xmlpatterns/queries/simpleLibraryModule.xq5
-rw-r--r--tests/auto/xmlpatterns/queries/staticBaseURI.xq3
-rw-r--r--tests/auto/xmlpatterns/queries/staticError.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/syntaxError.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/threeVariables.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/twoVariables.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/typeError.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq2
-rw-r--r--tests/auto/xmlpatterns/queries/unsupportedCollation.xq2
-rw-r--r--tests/auto/xmlpatterns/queries/wrongArity.xq1
-rw-r--r--tests/auto/xmlpatterns/queries/zeroDivision.xq1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Asimplemathquery.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Asingledashthatsinvalid.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Asinglequerythatdoesnotexist.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputqueryfirst.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputquerylast.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariable.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariablequeryappearinglast.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Callanamedtemplateandusenofocus..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Callfnerror.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Ensureisuricanappearafterthequeryfilename.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Evaluatealibrarymodule.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Evaluateastylesheetwithnocontextdocument.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invalidtemplatename.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokeatemplateandusepassparameters..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokeversion.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokewithcoloninvariablename..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokewithinvalidparamvalue..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokewithmissingnameinparamarg..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathasnovalue..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathastwoadjacentequalsigns..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaFTP.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaHTTP.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Loadqueryviadatascheme.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/MakesurequerypathsareresolvedagainstCWDnotthelocationoftheexecutable..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Notwellformedinstancedocumentcausescrashincoloringcode..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Notwellformedstylesheetcausescrashincoloringcode..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Openannonexistentfile.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Openanonexistingcollection..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt31
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passinanexternalvariablebutthequerydoesntuseit..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passinastylesheetfileandafocusfilewhichdoesntexist.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/PassinastylesheetfilewhichcontainsanXQueryquery.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passinastylsheetfileandafocusfilewhichdoesntexist.txt15
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/PassinastylsheetfilewhichcontainsanXQueryquery.txt16
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passingasingledashisinsufficient.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passingtwodashesthelastisinterpretedasafilename.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/PassininvalidURI.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passthreedashesthetwolastgetsinterpretedastwoqueryarguments.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/PrintalistofavailableregexpflagsTheavailableflagsareformattedinacomplexway..txt5
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestoasingledocumentnodewithnochildren..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestotheemptysequence..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatdoesnotexists.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatexists.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifynoargumentsatall..txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicedifferentvalues.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicesamevalues.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifytwodifferentquerynames.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Specifytwoidenticalquerynames.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/TriggeranassertinQPatternistColorOutput.ThequerynaturallycontainsanerrorXPTY0004..txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/TriggerasecondassertinQPatternistColorOutput.ThequerynaturallycontainsXPST0003..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Triggerastaticerror..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Unknownswitchd.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Unknownswitchunknownswitch.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useanativepath.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useanexternalvariablemultipletimes..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useasimplifiedstylesheetmodule.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Usefndoc.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatfirst.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatlast.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useoutputonafilewithexistingcontenttoensurewetruncatenotappendthecontentweproduce..txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useoutputtwice.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useparamthrice.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Useparamtwice.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Wedontsupportformatanylonger.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/XQuerydataXQuerykeywordmessagemarkups.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/XQueryexpressionmessagemarkups.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/XQueryfunctionmessagemarkups.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/XQuerytypemessagemarkups.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/XQueryurimessagemarkups.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/initialtemplatedoesntworkwithXQueries..txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue2.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/onequeryandaterminatingdashattheend.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/onequerywithaprecedingdash.txt0
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/onlynoformat.txt2
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/outputwithanonwritablefile.txt1
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/paramismissingsomultiplequeriesappear.txt1
-rw-r--r--tests/auto/xmlpatterns/stylesheets/bool070.xml1
-rw-r--r--tests/auto/xmlpatterns/stylesheets/bool070.xsl6
-rw-r--r--tests/auto/xmlpatterns/stylesheets/copyWholeDocument.xsl9
-rw-r--r--tests/auto/xmlpatterns/stylesheets/documentElement.xml1
-rw-r--r--tests/auto/xmlpatterns/stylesheets/namedAndRootTemplate.xsl5
-rw-r--r--tests/auto/xmlpatterns/stylesheets/namedTemplate.xsl8
-rw-r--r--tests/auto/xmlpatterns/stylesheets/notWellformed.xsl9
-rw-r--r--tests/auto/xmlpatterns/stylesheets/onlyRootTemplate.xsl9
-rw-r--r--tests/auto/xmlpatterns/stylesheets/parameters.xsl41
-rw-r--r--tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl1
-rw-r--r--tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xml1
-rw-r--r--tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xsl4
-rw-r--r--tests/auto/xmlpatterns/stylesheets/useParameters.xsl16
-rw-r--r--tests/auto/xmlpatterns/tst_xmlpatterns.cpp1011
-rw-r--r--tests/auto/xmlpatterns/xmlpatterns.pro5
130 files changed, 3012 insertions, 0 deletions
diff --git a/tests/auto/xmlpatterns/.gitattributes b/tests/auto/xmlpatterns/.gitattributes
new file mode 100644
index 0000000..1b5e28a
--- /dev/null
+++ b/tests/auto/xmlpatterns/.gitattributes
@@ -0,0 +1,3 @@
+stylesheets/copyWholeDocument.xsl -crlf
+stylesheets/onlyRootTemplate.xsl -crlf
+stylesheets/useParameters.xsl -crlf
diff --git a/tests/auto/xmlpatterns/.gitignore b/tests/auto/xmlpatterns/.gitignore
new file mode 100644
index 0000000..70e7478
--- /dev/null
+++ b/tests/auto/xmlpatterns/.gitignore
@@ -0,0 +1,5 @@
+notWritable.out
+existingContent.out
+basicOutput.out
+basicOutput2.out
+tst_xmlpatterns
diff --git a/tests/auto/xmlpatterns/XSLTTODO b/tests/auto/xmlpatterns/XSLTTODO
new file mode 100644
index 0000000..5a20441
--- /dev/null
+++ b/tests/auto/xmlpatterns/XSLTTODO
@@ -0,0 +1,1450 @@
+This is a TODO file for XSL-T 2.0 support.
+
+- LHF:
+ * Warning bug, last parameter is always whined about.
+ * Box in comment/PI/text/ws(?) handling -- pending Matthias
+ * type036 -- namespace on top element isn't copied
+ * XTDE0865
+ * Attend XSLTTokenizer::isXSLT()
+ * Remove redundant set() calls in setFocusHelper().
+
+- Missing features:
+ General Priority
+ ---------------------
+ * 1.0 QXmlQuery::evaluateTo(QIODevice *) P1 DONE
+ * 1.0 Test suite integration P1 DONE
+ * 1.0 xsl:key P1
+ * 1.0 fn:key() P1
+ * 1.0 2.0 Compatibility mode P1
+ * 1.0 Regular parameters in templates P1
+ * 1.0 xsl:include P1
+ * 1.0 xsl:copy-of P1
+ * 1.0 xsl:copy P1
+ * 1.0 xsl:import P1
+ * 1.0 fn:format-number P1
+ * 1.0 xsl:message P2
+ * 1.0 fn:current() P1 DONE
+ * 2.0 fn:type-available() P3 DONE
+ * 2.0 xsl:use-when P3
+ * 2.0 fn:unparsed-entity-uri() P3
+ * 2.0 fn:unparsed-entity-public-id() P3
+ * 2.0 Tunnel Parameters P3
+ * 2.0 xsl:attribute-set P3
+ * 1.0 xsl:decimal-format P2
+ * 1.0 xmlpatterns: initial template P1 DONE
+ * 1.0 xsl:number P1
+ * 1.0 Complete handling of xsl:sort P2
+ * 2.0 Grouping
+ - fn:current-group()
+ - fn:grouping-key()
+ - xsl:for-each-group()
+ * 2.0 Regexp
+ - xsl:analyze-string
+ - xsl:matching-substring
+ - xsl:non-matching-substring
+ - fn:regex-group()
+ * 2.0 Date & Time formatting
+ - fn:format-dateTime()
+ - fn:format-date()
+ - fn:format-time()
+
+ Serialization & Output:
+ ----------------------
+ * 1.0 xsl:output
+ --- Tie together serialization. Should we add
+ QXmlQuery::evaluateTo(QIODevice 1.0 const) ?
+ * 2.0 xsl:character-maps
+ * 2.0 xsl:character-map
+ * 2.0 xsl:result-document
+ --- Should the "default output" be handle with xsl:result-document? Would
+ depend on compilation.
+
+Optimizations:
+ * Remove adjacent text node constructors
+ * Remove string-join when first arg's static cardinality is not more than one
+ * Remove string-join when the second arg is statically known to be the empty string.
+ * Remove string-join when the second arg is a single space and the parent is a text node ctor.
+ * Rewrite to operand if operands are one. What about type conversions?
+ * Replace lookups with xml:id with calls on id().
+ * Recognize that a/(b, c) is equal to a/(b | c). The later does selection and node sorting in one step.
+ * Remove LetClause which has empty sequence as return clause, or no variable dependencies at all.
+ * Do a mega test for rewriting /patterns/:
+ "node() | element()" => element()
+ "comment() | node()" => comment()
+
+ and so forth. This sometimes happens in poorly written patterns. How does
+ this rewrite affect priority calculation?
+
+Tests:
+ * xml:id
+ - Come on, the stuff needs to be reorganized xml:id.
+ - Read in xml:id document with whitespace in attrs, write the doc out. Attrs should be normalized.
+ - Do lookups of IDs with xml:id attrs containing whitespace.
+
+ * current()
+ - Use current() inside each instruction
+ - In a template pattern
+ - Several invocations: current()/current()/current()
+
+
+ * Diagnosticsts:
+ - See http://www.w3.org/Bugs/Public/show_bug.cgi?id=5643 . Comments
+ should be taken into account when comparing. This suggests that we
+ don't have any test which produces a document with XML comments.
+
+ * element-available()
+ - Review the tests.
+ - Try using declarations in XSL-T, should return false
+ - Use xsl:variable(both instr and decl)
+ - invoke with all the XSL-T instructions.
+ - Should return false for when, otherwise, matching-substring, non-matching-substring, etc?
+ - Supply the namespace in the name via the default namespace, no prefix.
+
+ * unparsed-text()
+ - Load an empty file
+ - Use a fragment in the URI
+ - Use an invalid URI
+ - Use device bindings and a QRC to ensure that we're not using a generic
+ network manager.
+ - Duplicate all the network tests. Same as for doc()
+
+ * unparsed-text-available()
+ - Same as for unparsed-text()
+
+ * Sequence constructor that contains only:
+ - XML comment
+ - whitespace text node
+ - processing instruction
+ - a mix of the three
+
+ * xsl:function
+ - Ensure that it's not it's not in scope for use-when.
+ - xsl:function/xsl:param: use processing instructions, whitespace and comments as child: should be stripped
+ - Use <xsl:function/> : @name missing.
+ - Don't strip ws, and have ws between two xsl:param, and between xsl:function and xsl:param.
+ - Use xsl:function with no body.
+ - use xsl:param/@tunnel = no
+ - use xsl:param/@tunnel = yes
+ - use an invalid value for xsl:param/@tunnel = yes
+ - Have a non-WS text node in xsl:function/xsl:param/
+ - Have a WS text node in xsl:function/xsl:param/
+ - Have a WS text node in xsl:function/xsl:param/ while preserving WS.
+ - use a comment as child of xsl:param
+ - use a PI as child of xsl:param
+ - XTSE0770 with import precedence and all that.
+ - have two identical function in the stylesheet. The last has override=no. Should still report XTSE0770.
+ - have @override with invalid value.
+ - have whitespace inside xsl:param with different strip modes.
+ - Have @select => error
+ - Have body => error
+ - call current() inside body. XPDY0002?
+
+ * Does xml:base/StaticBaseURI and StaticCompatiblityStore prevent proper
+ type checking due to expectedOperandTypes() returns item()*?
+
+ * xsl:template/xsl:param
+ - Have @required=yes, and have @select => error
+ - Have @required=yes, and have body => error
+ - Have a variable reference in a template after another, which has
+ param, to ensure they aren't in scope.
+
+ * xsl:template/@match
+ - Have a pattern with unions, and have a body which relies on its
+ static type.
+
+ * @version:
+ Have @version on *all* attributes.
+
+ * xsl:call-template
+ - Have a variable reference just after a xsl:call-template which has
+ with-param, to ensure they aren't in scope.
+ - Have an xsl:with-param which isn't used in the template. Error?
+ - Have an xsl:with-param that has a type error.
+ - an xsl:with-param is not in scope for the next one. Test this => error.
+ - Have a call:template, whose with-param computes its value by calling
+ another template, while using an with-param too.
+
+ * XQuery:
+ - DONE Ensure namespace {expr} {expr} is flagged as invalid
+ - Use all XSL-T functions: error. Or we do that already?
+ - Ensure order by collation 1 + 1 is an error
+ - Ensure order by collation {1 + 1} is an error
+
+ * document()
+ - Basic node deduplication, no test exists for that.
+
+ * xsl:perform-sort
+ - Have no xsl:sort. Error. Must be at least one.
+ - have xsl:sort with invalid value.
+ - sort atomic values.
+ - Trigger "The stable attribute is permitted only on the first xsl:sort element within a sort key specification"
+ - have xsl:sort with no select and no seq ctor.
+ - trigger the delegated queueing. All instructions inside.. xsl:sort?
+ - have multiple sort statements, with the last being <xsl:sort/> only.
+ - have WS between xsl:sort that is not ignorable.
+ - Use a variable reference whose name is equal to our synthetic name. This should be XPST0008, but probably isn't.
+ - Have an invalid value in xsl:sort/order. Use space
+ - have xsl:sort return numbers, but data-type specify string.
+ - have an AVT in xsl:sort/@lang
+ - have an AVT in xsl:sort/@case-order
+ - have an AVT in xsl:sort/@data-type
+ - have an AVT in xsl:sort/@stable
+ - Have mixed result, and hence incorrectly trigger XPTY0018 which the code currently raise.
+ - Depend on the context position inside xsl:sort, when being child of
+ perform-sort. Currently we create singleton focuses(I think), while
+ we want the focus to be over the whole input sequence, not on indivual items.
+ - Have <xsl:perform-sort select="valid-expr"/>: xsl:sort is missing
+ - Use current() in the xsl:sort and the body, to ensure the right scope is picked up
+
+ * xsl:copy-of
+ - Have a text node. It's not allowed.
+ - Have PIs, comments, and ignorable whitespace as children. Sigh.
+
+ * xsl:namespace
+ - Use xsl:fallback.
+ - Use xsl:namespace inside xsl:variable and introspec the result in various
+ ways. This is a big area, we don't have namespace nodes in XQuery. Yes, calling evaluateSingleton() will probably crash.
+ - Use no select and no body, error: XTSE0910
+ - Have name expression evaluate to the empty sequence.
+
+ * Sequence ctor that:
+ - Has invalid element in XSL namespace. E.g, xsl:foo
+
+ * xsl:import
+ - Have element as child as xsl:import: disallowed.
+ - Have text as child as xsl:import: disallowed.
+ - Have PIs and comments as child as xsl:import: allowed.
+
+ * xsl:include
+ - Have element as child as xsl:include: disallowed.
+ - Have text as child as xsl:include: disallowed.
+ - Have PIs and comments as child as xsl:include: allowed.
+
+ * xsl:strip-space
+ - Have PIs, comments, whitespace as child.
+
+ * xsl:element
+ - Extract EBV from result.
+ - Use space in validation element.
+
+ * xsl:perform-sort
+ - Have PIs and comments in between xsl:sort elements.
+
+ * xml:space
+ - We never pop our stack. Fix the bug, and ensure we have tests for it.
+
+ * fn:unparsed-entity-uri
+ - Check type of return value
+ - Do basic unparsed-entity-uri("does-not-exist")
+
+ * fn:unparsed-entity-public-id
+ - Do basic unparsed-entity-uri("does-not-exist"), two permutations, check the spec
+
+ * xsl:element
+ - Use disallowed attribute: select
+ - use unknown type in @type
+ - Use @namespace, but be not in the lexical space of xs:anyURI
+ - use disallowed enumeration in @validation
+ - have a name expression that evaluates to a xs:QName value as opposed to a string.
+ - have a name expression that evaluates to a xs:QName value as opposed to a string. but
+ also have the namespace attribute
+
+ * xsl:attribute
+ - Use disallowed attribute: match
+ - use unknown type in @type
+ - Use @namespace, but be not in the lexical space of xs:anyURI
+ - use disallowed enumeration in @validation
+ - have a name expression that evaluates to a xs:QName value as opposed to a string.
+ - have a name expression that evaluates to a xs:QName value as opposed to a string. but
+ also have the namespace attribute
+
+ * xsl:template
+ - Use the union keyword, it's forbidden, only "|" is allowed
+ - Use an expression other than Literal and VarRef in KeyValue[8]
+ - use a function other than key().
+ - have a declaration that only can apperar as a child of xsl:stylesheet.
+ - Have an element in the XSL-T namespace, but which is invalid, e.g "bar"
+ - Use an axis other than child or attribute in pattern.
+ - Have a template that no no match and no name attribute., XTSE0500
+ - use child::document-node() in pattern
+ - use @foo/child in pattern
+ - apply templates to parentless attributes.
+ - Have 3e3 in @priority
+ - Have a @match with more than two alternatives, e.g "a | b | c", and have them all actually matching.
+ - Use an XML name in the mode so we trigger
+ NCNameConstructor::validateTargetName()
+ - A template which only has a non-WS text node.
+ - A template with param, followed by text node.
+
+ * Simplified stylesheet
+ - Use @version attribute only on doc element. Should fail, since @{XSL-T]version must be present
+
+ * fn:current()
+ - Have <xsl:value-of select="current()"/>
+
+ * xsl:variable have a variable reference appearing before its global declaration, and then somehow trigger recursion.
+ * xsl:choose
+ - elements/nodes intermixed with xsl:choose/xsl:when
+ - invalid attribute on xsl:choose
+ - invalid attribute on xsl:when
+ - invalid attribute on xsl:otherwise
+ - invalid attribute on xsl:if
+ - invalid attribute on xsl:template
+ - invalid attribute on xsl:stylesheet
+ - invalid attribute on xsl:transform
+ - xsl:otherwise in the middle between xsl:when elements.
+ - use namespace declarations on xsl:when
+ - use namespace declarations on xsl:otherwise
+ - use namespace declarations on xsl:choose
+
+ * Namespaces:
+ - Have:
+ <xsl:sequence xmlns:bar="http://example.com/" select="1"/>
+ <xsl:sequence select="bar:foo()"/>
+
+ * XPath
+ - For each XQuery-specific expression, add a test using that expression:
+ - typeswitch
+ - let
+ - validate
+ - extension expression
+ - unordered
+ - ordered
+ - for
+ - computed text node constructor
+ - computed attribute constructor
+ - computed comment constructor
+ - computed PI constructor
+ - computed element constructor
+ - computed document constructor
+ - direct element constructor
+ - direct comment constructor
+ - direct PI constructor
+ - all declarations
+
+ - Use all the predefined prefixes in XQuery; non are in XSL-T.
+
+ * xsl:when
+ - Use xml:space on it
+
+ * xsl:otherwise
+ - Use xml:space on it
+
+ * xsl:version
+ - Use letters, XTSE0110
+ - Use a float: 2e3, XTSE0110
+ - Use a weird number, 2.00000001
+
+ * xsl:document
+ - use disallowed attribute: select.
+ - use unknown type in @type
+ - use disallowed enumeration in @validation
+ - What happens if the type in @type is unknown?
+ - Use xml:base attr and check URI.
+
+ * xsl:sequence
+ - use match attribute
+
+ * xsl:stylesheet
+ - Use @xsl:default-collation on xsl:stylesheet. Shouldn't have any effect. Or?
+ - Use an XSL-T instruction as child -- invalid.
+ - Have an element in the XSL-T namespace, but which is invalid, e.g "foo"
+ - Have xsl:default-collation="http://example.com/" on xsl:stylesheet
+ - Use prefix local: in say a function name. Not allowed.
+ - Use comments after document element.
+ - XTSE0010: <xsl:invalid version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
+ - Change the version with @xsl:version on all elements that we have.
+
+ * Patterns.
+ - Basic */* test:
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="*/*"><xsl:sequence select="'MATCH'"/></xsl:template>
+
+
+</xsl:stylesheet>
+
+ - Basic a/b test:
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="a/b"><xsl:sequence select="'MATCH'"/></xsl:template>
+
+
+</xsl:stylesheet>
+ * xsl:strip-whitespace
+ - Use a namespace prefix which is not unboudn
+ - have a syntax error in one of the node tests
+
+ * xsl:preserve-whitespace
+ - Use a namespace prefix which is not unboudn
+ - have a syntax error in one of the node tests
+
+ * xsl:value-of
+ - select attribute, and comment in body(error, XTSE0870)
+ - select attribute, and processing instruction in body(error, XTSE0870)
+ - select attribute, and CCDATA in body(error, XTSE0870)
+ - select attribute, and element in body(error, XTSE0870)
+ - use xsl:sequence in body. Default separator should be none.
+ - use match attribute
+ - use double apostrophes/quotes. How are they dealt with?
+
+ * xsl:apply-templates
+ - use match attribute
+ - apply in a mode for which no templates are declared
+ - apply in a mode which is mispelled for another.
+ - Have: <xsl:apply-templates select="id('id2')/a | id('id5')"/>
+ We CRASH
+
+ * xsl:for-each
+ - No body: <xsl:for-each select="abc"/>
+ - No select attribute: <xsl:for-each>text</xsl:for-each>
+ - Have mixed result, and hence incorrectly trigger XPTY0018 which the code currently raise.
+ - Have:
+ <xsl:for-each select="1, 'asd'">
+ <xsl:sequence select="."/>
+ </xsl:for-each>
+
+ * xsl:variable
+ - Test that function conversion rules are invoked
+ - For what is an xsl:variable in scope? Where does the spec state it? Test
+ that it is not in scope where applicable.
+ - Have: <variable name="a" select=""/>
+
+ * xsl:text
+ - count the result of a template that has text node(non-ws),
+ xsl:text(content), xsl:content(zero content), text node(non-ws
+ - Have an element inside xsl:text: XTSE0010.
+ - Use comments and PIs intermixed with text inside.
+
+ * xsl:for-each
+ - use match attribute
+ - What should this produce? Saxon produces "123" but with xsl:text removed, "1 2 3".
+ <xsl:template match="/">
+ <xsl:for-each select="1 to 3">
+ <xsl:sequence select="."/>
+ <xsl:text></xsl:text>
+ </xsl:for-each>
+ </xsl:template>
+
+ * xsl:if
+ - Have <xsl:if test="">body</xsl:if>. Error
+ - Have <xsl:if test="valid-test"/>. That is, empty body.
+
+ * xsl:sequence
+ - select attribute missing: <xsl:sequence/>
+ - content other than xsl:fallback, e.g text node.
+ - How do we sort?
+
+ * for every state for XSL-T parsing:
+ - Use invalid element that is in the XSL-T namespace.
+
+ * In all cases expressions are queued/generated:
+ - Trigger expression precedence bugs, due to lack of paranteses.
+
+ * Use xml:space in stylsheeet that doesn't have value preserve nor default.
+ * For each case we have while(!reader.atEnd()):
+ - test that triggers parser error and that we detect it properly.
+
+ * for every element that allows text:
+ * Use CDATA. QXmlStreamReader distinguishes between the two. text before and after.:wa
+ * Use XML Comments and split up text nodes.
+
+ * Patterns:
+ * Ensure node() doesn't match document nodes().
+ * "//" is an invalid pattern
+ * Is there some expression which has no children? findAxisStep()
+ * Use @*/asdo
+ * XPST0003: key(concat("abc", "def"), "abc")
+ * XPST0003: id(concat("abc", "def"))
+ * XPST0003: concat('abc', 'def') // WILL CRASH
+ * XPST0003: unknownFunction()
+ * Use double: key("abc", 3e3)
+ * Use three argument key() in pattern.
+
+ * Simplified stylsheet modules:
+ * Omit the xsl:version attribute. XTSE0010
+
+ * type-available()
+ * We have no tests at all?
+
+ * have xml:base on the following elements and check them with
+ static-base-uri():
+ - all instructions
+ - all declarations, eg:
+ - xsl:choose, xsl:choice, xsl:otherwise
+ - xsl:template
+ - xsl:function
+ - etc
+
+ Embedded stylesheet modules
+ - Verify that we don't choke on xsl attrs with invalid attributes outside;
+ "In an embedded stylesheet module, standard attributes appearing on
+ ancestors of the outermost element of the stylesheet module have no effect."
+
+ Parsing:
+ - Error message for:
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="/">
+ <e/>
+ </xsl:stylesheet>
+ - Use the document "<do/" as focus.
+ - Write a test for each call to checkForParseError();
+
+
+ function-available:
+ - Generally low coverage it seems.
+
+
+<xsl:template match="/"/> <!-- t0 -->
+<xsl:template match="*"/> <!-- t1 -->
+<xsl:template match="asd"/> <!-- t2 -->
+<xsl:template match="comment()"/> <!-- t3 -->
+<xsl:template match="a/b"/> <!-- t4 -->
+
+<xsl:apply-templates select="*"/>
+
+
+*(
+((/)/call-template(t0))
+(*/call-template(t1))
+(element(asd)/call-template(t2))
+(comment()/call-template(t3))
+(a/b/call-template(t3))
+)
+
+==>
+
+*/typeswitch(.)
+ case $g0 as document-root() return call-template(t0)
+ case $g0 as element() return call-template(t1)
+ case $g0 as element(asd) return call-template(t2)
+ case $g0 as comment() return (call-template(t3)
+ case $g0 as a/b return (call-template(t4)
+
+
+Patterns are used in:
+ - xsl:for-each-group/@group-starting-with
+ - xsl:key/@match
+ - xsl:number/(@count, @from)
+ - xsl:template/@match
+
+
+
+c/b
+=>
+child-or-self::element(b)[parent::element(c)]
+
+c/b/a
+=>
+child-or-self::element(a)[parent::element(b)[parent::element(c)]]
+
+d/c/b/a
+=>
+child-or-self::element(a)[parent::element(b)[parent::element(c)[parent::element(d)]]]
+
+
+
+-----------------------------------
+ <xsl:apply-templates select="foo"/>
+ =>
+
+ child::element(foo) map apply-template(#default)
+-----------------------------------
+
+-----------------------------------
+ <xsl:apply-templates mode="yo" select="foo">
+ <xsl:sort select="@bar"/>
+ </xsl:apply-templates>
+ =>
+
+ let $g0 := for $g1 in child::element(foo)
+ order by @bar
+ return $g1
+ return apply-template(yo)
+-----------------------------------
+
+-----------------------------------
+<xsl:perform-sort select="$in">
+ <xsl:sort select="@sortKey"/>
+</xsl:perform-sort>
+
+ =>
+
+sort $in/order by @sortKey
+-----------------------------------
+
+
+-----------
+
+John Snelson of Oracle Berkeley DB XML & XQilla writes in private mail:
+
+ I'd had the same thought myself, too - you must be reading my mind ;-)
+
+What is he referring to?
+
+If one spends some time on fancy diagrams, QtXmlPatterns[LINK]'s, the XQuery
+engine that shipped in Qt 4.4, architecture looks like this:
+
+
+Recently I've started implementing XSL-T 2.0(hopefully to be done for Qt 4.5)
+and the whole approach to this is modifying the existing codebase as follows:
+
+
+
+
+
+
+Put differently, when QtXmlPatterns is dealing with XSL-T stylesheets, it
+replaces the XQuery tokenizer with a tokenizer which translates the
+stylesheet into XQuery tokens, that is consumed by the existing XQuery
+parser, extended with both grammar non-terminals and tokens to accomodate the
+XSL-T features that XQuery doesn't have. In compiler terms, it can be seen as
+an "extreme" frontend. Not only is the same intermediate representation used,
+the grammar is too.
+
+What is the point of this?
+
+The functional overlaps XQuery, XSL-T and others as well have is of course
+widely established. Even the specifications are at times generated from the
+same source documents, and that implementations subsequently modularize code
+is of course second nature to any engineer, and seen to some degree or
+another in contemporary implementations. Typically this happens in a
+traditional fashion, classes are re-used, their functionality widened to
+cover both/more languages. However, I believe doing it directly on the
+grammar level introduce several advantages.
+
+The parser is based on Bison and since it's not running in the experimental
+pull mode, it uninterruptedly calls the tokenizer. The tokenizer, class
+XSLTTokenizer, in turns calls an pull-based XML parser: QXmlStreamReader.
+What often complicate in ocassions like this is who that gets the right to
+call who, and who gets the convenience of tracking state in a natural way
+through a call stack.
+
+XSLTTokenizer is conveniently implemented: as it encounters declarations and
+instructions in the stylsheet, it recursively descends in the XSL-T grammar
+through its own functions, adding tokens to a queue, which is delivered to
+the parser when asked -- and when the queue is empty it resumes queuing
+tokens. The tokenizer is fairly crude, it queues up tokens for instructions
+uninterrupted, and only have states between declarations. Hence,
+XSLTTokenizer queues up tokens for each template and function body, but
+enters "delivery mode" inbetween. This of course periodically breaks
+streaming since it's buffering up tokens, but considering that the memory
+usage for tokens is low and that a finer granularity for states(say, being
+able to pop the stacks when being inbetween two xsl:when elements) requires a
+significant effort, this is fine until proven otherwise.
+
+
+Advantages
+---------------
+discuss analysis.
+
+
+XSLTTokenizer rewrite XSL-T to XQuery as follows:'
+
+Instructions
+-------------
+xsl:if An if/then/else expression whose else branch is the empty sequence
+
+xsl:choose: again, a nesting of if/then/else expressions
+
+xsl:value-of: a computed text node constructor. Its body contains a call to
+string-join() involving the separator attribute
+
+xsl:variable: a let/return binding. Since XSL-T is statement-like in its
+sequence constructors, parantheses are used to ensure the variable binding is
+in-scope for all subsequent statements.
+
+for-each: it is the iteration/mapping mechanism XQuery fails to supply,
+despite path steps and the FLWOR machinery. for-each iterates using a
+focus(which for doesn't, but paths do), but can do so over atomic values and
+unconditionally without sorting the result by document order(which paths
+can't/doesn't, but for do). For implementations that normalize paths into for
+loops as the formal semantics do, the approach is straight forward. In
+QtXmlPatterns' case, a synthetic token is queued which signals to create
+a "relaxed" path expression which skips halting on atomic values in its
+operands(XPTY0019) and also skips node sorting.
+
+All "direct" node constructors, like <myElement/>, and "computed" node
+constructors, like xsl:element, are all rewritten into the corresponding
+XQuery computed node constructors. In some cases direct node constructors
+could have been used, but in anycase the IR yielded is the same, and that
+computed constructors happen to use less tokens.
+
+A particular case is xsl:namespace, an instruction which doesn't have any
+corresponding expression in XQuery. In the case of QtXmlPatterns, the code
+obvious already have a notion of "create this namespace on this element", and
+an AST node was trivially added for fetching the namespace components
+computationally. However, the introduction of xsl:namespace in an XQuery
+implementation is not to be taken lightly wrt. to for instance testing, since
+it introduces a new node type.
+
+perform-sort: surprisingly this expression of all complicate matters, for the
+simple reason that its operands occur in the opposite order compared to
+XQuery when the input sequence is supplied through a sequence constructor,
+hence breaking the streamed approach. XSLTokenizer solves this by
+buffer: the attributes of the xsl:perform-sort elements are stored,
+the xsl:sort elements queued onto a temporary queue, and subsequently is
+either the select attribute or the sequence constructor queued, and the
+tokens for xsl:sort appended afterwards. This complicated code greatly, since
+XSLTokenizer had to be able to "move around" sequences of tokens.
+
+In addition perform-sort has the same problem as for-each, the iteration
+mechanism falls inbetween paths and the for loop. The focus for perform-sort
+is also the focus for the sequence constructor and the select attribute, but
+the focus for the xsl:sort elements is the initial sequence. This is
+approached by having a for loop, and where the expression in each order by
+clause has a relaxed path expression whose left operand is a variable
+reference to what the for loop bound.
+TODO Doesn't work. Focus size wrong.
+
+This is an approach that implementations of the "second generation" of the
+technologies can take. The bif difference is that XSL-T 2.0 doesn't have the
+restrictions of 1.0, more evident in XQuery's syntax.
+
+xsl:sort XSL-T is much more dynamic than XQuery through the use of templates,
+but also
+because more decisions can be taken at runtime through all attribute value
+templates. xsl:sort is surely a good example of this with its AVTs for
+language, order, collation, stability and what not. XQuery's order by stands
+in strong contrast, which has these coded in the grammar. In QtXmlPatterns'
+case, the AST node corresponding to order by was generalized to take things
+such as stability and order from operands. This is paid by the code paths in
+XQuery since for them are constants generated and inserted as operands even
+though its known at compile time what is needed. However, considering that
+these evaluations are not inside the actual sort loop, but instead only
+computed on each sort invocation, it shouldn't be too bad.
+
+xsl:message
+
+Templates
+-------------------------
+
+A big bucket of questions for an XQuery implementation is of course the
+introduction of templates. In this case it is too of large interest to
+rewrite relevant code into primitive XQuery expressions.
+
+Templates' drawback is often mentioned to be their dynamic nature which makes
+static inferences hard or impossible. However, by again rewriting in clever
+ways and making the code visible in a standard way, existing analysis code
+can operate upon it.
+
+For the purposes of this discussion, templates can be broken down into three
+distinct problems:
+
+A Finding what nodes to invoke upon. This is the expression found on
+xsl:apply-templates/@select, in the case of template rules
+
+B Concluding what template to invoke. This is the analyzis and evaluation of
+patterns, as found on xsl:template/@match, in the case of templates rules.
+This is seen as a critical, as for instance Michael Kay emphasizes in Saxon:
+Anatomy of an XSLT processor [LINK
+http://www.ibm.com/developerworks/library/x-xslt2/]
+
+C Invoking the template for the given context node
+
+For these three steps, the two first are specific to template rules, while the
+latter, invoking templates, can be seen to be treated identically regardless
+of kind: template rules as well as named templates.
+
+With this perspective as background, lets try to write it into XQuery
+primitives.
+
+First, all templates regardless of kind are instanciated by name. In the case
+of templates rules, a synthetic name is given. They are invoked by an XPath
+function named call-template() that as first argument takes the name of the
+template, and also handles template parameters. This "template callsite"
+which is separated from what it is invoked with and whether it is invoked,
+knows its target template statically, and hence can be subject to inlining,
+and usual functional analysis.
+
+Focus and concatenation of output handled.
+One should consider whether templates couldn't be considered as functions,
+with specialized arguments in the case of tunnel parameters.
+Knowing what templates will be invoked could be used to conclude
+node sorting is not necessary.
+Mention how we do builtin templates
+
+Attribute Value Templates
+-------------------------
+XSL-T make extensive use of Attribute Value Templates(AVTs), which are handled
+by turning the grammar piece in XQuery that is closest, into an expression.
+Simply, ExprSingle[32] is extended with the branch:
+
+AVT LPAREN AttrValueContent RPAREN
+
+where AVT is a synthetic token XSLTokenizer generates. This means that the
+code handling AVTs in XQuery's direct attribute constructors handles AVTs as
+generic expressions. AttrValueContent creates a call to the concat()
+function, over the operands.
+
+Deal with fn:current by using let $current := . return instruction.
+
+Another thing related to order and parsing is that XSL-T has more freedom wrt.
+to where variables are in scope. For instance, a variable declaration appearing
+after a user function declaration is in scope for the function in XSL-T, but
+that's not the case in XQuery. This means that delayed variable resolution must
+be added, something which wasn't, and cannot be active, for the XQuery code.
+See 9.7 Scope of Variables.
+
+The parser generates for the builtin template rules:
+
+ declare template matches (text() | @*) mode #all
+ {
+ text{.}
+ };
+
+ *
+By having templates invocations essentially expressed as a callsite, or
+branching, allows control flow analysis in a traditional manner, and hence the
+possiblity to conclude what templates that are possibly invoked in various
+contexts (or not invoked). One good example where this could improve template
+matching is patterns containg predicates: let's say a template matches text
+nodes with a predicate, but , doh I'm wrong.
+
+The problem with expressing template invocation with if expressions, is finding
+ambiguous matches.
+
+Although normalizing down to a small set of primitives has its advantages, one
+problem is with doing it too early. When doing it directly when tokenization,
+the higher-level perspective is lost and therefore must be restored
+again(example?). For instance, if an error is reported in a primitive, it must
+not appear as originating from that primitive. It's not contstrained to error
+reporting(example?). However, this is a general problem when compilers shift
+between different representations.
+
+One effect this parsing approach has, is that the stylesheet cannot be used as
+an input document(e.g, what document("") would evaluate to); in that case it
+has to be parsed again. I think this is for the better; in the case that the
+stylsheet has this dual role, it means representations are used which are
+designed specifically for these respective roles. Although doing a dual parsing
+step is costly, it's somewhat relieved by that the input is typically cached at
+the byte level(file system and higher layers such as web/application caches) in
+the case of traditional file loading.
+
+Another problem is that the grammar is used to solve implementation details,
+and this might show as part of when the parser do error reporting.
+
+If one decide to not send XSL-T through the XQuery parser, it can be an
+advantage to have as little business logic as possible in the XQuery parser
+such that it can be reused.
+
+Some parts of XSL-T's syntax doesn't translate well to XQUery syntax. Some
+parts doesn't follow structure very strongly, surely not the structures that
+map well to XQuery's syntax. These are xml:base, @version and other attributes
+that can appear on any element. Their information needs to be preserved and
+need to affect the output code, but these cannot be done in a way which fits
+naturally with the XQuery syntax, and hence leads to workarounds. Have whole
+section on how we do @version and @xml:base. Another problem is namespace
+declarations on the top document element.
+
+What largely makes me believe this technique fails is that the large and most
+important parts, templates, instructions, maps well to XQuery, but the small
+but yet not ignorable details like @version and @xml:base does not, to the
+degree that the approach at large fails.
+
+fn:document()
+------------------------
+See class documentation for DocumentFN. Document what optimizations one typically
+wants to implement(const-fold on card 1, constant propagate).
+
+
+In other words, it's reasonable to believe that it's possible to extend the
+XQuery grammar such that it functionality wise is able to do the same as XSL-T,
+but this doesn't equal that it is a good way to reach every gritty corner of
+the XSL-T specification.
+
+Patterns
+--------------------
+The up-side-down turning, discuss id/key().
+
+Declarations
+---------------------
+xsl:function: the 'declare function' declaration. TODO override
+
+XSL-T's error codes goes against good refactoring. Its codes are
+specific on each usage, compared to for instance XPTY0004.
+
+Optimizations: string-join()/value-of
+
+ <xsl:template match="document-node">
+ <xsl:apply-templates select="child::element(doc)"/>
+ </xsl:template>
+
+ <xsl:template match="child-or-top::element(doc)"/>
+
+ =>
+
+ document-node()/child::element(doc) map apply-template
+
+ matches child-or-top::element(doc)
+
+ =>
+
+ N/root(.)//(EE)
+
+ N == document-node()
+ EE == child::element(doc)
+
+ =>
+
+ document-node()/root(.)/descendant-or-self::node()/child::element(doc)
+
+ Optimize out already in createCopyOf()
+
+Bugs:
+ - DynamicContextStore and CurrentItemStore needs to implement
+ evaluateToReceiver().
+ - Don't we have a parsing bug in each place where we call insideSequenceConstructor(), and don't
+ wrap the result in parantheses? E.g, a whitespace node followed by an instruction will lead to parse
+ error if the parent is for instance xsl:when.
+
+In patterns we find:
+ - Function :id()
+ - Function :key()
+ - AxisStep
+ - GenericPredicate. Also used for paths.
+ - (CombineNodes)
+ - empty sequence; attribute::foo()/child::asd
+
+
+Test case, tokenizer asserts(fixed in 2a0e83b):
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+
+ <xsl:template match="/">
+ <xsl:call-template name="TestFunction"/>
+ </xsl:template>
+
+
+ <xsl:template name="TestFunction">
+
+
+ <xsl:call-template name="GetElem">
+ <xsl:with-param name="element-set"select="$super/*"/>
+ </xsl:call-template>
+
+ </xsl:template>
+
+ <xsl:template name="GetElem">
+ <xsl:param name="element-set"/>
+ <xsl:copy-of select="$element-set[@name]"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Typing code:
+
+ <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/">
+
+ <xsl:call-template name="templateName">
+ <xsl:with-param name="a" select="2" />
+ </xsl:call-template>
+
+ </xsl:template>
+
+ <xsl:template name="templateName">
+ <xsl:param name="a" as="xs:integer"/>
+ <xsl:sequence select="$a"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Compat mode in attribute sets:
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:attribute-set name="attrSet" version="1.0">
+ <xsl:attribute name="attributeName" select="1 + 'type error without compat mode'"/>
+ </xsl:attribute-set>
+
+ <xsl:template match="/">
+ <out xsl:use-attribute-sets="attrSet"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Space in mode:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/">
+ <xsl:apply-templates mode=" #default"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+Type error in global template:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:variable name="wa" as="item()"/><!-- HERE, incorrect cardinality. -->
+
+ <xsl:template name="templateName"/>
+
+ </xsl:stylesheet>
+
+
+Variables are not in scope before its siblings:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template name="templateName">
+ <xsl:sequence select="$var"/>
+ <xsl:variable name="var" select="1"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Crashes:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:local="http://example.com/"
+ version="2.0">
+
+ <xsl:variable name="var" as="xs:boolean">
+ <xsl:value-of select="local:doesNotExist()"/>
+ </xsl:variable>
+
+ </xsl:stylesheet>
+
+
+
+Whitespace handling, the important part is WS after xsl:template:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/" xml:space="preserve"><MATCH/></xsl:template>
+
+ </xsl:stylesheet>
+
+
+
+Whitespace handling, preserve, but not inside xsl:apply-templates:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w2.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/" xml:space="preserve">MATCH<xsl:apply-templates>
+
+ </xsl:apply-templates></xsl:template>
+
+ </xsl:stylesheet>
+
+Have top-level xml:space, ensure whitespace as child of xsl:stylesheet is ignored:
+
+ <xsl:stylesheet xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/">MATCH<xsl:apply-templates>
+
+ </xsl:apply-templates>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Compat mode, Saxon & QtXmlPatterns fails:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/">
+ <xsl:sequence version="1.0" select="string-join(current-dateTime(), 'separator')"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Compat mode, this is not in the suite:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/">
+ <xsl:sequence version="1.0" select="subsequence((1, 2), '2')"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Crashes:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="doc"/>
+
+ <xsl:apply-templates select="item" mode="crazy" />
+
+
+ </xsl:stylesheet>
+
+Incorrectly yields compile error, XPST0003:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match=""/>
+
+ <xsl:apply-templates select="item" mode="crazy" />
+
+ </xsl:stylesheet>
+
+Have a basic simplified stylesheet module:
+
+ <output xsl:version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:value-of select="/"/>
+ </output>
+
+Have no @version:
+ <output xsl:version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:value-of select="/"/>
+ </output>
+
+
+Is valid:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
+
+ <xsl:template match="/">
+ <xsl:perform-sort select=".">
+ <xsl:sort select="*"/>
+ <xsl:variable name="abc" select="b"/>
+ </xsl:perform-sort>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+Is valid:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
+
+ <xsl:template match="/">
+ <xsl:perform-sort select=".">
+ <xsl:sort select="*"/>
+ TEXT
+ </xsl:perform-sort>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+XTSE0020:
+ <literalResultElement xsl:validation="disallowedValue"/>
+
+XTSE0020:
+ <xsl:element name="localName" validation="disallowedValue"/>
+
+XTSE0805:
+ <e xsl:disallowedAttribute=""/>
+
+not XPST0003, not in test suite:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+ <xsl:template match="/">
+ <xsl:variable name="s" as="element()*"/>
+ </xsl:template>
+ </xsl:stylesheet>
+
+Parsing of many exprs in xsl:value-of(with separator):
+
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <xsl:value-of separator="SEP">
+ <xsl:sequence select="1"/>
+ <xsl:sequence select="2"/>
+ </xsl:value-of>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+Parsing of many exprs in xsl:value-of(without separator):
+
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <xsl:value-of>
+ <xsl:sequence select="1"/>
+ <xsl:sequence select="2"/>
+ </xsl:value-of>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+Check type of empty variables:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ version="2.0">
+
+ <xsl:template match="/">
+ <xsl:variable name="empty"/>
+
+ <xsl:sequence select="'instance of xs:string:', $empty instance of xs:string, '(should be true)',
+ 'instance of document-node():', $empty instance of document-node(), '(should be false)',
+ 'value is:', $empty,
+ 'END'"/>
+
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+Crashes:
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <e xmlns="ABC"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+invalid standard attributes on a simplified stylesheet module.
+
+
+
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ version="2.0">
+
+ <!-- Type error: applying templates to a variable of type string -->
+ <?spec xslt#applying-templates?>
+ <?error XTTE0520?>
+
+ <xsl:template match="/">
+ <xsl:variable name="empty"/>
+
+ <xsl:sequence select="'instance of xs:string:', $empty instance of xs:string, 'instance of document-node():', $empty instance of document-node()"/>
+
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/">
+ <output>
+ <xsl:sequence select="string-length(doesNotMatch)"/>
+ </output>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Asserts(not wellformed):
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+ <xsl:template match="/">
+ <output>
+ </outpu>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+From within a function, use the focus /through/ a variable reference:
+
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:local="http://www.w3.org/2005/xquery-local-functions">
+
+ <xsl:variable name="var" select="node()"/>
+
+ <xsl:function name="local:function">
+ <xsl:sequence select="$var"/>
+ </xsl:function>
+
+ <xsl:template match="/">
+ <xsl:sequence select="local:function()"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+
+Loops infinitely:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template match="/" version="1.0">
+ <xsl:namespace name="{doc/item}" select="'http://www.example.com'" version="1.0"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+
+Gives crash in coloring code:
+ Stylesheet:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:template match="/">
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+ Focus:
+ <a><b/><</a>
+
+
+Should evaluate to true:
+
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
+
+ <xsl:template match="/">
+ <xsl:call-template name="yo">
+ <xsl:with-param name="arg" as="xs:integer">
+ <xsl:sequence select="xs:untypedAtomic('1')"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="yo">
+ <xsl:param name="arg"/>
+ <xsl:sequence select="$arg instance of xs:integer"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+Crashes, should be XTTE0570:
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ exclude-result-prefixes="xs" version="2.0">
+
+ <xsl:template match="/">
+ <xsl:apply-templates>
+ <xsl:with-param name="second_seq" as="xs:string">
+ </xsl:with-param>
+
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="empty">
+ <xsl:param name="second_seq">def</xsl:param>
+ <xsl:sequence select="$second_seq instance of xs:string"/>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+* Parse error:
+
+ <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <xsl:copy>
+ <xsl:sequence select="1"/>
+ <xsl:sequence select="2"/>
+ </xsl:copy>
+ </xsl:template>
+
+ </xsl:stylesheet>
+
+* Write tests with xsl:with-param whose body is empty. That's effectively an
+ empty sequence(?) which needs to be handled properly, and (dynamically) type
+ checked correctly.
+
+--------------------------------------------------------------------------
+
+
+
+
+
+--------------------------------------------------------------------------
+
+
+
+ -------------------------------------------------------------
+ /a/b
+
+ =>
+
+ b[parent::a[parent::document()]]
+
+ but we currently have:
+
+ (b[parent::a])[parent::document()]
+
+ -------------------------------------------------------------
+ a/b
+
+ =>
+
+ b[parent::a]
+
+ -------------------------------------------------------------
+ a/b/c
+
+ =>
+
+ c[parent::b[parent::a]]
+
+ -------------------------------------------------------------
+ a/b/c/d
+
+ =>
+
+ d[parent::c[parent::b[parent::a]]]
+
+
+ -------------------------------------------------------------
+ /a/b/c/d
+
+ =>
+
+ d[parent::c[parent::b[parent::a[parent::document()]]]]
+
+ This is handled specially; see | SLASH RelativePathPattern
+
+
+ b/c rewrites to:
+ TruthPredicate
+ AxisStep self::element(c)
+ AxisStep parent::element(b)
+
+ For a/b/c we get:
+
+ TruthPredicate
+ TruthPredicate
+ AxisStep self::element(c)
+ AxisStep parent::element(b)
+ AxisStep parent::element(a)
+
+ But we want:
+
+ TruthPredicate
+ AxisStep child-or-top::element(c)
+ TruthPredicate
+ AxisStep parent::element(b)
+ AxisStep parent::element(a)
+
+ For a/b/c/d we get:
+
+ TruthPredicate
+ TruthPredicate
+ TruthPredicate
+ AxisStep self::element(d)
+ AxisStep parent::element(c)
+ AxisStep parent::element(b)
+ AxisStep parent::element(a)
+
+ For a/b/c/d we want:
+
+ TruthPredicate
+ AxisStep self::element(d)
+ TruthPredicate
+ AxisStep parent::element(c)
+ TruthPredicate
+ AxisStep parent::element(b)
+ AxisStep parent::element(a)
+
+
+ For /a/b we get:
+
+ TruthPredicate
+ TruthPredicate:
+ AxisStep self::element(b)
+ AxisStep parent::element(a)
+ AxisStep parent::document()
+
+ but we want:
+
+ TruthPredicate
+ AxisStep self::element(b)
+ TruthPredicate: // PREDICATE
+ AxisStep parent::element(a)
+ AxisStep parent::document() // PREDICATE
+
+ --------------------------------------------------------------
+ For a/b/c we get:
+ TruthPredicate
+ AxisStep self::element(c)
+ TruthPredicate
+ parent::element(b)
+ parent::element(a)
+
diff --git a/tests/auto/xmlpatterns/baselines/globals.xml b/tests/auto/xmlpatterns/baselines/globals.xml
new file mode 100644
index 0000000..2457aaa
--- /dev/null
+++ b/tests/auto/xmlpatterns/baselines/globals.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en"><head><title>Global variables report for globals.gccxml</title></head><style type="text/css">
+ .details
+ {
+ text-align: center;
+ font-size: 80%;
+ color: gray
+ }
+ .variableName
+ {
+ font-family: courier
+ }
+ </style><body><p>The following global, complex variables were found:</p><ol><li><span class="variableName">constComplex2</span> in globals.cpp at line 17</li><li><span class="variableName">constComplex1</span> in globals.cpp at line 16</li><li><span class="variableName">mutableComplex2</span> in globals.cpp at line 15</li><li><span class="variableName">mutableComplex1</span> in globals.cpp at line 14</li></ol><p>The following mutable primitives were found:</p><ol><li><span class="variableName">mutablePrimitive2</span> in globals.cpp at line 2</li><li><span class="variableName">mutablePrimitive1</span> in globals.cpp at line 1</li></ol><p class="details">This report was generated on</p></body></html> \ No newline at end of file
diff --git a/tests/auto/xmlpatterns/queries/README b/tests/auto/xmlpatterns/queries/README
new file mode 100644
index 0000000..ab0726f
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/README
@@ -0,0 +1,4 @@
+The queries in this directory are used by several tests, at least: cli/ and
+qxmlquery/. When adding queries, make sure the correct baselines have been
+generated for the auto tests that use them.
+
diff --git a/tests/auto/xmlpatterns/queries/allAtomics.xq b/tests/auto/xmlpatterns/queries/allAtomics.xq
new file mode 100644
index 0000000..f2ea459
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/allAtomics.xq
@@ -0,0 +1,50 @@
+xs:untypedAtomic("xs:untypedAtomic"),
+xs:dateTime("2002-10-10T23:02:11Z"),
+xs:date("2002-10-10Z"),
+xs:time("23:02:12Z"),
+xs:duration("P12M"),
+
+(: Sub-types of xs:duration :)
+xs:dayTimeDuration("PT1S"),
+xs:yearMonthDuration("P1M"),
+
+xs:float("3e3"),
+xs:double("4e4"),
+xs:decimal("2.0"),
+(: Sub-types of xs:decimal :)
+xs:integer("16"),
+xs:nonPositiveInteger("-6"),
+xs:negativeInteger("-4"),
+xs:long("5"),
+xs:int("6"),
+xs:short("7"),
+xs:byte("8"),
+xs:nonNegativeInteger("9"),
+xs:unsignedLong("10"),
+xs:unsignedInt("11"),
+xs:unsignedShort("12"),
+xs:unsignedByte("13"),
+xs:positiveInteger("14"),
+
+xs:gYearMonth("1976-02Z"),
+xs:gYear("2005-12:00"),
+xs:gMonthDay("--12-25-14:00"),
+xs:gDay("---25-14:00"),
+xs:gMonth("--12-14:00"),
+xs:boolean("true"),
+xs:base64Binary("aaaa"),
+xs:hexBinary("FFFF"),
+xs:anyURI("http://example.com/"),
+QName("http://example.com/2", "prefix:localName"),
+
+xs:string("An xs:string"),
+(: Sub-types of xs:string :)
+xs:normalizedString("normalizedString"),
+xs:token("token"),
+xs:language("language"),
+xs:NMTOKEN("NMTOKEN"),
+xs:Name("Name"),
+xs:NCName("NCName"),
+xs:ID("ID"),
+xs:IDREF("IDREF"),
+xs:ENTITY("ENTITY")
diff --git a/tests/auto/xmlpatterns/queries/allAtomicsExternally.xq b/tests/auto/xmlpatterns/queries/allAtomicsExternally.xq
new file mode 100644
index 0000000..e3f8686
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/allAtomicsExternally.xq
@@ -0,0 +1,33 @@
+(: fromQTime is intentionally not here, since
+ we don't support it. :)
+
+string-join(for $i in (
+ $fromFloat,
+ $fromBool,
+ $fromDouble,
+ $fromIntLiteral,
+ $fromLongLong,
+ $fromQByteArray,
+ $fromQChar,
+ $fromQDate,
+ $fromQDateTime,
+ $fromQString,
+ $fromQUrl,
+ $fromUInt,
+ $fromULongLong,
+ $fromBool instance of xs:boolean,
+ $fromDouble instance of xs:double,
+ $fromFloat instance of xs:double,
+ $fromIntLiteral instance of xs:integer,
+ $fromLongLong instance of xs:integer,
+ $fromQByteArray instance of xs:base64Binary,
+ $fromQChar instance of xs:string,
+ $fromQDate instance of xs:date,
+ $fromQDateTime instance of xs:dateTime,
+ $fromQString instance of xs:string,
+ $fromQUrl instance of xs:string,
+ $fromUInt instance of xs:integer,
+ $fromULongLong instance of xs:unsignedLong)
+ return string($i),
+ " ")
+
diff --git a/tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq b/tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/completelyEmptyQuery.xq
diff --git a/tests/auto/xmlpatterns/queries/concat.xq b/tests/auto/xmlpatterns/queries/concat.xq
new file mode 100644
index 0000000..08acf55
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/concat.xq
@@ -0,0 +1 @@
+concat("abc", "def")
diff --git a/tests/auto/xmlpatterns/queries/emptySequence.xq b/tests/auto/xmlpatterns/queries/emptySequence.xq
new file mode 100644
index 0000000..df672d0
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/emptySequence.xq
@@ -0,0 +1,2 @@
+(: This query evaluates to nothing. :)
+()
diff --git a/tests/auto/xmlpatterns/queries/errorFunction.xq b/tests/auto/xmlpatterns/queries/errorFunction.xq
new file mode 100644
index 0000000..a77884a
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/errorFunction.xq
@@ -0,0 +1 @@
+fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000'))
diff --git a/tests/auto/xmlpatterns/queries/externalStringVariable.xq b/tests/auto/xmlpatterns/queries/externalStringVariable.xq
new file mode 100644
index 0000000..1133714
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/externalStringVariable.xq
@@ -0,0 +1 @@
+concat("START ", $externalString, " END")
diff --git a/tests/auto/xmlpatterns/queries/externalVariable.xq b/tests/auto/xmlpatterns/queries/externalVariable.xq
new file mode 100644
index 0000000..edff16e
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/externalVariable.xq
@@ -0,0 +1,2 @@
+declare variable $externalVariableAsInt as xs:integer := xs:integer($externalVariable);
+$externalVariable, $externalVariableAsInt + 3, <e>{$externalVariable}</e>, $externalVariable instance of xs:string
diff --git a/tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq b/tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq
new file mode 100644
index 0000000..ba13875
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/externalVariableUsedTwice.xq
@@ -0,0 +1 @@
+$externalVariable, $externalVariable
diff --git a/tests/auto/xmlpatterns/queries/flwor.xq b/tests/auto/xmlpatterns/queries/flwor.xq
new file mode 100644
index 0000000..16e3b2c
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/flwor.xq
@@ -0,0 +1,4 @@
+for $a in (1, 4, 2)
+let $i := (1, 3, 2)
+order by $i
+return $i
diff --git a/tests/auto/xmlpatterns/queries/globals.gccxml b/tests/auto/xmlpatterns/queries/globals.gccxml
new file mode 100644
index 0000000..81bcb22
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/globals.gccxml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<GCC_XML>
+ <Namespace id="_1" name="::" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 " mangled="_Z2::"/>
+ <Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/>
+ <Function id="_3" name="_GLOBAL__D_globals.cppwVRo3a" returns="_16" context="_1" location="f0:14" file="f0" line="14" endline="14"/>
+ <Function id="_4" name="_GLOBAL__I_globals.cppwVRo3a" returns="_16" context="_1" location="f0:14" file="f0" line="14" endline="14"/>
+ <Function id="_5" name="__static_initialization_and_destruction_0" returns="_16" context="_1" mangled="_Z41__static_initialization_and_destruction_0ii" location="f0:23" file="f0" line="23" endline="14">
+ <Argument name="__initialize_p" type="_17"/>
+ <Argument name="__priority" type="_17"/>
+ </Function>
+ <Function id="_6" name="main" returns="_17" context="_1" location="f0:20" file="f0" line="20" endline="24"/>
+ <Variable id="_7" name="constComplex2" type="_11c" context="_1" location="f0:17" file="f0" line="17"/>
+ <Variable id="_8" name="constComplex1" type="_11c" context="_1" location="f0:16" file="f0" line="16"/>
+ <Variable id="_9" name="mutableComplex2" type="_11" context="_1" location="f0:15" file="f0" line="15"/>
+ <Variable id="_10" name="mutableComplex1" type="_11" context="_1" location="f0:14" file="f0" line="14"/>
+ <Class id="_11" name="ComplexClass" context="_1" mangled="12ComplexClass" location="f0:7" file="f0" line="7" members="_19 _20 _21 " bases=""/>
+ <Variable id="_12" name="constPrimitive2" type="_17c" init="3" context="_1" location="f0:4" file="f0" line="4"/>
+ <Variable id="_13" name="constPrimitive1" type="_17c" init="4" context="_1" location="f0:3" file="f0" line="3"/>
+ <Variable id="_14" name="mutablePrimitive2" type="_17" context="_1" location="f0:2" file="f0" line="2"/>
+ <Variable id="_15" name="mutablePrimitive1" type="_17" context="_1" location="f0:1" file="f0" line="1"/>
+ <FundamentalType id="_16" name="void"/>
+ <FundamentalType id="_17" name="int"/>
+ <CvQualifiedType id="_11c" type="_11" const="1"/>
+ <Constructor id="_19" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassC1Ev *INTERNAL* " location="f0:9" file="f0" line="9" extern="1"/>
+ <Constructor id="_20" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassC1ERKS_ *INTERNAL* " location="f0:10" file="f0" line="10" extern="1">
+ <Argument type="_23"/>
+ </Constructor>
+ <Destructor id="_21" name="ComplexClass" context="_11" mangled="_ZN12ComplexClassD1Ev *INTERNAL* " location="f0:11" file="f0" line="11" extern="1">
+ </Destructor>
+ <CvQualifiedType id="_17c" type="_17" const="1"/>
+ <ReferenceType id="_23" type="_11c"/>
+ <File id="f0" name="globals.cpp"/>
+</GCC_XML>
diff --git a/tests/auto/xmlpatterns/queries/invalidRegexp.xq b/tests/auto/xmlpatterns/queries/invalidRegexp.xq
new file mode 100644
index 0000000..fa89b22
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/invalidRegexp.xq
@@ -0,0 +1 @@
+tokenize("input", "\")
diff --git a/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq b/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq
new file mode 100644
index 0000000..b15f8ad
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq
@@ -0,0 +1 @@
+tokenize("input", "pattern", "INVALID")
diff --git a/tests/auto/xmlpatterns/queries/nodeSequence.xq b/tests/auto/xmlpatterns/queries/nodeSequence.xq
new file mode 100644
index 0000000..721cb86
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/nodeSequence.xq
@@ -0,0 +1,31 @@
+document{()},
+document{()},
+document{()},
+document{""},
+document{""},
+document{text{()}},
+document{text{()}},
+document{text{"text1"}},
+document{text{"text2"}},
+document{<f/>},
+<e1/>,
+<e2/>,
+<e3/>,
+<e3 attr1="value1"/>,
+attribute name {"value"},
+text{()},
+text{"text3"},
+<e5>
+ text4
+ <e/>
+ text5
+ <?target data?>
+ <!-- comment -->
+ <e6 attr2="value2" attr3="value2"/>
+ <e6 attr2="value3" attr3="value3"/>
+ <e6 attr2="value4" attr3="value4"/>
+</e5>,
+<?target data?>,
+<!-- comment -->,
+<e xmlns="http://example.com/"/>,
+<p:e xmlns:p="http://example.com/"/>
diff --git a/tests/auto/xmlpatterns/queries/nonexistingCollection.xq b/tests/auto/xmlpatterns/queries/nonexistingCollection.xq
new file mode 100644
index 0000000..1c18cc4
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/nonexistingCollection.xq
@@ -0,0 +1 @@
+collection("doesNotExistForSure")
diff --git a/tests/auto/xmlpatterns/queries/oneElement.xq b/tests/auto/xmlpatterns/queries/oneElement.xq
new file mode 100644
index 0000000..10a7e70
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/oneElement.xq
@@ -0,0 +1 @@
+<e/>
diff --git a/tests/auto/xmlpatterns/queries/onePlusOne.xq b/tests/auto/xmlpatterns/queries/onePlusOne.xq
new file mode 100644
index 0000000..8d2f097
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/onePlusOne.xq
@@ -0,0 +1 @@
+1 + 1
diff --git a/tests/auto/xmlpatterns/queries/onlyDocumentNode.xq b/tests/auto/xmlpatterns/queries/onlyDocumentNode.xq
new file mode 100644
index 0000000..c0c40ee
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/onlyDocumentNode.xq
@@ -0,0 +1 @@
+document{ () }
diff --git a/tests/auto/xmlpatterns/queries/openDocument.xq b/tests/auto/xmlpatterns/queries/openDocument.xq
new file mode 100644
index 0000000..73702dd
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/openDocument.xq
@@ -0,0 +1 @@
+doc("simpleDocument.xml")
diff --git a/tests/auto/xmlpatterns/queries/reportGlobals.xq b/tests/auto/xmlpatterns/queries/reportGlobals.xq
new file mode 100644
index 0000000..52fecd5
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/reportGlobals.xq
@@ -0,0 +1,101 @@
+(:
+ This query opens a C++ GCC-XML output file, and outputs a report describing the use
+ of globals variables.
+
+ Run it, by invoking, for instance:
+
+ patternist reportGlobal.xq fileToOpen=globals.gccxml > globals.html
+
+ "fileToOpen=globals.gccxml" binds the string "globals.gccxml" to the variable
+ "fileToOpen." It identifies the GCC-XML file to open.
+
+:)
+declare variable $inDoc as document-node() := doc($fileToOpen);
+
+(: Determines whether the type by ID @p typeId is a complex type such as QString. :)
+declare function local:isComplexType($typeID as xs:string) as xs:boolean
+{
+ (: We're being a bit crude here and only checks whether it's a class. We
+ actually should check whether it has non-synthesized,
+ constructors, I believe. :)
+
+ exists($inDoc/GCC_XML/Class[@id = $typeID])
+ or
+ (: We also want const-qualified variables. :)
+ exists($inDoc/GCC_XML/Class[@id = $inDoc/GCC_XML/CvQualifiedType[@id = $typeID]/@type])
+};
+
+declare function local:isPrimitive($typeId as xs:string) as xs:boolean
+{
+ exists($inDoc/GCC_XML/FundamentalType[@id = $typeId])
+};
+
+(: Returns a string for human consumption that describes
+ the location of @p block. :)
+declare function local:location($block as element()) as xs:string
+{
+ concat($inDoc/GCC_XML/File[@id = $block/@file]/@name, " at line ", $block/@line)
+};
+
+declare function local:report() as element()+
+{
+ let $complexVariables as element(Variable)* := $inDoc/GCC_XML/Variable[local:isComplexType(@type)]
+ return if(exists($complexVariables)) (: Is the length larger than zero? :)
+
+ then (<p xmlns="http://www.w3.org/1999/xhtml/">The following global, complex variables were found:</p>,
+ <ol xmlns="http://www.w3.org/1999/xhtml/">
+ {
+ (: For each Variable in $complexVariables... :)
+ $complexVariables/<li><span class="variableName">{string(@name)}</span> in {local:location(.)}</li>
+ }
+ </ol>)
+
+ else <p xmlns="http://www.w3.org/1999/xhtml/">No global variables that are of complex types were found.</p>
+
+ ,
+
+ (: List primitive, mutable types. :)
+ let $primitiveVariables as element(Variable)+ := $inDoc/GCC_XML/Variable[local:isPrimitive(@type)]
+ return if(exists($primitiveVariables))
+
+ then (<p xmlns="http://www.w3.org/1999/xhtml/">The following mutable primitives were found:</p>,
+ <ol xmlns="http://www.w3.org/1999/xhtml/">
+ {
+ (: For each Variable in $complexVariables... :)
+ $primitiveVariables/<li><span class="variableName">{string(@name)}</span> in {local:location(.)}</li>
+ }
+ </ol>)
+
+ else <p xmlns="http://www.w3.org/1999/xhtml/">No global variables that are of complex types were found.</p>
+};
+
+<html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en">
+ <head>
+ <title>Global variables report for {$fileToOpen}</title>
+ </head>
+ <style type="text/css">
+ .details
+ {{
+ text-align: center;
+ font-size: 80%;
+ color: gray
+ }}
+ .variableName
+ {{
+ font-family: courier
+ }}
+ </style>
+
+ <body>
+ {
+ (: We don't want simple types that are const, but all other types.
+ One could frown upon const integers and say enums should be used instead, but
+ let's be gentle. :)
+
+ local:report()
+ }
+
+ <p class="details">This report was generated on</p>
+ </body>
+
+</html>
diff --git a/tests/auto/xmlpatterns/queries/simpleDocument.xml b/tests/auto/xmlpatterns/queries/simpleDocument.xml
new file mode 100644
index 0000000..9b0ff02
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/simpleDocument.xml
@@ -0,0 +1 @@
+<e xmlns="http://example.com" attr="1" xmlns:p="http://example.com/P" p:attr=""><?target data?><!-- a comment --><e/><![CDATA[text]]> <f/>text node</e>
diff --git a/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq b/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq
new file mode 100644
index 0000000..42b4d2e
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq
@@ -0,0 +1,5 @@
+module namespace prefix = "http://example.com";
+declare function prefix:myFunction()
+{
+1
+};
diff --git a/tests/auto/xmlpatterns/queries/staticBaseURI.xq b/tests/auto/xmlpatterns/queries/staticBaseURI.xq
new file mode 100644
index 0000000..25b307a
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/staticBaseURI.xq
@@ -0,0 +1,3 @@
+(: We convert the value to xs:string such that we can use it
+ with QXmlQuery::evaluateTo(QStringList) :)
+string(static-base-uri())
diff --git a/tests/auto/xmlpatterns/queries/staticError.xq b/tests/auto/xmlpatterns/queries/staticError.xq
new file mode 100644
index 0000000..1aff277
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/staticError.xq
@@ -0,0 +1 @@
+"This string literal is never closeThis string literal is never closed
diff --git a/tests/auto/xmlpatterns/queries/syntaxError.xq b/tests/auto/xmlpatterns/queries/syntaxError.xq
new file mode 100644
index 0000000..5ad4982
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/syntaxError.xq
@@ -0,0 +1 @@
+for 1 to 100
diff --git a/tests/auto/xmlpatterns/queries/threeVariables.xq b/tests/auto/xmlpatterns/queries/threeVariables.xq
new file mode 100644
index 0000000..d0f98c1
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/threeVariables.xq
@@ -0,0 +1 @@
+$var1, $var2, $var3
diff --git a/tests/auto/xmlpatterns/queries/twoVariables.xq b/tests/auto/xmlpatterns/queries/twoVariables.xq
new file mode 100644
index 0000000..a3a67c8
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/twoVariables.xq
@@ -0,0 +1 @@
+$var1, $var2
diff --git a/tests/auto/xmlpatterns/queries/typeError.xq b/tests/auto/xmlpatterns/queries/typeError.xq
new file mode 100644
index 0000000..d91861a
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/typeError.xq
@@ -0,0 +1 @@
+1 + "type error"
diff --git a/tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq b/tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq
new file mode 100644
index 0000000..219ba0d
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/unavailableExternalVariable.xq
@@ -0,0 +1,2 @@
+declare variable $thisVariableIsNotBound external;
+1
diff --git a/tests/auto/xmlpatterns/queries/unsupportedCollation.xq b/tests/auto/xmlpatterns/queries/unsupportedCollation.xq
new file mode 100644
index 0000000..679323c
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/unsupportedCollation.xq
@@ -0,0 +1,2 @@
+declare default collation "http://example.com/UnsupportedCollation";
+1
diff --git a/tests/auto/xmlpatterns/queries/wrongArity.xq b/tests/auto/xmlpatterns/queries/wrongArity.xq
new file mode 100644
index 0000000..4e507a3
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/wrongArity.xq
@@ -0,0 +1 @@
+fn:doc()
diff --git a/tests/auto/xmlpatterns/queries/zeroDivision.xq b/tests/auto/xmlpatterns/queries/zeroDivision.xq
new file mode 100644
index 0000000..34d5ac5
--- /dev/null
+++ b/tests/auto/xmlpatterns/queries/zeroDivision.xq
@@ -0,0 +1 @@
+1 div 0
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
new file mode 100644
index 0000000..a7945f0
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
@@ -0,0 +1 @@
+Error XPST0008 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/externalVariable.xq, at line 1, column 69: No variable by name externalVariable exists
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Asimplemathquery.txt b/tests/auto/xmlpatterns/stderrBaselines/Asimplemathquery.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Asimplemathquery.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Asingledashthatsinvalid.txt b/tests/auto/xmlpatterns/stderrBaselines/Asingledashthatsinvalid.txt
new file mode 100644
index 0000000..9cbc501
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Asingledashthatsinvalid.txt
@@ -0,0 +1,2 @@
+query/stylesheet must occur at least 1 times, therefore 0 times is insufficient.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Asinglequerythatdoesnotexist.txt b/tests/auto/xmlpatterns/stderrBaselines/Asinglequerythatdoesnotexist.txt
new file mode 100644
index 0000000..595c6e7
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Asinglequerythatdoesnotexist.txt
@@ -0,0 +1 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.xq: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.xq: No such file or directory
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputqueryfirst.txt b/tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputqueryfirst.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputqueryfirst.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputquerylast.txt b/tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputquerylast.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Basicuseofoutputquerylast.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariable.txt b/tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariable.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariable.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariablequeryappearinglast.txt b/tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariablequeryappearinglast.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Bindanexternalvariablequeryappearinglast.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Callanamedtemplateandusenofocus..txt b/tests/auto/xmlpatterns/stderrBaselines/Callanamedtemplateandusenofocus..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Callanamedtemplateandusenofocus..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Callfnerror.txt b/tests/auto/xmlpatterns/stderrBaselines/Callfnerror.txt
new file mode 100644
index 0000000..3ff933a
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Callfnerror.txt
@@ -0,0 +1 @@
+Error FOER0000 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/errorFunction.xq, at line 1, column 1:
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Ensureisuricanappearafterthequeryfilename.txt b/tests/auto/xmlpatterns/stderrBaselines/Ensureisuricanappearafterthequeryfilename.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Ensureisuricanappearafterthequeryfilename.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Evaluatealibrarymodule.txt b/tests/auto/xmlpatterns/stderrBaselines/Evaluatealibrarymodule.txt
new file mode 100644
index 0000000..55a04ac
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Evaluatealibrarymodule.txt
@@ -0,0 +1 @@
+Error XPST0003 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/simpleLibraryModule.xq, at line 1, column 17: syntax error, unexpected namespace, expecting end of file
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Evaluateastylesheetwithnocontextdocument.txt b/tests/auto/xmlpatterns/stderrBaselines/Evaluateastylesheetwithnocontextdocument.txt
new file mode 100644
index 0000000..572552b
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Evaluateastylesheetwithnocontextdocument.txt
@@ -0,0 +1 @@
+When a stylesheet is used, a document must be specified as a focus, or an initial template name must be specified, or both.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invalidtemplatename.txt b/tests/auto/xmlpatterns/stderrBaselines/Invalidtemplatename.txt
new file mode 100644
index 0000000..0ee649c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invalidtemplatename.txt
@@ -0,0 +1 @@
+abc:def is an invalid Clark Name
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokeatemplateandusepassparameters..txt b/tests/auto/xmlpatterns/stderrBaselines/Invokeatemplateandusepassparameters..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokeatemplateandusepassparameters..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokeversion.txt b/tests/auto/xmlpatterns/stderrBaselines/Invokeversion.txt
new file mode 100644
index 0000000..4c41928
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokeversion.txt
@@ -0,0 +1 @@
+xmlpatterns version 0.1 using \ No newline at end of file
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokewithcoloninvariablename..txt b/tests/auto/xmlpatterns/stderrBaselines/Invokewithcoloninvariablename..txt
new file mode 100644
index 0000000..0516df7
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokewithcoloninvariablename..txt
@@ -0,0 +1 @@
+The variable name must be a valid NCName, which xs:name isn't.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokewithinvalidparamvalue..txt b/tests/auto/xmlpatterns/stderrBaselines/Invokewithinvalidparamvalue..txt
new file mode 100644
index 0000000..6b2eafa
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokewithinvalidparamvalue..txt
@@ -0,0 +1 @@
+Each binding must contain an equal sign.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokewithmissingnameinparamarg..txt b/tests/auto/xmlpatterns/stderrBaselines/Invokewithmissingnameinparamarg..txt
new file mode 100644
index 0000000..5782ce1
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokewithmissingnameinparamarg..txt
@@ -0,0 +1 @@
+The variable name must be a valid NCName, which isn't.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathasnovalue..txt b/tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathasnovalue..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathasnovalue..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathastwoadjacentequalsigns..txt b/tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathastwoadjacentequalsigns..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Invokewithparamthathastwoadjacentequalsigns..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaFTP.txt b/tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaFTP.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaFTP.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaHTTP.txt b/tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaHTTP.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/LoadqueryviaHTTP.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Loadqueryviadatascheme.txt b/tests/auto/xmlpatterns/stderrBaselines/Loadqueryviadatascheme.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Loadqueryviadatascheme.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/MakesurequerypathsareresolvedagainstCWDnotthelocationoftheexecutable..txt b/tests/auto/xmlpatterns/stderrBaselines/MakesurequerypathsareresolvedagainstCWDnotthelocationoftheexecutable..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/MakesurequerypathsareresolvedagainstCWDnotthelocationoftheexecutable..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Notwellformedinstancedocumentcausescrashincoloringcode..txt b/tests/auto/xmlpatterns/stderrBaselines/Notwellformedinstancedocumentcausescrashincoloringcode..txt
new file mode 100644
index 0000000..190300f
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Notwellformedinstancedocumentcausescrashincoloringcode..txt
@@ -0,0 +1 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-45/tests/auto/xmlpatterns/stylesheets/bool070.xml, at line 1, column 9: Unexpected '<'.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Notwellformedstylesheetcausescrashincoloringcode..txt b/tests/auto/xmlpatterns/stderrBaselines/Notwellformedstylesheetcausescrashincoloringcode..txt
new file mode 100644
index 0000000..f070936
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Notwellformedstylesheetcausescrashincoloringcode..txt
@@ -0,0 +1 @@
+Error XTSE0010 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/stylesheets/notWellformed.xsl, at line 4, column 9: Parse error: Unexpected '<'.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Openannonexistentfile.txt b/tests/auto/xmlpatterns/stderrBaselines/Openannonexistentfile.txt
new file mode 100644
index 0000000..5be39d9
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Openannonexistentfile.txt
@@ -0,0 +1 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/ThisFileDoesNotExist.xq: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/ThisFileDoesNotExist.xq: No such file or directory
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Openanonexistingcollection..txt b/tests/auto/xmlpatterns/stderrBaselines/Openanonexistingcollection..txt
new file mode 100644
index 0000000..9c648e9
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Openanonexistingcollection..txt
@@ -0,0 +1 @@
+Error FODC0004 in file:///home/fenglich/dev/qt-45/tests/auto/xmlpatterns/queries/nonexistingCollection.xq, at line 1, column 1: doesNotExistForSure cannot be retrieved
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt b/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt
new file mode 100644
index 0000000..4e789e7
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt
@@ -0,0 +1,31 @@
+
+ xmlpatterns -- A tool for running XQuery queries.
+
+ - When appearing, any following options are not
+ interpreted as switches.
+ -help Displays this help.
+ -initial-template <string> The name of the initial template to call as a
+ Clark Name.
+ -is-uri If specified, all filenames on the command line
+ are interpreted as URIs instead of a local
+ filenames.
+ -no-format By default output is formatted for readability.
+ When specified, strict serialization is
+ performed.
+ -output <local file> A local file to which the output should be
+ written. The file is overwritten, or if not
+ exist, created. If absent, stdout is used.
+ -param <name=value> Binds an external variable. The value is
+ directly available using the variable
+ reference: $name.
+ -version Displays version information.
+ focus <string> The document to use as focus. Mandatory in case
+ a stylesheet is used. This option is also
+ affected by the is-uris option.
+ query/stylesheet <string> A local filename pointing to the query to run.
+ If the name ends with .xsl it's assumed to be
+ an XSL-T stylesheet. If it ends with .xq, it's
+ assumed to be an XQuery query. (In other cases
+ it's also assumed to be an XQuery query, but
+ that interpretation may change in a future
+ release of Qt.)
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passinanexternalvariablebutthequerydoesntuseit..txt b/tests/auto/xmlpatterns/stderrBaselines/Passinanexternalvariablebutthequerydoesntuseit..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passinanexternalvariablebutthequerydoesntuseit..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passinastylesheetfileandafocusfilewhichdoesntexist.txt b/tests/auto/xmlpatterns/stderrBaselines/Passinastylesheetfileandafocusfilewhichdoesntexist.txt
new file mode 100644
index 0000000..b2edfa1
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passinastylesheetfileandafocusfilewhichdoesntexist.txt
@@ -0,0 +1 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.Nope.xml: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.Nope.xml: No such file or directory
diff --git a/tests/auto/xmlpatterns/stderrBaselines/PassinastylesheetfilewhichcontainsanXQueryquery.txt b/tests/auto/xmlpatterns/stderrBaselines/PassinastylesheetfilewhichcontainsanXQueryquery.txt
new file mode 100644
index 0000000..1122c3e
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/PassinastylesheetfilewhichcontainsanXQueryquery.txt
@@ -0,0 +1 @@
+Error XTSE0010 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl, at line 1, column 1: Parse error: Start tag expected.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passinastylsheetfileandafocusfilewhichdoesntexist.txt b/tests/auto/xmlpatterns/stderrBaselines/Passinastylsheetfileandafocusfilewhichdoesntexist.txt
new file mode 100644
index 0000000..c890e65
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passinastylsheetfileandafocusfilewhichdoesntexist.txt
@@ -0,0 +1,15 @@
+ QUrl( "file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.Nope.xml" )
+virtual QExplicitlySharedDataPointer<QPatternist::Expression> QPatternist::ExpressionFactory::createExpression(QIODevice*, const QExplicitlySharedDataPointer<QPatternist::StaticContext>&, QXmlQuery::QueryLanguage, const QExplicitlySharedDataPointer<QPatternist::SequenceType>&, const QUrl&) QUrl( "file:///home/fenglich/shadow/qt-xslt/bin/xmlpatterns" )
+----- Initial AST build. -----
+------------------------------
+----- Type Check -----
+------------------------------
+----- Compress -----
+------------------------------
+Tokens Revealed: "doc ( $ u ) end of file "
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.Nope.xml: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/doesNotExist.Nope.xml: No such file or directory
+virtual QExplicitlySharedDataPointer<QPatternist::Expression> QPatternist::ExpressionFactory::createExpression(QIODevice*, const QExplicitlySharedDataPointer<QPatternist::StaticContext>&, QXmlQuery::QueryLanguage, const QExplicitlySharedDataPointer<QPatternist::SequenceType>&, const QUrl&) QUrl( "file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl" )
+PUSHED STATE 0
+void QPatternist::XSLTTokenizer::stateOutsideDocumentElement()
+Error XPST0003 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl, at line 22, column -1212431692: syntax error, unexpected end of file, expecting QName
+Tokens Revealed: "end of file "
diff --git a/tests/auto/xmlpatterns/stderrBaselines/PassinastylsheetfilewhichcontainsanXQueryquery.txt b/tests/auto/xmlpatterns/stderrBaselines/PassinastylsheetfilewhichcontainsanXQueryquery.txt
new file mode 100644
index 0000000..73edd0e
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/PassinastylsheetfilewhichcontainsanXQueryquery.txt
@@ -0,0 +1,16 @@
+virtual QExplicitlySharedDataPointer<QPatternist::Expression> QPatternist::ExpressionFactory::createExpression(QIODevice*, const QExplicitlySharedDataPointer<QPatternist::StaticContext>&, QXmlQuery::QueryLanguage, const QExplicitlySharedDataPointer<QPatternist::SequenceType>&, const QUrl&) QUrl( "file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl" )
+PUSHED STATE 0
+void QPatternist::XSLTTokenizer::stateOutsideDocumentElement()
+Now at end of input.
+Reducing stack by rule 3 (line 1018):
+-> $$ = nterm VersionDecl (: )
+Stack now 0
+Entering state 3
+Now at end of input.
+Reducing stack by rule 10 (line 1139):
+-> $$ = nterm Prolog (: )
+Stack now 0 3
+Entering state 10
+Now at end of input.
+Error XPST0003 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl, at line -1212346368, column -1214801237: syntax error, unexpected end of file
+Tokens Revealed: "end of file "
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passingasingledashisinsufficient.txt b/tests/auto/xmlpatterns/stderrBaselines/Passingasingledashisinsufficient.txt
new file mode 100644
index 0000000..9cbc501
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passingasingledashisinsufficient.txt
@@ -0,0 +1,2 @@
+query/stylesheet must occur at least 1 times, therefore 0 times is insufficient.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passingtwodashesthelastisinterpretedasafilename.txt b/tests/auto/xmlpatterns/stderrBaselines/Passingtwodashesthelastisinterpretedasafilename.txt
new file mode 100644
index 0000000..03c3d99
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passingtwodashesthelastisinterpretedasafilename.txt
@@ -0,0 +1 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/-: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/-: No such file or directory
diff --git a/tests/auto/xmlpatterns/stderrBaselines/PassininvalidURI.txt b/tests/auto/xmlpatterns/stderrBaselines/PassininvalidURI.txt
new file mode 100644
index 0000000..eab49d4
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/PassininvalidURI.txt
@@ -0,0 +1 @@
+Error XPST0003 in data:application/xml;base64,PGUvg===, at line 1, column 3: syntax error, unexpected unknown keyword, expecting POSITION_SET
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passthreedashesthetwolastgetsinterpretedastwoqueryarguments.txt b/tests/auto/xmlpatterns/stderrBaselines/Passthreedashesthetwolastgetsinterpretedastwoqueryarguments.txt
new file mode 100644
index 0000000..4fadd23
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passthreedashesthetwolastgetsinterpretedastwoqueryarguments.txt
@@ -0,0 +1,2 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/-: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/-: No such file or directory
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/-: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/-: No such file or directory
diff --git a/tests/auto/xmlpatterns/stderrBaselines/PrintalistofavailableregexpflagsTheavailableflagsareformattedinacomplexway..txt b/tests/auto/xmlpatterns/stderrBaselines/PrintalistofavailableregexpflagsTheavailableflagsareformattedinacomplexway..txt
new file mode 100644
index 0000000..9f09298
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/PrintalistofavailableregexpflagsTheavailableflagsareformattedinacomplexway..txt
@@ -0,0 +1,5 @@
+Error FORX0001 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/invalidRegexpFlag.xq, at line 1, column 1: I is an invalid flag for regular expressions. Valid flags are:
+x - Whitespace characters are removed, except when they appear in character classes
+i - Matches are case insensitive
+m - ^ and $ match the start and end of a line.
+s - . matches newline characters
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestoasingledocumentnodewithnochildren..txt b/tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestoasingledocumentnodewithnochildren..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestoasingledocumentnodewithnochildren..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestotheemptysequence..txt b/tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestotheemptysequence..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Runaquerywhichevaluatestotheemptysequence..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatdoesnotexists.txt b/tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatdoesnotexists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatdoesnotexists.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatexists.txt b/tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatexists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifyanamedtemplatethatexists.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifynoargumentsatall..txt b/tests/auto/xmlpatterns/stderrBaselines/Specifynoargumentsatall..txt
new file mode 100644
index 0000000..9cbc501
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifynoargumentsatall..txt
@@ -0,0 +1,2 @@
+query/stylesheet must occur at least 1 times, therefore 0 times is insufficient.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicedifferentvalues.txt b/tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicedifferentvalues.txt
new file mode 100644
index 0000000..6f65a8c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicedifferentvalues.txt
@@ -0,0 +1 @@
+Each parameter must be unique, duplicated is specified at least twice.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicesamevalues.txt b/tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicesamevalues.txt
new file mode 100644
index 0000000..6f65a8c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifythesameparametertwicesamevalues.txt
@@ -0,0 +1 @@
+Each parameter must be unique, duplicated is specified at least twice.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifytwodifferentquerynames.txt b/tests/auto/xmlpatterns/stderrBaselines/Specifytwodifferentquerynames.txt
new file mode 100644
index 0000000..e9fd86b
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifytwodifferentquerynames.txt
@@ -0,0 +1,2 @@
+<string> can occur at most 1 times
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Specifytwoidenticalquerynames.txt b/tests/auto/xmlpatterns/stderrBaselines/Specifytwoidenticalquerynames.txt
new file mode 100644
index 0000000..40ad757
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Specifytwoidenticalquerynames.txt
@@ -0,0 +1,2 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/query.xq: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/query.xq: No such file or directory
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/query.xq: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/query.xq: No such file or directory
diff --git a/tests/auto/xmlpatterns/stderrBaselines/TriggeranassertinQPatternistColorOutput.ThequerynaturallycontainsanerrorXPTY0004..txt b/tests/auto/xmlpatterns/stderrBaselines/TriggeranassertinQPatternistColorOutput.ThequerynaturallycontainsanerrorXPTY0004..txt
new file mode 100644
index 0000000..8cac706
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/TriggeranassertinQPatternistColorOutput.ThequerynaturallycontainsanerrorXPTY0004..txt
@@ -0,0 +1,2 @@
+Warning in : The variable a is unused
+Error XPTY0004 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/flwor.xq, at line 2, column 13: Required cardinality is zero or one("?"); got cardinality one or more("+").
diff --git a/tests/auto/xmlpatterns/stderrBaselines/TriggerasecondassertinQPatternistColorOutput.ThequerynaturallycontainsXPST0003..txt b/tests/auto/xmlpatterns/stderrBaselines/TriggerasecondassertinQPatternistColorOutput.ThequerynaturallycontainsXPST0003..txt
new file mode 100644
index 0000000..af9a5f1
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/TriggerasecondassertinQPatternistColorOutput.ThequerynaturallycontainsXPST0003..txt
@@ -0,0 +1 @@
+Error XPST0003 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/syntaxError.xq, at line 1, column 5: syntax error, unexpected <number literal>, expecting end of file
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Triggerastaticerror..txt b/tests/auto/xmlpatterns/stderrBaselines/Triggerastaticerror..txt
new file mode 100644
index 0000000..371fac5
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Triggerastaticerror..txt
@@ -0,0 +1 @@
+Error XPST0003 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/staticError.xq, at line 1, column 1: syntax error, unexpected unknown keyword
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Unknownswitchd.txt b/tests/auto/xmlpatterns/stderrBaselines/Unknownswitchd.txt
new file mode 100644
index 0000000..ece8ed4
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Unknownswitchd.txt
@@ -0,0 +1,2 @@
+"d" is an unknown argument.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Unknownswitchunknownswitch.txt b/tests/auto/xmlpatterns/stderrBaselines/Unknownswitchunknownswitch.txt
new file mode 100644
index 0000000..91b45df
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Unknownswitchunknownswitch.txt
@@ -0,0 +1,2 @@
+"unknown-switch" is an unknown argument.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useanativepath.txt b/tests/auto/xmlpatterns/stderrBaselines/Useanativepath.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useanativepath.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useanexternalvariablemultipletimes..txt b/tests/auto/xmlpatterns/stderrBaselines/Useanexternalvariablemultipletimes..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useanexternalvariablemultipletimes..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useasimplifiedstylesheetmodule.txt b/tests/auto/xmlpatterns/stderrBaselines/Useasimplifiedstylesheetmodule.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useasimplifiedstylesheetmodule.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Usefndoc.txt b/tests/auto/xmlpatterns/stderrBaselines/Usefndoc.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Usefndoc.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatfirst.txt b/tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatfirst.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatfirst.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatlast.txt b/tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatlast.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Usefndoctogetherwithnoformatlast.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useoutputonafilewithexistingcontenttoensurewetruncatenotappendthecontentweproduce..txt b/tests/auto/xmlpatterns/stderrBaselines/Useoutputonafilewithexistingcontenttoensurewetruncatenotappendthecontentweproduce..txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useoutputonafilewithexistingcontenttoensurewetruncatenotappendthecontentweproduce..txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useoutputtwice.txt b/tests/auto/xmlpatterns/stderrBaselines/Useoutputtwice.txt
new file mode 100644
index 0000000..a5dc84c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useoutputtwice.txt
@@ -0,0 +1,2 @@
+"output" can only be used once.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useparamthrice.txt b/tests/auto/xmlpatterns/stderrBaselines/Useparamthrice.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useparamthrice.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Useparamtwice.txt b/tests/auto/xmlpatterns/stderrBaselines/Useparamtwice.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Useparamtwice.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Wedontsupportformatanylonger.txt b/tests/auto/xmlpatterns/stderrBaselines/Wedontsupportformatanylonger.txt
new file mode 100644
index 0000000..3f1694f
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/Wedontsupportformatanylonger.txt
@@ -0,0 +1,2 @@
+"format" is an unknown argument.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/XQuerydataXQuerykeywordmessagemarkups.txt b/tests/auto/xmlpatterns/stderrBaselines/XQuerydataXQuerykeywordmessagemarkups.txt
new file mode 100644
index 0000000..b43698c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/XQuerydataXQuerykeywordmessagemarkups.txt
@@ -0,0 +1 @@
+Error FOAR0001 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/zeroDivision.xq, at line 1, column 1: Division (div) by zero (0) is undefined.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/XQueryexpressionmessagemarkups.txt b/tests/auto/xmlpatterns/stderrBaselines/XQueryexpressionmessagemarkups.txt
new file mode 100644
index 0000000..4bfef93
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/XQueryexpressionmessagemarkups.txt
@@ -0,0 +1 @@
+Error FORX0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/invalidRegexp.xq, at line 1, column 1: \ is an invalid regular expression pattern: unexpected end
diff --git a/tests/auto/xmlpatterns/stderrBaselines/XQueryfunctionmessagemarkups.txt b/tests/auto/xmlpatterns/stderrBaselines/XQueryfunctionmessagemarkups.txt
new file mode 100644
index 0000000..bde01fb
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/XQueryfunctionmessagemarkups.txt
@@ -0,0 +1 @@
+Error XPST0017 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/wrongArity.xq, at line 1, column 1: fn:doc($uri as xs:string?) as document()? requires at least 1 argument(s). 0 is therefore invalid.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/XQuerytypemessagemarkups.txt b/tests/auto/xmlpatterns/stderrBaselines/XQuerytypemessagemarkups.txt
new file mode 100644
index 0000000..4d40ccf
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/XQuerytypemessagemarkups.txt
@@ -0,0 +1 @@
+Error XPTY0004 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/typeError.xq, at line 1, column 1: Operator + cannot be used on atomic values of type xs:integer and xs:string.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/XQueryurimessagemarkups.txt b/tests/auto/xmlpatterns/stderrBaselines/XQueryurimessagemarkups.txt
new file mode 100644
index 0000000..89e19dd
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/XQueryurimessagemarkups.txt
@@ -0,0 +1 @@
+Error XQST0038 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/unsupportedCollation.xq, at line 1, column 1: Only the Unicode Codepoint Collation is supported(http://www.w3.org/2005/xpath-functions/collation/codepoint). http://example.com/UnsupportedCollation is unsupported.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/initialtemplatedoesntworkwithXQueries..txt b/tests/auto/xmlpatterns/stderrBaselines/initialtemplatedoesntworkwithXQueries..txt
new file mode 100644
index 0000000..8f94e34
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/initialtemplatedoesntworkwithXQueries..txt
@@ -0,0 +1 @@
+An initial template name cannot be specified when running an XQuery.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue.txt b/tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue.txt
new file mode 100644
index 0000000..5b67eef
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue.txt
@@ -0,0 +1 @@
+stylesheets/onlyRootTemplate.xsl is an invalid Clark Name
diff --git a/tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue2.txt b/tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue2.txt
new file mode 100644
index 0000000..5ed490c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/initialtemplatemustbefollowedbyavalue2.txt
@@ -0,0 +1,2 @@
+"initial-template" must be followed by a value.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/onequeryandaterminatingdashattheend.txt b/tests/auto/xmlpatterns/stderrBaselines/onequeryandaterminatingdashattheend.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/onequeryandaterminatingdashattheend.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/onequerywithaprecedingdash.txt b/tests/auto/xmlpatterns/stderrBaselines/onequerywithaprecedingdash.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/onequerywithaprecedingdash.txt
diff --git a/tests/auto/xmlpatterns/stderrBaselines/onlynoformat.txt b/tests/auto/xmlpatterns/stderrBaselines/onlynoformat.txt
new file mode 100644
index 0000000..9cbc501
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/onlynoformat.txt
@@ -0,0 +1,2 @@
+query/stylesheet must occur at least 1 times, therefore 0 times is insufficient.
+Pass -help for information about the command line.
diff --git a/tests/auto/xmlpatterns/stderrBaselines/outputwithanonwritablefile.txt b/tests/auto/xmlpatterns/stderrBaselines/outputwithanonwritablefile.txt
new file mode 100644
index 0000000..1303af2
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/outputwithanonwritablefile.txt
@@ -0,0 +1 @@
+Failed to open file notWritable.out for writing: Permission denied
diff --git a/tests/auto/xmlpatterns/stderrBaselines/paramismissingsomultiplequeriesappear.txt b/tests/auto/xmlpatterns/stderrBaselines/paramismissingsomultiplequeriesappear.txt
new file mode 100644
index 0000000..23fa5a7
--- /dev/null
+++ b/tests/auto/xmlpatterns/stderrBaselines/paramismissingsomultiplequeriesappear.txt
@@ -0,0 +1 @@
+Error FODC0002 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/fileToOpen=globals.gccxml: Error opening file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/fileToOpen=globals.gccxml: No such file or directory
diff --git a/tests/auto/xmlpatterns/stylesheets/bool070.xml b/tests/auto/xmlpatterns/stylesheets/bool070.xml
new file mode 100644
index 0000000..3504667
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/bool070.xml
@@ -0,0 +1 @@
+<a><b/><</a>
diff --git a/tests/auto/xmlpatterns/stylesheets/bool070.xsl b/tests/auto/xmlpatterns/stylesheets/bool070.xsl
new file mode 100644
index 0000000..a78e61a
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/bool070.xsl
@@ -0,0 +1,6 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:template match="/">
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/auto/xmlpatterns/stylesheets/copyWholeDocument.xsl b/tests/auto/xmlpatterns/stylesheets/copyWholeDocument.xsl
new file mode 100644
index 0000000..1cd90c4
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/copyWholeDocument.xsl
@@ -0,0 +1,9 @@
+<xsl:stylesheet
+ version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <xsl:copy-of select="."/>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/auto/xmlpatterns/stylesheets/documentElement.xml b/tests/auto/xmlpatterns/stylesheets/documentElement.xml
new file mode 100644
index 0000000..69d62f2
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/documentElement.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/auto/xmlpatterns/stylesheets/namedAndRootTemplate.xsl b/tests/auto/xmlpatterns/stylesheets/namedAndRootTemplate.xsl
new file mode 100644
index 0000000..3e8f93d
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/namedAndRootTemplate.xsl
@@ -0,0 +1,5 @@
+<xsl:stylesheet xmlns:ex="http://example.com/NS" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+ <xsl:template match="/">root-template</xsl:template>
+ <xsl:template name="main">named-template</xsl:template>
+ <xsl:template name="ex:main">namespaced-template</xsl:template>
+</xsl:stylesheet>
diff --git a/tests/auto/xmlpatterns/stylesheets/namedTemplate.xsl b/tests/auto/xmlpatterns/stylesheets/namedTemplate.xsl
new file mode 100644
index 0000000..e296e6d
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/namedTemplate.xsl
@@ -0,0 +1,8 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <xsl:template name="main">
+ <xsl:value-of select="1 to 5"/>
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/tests/auto/xmlpatterns/stylesheets/notWellformed.xsl b/tests/auto/xmlpatterns/stylesheets/notWellformed.xsl
new file mode 100644
index 0000000..241668a
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/notWellformed.xsl
@@ -0,0 +1,9 @@
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/
+ <out>
+ <xsl:copy-of select="document('bug42.xml', /)"/>
+ </out>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/auto/xmlpatterns/stylesheets/onlyRootTemplate.xsl b/tests/auto/xmlpatterns/stylesheets/onlyRootTemplate.xsl
new file mode 100644
index 0000000..d40874c
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/onlyRootTemplate.xsl
@@ -0,0 +1,9 @@
+<xsl:stylesheet
+ version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/">
+ <result/>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/auto/xmlpatterns/stylesheets/parameters.xsl b/tests/auto/xmlpatterns/stylesheets/parameters.xsl
new file mode 100644
index 0000000..db0a4aa
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/parameters.xsl
@@ -0,0 +1,41 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ version="2.0">
+
+ <!-- QXmlQuery::bindVariable() never overrides xsl:variable. -->
+ <xsl:variable name="variableNoSelectNoBody"/>
+ <xsl:variable name="variableNoSelectNoBodyBoundWithBindVariable"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:variable name="variableSelect" select="'variableSelectsDefaultValue'"/>
+ <xsl:variable name="variableSelectBoundWithBindVariable" select="'variableSelectsDefaultValue2'"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:variable name="variableSelectWithTypeInt" as="xs:integer" select="3"/>
+ <xsl:variable name="variableSelectWithTypeIntBoundWithBindVariable" as="xs:integer" select="4"/> <!-- Test calls bindVariable() for this. -->
+
+ <xsl:param name="paramNoSelectNoBody"/>
+ <xsl:param name="paramNoSelectNoBodyBoundWithBindVariable"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:param name="paramNoSelectNoBodyBoundWithBindVariableRequired" required="yes"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:param name="paramSelect" select="'variableSelectsDefaultValue'"/>
+ <xsl:param name="paramSelectBoundWithBindVariable" select="'variableSelectsDefaultValue'"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:param name="paramSelectBoundWithBindVariableRequired" required="yes"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:param name="paramSelectWithTypeInt" as="xs:integer" select="1"/>
+ <xsl:param name="paramSelectWithTypeIntBoundWithBindVariable" as="xs:integer" select="1"/> <!-- Test calls bindVariable() for this. -->
+ <xsl:param name="paramSelectWithTypeIntBoundWithBindVariableRequired" required="yes" as="xs:integer"/> <!-- Test calls bindVariable() for this. -->
+
+ <xsl:template name="main">
+ <xsl:sequence select="'Variables:',
+ $variableNoSelectNoBody,
+ $variableNoSelectNoBodyBoundWithBindVariable,
+ $variableSelect,
+ $variableSelectBoundWithBindVariable,
+ $variableSelectWithTypeInt,
+ $variableSelectWithTypeIntBoundWithBindVariable,
+ 'Parameters:',
+ $paramNoSelectNoBodyBoundWithBindVariable,
+ $paramNoSelectNoBodyBoundWithBindVariableRequired,
+ $paramSelectBoundWithBindVariable,
+ $paramSelectBoundWithBindVariableRequired,
+ $paramSelectWithTypeIntBoundWithBindVariable,
+ $paramSelectWithTypeIntBoundWithBindVariableRequired"/>
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl b/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl
new file mode 100644
index 0000000..8d2f097
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/queryAsStylesheet.xsl
@@ -0,0 +1 @@
+1 + 1
diff --git a/tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xml b/tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xml
new file mode 100644
index 0000000..067f98f
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xml
@@ -0,0 +1 @@
+<input>some text</input>
diff --git a/tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xsl b/tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xsl
new file mode 100644
index 0000000..63da011
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/simplifiedStylesheetModule.xsl
@@ -0,0 +1,4 @@
+<output xsl:version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:value-of select="/"/>
+</output>
+
diff --git a/tests/auto/xmlpatterns/stylesheets/useParameters.xsl b/tests/auto/xmlpatterns/stylesheets/useParameters.xsl
new file mode 100644
index 0000000..72aa056
--- /dev/null
+++ b/tests/auto/xmlpatterns/stylesheets/useParameters.xsl
@@ -0,0 +1,16 @@
+<xsl:stylesheet
+ version="2.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:param name="defaultedParam" select="'defParam'"/>
+ <xsl:param name="overridedDefaultedParam" select="'DOESNOTAPPEAR'"/>
+ <xsl:param name="implicitlyRequiredValue" as="xs:string"/>
+
+ <xsl:template name="main">
+ <xsl:sequence select="$defaultedParam,
+ $overridedDefaultedParam,
+ $implicitlyRequiredValue"/>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
new file mode 100644
index 0000000..1a74ccc
--- /dev/null
+++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
@@ -0,0 +1,1011 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QFile>
+#include <QtTest/QtTest>
+
+#ifdef QTEST_XMLPATTERNS
+
+#include "../qxmlquery/TestFundament.h"
+#include "../network-settings.h"
+
+/*!
+ \class tst_XmlPatterns
+ \internal
+ \since 4.4
+ \brief Tests the command line interface, \c xmlpatterns, for the XQuery code.
+
+ This test is not intended for testing the engine, but all the gluing the
+ command line interface do: error reporting, query output, variable bindings, exit
+ codes, and so on.
+
+ In other words, if you have an engine bug; don't add it here because it won't be
+ tested properly. Instead add it to the test suite.
+
+ */
+class tst_XmlPatterns : public QObject
+ , private TestFundament
+{
+ Q_OBJECT
+
+public:
+ tst_XmlPatterns();
+
+private Q_SLOTS:
+ void initTestCase();
+ void xquerySupport();
+ void xquerySupport_data() const;
+ void xsltSupport();
+ void xsltSupport_data() const;
+ void stdoutFailure() const;
+ void cleanupTestCase() const;
+
+private:
+ static void createNonWritable(const QString &name);
+ static void removeNonWritable(QFile &outFile);
+
+ int m_generatedTests;
+ /**
+ * Get rid of characters that complicates on various file systems.
+ */
+ const QRegExp m_normalizeTestName;
+ /**
+ * @note Perforce disallows wildcards in the name.
+ */
+ const QRegExp m_filenameInStderr;
+ const QString m_command;
+ bool m_dontRun;
+};
+
+tst_XmlPatterns::tst_XmlPatterns() : m_generatedTests(0)
+ , m_normalizeTestName(QLatin1String("[\\*\\?#\\-\\/:; ()',&]"))
+ , m_filenameInStderr(QLatin1String("file:\\/\\/.*(\\.xq|\\.gccxml|\\.xml|\\.xsl|-)(,|:)"))
+ , m_command(QLatin1String("xmlpatterns"))
+ , m_dontRun(false)
+{
+ Q_ASSERT(m_normalizeTestName.isValid());
+ Q_ASSERT(m_filenameInStderr.isValid());
+}
+
+void tst_XmlPatterns::initTestCase()
+{
+ QProcess process;
+ process.start(m_command);
+
+ if(!process.waitForFinished())
+ {
+ m_dontRun = true;
+ QEXPECT_FAIL("", "The command line tool is not in the path, most likely because Qt "
+ "has been partically built, such as only the sub-src rule. No tests will be run.", Abort);
+ QVERIFY(false);
+ }
+
+}
+
+void tst_XmlPatterns::xquerySupport()
+{
+ if(m_dontRun)
+ QSKIP("The command line utility is not in the path.", SkipAll);
+
+#ifdef Q_OS_WINCE
+ QSKIP("WinCE: This test uses unsupported WinCE functionality", SkipAll);
+#endif
+
+ QFETCH(int, expectedExitCode);
+ QFETCH(QByteArray, expectedQueryOutput);
+ QFETCH(QStringList, arguments);
+ QFETCH(QString, cwd);
+ QFETCH(QString, outputFile);
+
+ QProcess process;
+
+ if(!cwd.isEmpty())
+ process.setWorkingDirectory(inputFile(cwd));
+
+ process.start(m_command, arguments);
+
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QVERIFY(process.waitForFinished());
+
+ if(process.exitCode() != expectedExitCode)
+ QTextStream(stderr) << "stderr:" << process.readAllStandardError();
+
+ QCOMPARE(process.exitCode(), expectedExitCode);
+
+ const QByteArray rawProducedStderr((process.readAllStandardError()));
+ const QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr));
+
+ const QString errorFileName(inputFile(QLatin1String("stderrBaselines/") +
+ QString::fromUtf8(QTest::currentDataTag()).remove(m_normalizeTestName) +
+ QLatin1String(".txt")));
+
+ QFile writeErr(errorFileName);
+
+ if(writeErr.exists())
+ {
+ QVERIFY(writeErr.open(QIODevice::ReadOnly));
+ QString rawExpectedStdErr(QString::fromLocal8Bit(writeErr.readAll()));
+
+ /* On Windows, at least MinGW, this differs. */
+ if(qstrcmp(QTest::currentDataTag(), "-output with a non-writable file") == 0)
+ {
+ QVERIFY(fixedStderr == rawExpectedStdErr.remove(m_filenameInStderr) ||
+ fixedStderr.trimmed() == "Failed to open file notWritable.out for writing: Access is denied.");
+ }
+ else if(qstrcmp(QTest::currentDataTag(), "Invoke -version") == 0)
+ {
+ /* There's a wide range of different version strings used. For
+ * instance, "4.4.0-rc1". */
+ const QRegExp removeVersion(QLatin1String(" Qt \\d\\.\\d.*"));
+ QVERIFY(removeVersion.isValid());
+ QCOMPARE(QString(fixedStderr).remove(removeVersion) + QChar('|'), rawExpectedStdErr + QChar('|'));
+ }
+ else
+ QCOMPARE(fixedStderr, rawExpectedStdErr.remove(m_filenameInStderr));
+ }
+ else
+ {
+ QFile writeErr(errorFileName);
+ QVERIFY(writeErr.open(QIODevice::WriteOnly));
+
+ QCOMPARE(writeErr.write(rawProducedStderr), qint64(rawProducedStderr.count()));
+ QTextStream(stderr) << "creating file " << errorFileName;
+ ++m_generatedTests;
+ }
+
+ const QByteArray actual(process.readAllStandardOutput());
+
+ if(outputFile.isEmpty())
+ {
+ QCOMPARE(actual, expectedQueryOutput);
+ return; /* We're done, this test was not creating any output file. */
+ }
+ else
+ {
+ QVERIFY(actual.isEmpty());
+
+ QFile outFile(outputFile);
+
+ QVERIFY(outFile.exists());
+ QVERIFY(outFile.open(QIODevice::ReadOnly));
+
+ QCOMPARE(outFile.readAll(), expectedQueryOutput);
+
+ removeNonWritable(outFile);
+ }
+}
+
+void tst_XmlPatterns::xquerySupport_data() const
+{
+#ifdef Q_OS_WINCE
+ return;
+#endif
+
+ /* Check one file for existence, to avoid possible false positives. */
+ QVERIFY(QFile::exists(inputFile(QLatin1String("queries/onePlusOne.xq"))));
+
+ QTest::addColumn<int>("expectedExitCode");
+ QTest::addColumn<QByteArray>("expectedQueryOutput");
+ QTest::addColumn<QStringList>("arguments");
+ QTest::addColumn<QString>("cwd");
+ QTest::addColumn<QString>("outputFile");
+
+ QTest::newRow("A simple math query")
+ << 0
+ << QByteArray("2\n")
+ << QStringList((QLatin1String("queries/onePlusOne.xq")))
+ << QString()
+ << QString();
+
+ QTest::newRow("An unbound external variable")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/externalVariable.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Bind an external variable")
+ << 0
+ << QByteArray("1 4<e>1</e>true\n")
+ << (QStringList() << QLatin1String("queries/externalVariable.xq")
+ << QLatin1String("-param")
+ << QLatin1String("externalVariable=1"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Bind an external variable, query appearing last")
+ << 0
+ << QByteArray("1 4<e>1</e>true\n")
+ << (QStringList() << QLatin1String("-param")
+ << QLatin1String("externalVariable=1")
+ << QLatin1String("queries/externalVariable.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Use fn:doc")
+ << 0
+ << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\">\n <?target data?>\n <!-- a comment -->\n <e/>text <f/>text node</e>\n")
+ << QStringList(QLatin1String("queries/openDocument.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Use fn:doc, together with -no-format, last")
+ << 0
+ << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\"><?target data?><!-- a comment --><e/>text <f/>text node</e>")
+ << (QStringList() << QLatin1String("queries/openDocument.xq")
+ << QLatin1String("-no-format"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Use fn:doc, together with -no-format, first")
+ << 0
+ << QByteArray("<e xmlns=\"http://example.com\" xmlns:p=\"http://example.com/P\" attr=\"1\" p:attr=\"\"><?target data?><!-- a comment --><e/>text <f/>text node</e>")
+ << (QStringList() << QLatin1String("-no-format")
+ << QLatin1String("queries/openDocument.xq"))
+ << QString()
+ << QString();
+
+ /* This is true for the command line utility, but not QXmlQuery::setQuery(). */
+ QTest::newRow("Make sure query paths are resolved against CWD, not the location of the executable.")
+ << 0
+ << QByteArray("2\n")
+ << QStringList(QLatin1String("onePlusOne.xq"))
+ << QString::fromLatin1("queries")
+ << QString();
+
+ QTest::newRow("Call fn:error()")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/errorFunction.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Evaluate a library module")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/simpleLibraryModule.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Trigger a static error.")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/staticError.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Pass -help")
+ << 0
+ << QByteArray()
+ << QStringList(QLatin1String("-help"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Open an nonexistent file")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/ThisFileDoesNotExist.xq"))
+ << QString()
+ << QString();
+
+ /* The following five tests exists to test the various
+ * markup classes in the message. */
+ QTest::newRow("XQuery-function message markups")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/wrongArity.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("XQuery-type message markups")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/typeError.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("XQuery-data & XQuery-keyword message markups")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/zeroDivision.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("XQuery-uri message markups")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/unsupportedCollation.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("XQuery-expression message markups")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/invalidRegexp.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Print a list of available regexp flags(The available flags are formatted in a complex way.)")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/invalidRegexpFlag.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Trigger an assert in QPatternist::ColorOutput. The query naturally contains an error; XPTY0004.")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/flwor.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Trigger a second assert in QPatternist::ColorOutput. The query naturally contains XPST0003.")
+ << 2
+ << QByteArray()
+ << QStringList(QLatin1String("queries/syntaxError.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("-param is missing so multiple queries appear")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/reportGlobals.xq")
+ << QLatin1String("fileToOpen=globals.gccxml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("only -no-format")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-no-format"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Basic use of -output, query first")
+ << 0
+ << QByteArray("2\n")
+ << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+ << QLatin1String("-output")
+ << QLatin1String("basicOutput.out"))
+ << QString()
+ << QString::fromLatin1("basicOutput.out");
+
+ QTest::newRow("Basic use of -output, query last")
+ << 0
+ << QByteArray("<e/>\n")
+ << (QStringList() << QLatin1String("-output")
+ << QLatin1String("basicOutput2.out")
+ << QLatin1String("queries/oneElement.xq"))
+ << QString()
+ << QString::fromLatin1("basicOutput2.out");
+
+ QTest::newRow("A single query, that does not exist")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("doesNotExist.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Specify two identical query names")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("query.xq")
+ << QLatin1String("query.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Specify no arguments at all.")
+ << 1
+ << QByteArray()
+ << QStringList()
+ << QString()
+ << QString();
+
+ QTest::newRow("Use -output twice")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-output")
+ << QLatin1String("output1")
+ << QLatin1String("-output")
+ << QLatin1String("output2"))
+ << QString()
+ << QString();
+
+ {
+ const QString filename(QString::fromLatin1("notWritable.out"));
+ createNonWritable(filename);
+
+ QTest::newRow("-output with a non-writable file")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-output")
+ << filename
+ << QLatin1String("queries/onePlusOne.xq"))
+ << QString()
+ << filename;
+ }
+
+ {
+ const QString outName(QString::fromLatin1("existingContent.out"));
+ QFile outFile(outName);
+ QVERIFY(outFile.open(QIODevice::WriteOnly));
+ QCOMPARE(outFile.write("Existing content\n"), qint64(17));
+ outFile.close();
+
+ QTest::newRow("Use -output on a file with existing content, to ensure we truncate, not append the content we produce.")
+ << 0
+ << QByteArray("2\n")
+ << (QStringList() << QLatin1String("-output")
+ << outName
+ << QLatin1String("queries/onePlusOne.xq"))
+ << QString()
+ << outName;
+ }
+
+ QTest::newRow("one query, and a terminating dash at the end")
+ << 0
+ << QByteArray("2\n")
+ << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+ << QLatin1String("-"))
+ << QString()
+ << QString();
+
+ QTest::newRow("one query, with a preceding dash")
+ << 0
+ << QByteArray("2\n")
+ << (QStringList() << QLatin1String("-")
+ << QLatin1String("queries/onePlusOne.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("A single dash, that's invalid")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invoke -version")
+ << 0
+ << QByteArray()
+ << (QStringList() << QLatin1String("-version"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Unknown switch; -unknown-switch")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-unknown-switch"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Unknown switch; -d")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-d"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Passing a single dash is insufficient")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Passing two dashes, the last is interpreted as a file name")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("-")
+ << QLatin1String("-"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Pass three dashes, the two last gets interpreted as two query arguments")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("-")
+ << QLatin1String("-")
+ << QLatin1String("-"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Load query via data: scheme")
+ << 0
+ << QByteArray("<e/>\n")
+ << (QStringList() << QLatin1String("-is-uri") << QLatin1String("data:application/xml,%3Ce%2F%3E"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Load query via FTP")
+ << 0
+ << QByteArray("This was received via FTP\n")
+ << (QStringList() << QLatin1String("-is-uri") << QString("ftp://" + QtNetworkSettings::serverName() + "/pub/qxmlquery/viaFtp.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Load query via HTTP")
+ << 0
+ << QByteArray("This was received via HTTP.\n")
+ << (QStringList() << QLatin1String("-is-uri") << QString("http://" + QtNetworkSettings::serverName() + "/qxmlquery/viaHttp.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("We don't support -format any longer")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-format"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Run a query which evaluates to the empty sequence.")
+ << 0
+ << QByteArray("\n")
+ << (QStringList() << QLatin1String("queries/emptySequence.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Run a query which evaluates to a single document node with no children.")
+ << 0
+ << QByteArray("\n")
+ << (QStringList() << QLatin1String("queries/onlyDocumentNode.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invoke with invalid -param value.")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/externalVariable.xq")
+ << QLatin1String("-param")
+ << QLatin1String("EqualSignIsMissing"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invoke with colon in variable name.")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/externalVariable.xq")
+ << QLatin1String("-param")
+ << QLatin1String("xs:name=value"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invoke with missing name in -param arg.")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/externalVariable.xq")
+ << QLatin1String("-param")
+ << QLatin1String("=value"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invoke with -param that has two adjacent equal signs.")
+ << 0
+ << QByteArray("START =text END\n")
+ << (QStringList() << QLatin1String("queries/externalStringVariable.xq")
+ << QLatin1String("-param")
+ << QLatin1String("externalString==text"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Pass in an external variable, but the query doesn't use it.")
+ << 0
+ << QByteArray("2\n")
+ << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+ << QLatin1String("-param")
+ << QLatin1String("externalString==text"))
+ << QString()
+ << QString();
+
+ /* This is how an empty string would have been passed in. */
+ QTest::newRow("Invoke with -param that has no value.")
+ << 0
+ << QByteArray("START END\n")
+ << (QStringList() << QLatin1String("queries/externalStringVariable.xq")
+ << QLatin1String("-param")
+ << QLatin1String("externalString="))
+ << QString()
+ << QString();
+
+ QTest::newRow("Ensure -is-uri can appear after the query filename")
+ << 0
+ << QByteArray("<e/>\n")
+ << (QStringList() << QLatin1String("data:application/xml,%3Ce%2F%3E") << QLatin1String("-is-uri"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Use a native path")
+ << 0
+ << QByteArray("2\n")
+ << (QStringList() << QDir::toNativeSeparators(QLatin1String("queries/onePlusOne.xq")))
+ << QString()
+ << QString();
+
+ QTest::newRow("Pass in invalid URI")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("-is-uri") << QLatin1String("data:application/xml;base64,PGUvg==="))
+ << QString()
+ << QString();
+
+ /* Not relevant anymore.
+ QTest::newRow("A valid, existing query, followed by a bogus one")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+ << QLatin1String("doesNotExist.xq"))
+ << QString()
+ << QString();
+ */
+
+ /* Not relevant anymore.
+ QTest::newRow("Specify two different query names")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("query1.xq")
+ << QLatin1String("query2.xq"))
+ << QString()
+ << QString();
+ */
+
+ // TODO use focus with xquery
+ // TODO fail to load focus with xquery
+ // TODO focus with URI with xquery
+ // TODO focus via FTP or so with xquery
+
+
+ QTest::newRow("Use -param twice")
+ << 0
+ << QByteArray("param1 param2\n")
+ << (QStringList() << QLatin1String("queries/twoVariables.xq")
+ << QLatin1String("-param")
+ << QLatin1String("var1=param1")
+ << QLatin1String("-param")
+ << QLatin1String("var2=param2"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Use -param thrice")
+ << 0
+ << QByteArray("param1 param2 third\n")
+ << (QStringList() << QLatin1String("queries/threeVariables.xq")
+ << QLatin1String("-param")
+ << QLatin1String("var1=param1")
+ << QLatin1String("-param")
+ << QLatin1String("var2=param2")
+ << QLatin1String("-param")
+ << QLatin1String("var3=third"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Specify the same parameter twice, different values")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+ << QLatin1String("-param")
+ << QLatin1String("duplicated=param1")
+ << QLatin1String("-param")
+ << QLatin1String("duplicated=param2"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Specify the same parameter twice, same values")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/onePlusOne.xq")
+ << QLatin1String("-param")
+ << QLatin1String("duplicated=param1")
+ << QLatin1String("-param")
+ << QLatin1String("duplicated=param2"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Open a non-existing collection.")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("queries/nonexistingCollection.xq"))
+ << QString()
+ << QString();
+
+ // TODO https?
+ // TODO pass external variables that allows space around the equal sign.
+ // TODO run fn:trace()
+ // TODO Trigger warning
+ // TODO what can we do with queries/nodeSequence.xq?
+ // TODO trigger serialization error
+ // TODO "xmlpatterns e.xq x" gives "binding must equal .."
+ //
+ // TODO use stdout where it's connected to a non-writable file.
+ // TODO specify -format twice, or whatever it's called.
+ // TODO query name that starts with "-".
+ //
+ // TODO Consider what we should do with paths on windows. Stuff like path\filename.xml fails.
+ // TODO use invalid URI in query name, xmlpatterns -is-uri 'as1/#(¤/¤)("#'
+
+ // TODO add xmlpatterns file1 file2 file3
+ // TODO add xmlpatterns -is-uri file1 file2 file3
+}
+
+void tst_XmlPatterns::createNonWritable(const QString &name)
+{
+ /* Create an existing, empty, non-writable file. */
+ QFile outFile(name);
+ QVERIFY(outFile.open(QIODevice::ReadWrite));
+ outFile.write(QByteArray("1"));
+ QVERIFY(outFile.resize(0));
+ outFile.close();
+ QVERIFY(outFile.setPermissions(QFile::Permissions(QFile::ReadOwner)));
+}
+
+void tst_XmlPatterns::removeNonWritable(QFile &outFile)
+{
+ /* Kill off temporary files. */
+ if(!outFile.remove())
+ {
+ /* Since one file is used for testing that we can handle non-writable file by
+ * changing the permissions, we need to revert it such that we can remove it. */
+ outFile.setPermissions(QFile::WriteOwner);
+ outFile.remove();
+ }
+}
+
+/*!
+ Check that we gracefully handle writing out to stdout
+ when the latter is not writable.
+ */
+void tst_XmlPatterns::stdoutFailure() const
+{
+ return; // TODO It's really hard to write testing code for this.
+
+ const QString outName(QLatin1String("stdoutFailure.out"));
+ createNonWritable(outName);
+
+ QProcess process;
+ // If we enable this line, waitForFinished() fails.
+ //process.setStandardOutputFile(outName);
+
+ process.setWorkingDirectory(QDir::current().absoluteFilePath(QString()));
+ process.start(m_command, QStringList("queries/onePlusOne.xq"));
+
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QVERIFY(process.waitForFinished());
+
+ QFile outFile(outName);
+ QVERIFY(outFile.open(QIODevice::ReadOnly));
+ QCOMPARE(outFile.readAll(), QByteArray());
+
+ QCOMPARE(process.exitCode(), 1);
+
+ removeNonWritable(outFile);
+}
+
+void tst_XmlPatterns::cleanupTestCase() const
+{
+ /* Remove temporaries that we create. */
+ QStringList files;
+ files << QLatin1String("existingContent.out")
+ << QLatin1String("notWritable.out")
+ << QLatin1String("output1");
+
+ for(int i = 0; i < files.count(); ++i)
+ {
+ QFile file(files.at(i));
+ removeNonWritable(file);
+ }
+
+ QCOMPARE(m_generatedTests, 0);
+}
+
+void tst_XmlPatterns::xsltSupport()
+{
+ xquerySupport();
+}
+
+void tst_XmlPatterns::xsltSupport_data() const
+{
+ if(m_dontRun)
+ QSKIP("The command line utility is not in the path.", SkipAll);
+
+#ifdef Q_OS_WINCE
+ QSKIP("WinCE: This test uses unsupported WinCE functionality", SkipAll);
+#endif
+
+ QTest::addColumn<int>("expectedExitCode");
+ QTest::addColumn<QByteArray>("expectedQueryOutput");
+ QTest::addColumn<QStringList>("arguments");
+ QTest::addColumn<QString>("cwd");
+ QTest::addColumn<QString>("outputFile");
+
+ QTest::newRow("Evaluate a stylesheet, with no context document")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("stylesheets/onlyRootTemplate.xsl"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Pass in a stylesheet file which contains an XQuery query")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("stylesheets/queryAsStylesheet.xsl")
+ << QLatin1String("queries/simpleDocument.xml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Pass in a stylesheet file and a focus file which doesn't exist")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("stylesheets/onlyRootTemplate.xsl")
+ << QLatin1String("doesNotExist.Nope.xml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("-initial-template doesn't work with XQueries.")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-initial-template")
+ << QLatin1String("name")
+ << QLatin1String("queries/onePlusOne.xq"))
+ << QString()
+ << QString();
+
+ QTest::newRow("-initial-template must be followed by a value")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-initial-template")
+ << QLatin1String("stylesheets/onlyRootTemplate.xsl"))
+ << QString()
+ << QString();
+
+ QTest::newRow("-initial-template must be followed by a value(#2)")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("stylesheets/onlyRootTemplate.xsl")
+ << QLatin1String("-initial-template"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invalid template name")
+ << 1
+ << QByteArray()
+ << (QStringList() << QLatin1String("-initial-template")
+ << QLatin1String("abc:def")
+ << QLatin1String("stylesheets/onlyRootTemplate.xsl"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Specify a named template, that exists")
+ << 0
+ << QByteArray("named-template")
+ << (QStringList() << QLatin1String("-no-format")
+ << QLatin1String("-initial-template")
+ << QLatin1String("main")
+ << QLatin1String("stylesheets/namedAndRootTemplate.xsl")
+ << QLatin1String("stylesheets/documentElement.xml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Specify a named template, that does not exists")
+ << 0
+ << QByteArray("root-template")
+ << (QStringList() << QLatin1String("-no-format")
+ << QLatin1String("-initial-template")
+ << QLatin1String("no-template-by-this-name")
+ << QLatin1String("stylesheets/namedAndRootTemplate.xsl")
+ << QLatin1String("stylesheets/documentElement.xml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Call a named template, and use no focus.")
+ << 0
+ << QByteArray("named-template")
+ << (QStringList() << QLatin1String("-no-format")
+ << QLatin1String("-initial-template")
+ << QLatin1String("main")
+ << QLatin1String("stylesheets/namedAndRootTemplate.xsl"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Call a named template, and use no focus.")
+ << 0
+ << QByteArray("namespaced-template")
+ << (QStringList() << QLatin1String("-no-format")
+ << QLatin1String("-initial-template")
+ << QLatin1String("{http://example.com/NS}main")
+ << QLatin1String("stylesheets/namedAndRootTemplate.xsl"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Invoke a template, and use/pass parameters.")
+ << 0
+ << QByteArray("defParam overridedDefaultedParam implicitlyRequiredValue\n")
+ << (QStringList() << QLatin1String("-initial-template")
+ << QLatin1String("main")
+ << QLatin1String("stylesheets/useParameters.xsl")
+ << QLatin1String("-param")
+ << QLatin1String("overridedDefaultedParam=overridedDefaultedParam")
+ << QLatin1String("-param")
+ << QLatin1String("implicitlyRequiredValue=implicitlyRequiredValue"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Use a simplified stylesheet module")
+ << 0
+ << QByteArray("<output>some text</output>\n")
+ << (QStringList() << QLatin1String("stylesheets/simplifiedStylesheetModule.xsl")
+ << QLatin1String("stylesheets/simplifiedStylesheetModule.xml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Not well-formed stylesheet, causes crash in coloring code.")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("stylesheets/notWellformed.xsl")
+ << QLatin1String("queries/simpleDocument.xml"))
+ << QString()
+ << QString();
+
+ QTest::newRow("Not well-formed instance document, causes crash in coloring code.")
+ << 2
+ << QByteArray()
+ << (QStringList() << QLatin1String("stylesheets/bool070.xsl")
+ << QLatin1String("stylesheets/bool070.xml"))
+ << QString()
+ << QString();
+
+ // TODO test -is-uris with context
+ // TODO fail to load focus document when using XSL-T
+ // TODO fail to load focus document when using XQuery
+ // TODO focus via FTP or so with xquery
+ // TODO use URI in focus
+ // TODO use invalid URI in focus
+
+ // TODO invoke a template which has required params.
+}
+
+QTEST_MAIN(tst_XmlPatterns)
+
+#include "tst_xmlpatterns.moc"
+#else
+QTEST_NOOP_MAIN
+#endif
+
+// vim: et:ts=4:sw=4:sts=4
diff --git a/tests/auto/xmlpatterns/xmlpatterns.pro b/tests/auto/xmlpatterns/xmlpatterns.pro
new file mode 100644
index 0000000..569e23f
--- /dev/null
+++ b/tests/auto/xmlpatterns/xmlpatterns.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+SOURCES += tst_xmlpatterns.cpp \
+ ../qxmlquery/TestFundament.cpp
+
+include (../xmlpatterns.pri)