Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/xquery
File: index.html
<!doctype html>
[0] Fix | Delete
[1] Fix | Delete
<title>CodeMirror: XQuery mode</title>
[2] Fix | Delete
<meta charset="utf-8"/>
[3] Fix | Delete
<link rel=stylesheet href="../../doc/docs.css">
[4] Fix | Delete
[5] Fix | Delete
<link rel="stylesheet" href="../../lib/codemirror.css">
[6] Fix | Delete
<link rel="stylesheet" href="../../theme/xq-dark.css">
[7] Fix | Delete
<script src="../../lib/codemirror.js"></script>
[8] Fix | Delete
<script src="xquery.js"></script>
[9] Fix | Delete
<style type="text/css">
[10] Fix | Delete
.CodeMirror {
[11] Fix | Delete
border-top: 1px solid black; border-bottom: 1px solid black;
[12] Fix | Delete
height:400px;
[13] Fix | Delete
}
[14] Fix | Delete
</style>
[15] Fix | Delete
<div id=nav>
[16] Fix | Delete
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
[17] Fix | Delete
[18] Fix | Delete
<ul>
[19] Fix | Delete
<li><a href="../../index.html">Home</a>
[20] Fix | Delete
<li><a href="../../doc/manual.html">Manual</a>
[21] Fix | Delete
<li><a href="https://github.com/codemirror/codemirror">Code</a>
[22] Fix | Delete
</ul>
[23] Fix | Delete
<ul>
[24] Fix | Delete
<li><a href="../index.html">Language modes</a>
[25] Fix | Delete
<li><a class=active href="#">XQuery</a>
[26] Fix | Delete
</ul>
[27] Fix | Delete
</div>
[28] Fix | Delete
[29] Fix | Delete
<article>
[30] Fix | Delete
<h2>XQuery mode</h2>
[31] Fix | Delete
[32] Fix | Delete
[33] Fix | Delete
<div class="cm-s-default">
[34] Fix | Delete
<textarea id="code" name="code">
[35] Fix | Delete
xquery version &quot;1.0-ml&quot;;
[36] Fix | Delete
(: this is
[37] Fix | Delete
: a
[38] Fix | Delete
"comment" :)
[39] Fix | Delete
let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;
[40] Fix | Delete
let $joe:=1
[41] Fix | Delete
return element element {
[42] Fix | Delete
attribute attribute { 1 },
[43] Fix | Delete
element test { &#39;a&#39; },
[44] Fix | Delete
attribute foo { &quot;bar&quot; },
[45] Fix | Delete
fn:doc()[ foo/@bar eq $let ],
[46] Fix | Delete
//x }
[47] Fix | Delete
[48] Fix | Delete
(: a more 'evil' test :)
[49] Fix | Delete
(: Modified Blakeley example (: with nested comment :) ... :)
[50] Fix | Delete
declare private function local:declare() {()};
[51] Fix | Delete
declare private function local:private() {()};
[52] Fix | Delete
declare private function local:function() {()};
[53] Fix | Delete
declare private function local:local() {()};
[54] Fix | Delete
let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;
[55] Fix | Delete
return element element {
[56] Fix | Delete
attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
[57] Fix | Delete
attribute fn:doc { &quot;bar&quot; castable as xs:string },
[58] Fix | Delete
element text { text { &quot;text&quot; } },
[59] Fix | Delete
fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
[60] Fix | Delete
//fn:doc
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
[64] Fix | Delete
[65] Fix | Delete
xquery version &quot;1.0-ml&quot;;
[66] Fix | Delete
[67] Fix | Delete
(: Copyright 2006-2010 Mark Logic Corporation. :)
[68] Fix | Delete
[69] Fix | Delete
(:
[70] Fix | Delete
: Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
[71] Fix | Delete
: you may not use this file except in compliance with the License.
[72] Fix | Delete
: You may obtain a copy of the License at
[73] Fix | Delete
:
[74] Fix | Delete
: http://www.apache.org/licenses/LICENSE-2.0
[75] Fix | Delete
:
[76] Fix | Delete
: Unless required by applicable law or agreed to in writing, software
[77] Fix | Delete
: distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
[78] Fix | Delete
: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
[79] Fix | Delete
: See the License for the specific language governing permissions and
[80] Fix | Delete
: limitations under the License.
[81] Fix | Delete
:)
[82] Fix | Delete
[83] Fix | Delete
module namespace json = &quot;http://marklogic.com/json&quot;;
[84] Fix | Delete
declare default function namespace &quot;http://www.w3.org/2005/xpath-functions&quot;;
[85] Fix | Delete
[86] Fix | Delete
(: Need to backslash escape any double quotes, backslashes, and newlines :)
[87] Fix | Delete
declare function json:escape($s as xs:string) as xs:string {
[88] Fix | Delete
let $s := replace($s, &quot;\\&quot;, &quot;\\\\&quot;)
[89] Fix | Delete
let $s := replace($s, &quot;&quot;&quot;&quot;, &quot;\\&quot;&quot;&quot;)
[90] Fix | Delete
let $s := replace($s, codepoints-to-string((13, 10)), &quot;\\n&quot;)
[91] Fix | Delete
let $s := replace($s, codepoints-to-string(13), &quot;\\n&quot;)
[92] Fix | Delete
let $s := replace($s, codepoints-to-string(10), &quot;\\n&quot;)
[93] Fix | Delete
return $s
[94] Fix | Delete
};
[95] Fix | Delete
[96] Fix | Delete
declare function json:atomize($x as element()) as xs:string {
[97] Fix | Delete
if (count($x/node()) = 0) then 'null'
[98] Fix | Delete
else if ($x/@type = &quot;number&quot;) then
[99] Fix | Delete
let $castable := $x castable as xs:float or
[100] Fix | Delete
$x castable as xs:double or
[101] Fix | Delete
$x castable as xs:decimal
[102] Fix | Delete
return
[103] Fix | Delete
if ($castable) then xs:string($x)
[104] Fix | Delete
else error(concat(&quot;Not a number: &quot;, xdmp:describe($x)))
[105] Fix | Delete
else if ($x/@type = &quot;boolean&quot;) then
[106] Fix | Delete
let $castable := $x castable as xs:boolean
[107] Fix | Delete
return
[108] Fix | Delete
if ($castable) then xs:string(xs:boolean($x))
[109] Fix | Delete
else error(concat(&quot;Not a boolean: &quot;, xdmp:describe($x)))
[110] Fix | Delete
else concat('&quot;', json:escape($x), '&quot;')
[111] Fix | Delete
};
[112] Fix | Delete
[113] Fix | Delete
(: Print the thing that comes after the colon :)
[114] Fix | Delete
declare function json:print-value($x as element()) as xs:string {
[115] Fix | Delete
if (count($x/*) = 0) then
[116] Fix | Delete
json:atomize($x)
[117] Fix | Delete
else if ($x/@quote = &quot;true&quot;) then
[118] Fix | Delete
concat('&quot;', json:escape(xdmp:quote($x/node())), '&quot;')
[119] Fix | Delete
else
[120] Fix | Delete
string-join(('{',
[121] Fix | Delete
string-join(for $i in $x/* return json:print-name-value($i), &quot;,&quot;),
[122] Fix | Delete
'}'), &quot;&quot;)
[123] Fix | Delete
};
[124] Fix | Delete
[125] Fix | Delete
(: Print the name and value both :)
[126] Fix | Delete
declare function json:print-name-value($x as element()) as xs:string? {
[127] Fix | Delete
let $name := name($x)
[128] Fix | Delete
let $first-in-array :=
[129] Fix | Delete
count($x/preceding-sibling::*[name(.) = $name]) = 0 and
[130] Fix | Delete
(count($x/following-sibling::*[name(.) = $name]) &gt; 0 or $x/@array = &quot;true&quot;)
[131] Fix | Delete
let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) &gt; 0
[132] Fix | Delete
return
[133] Fix | Delete
[134] Fix | Delete
if ($later-in-array) then
[135] Fix | Delete
() (: I was handled previously :)
[136] Fix | Delete
else if ($first-in-array) then
[137] Fix | Delete
string-join(('&quot;', json:escape($name), '&quot;:[',
[138] Fix | Delete
string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), &quot;,&quot;),
[139] Fix | Delete
']'), &quot;&quot;)
[140] Fix | Delete
else
[141] Fix | Delete
string-join(('&quot;', json:escape($name), '&quot;:', json:print-value($x)), &quot;&quot;)
[142] Fix | Delete
};
[143] Fix | Delete
[144] Fix | Delete
(:~
[145] Fix | Delete
Transforms an XML element into a JSON string representation. See http://json.org.
[146] Fix | Delete
&lt;p/&gt;
[147] Fix | Delete
Sample usage:
[148] Fix | Delete
&lt;pre&gt;
[149] Fix | Delete
xquery version &quot;1.0-ml&quot;;
[150] Fix | Delete
import module namespace json=&quot;http://marklogic.com/json&quot; at &quot;json.xqy&quot;;
[151] Fix | Delete
json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;)
[152] Fix | Delete
&lt;/pre&gt;
[153] Fix | Delete
Sample transformations:
[154] Fix | Delete
&lt;pre&gt;
[155] Fix | Delete
&amp;lt;e/&amp;gt; becomes {&quot;e&quot;:null}
[156] Fix | Delete
&amp;lt;e&amp;gt;text&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;text&quot;}
[157] Fix | Delete
&amp;lt;e&amp;gt;quote &quot; escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;quote \&quot; escaping&quot;}
[158] Fix | Delete
&amp;lt;e&amp;gt;backslash \ escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;backslash \\ escaping&quot;}
[159] Fix | Delete
&amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;b&amp;gt;text2&amp;lt;/b&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:&quot;text1&quot;,&quot;b&quot;:&quot;text2&quot;}}
[160] Fix | Delete
&amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;a&amp;gt;text2&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;,&quot;text2&quot;]}}
[161] Fix | Delete
&amp;lt;e&amp;gt;&amp;lt;a array=&quot;true&quot;&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;]}}
[162] Fix | Delete
&amp;lt;e&amp;gt;&amp;lt;a type=&quot;boolean&quot;&amp;gt;false&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:false}}
[163] Fix | Delete
&amp;lt;e&amp;gt;&amp;lt;a type=&quot;number&quot;&amp;gt;123.5&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:123.5}}
[164] Fix | Delete
&amp;lt;e quote=&quot;true&quot;&amp;gt;&amp;lt;div attrib=&quot;value&quot;/&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;&amp;lt;div attrib=\&quot;value\&quot;/&amp;gt;&quot;}
[165] Fix | Delete
&lt;/pre&gt;
[166] Fix | Delete
&lt;p/&gt;
[167] Fix | Delete
Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
[168] Fix | Delete
&lt;p/&gt;
[169] Fix | Delete
Attributes are ignored, except for the special attribute @array=&quot;true&quot; that
[170] Fix | Delete
indicates the JSON serialization should write the node, even if single, as an
[171] Fix | Delete
array, and the attribute @type that can be set to &quot;boolean&quot; or &quot;number&quot; to
[172] Fix | Delete
dictate the value should be written as that type (unquoted). There's also
[173] Fix | Delete
an @quote attribute that when set to true writes the inner content as text
[174] Fix | Delete
rather than as structured JSON, useful for sending some XHTML over the
[175] Fix | Delete
wire.
[176] Fix | Delete
&lt;p/&gt;
[177] Fix | Delete
Text nodes within mixed content are ignored.
[178] Fix | Delete
[179] Fix | Delete
@param $x Element node to convert
[180] Fix | Delete
@return String holding JSON serialized representation of $x
[181] Fix | Delete
[182] Fix | Delete
@author Jason Hunter
[183] Fix | Delete
@version 1.0.1
[184] Fix | Delete
[185] Fix | Delete
Ported to xquery 1.0-ml; double escaped backslashes in json:escape
[186] Fix | Delete
:)
[187] Fix | Delete
declare function json:serialize($x as element()) as xs:string {
[188] Fix | Delete
string-join(('{', json:print-name-value($x), '}'), &quot;&quot;)
[189] Fix | Delete
};
[190] Fix | Delete
</textarea>
[191] Fix | Delete
</div>
[192] Fix | Delete
[193] Fix | Delete
<script>
[194] Fix | Delete
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
[195] Fix | Delete
lineNumbers: true,
[196] Fix | Delete
matchBrackets: true,
[197] Fix | Delete
theme: "xq-dark"
[198] Fix | Delete
});
[199] Fix | Delete
</script>
[200] Fix | Delete
[201] Fix | Delete
<p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
[202] Fix | Delete
[203] Fix | Delete
<p>Development of the CodeMirror XQuery mode was sponsored by
[204] Fix | Delete
<a href="http://marklogic.com">MarkLogic</a> and developed by
[205] Fix | Delete
<a href="https://twitter.com/mbrevoort">Mike Brevoort</a>.
[206] Fix | Delete
</p>
[207] Fix | Delete
[208] Fix | Delete
</article>
[209] Fix | Delete
[210] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function