Permalink
Browse files

have xquery 1.0 processor generating all xquery variants

  • Loading branch information...
1 parent 9651f31 commit 95cde936582b17b0ee6748fd3f7e83ea09e68f72 @xquery committed Sep 17, 2011
View
@@ -20,14 +20,14 @@
cd src/tests
-/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/default.xml marklogic-test.xpl test=/tests/unit/marklogic/simple.xqy example=/src/tests/examples/default.xqy expected=/src/tests/expected/default.xml
+/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/default.xml marklogic-test.xpl test=/tests/unit/marklogic/simple.xqy example=/src/tests/examples/default.xqy expected=/src/tests/expected/marklogic/default.xml
-/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/get-code.xml marklogic-test.xpl test=/tests/unit/marklogic/simple.xqy example=/src/tests/examples/get-code.xqy expected=/src/tests/expected/get-code.xml
+/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/get-code.xml marklogic-test.xpl test=/tests/unit/marklogic/simple.xqy example=/src/tests/examples/get-code.xqy expected=/src/tests/expected/marklogic/get-code.xml
-/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/output-html.xml marklogic-test.xpl test=/tests/unit/marklogic/output-html.xqy example=/src/tests/examples/default.xqy expected=/src/tests/expected/output-html.xml
+/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/output-html.xml marklogic-test.xpl test=/tests/unit/marklogic/output-html.xqy example=/src/tests/examples/default.xqy expected=/src/tests/expected/marklogic/output-html.xml
-/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/json.xml marklogic-test.xpl test=/tests/unit/marklogic/simple.xqy example=/src/tests/examples/json.xqy expected=/src/tests/expected/json.xml
+/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/json.xml marklogic-test.xpl test=/tests/unit/marklogic/simple.xqy example=/src/tests/examples/json.xqy expected=/src/tests/expected/marklogic/json.xml
-/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/json-output-html.xml marklogic-test.xpl test=/tests/unit/marklogic/output-html.xqy example=/src/tests/examples/json.xqy expected=/src/tests/expected/json-html-output.xml
+/usr/local/bin/calabash -isource=config.xml -oresult=result/MarkLogic/json-output-html.xml marklogic-test.xpl test=/tests/unit/marklogic/output-html.xqy example=/src/tests/examples/json.xqy expected=/src/tests/expected/marklogic/json-html-output.xml
/usr/local/bin/calabash -isource=config.xml -oresult=result/marklogic-report.html report.xpl processor=MarkLogic
View
@@ -1,5 +1,29 @@
#!/bin/bash
+
+# This script runs the xquerydoc testsuite for the Saxon processor
+# using an XProc pipeline (src/tests/marklogic-test.xpl), which is a generic
+# testrunner.
+#
+# MarkLogic unit tests are located under src/tests/unit/saxon
+#
+# to add new tests review existing tests there and add an entry here to run them.
+#
+# the following describes the input/output and options passed in through XProc
+#
+# -isource: XProc input takes in MarkLogic configuration file (src/tests/config.xml)
+# -oresult: XProc output writes result of tests to src/tests/results/marklogic
+#
+# test: option contains the unit test path (unit tests are written in xquery)
+# example: option contains the path to the example xquery document to apply unit test too
+# expected: option contains the path to the expected result for the test
+#
+
cd src/tests
-/usr/local/bin/calabash -isource=config.xml -oresult=result/Saxon/default.xml saxon-test.xpl test=/tests/unit/simple.xqy example=/src/tests/examples/?select=default.xqy
+/usr/local/bin/calabash -isource=config.xml -oresult=result/Saxon/default.xml saxon-test.xpl test=/tests/unit/saxon/simple.xqy example=/src/tests/examples/?select=default.xqy expected=/src/tests/expected/default.xml
+
+/usr/local/bin/calabash -isource=config.xml -oresult=result/Saxon/get-code.xml saxon-test.xpl test=/tests/unit/saxon/simple.xqy example=/src/tests/examples/?select=get-code.xqy expected=/src/tests/expected/get-code.xml
+
+
/usr/local/bin/calabash -isource=config.xml -oresult=result/saxon-report.html report.xpl processor=Saxon
+
File renamed without changes.
@@ -0,0 +1 @@
+<doc:xqdoc xmlns:doc="http://www.xqdoc.org/1.0"><doc:control><!--Generated by xquerydoc: http://github.com/xquery/xquerydoc--><doc:date/><doc:version>N/A</doc:version></doc:control><doc:module type="main"><doc:uri/><doc:comment><doc:description> &#xD; This main module controls the presentation of the home page for&#xD; xqDoc. The home page will list all of the library and main modules&#xD; contained in the 'xqDoc' collection.&#xD; The mainline function invokes only the&#xD; method to generate the HTML for the xqDoc home page. A parameter of type &#xD; xs:boolean is passed to indicate whether links on the page should be constructed &#xD; to static HTML pages (for off-line viewing) or to XQuery scripts for dynamic&#xD; real-time viewing.&#xD; &#xD; </doc:description><doc:author> Darin McBeath&#xD; </doc:author><doc:since> June 9, 2006&#xD; </doc:since><doc:version> 1.3&#xD;</doc:version></doc:comment></doc:module><doc:variables/><doc:functions/></doc:xqdoc>
@@ -0,0 +1 @@
+<doc:xqdoc xmlns:doc="http://www.xqdoc.org/1.0"><doc:control><!--Generated by xquerydoc: http://github.com/xquery/xquerydoc--><doc:date/><doc:version>N/A</doc:version></doc:control><doc:module type="main"><doc:uri/><doc:comment><doc:description> &#xD; This main module controls the presentation of the code for either&#xD; an entire mdoule or a particlur function within a module. &#xD; The mainline function invokes only the&#xD; method to retrieve the source code. The 'module' and 'function' parameters&#xD; are extracted from the query-string. If only a 'module' is specified, then&#xD; the source code for the entire module will be returned. If both a 'module'&#xD; and a 'function' are specified, only the source code for the specified function&#xD; within the module will be returned. A parameter of type xs:boolean &#xD; is passed to indicate whether links on the page should be constructed &#xD; to static HTML pages (for off-line viewing) or to XQuery scripts for dynamic&#xD; real-time viewing.&#xD; &#xD; </doc:description><doc:author> Darin McBeath&#xD; </doc:author><doc:since> June 9, 2006&#xD; </doc:since><doc:version> 1.3&#xD;</doc:version></doc:comment></doc:module><doc:variables/><doc:functions/></doc:xqdoc>
@@ -0,0 +1,195 @@
+<html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN">
+ <head>
+ <title>xqDoc - </title>
+ <style type="text/css">
+ body {
+ font-family: Helvetica;
+ padding: 0.5em 1em;
+ }
+ pre {
+ font-family: Inconsolata, Consolas, monospace;
+ }
+ ol.results {
+ padding-left: 0;
+ }
+ .footer {
+ text-align:right;
+ border-top: solid 4px;
+ padding: 0.25em 0.5em;
+ font-size: 85%;
+ color: #999;
+ }
+ li.result {
+ list-style-position: inside;
+ list-style: none;
+ height:140px;
+ }
+ h2 {
+ display: inline-block;
+ margin: 0;
+ }
+
+ h2 a,
+ .result h3 a {
+ text-decoration: inherit;
+ color: inherit;
+ }
+ h3{
+ font-size: 140%;
+ background-color: #aaa;
+ border-bottom: 1px solid #99f;
+ width: 100%;
+ }
+ h4{
+ font-size: 100%;
+ background-color: #ddd;
+ width: 50%;
+ }
+
+ .namespace {
+ color: #999;
+ }
+ .namespace:before {
+ content: "{";
+ }
+ .namespace:after {
+ content: "}";
+ }
+ table{
+ width:75%;
+ float:right;
+ }
+ td {
+ height:100px;
+ width:50%;
+ vertical-align:text-top;
+ }
+ </style>
+ <script src="src/tests/result/resource/prettify.js" type="text/javascript">  </script>
+ <script src="src/tests/result/resource/lang-xq.js" type="text/javascript">  </script>
+ <link rel="stylesheet" type="text/css" href="src/tests/result/resource/prettify.css"> </link>
+ </head>
+ <body class="home"><div id="main"><h1><span class="namespace">http://marklogic.com/json</span>  library module </h1><h5>Comment</h5><p> This is an example xquery file taken from several files to demonstrate xqdoc commenting Sample usage: example bold tag Proin facilisis ultrices velit id bibendum. Curabitur eu nisi velit, vel pharetra eros. Fusce eu metus sem. Etiam sed risus ultrices turpis blandit placerat. Suspendisse eu massa arcu, eget feugiat arcu. Donec eget rutrum nisi. Vivamus eget massa libero. Pellentesque placerat tortor elit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed molestie odio lacinia eros iaculis laoreet. </p>
+ Author: Jim Fuller
+ v. 1 <h3>Variables</h3><ul>
+ <li>new-line-regex xs:string</li>
+ </ul><h3>Functions</h3><h4>Function <pre class="prettyprint lang-xq"><u>escape</u>($s as xs:string) as xs:string</pre></h4><h5>Params</h5><ul>
+ <li>s: xs:string</li>
+ </ul><h5>Returns</h5><ul>
+ <li>: xs:string</li>
+ </ul><h4>Function <pre class="prettyprint lang-xq"><u>print-value</u>($x as element()) as xs:string</pre></h4><h5>Params</h5><ul>
+ <li>x: element()</li>
+ </ul><h5>Returns</h5><ul>
+ <li>: xs:string</li>
+ </ul><h4>Function <pre class="prettyprint lang-xq"><u>print-name-value</u>($x as element()) as xs:string?</pre></h4><h5>Params</h5><ul>
+ <li>x: element()</li>
+ </ul><h5>Returns</h5><ul>
+ <li>: xs:string</li>
+ </ul><h4>Function <pre class="prettyprint lang-xq"><u>serialize</u>($x as element()) as xs:string</pre></h4><h5>Comment</h5><p> Transforms an XML element into a JSON string representation. See http://json.org. Sample usage: xquery version "1.0-ml"; import module namespace json="http://marklogic.com/json" at "json.xqy"; json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;) Sample transformations: Namespace URIs are ignored. Namespace prefixes are included in the JSON name. Attributes are ignored, except for the special attribute </p>="true" that indicates the JSON serialization should write the node, even if single, as an array, and the attribute that can be set to "boolean" or "number" to dictate the value should be written as that type (unquoted). There's also an attribute that when set to true writes the inner content as text rather than as structured JSON, useful for sending some XHTML over the wire. Text nodes within mixed content are ignored. $x Element node to convert String holding JSON serialized representation of $x
+ Author: Jason Hunter
+ v. 1.0.1 Ported to xquery 1.0-ml; double escaped backslashes in json:escape<h5>Params</h5><ul>
+ <li>x: element()</li>
+ </ul><h5>Returns</h5><ul>
+ <li>: xs:string</li>
+ </ul><h3>Original Source Code</h3><pre class="prettyprint lang-xq">xquery version "1.0-ml";
+
+
+(:~
+ : This is an example xquery file taken from several files to demonstrate xqdoc commenting
+ :
+ : Sample usage:
+ : &lt;b&gt;
+ : example bold tag
+ : &lt;/b&gt;
+ :
+ : Proin facilisis ultrices velit id bibendum. Curabitur eu nisi velit, vel pharetra
+ : eros. Fusce eu metus sem. Etiam sed risus ultrices turpis blandit placerat. Suspendisse
+ : eu massa arcu, eget feugiat arcu. Donec eget rutrum nisi. Vivamus eget massa libero.
+ : Pellentesque placerat tortor elit. Vestibulum ante ipsum primis in faucibus orci luctus
+ : et ultrices posuere cubilia Curae; Sed molestie odio lacinia eros iaculis laoreet.
+ :
+ :
+ : @author Jim Fuller
+ : @version 1
+ :
+ :
+:)
+
+module namespace json = "http://marklogic.com/json";
+declare namespace test="test";
+
+declare default function namespace "http://www.w3.org/2005/xpath-functions";
+
+declare variable $new-line-regex as xs:string := concat('[',codepoints-to-string((13, 10)),']+');
+
+(: Need to backslash escape any double quotes, backslashes, newlines and tabs :)
+declare function json:escape($s as xs:string) as xs:string {
+ let $s := replace($s, "(\\|"")", "\\$1")
+ let $s := replace($s, $new-line-regex, "\\n")
+ let $s := replace($s, codepoints-to-string(9), "\\t")
+ return $s
+};
+
+(: Print the thing that comes after the colon :)
+declare function json:print-value($x as element()) as xs:string {
+ if (count($x/*) = 0) then
+ json:atomize($x)
+ else if ($x/@quote = "true") then
+ concat('"', json:escape(xdmp:quote($x/node())), '"')
+ else
+ string-join(('{',
+ string-join(for $i in $x/* return json:print-name-value($i), ","),
+ '}'), "")
+};
+
+(: Print the name and value both :)
+declare function json:print-name-value($x as element()) as xs:string? {
+ let $name := name($x)
+ let $later-in-array := some $s in $x/following-sibling::* satisfies name($s) = $name
+ return
+ if ($later-in-array) then
+ ()
+ else
+ ()
+};
+
+(:~
+ : Transforms an XML element into a JSON string representation. See http://json.org.
+ :
+ : Sample usage:
+ : &lt;pre&gt;
+ : xquery version "1.0-ml";
+ : import module namespace json="http://marklogic.com/json" at "json.xqy";
+ : json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;)
+ : &lt;/pre&gt;
+ : Sample transformations:
+ :
+ : Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
+ :
+ : Attributes are ignored, except for the special attribute @array="true" that
+ : indicates the JSON serialization should write the node, even if single, as an
+ : array, and the attribute @type that can be set to "boolean" or "number" to
+ : dictate the value should be written as that type (unquoted). There's also
+ : an @quote attribute that when set to true writes the inner content as text
+ : rather than as structured JSON, useful for sending some XHTML over the
+ : wire.
+ :
+ : Text nodes within mixed content are ignored.
+ :
+ : @param $x Element node to convert
+ : @return String holding JSON serialized representation of $x
+ :
+ : @author Jason Hunter
+ : @version 1.0.1
+ :
+ : Ported to xquery 1.0-ml; double escaped backslashes in json:escape
+:)
+declare function json:serialize($x as element()) as xs:string {
+ string-join(('{', json:print-name-value($x), '}'), "")
+};
+
+</pre><br/><div class="footer"><p style="text-align:right"><i/> |
+ generated by xquerydoc <a href="https://github.com/xquery/xquerydoc" target="xquerydoc">https://github.com/xquery/xquerydoc</a></p></div></div><script type="application/javascript">
+ window.onload = function(){ prettyPrint(); }
+ </script></body>
+ </html>
@@ -0,0 +1 @@
+<doc:xqdoc xmlns:doc="http://www.xqdoc.org/1.0"><doc:control><!--Generated by xquerydoc: http://github.com/xquery/xquerydoc--><doc:version>N/A</doc:version></doc:control><doc:module type="library"><doc:uri>http://marklogic.com/json</doc:uri><doc:comment><doc:description> This is an example xquery file taken from several files to demonstrate xqdoc commenting Sample usage: <b> example bold tag </b> Proin facilisis ultrices velit id bibendum. Curabitur eu nisi velit, vel pharetra eros. Fusce eu metus sem. Etiam sed risus ultrices turpis blandit placerat. Suspendisse eu massa arcu, eget feugiat arcu. Donec eget rutrum nisi. Vivamus eget massa libero. Pellentesque placerat tortor elit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed molestie odio lacinia eros iaculis laoreet. </doc:description><doc:author> Jim Fuller </doc:author><doc:version> 1 </doc:version></doc:comment></doc:module><doc:variables><doc:variable><doc:uri>new-line-regex</doc:uri><doc:type> xs:string</doc:type></doc:variable></doc:variables><doc:functions><doc:function><doc:name>escape</doc:name><doc:signature>($s as xs:string) as xs:string</doc:signature><doc:parameters><doc:parameter><doc:name>s</doc:name><doc:type> xs:string</doc:type></doc:parameter></doc:parameters><doc:return><doc:type> xs:string</doc:type></doc:return></doc:function><doc:function><doc:name>print-value</doc:name><doc:signature>($x as element()) as xs:string</doc:signature><doc:parameters><doc:parameter><doc:name>x</doc:name><doc:type> element()</doc:type></doc:parameter></doc:parameters><doc:return><doc:type> xs:string</doc:type></doc:return></doc:function><doc:function><doc:name>print-name-value</doc:name><doc:signature>($x as element()) as xs:string?</doc:signature><doc:parameters><doc:parameter><doc:name>x</doc:name><doc:type> element()</doc:type></doc:parameter></doc:parameters><doc:return><doc:type occurrence="?"> xs:string</doc:type></doc:return></doc:function><doc:function><doc:comment><doc:description> Transforms an XML element into a JSON string representation. See http://json.org. Sample usage: <pre> xquery version "1.0-ml"; import module namespace json="http://marklogic.com/json" at "json.xqy"; json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;) </pre> Sample transformations: Namespace URIs are ignored. Namespace prefixes are included in the JSON name. Attributes are ignored, except for the special attribute </doc:description><doc:custom tag="array">="true" that indicates the JSON serialization should write the node, even if single, as an array, and the attribute </doc:custom><doc:custom tag="type"> that can be set to "boolean" or "number" to dictate the value should be written as that type (unquoted). There's also an </doc:custom><doc:custom tag="quote"> attribute that when set to true writes the inner content as text rather than as structured JSON, useful for sending some XHTML over the wire. Text nodes within mixed content are ignored. </doc:custom><doc:param> $x Element node to convert </doc:param><doc:return> String holding JSON serialized representation of $x </doc:return><doc:author> Jason Hunter </doc:author><doc:version> 1.0.1 Ported to xquery 1.0-ml; double escaped backslashes in json:escape</doc:version></doc:comment><doc:name>serialize</doc:name><doc:signature>($x as element()) as xs:string</doc:signature><doc:parameters><doc:parameter><doc:name>x</doc:name><doc:type> element()</doc:type></doc:parameter></doc:parameters><doc:return><doc:type> xs:string</doc:type></doc:return></doc:function></doc:functions></doc:xqdoc>
Oops, something went wrong.

0 comments on commit 95cde93

Please sign in to comment.