rubinium 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +7 -0
- data/MIT-LICENSE +21 -0
- data/README +137 -0
- data/Rakefile +139 -0
- data/TODO +7 -0
- data/doc/examples/rtc_site_live.rb +12 -0
- data/doc/examples/rts_main.rb +9 -0
- data/doc/examples/rts_shared_code.rb +25 -0
- data/lib/rubinium.rb +9 -0
- data/lib/rubinium/string.rb +3 -0
- data/lib/rubinium/test_base.rb +80 -0
- data/lib/rubinium/test_suite.rb +53 -0
- data/lib/rubinium/validator.rb +16 -0
- data/test/selenium_tests/test_click.rb +22 -0
- data/test/selenium_tests/test_open.rb +11 -0
- data/test/tc_file_creation.rb +60 -0
- data/test/ts_rubinium.rb +1 -0
- data/vendor/selenium-0.6.0/install-readme.txt +9 -0
- data/vendor/selenium-0.6.0/selenium/SeleneseRunner.html +253 -0
- data/vendor/selenium-0.6.0/selenium/SeleniumLog.html +61 -0
- data/vendor/selenium-0.6.0/selenium/TestRunner-splash.html +55 -0
- data/vendor/selenium-0.6.0/selenium/TestRunner.hta +146 -0
- data/vendor/selenium-0.6.0/selenium/TestRunner.html +146 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestClickInFrame.html +58 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInFrame.html +48 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInNewWindow.html +78 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestOpenMeta.html +43 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestSuite.html +39 -0
- data/vendor/selenium-0.6.0/selenium/devtests/meta/page.html +5 -0
- data/vendor/selenium-0.6.0/selenium/dom-images/butmin.gif +0 -0
- data/vendor/selenium-0.6.0/selenium/dom-images/butplus.gif +0 -0
- data/vendor/selenium-0.6.0/selenium/dom-styles/default.css +298 -0
- data/vendor/selenium-0.6.0/selenium/domviewer.html +16 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/carnation.jpg +0 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/example.html +75 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath-patched.js +657 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath.js +610 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/license.txt +504 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/rainbow.jpg +0 -0
- data/vendor/selenium-0.6.0/selenium/htmlutils.js +283 -0
- data/vendor/selenium-0.6.0/selenium/index.html +60 -0
- data/vendor/selenium-0.6.0/selenium/jsmock/mock-tests.html +205 -0
- data/vendor/selenium-0.6.0/selenium/jsmock/mock.js +124 -0
- data/vendor/selenium-0.6.0/selenium/selenium-api.js +683 -0
- data/vendor/selenium-0.6.0/selenium/selenium-browserbot.js +930 -0
- data/vendor/selenium-0.6.0/selenium/selenium-commandhandlers.js +286 -0
- data/vendor/selenium-0.6.0/selenium/selenium-domviewer.js +188 -0
- data/vendor/selenium-0.6.0/selenium/selenium-executionloop.js +250 -0
- data/vendor/selenium-0.6.0/selenium/selenium-fitrunner.js +597 -0
- data/vendor/selenium-0.6.0/selenium/selenium-logging.js +88 -0
- data/vendor/selenium-0.6.0/selenium/selenium-logo.png +0 -0
- data/vendor/selenium-0.6.0/selenium/selenium-tableparser.js +50 -0
- data/vendor/selenium-0.6.0/selenium/selenium.css +211 -0
- data/vendor/selenium-0.6.0/selenium/tests/ErrorCheckingTestSuite.html +36 -0
- data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSearch.html +69 -0
- data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSuite.html +32 -0
- data/vendor/selenium-0.6.0/selenium/tests/JsUnitSuite.html +38 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestClick.html +128 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestClickJavascriptHref.html +115 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestCommandError.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestConfirmations.html +77 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestErrorChecking.html +71 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestFailingAssert.html +59 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestFailingVerifications.html +198 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestFocusOnBlur.html +53 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestGoBack.html +81 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestImplicitLocators.html +81 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestJavascriptParameters.html +91 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestLocators.html +161 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestModalDialog.html +58 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestModalDialogDialog.html +48 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestOpen.html +66 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestPatternMatching.html +127 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestPause.html +78 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestPrompting.html +82 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestProxy.html +62 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSelect.html +111 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSelectWindow.html +106 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestStore.html +165 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite-InternetExplorer.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Konqueror.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Safari.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestType.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestUserExtensions.html +81 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifications.html +164 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlerts.html +80 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlertsFailures.html +108 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyConfirmationFailures.html +86 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditable.html +70 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditableFailures.html +95 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVisibility.html +91 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVisibilityFailures.html +131 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestWait.html +112 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestWaitFor.html +63 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestWaitInPopupWindow.html +94 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestXPathLocators.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/alert-handling-tests.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/assert-tests.html +113 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/browserbot-tests.html +123 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-factory-tests.html +290 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-handler-tests.html +115 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/confirm-handling-tests.html +97 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/error-checking-command-tests.html +198 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/event-bubble-tests.html +106 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/optionlocator-tests.html +180 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-accessor-tests.html +65 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-action-tests.html +200 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-attribute-tests.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests-include.html +33 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests.html +258 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-property-tests.html +49 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pattern-matcher-tests.html +66 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-api-tests.html +412 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-parameter-tests.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/suite.html +52 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/testloop-handle-error-tests.html +74 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestButtonEvents.html +72 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestCheckboxEvents.html +107 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestFireEvents.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestLinkEvents.html +43 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestRadioEvents.html +149 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestSelectEvents.html +122 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestTextEvents.html +87 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/readme.txt +26 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/banner.gif +0 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_async_event.html +36 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_click_javascript_page.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page1.html +31 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page2.html +30 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_confirm.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_dummy_page.html +26 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_editable.html +36 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_focus_on_blur.html +33 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_form_events.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_framed_page.html +7 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_just_text.html +22 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_locators.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog.html +29 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog_dialog.html +35 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_open.html +23 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_prompt.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_reload_onchange_page.html +32 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_select.html +35 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window.html +29 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window_popup.html +28 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_slowloading_page.html +27 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_store_value.html +23 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page1.html +37 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page2.html +61 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_verifications.html +42 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_verify_alert.html +46 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_visibility.html +53 -0
- data/vendor/selenium-0.6.0/selenium/tests/readme.txt +1 -0
- data/vendor/selenium-0.6.0/selenium/tests/tableparser/tableparser-tests.html +122 -0
- data/vendor/selenium-0.6.0/selenium/tests/tinyWebServer.py +70 -0
- data/vendor/selenium-0.6.0/selenium/user-extensions.js.sample +62 -0
- data/vendor/selenium-0.6.0/selenium/version.txt +1 -0
- data/vendor/selenium-0.6.0/selenium/xmlextras.js +153 -0
- data/vendor/selenium-0.6.0/selenium/xpath.js +3910 -0
- metadata +216 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Create a TestSuite.html page, and a number of test pages here. Read the docs!
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
|
3
|
+
|
|
4
|
+
<!--
|
|
5
|
+
Copyright 2004 ThoughtWorks, Inc
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
-->
|
|
19
|
+
<html>
|
|
20
|
+
<head>
|
|
21
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
22
|
+
<title>JsUnit Utility Tests</title>
|
|
23
|
+
<link rel="stylesheet" type="text/css" href="jsunit/css/jsUnitStyle.css">
|
|
24
|
+
<script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
|
|
25
|
+
<script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
|
|
26
|
+
<script language="JavaScript" type="text/javascript" src="/selenium-commandhandlers.js"></script>
|
|
27
|
+
<script language="JavaScript" type="text/javascript" src="/selenium-tableparser.js"></script>
|
|
28
|
+
<script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
|
|
29
|
+
<script language="JavaScript" type="text/javascript">
|
|
30
|
+
|
|
31
|
+
///////////////////// HTML TABLE PARSING /////////////////////
|
|
32
|
+
function setUp() {
|
|
33
|
+
tableParser = new TableParser();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function assertCommand(expectedName, expectedTarget, expectedValue, command) {
|
|
37
|
+
assertEquals(expectedName, command.command);
|
|
38
|
+
assertEquals(expectedTarget, command.target);
|
|
39
|
+
assertEquals(expectedValue, command.value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function testShouldParseOneArgHtmlTableRowToJavascript() {
|
|
43
|
+
var row = document.getElementsByTagName("table")[0].rows[1]
|
|
44
|
+
var command = tableParser.createCommandFromHtmlRow(row);
|
|
45
|
+
assertCommand("click", "someButton", "", command);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function testShouldParseTwoArgHtmlTableRowToJavascript() {
|
|
49
|
+
var row = document.getElementsByTagName("table")[0].rows[2]
|
|
50
|
+
var command = tableParser.createCommandFromHtmlRow(row);
|
|
51
|
+
assertCommand("verifyText", "someButton", "Click me!", command);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function testShouldFailWithBadWikiRowFormat() {
|
|
55
|
+
var row = document.getElementsByTagName("table")[0].rows[3]
|
|
56
|
+
try {
|
|
57
|
+
tableParser.createCommandFromHtmlRow(row)
|
|
58
|
+
fail("Should fail")
|
|
59
|
+
} catch(expected) {
|
|
60
|
+
assertEquals("Bad HTML row format. Rows must have 3 coumns, but had 4", expected.message)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
///////////////////// WIKI TABLE PARSING /////////////////////
|
|
65
|
+
|
|
66
|
+
function testShouldParseOneArgWikiTableRowToJavascript() {
|
|
67
|
+
var wikiRow = "| click | someButton ||"
|
|
68
|
+
var command = tableParser.createCommandFromWikiRow(wikiRow);
|
|
69
|
+
assertCommand("click", "someButton", "", command);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function testShouldParseTwoArgWikiTableRowToJavascript() {
|
|
73
|
+
var wikiRow = "| verifyText | someButton |Click me!|"
|
|
74
|
+
var command = tableParser.createCommandFromWikiRow(wikiRow);
|
|
75
|
+
assertCommand("verifyText", "someButton", "Click me!", command);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function testShouldFailWithBadWikiRowFormat() {
|
|
79
|
+
var wikiRow = "| verifyText | someButton |Click me!||"
|
|
80
|
+
try {
|
|
81
|
+
tableParser.createCommandFromWikiRow(wikiRow);
|
|
82
|
+
fail("Should fail")
|
|
83
|
+
} catch(expected) {
|
|
84
|
+
assertEquals("Bad wiki row format:| verifyText | someButton |Click me!||", expected.message)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
</head>
|
|
89
|
+
|
|
90
|
+
<body>
|
|
91
|
+
<h1>TableParser Tests</h1>
|
|
92
|
+
|
|
93
|
+
<p>This page contains tests for TableParser. To see them, take a look at the source. To run them, load this file via JsUnit's testRunner.html</p>
|
|
94
|
+
|
|
95
|
+
<input id="someField"/>
|
|
96
|
+
|
|
97
|
+
<table cellpadding="1" cellspacing="1" border="1">
|
|
98
|
+
<tbody>
|
|
99
|
+
<tr>
|
|
100
|
+
<td rowspan="1" colspan="3">Test Type<br>
|
|
101
|
+
</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<td>click</td>
|
|
105
|
+
<td>someButton</td>
|
|
106
|
+
<td> </td>
|
|
107
|
+
</tr>
|
|
108
|
+
<tr>
|
|
109
|
+
<td>verifyText</td>
|
|
110
|
+
<td>someButton</td>
|
|
111
|
+
<td>Click me!</td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td>this</td>
|
|
115
|
+
<td>is</td>
|
|
116
|
+
<td>a bad</td>
|
|
117
|
+
<td>row</td>
|
|
118
|
+
</tr>
|
|
119
|
+
</tbody>
|
|
120
|
+
</table>
|
|
121
|
+
</body>
|
|
122
|
+
</html>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright 2004 ThoughtWorks, Inc
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
# minimal web server.
|
|
17
|
+
# serves files relative to the current directory.
|
|
18
|
+
# cgi-bin directory serves Python CGIs.
|
|
19
|
+
|
|
20
|
+
import BaseHTTPServer
|
|
21
|
+
import CGIHTTPServer
|
|
22
|
+
import time
|
|
23
|
+
import httplib
|
|
24
|
+
import sys
|
|
25
|
+
|
|
26
|
+
PORT = 8000
|
|
27
|
+
|
|
28
|
+
class HTTPHandler(CGIHTTPServer.CGIHTTPRequestHandler):
|
|
29
|
+
"""
|
|
30
|
+
Simple Web Server that can handle query strings in a request URL and can be stopped with a request
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
quitRequestReceived = False
|
|
35
|
+
|
|
36
|
+
def do_GET(self):
|
|
37
|
+
# SimpleHTTPServer doesn't know how to handle query strings in
|
|
38
|
+
# 'GET' requests, so we're processing them here:
|
|
39
|
+
if self.path.find('?') != -1:
|
|
40
|
+
self.path, self.query_string = self.path.split('?', 1)
|
|
41
|
+
else:
|
|
42
|
+
self.query_string = ''
|
|
43
|
+
|
|
44
|
+
# Add a delay before serving up the slow-loading test page
|
|
45
|
+
if self.path.find('test_slowloading_page') != -1:
|
|
46
|
+
time.sleep(0.3)
|
|
47
|
+
|
|
48
|
+
# Carry on with the rest of the processing...
|
|
49
|
+
CGIHTTPServer.CGIHTTPRequestHandler.do_GET(self)
|
|
50
|
+
|
|
51
|
+
def do_QUIT(self):
|
|
52
|
+
self.send_response(200)
|
|
53
|
+
self.end_headers()
|
|
54
|
+
HTTPHandler.quitRequestReceived = True
|
|
55
|
+
|
|
56
|
+
if __name__ == '__main__':
|
|
57
|
+
port = PORT
|
|
58
|
+
if len(sys.argv) > 1:
|
|
59
|
+
port = int(sys.argv[1])
|
|
60
|
+
|
|
61
|
+
server_address = ('', port)
|
|
62
|
+
httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler)
|
|
63
|
+
|
|
64
|
+
print "serving at port", port
|
|
65
|
+
print "To access the Selenium test suite, open"
|
|
66
|
+
print " http://localhost:%s/index.html" % port
|
|
67
|
+
|
|
68
|
+
while not HTTPHandler.quitRequestReceived :
|
|
69
|
+
httpd.handle_request()
|
|
70
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* By default, Selenium looks for a file called "user-extensions.js", and loads and javascript
|
|
3
|
+
* code found in that file. This file is a sample of what that file could look like.
|
|
4
|
+
*
|
|
5
|
+
* user-extensions.js provides a convenient location for adding extensions to Selenium, like
|
|
6
|
+
* new actions, checks and locator-strategies.
|
|
7
|
+
* By default, this file does not exist. Users can create this file and place their extension code
|
|
8
|
+
* in this common location, removing the need to modify the Selenium sources, and hopefully assisting
|
|
9
|
+
* with the upgrade process.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// The following examples try to give an indication of how Selenium can be extended with javascript.
|
|
13
|
+
|
|
14
|
+
// All do* methods on the Selenium prototype are added as actions.
|
|
15
|
+
// Eg add a typeRepeated action to Selenium, which types the text twice into a text box.
|
|
16
|
+
// The typeTwiceAndWait command will be available automatically
|
|
17
|
+
Selenium.prototype.doTypeRepeated = function(locator, text) {
|
|
18
|
+
// All locator-strategies are automatically handled by "findElement"
|
|
19
|
+
var element = this.page().findElement(locator);
|
|
20
|
+
|
|
21
|
+
// Create the text to type
|
|
22
|
+
var valueToType = text + text;
|
|
23
|
+
|
|
24
|
+
// Replace the element text with the new text
|
|
25
|
+
this.page().replaceText(element, valueToType);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// All assert* methods on the Selenium prototype are added as checks.
|
|
29
|
+
// Eg add a assertValueRepeated check, that makes sure that the element value
|
|
30
|
+
// consists of the supplied text repeated.
|
|
31
|
+
// The verify version will be available automatically.
|
|
32
|
+
Selenium.prototype.assertValueRepeated = function(locator, text) {
|
|
33
|
+
// All locator-strategies are automatically handled by "findElement"
|
|
34
|
+
var element = this.page().findElement(locator);
|
|
35
|
+
|
|
36
|
+
// Create the text to verify
|
|
37
|
+
var expectedValue = text + text;
|
|
38
|
+
|
|
39
|
+
// Get the actual element value
|
|
40
|
+
var actualValue = element.value;
|
|
41
|
+
|
|
42
|
+
// Make sure the actual value matches the expected
|
|
43
|
+
this.assertMatches(expectedValue, actualValue);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// All locateElementBy* methods are added as locator-strategies.
|
|
47
|
+
// Eg add a "valuerepeated=" locator, that finds the first element with the supplied value, repeated.
|
|
48
|
+
// The "inDocument" is a the document you are searching.
|
|
49
|
+
PageBot.prototype.locateElementByValueRepeated = function(text, inDocument) {
|
|
50
|
+
// Create the text to search for
|
|
51
|
+
var expectedValue = text + text;
|
|
52
|
+
|
|
53
|
+
// Loop through all elements, looking for ones that have a value === our expected value
|
|
54
|
+
var allElements = inDocument.getElementsByTagName("*");
|
|
55
|
+
for (var i = 0; i < allElements.length; i++) {
|
|
56
|
+
var testElement = allElements[i];
|
|
57
|
+
if (testElement.value && testElement.value === expectedValue) {
|
|
58
|
+
return testElement;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.6.0
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// This is a third party JavaScript library from
|
|
2
|
+
// http://webfx.eae.net/dhtml/xmlextras/xmlextras.html
|
|
3
|
+
// i.e. This has not been written by ThoughtWorks.
|
|
4
|
+
|
|
5
|
+
//<script>
|
|
6
|
+
//////////////////
|
|
7
|
+
// Helper Stuff //
|
|
8
|
+
//////////////////
|
|
9
|
+
|
|
10
|
+
// used to find the Automation server name
|
|
11
|
+
function getDomDocumentPrefix() {
|
|
12
|
+
if (getDomDocumentPrefix.prefix)
|
|
13
|
+
return getDomDocumentPrefix.prefix;
|
|
14
|
+
|
|
15
|
+
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
|
|
16
|
+
var o;
|
|
17
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
18
|
+
try {
|
|
19
|
+
// try to create the objects
|
|
20
|
+
o = new ActiveXObject(prefixes[i] + ".DomDocument");
|
|
21
|
+
return getDomDocumentPrefix.prefix = prefixes[i];
|
|
22
|
+
}
|
|
23
|
+
catch (ex) {};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
throw new Error("Could not find an installed XML parser");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getXmlHttpPrefix() {
|
|
30
|
+
if (getXmlHttpPrefix.prefix)
|
|
31
|
+
return getXmlHttpPrefix.prefix;
|
|
32
|
+
|
|
33
|
+
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
|
|
34
|
+
var o;
|
|
35
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
36
|
+
try {
|
|
37
|
+
// try to create the objects
|
|
38
|
+
o = new ActiveXObject(prefixes[i] + ".XmlHttp");
|
|
39
|
+
return getXmlHttpPrefix.prefix = prefixes[i];
|
|
40
|
+
}
|
|
41
|
+
catch (ex) {};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
throw new Error("Could not find an installed XML parser");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//////////////////////////
|
|
48
|
+
// Start the Real stuff //
|
|
49
|
+
//////////////////////////
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// XmlHttp factory
|
|
53
|
+
function XmlHttp() {}
|
|
54
|
+
|
|
55
|
+
XmlHttp.create = function () {
|
|
56
|
+
try {
|
|
57
|
+
if (window.XMLHttpRequest) {
|
|
58
|
+
var req = new XMLHttpRequest();
|
|
59
|
+
|
|
60
|
+
// some versions of Moz do not support the readyState property
|
|
61
|
+
// and the onreadystate event so we patch it!
|
|
62
|
+
if (req.readyState == null) {
|
|
63
|
+
req.readyState = 1;
|
|
64
|
+
req.addEventListener("load", function () {
|
|
65
|
+
req.readyState = 4;
|
|
66
|
+
if (typeof req.onreadystatechange == "function")
|
|
67
|
+
req.onreadystatechange();
|
|
68
|
+
}, false);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return req;
|
|
72
|
+
}
|
|
73
|
+
if (window.ActiveXObject) {
|
|
74
|
+
return new ActiveXObject(getXmlHttpPrefix() + ".XmlHttp");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (ex) {}
|
|
78
|
+
// fell through
|
|
79
|
+
throw new Error("Your browser does not support XmlHttp objects");
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// XmlDocument factory
|
|
83
|
+
function XmlDocument() {}
|
|
84
|
+
|
|
85
|
+
XmlDocument.create = function () {
|
|
86
|
+
try {
|
|
87
|
+
// DOM2
|
|
88
|
+
if (document.implementation && document.implementation.createDocument) {
|
|
89
|
+
var doc = document.implementation.createDocument("", "", null);
|
|
90
|
+
|
|
91
|
+
// some versions of Moz do not support the readyState property
|
|
92
|
+
// and the onreadystate event so we patch it!
|
|
93
|
+
if (doc.readyState == null) {
|
|
94
|
+
doc.readyState = 1;
|
|
95
|
+
doc.addEventListener("load", function () {
|
|
96
|
+
doc.readyState = 4;
|
|
97
|
+
if (typeof doc.onreadystatechange == "function")
|
|
98
|
+
doc.onreadystatechange();
|
|
99
|
+
}, false);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return doc;
|
|
103
|
+
}
|
|
104
|
+
if (window.ActiveXObject)
|
|
105
|
+
return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument");
|
|
106
|
+
}
|
|
107
|
+
catch (ex) {}
|
|
108
|
+
throw new Error("Your browser does not support XmlDocument objects");
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// Create the loadXML method and xml getter for Mozilla
|
|
112
|
+
if (window.DOMParser &&
|
|
113
|
+
window.XMLSerializer &&
|
|
114
|
+
window.Node && Node.prototype && Node.prototype.__defineGetter__) {
|
|
115
|
+
|
|
116
|
+
// XMLDocument did not extend the Document interface in some versions
|
|
117
|
+
// of Mozilla. Extend both!
|
|
118
|
+
//XMLDocument.prototype.loadXML =
|
|
119
|
+
Document.prototype.loadXML = function (s) {
|
|
120
|
+
|
|
121
|
+
// parse the string to a new doc
|
|
122
|
+
var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
|
|
123
|
+
|
|
124
|
+
// remove all initial children
|
|
125
|
+
while (this.hasChildNodes())
|
|
126
|
+
this.removeChild(this.lastChild);
|
|
127
|
+
|
|
128
|
+
// insert and import nodes
|
|
129
|
+
for (var i = 0; i < doc2.childNodes.length; i++) {
|
|
130
|
+
this.appendChild(this.importNode(doc2.childNodes[i], true));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
* xml getter
|
|
137
|
+
*
|
|
138
|
+
* This serializes the DOM tree to an XML String
|
|
139
|
+
*
|
|
140
|
+
* Usage: var sXml = oNode.xml
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
// XMLDocument did not extend the Document interface in some versions
|
|
144
|
+
// of Mozilla. Extend both!
|
|
145
|
+
/*
|
|
146
|
+
XMLDocument.prototype.__defineGetter__("xml", function () {
|
|
147
|
+
return (new XMLSerializer()).serializeToString(this);
|
|
148
|
+
});
|
|
149
|
+
*/
|
|
150
|
+
Document.prototype.__defineGetter__("xml", function () {
|
|
151
|
+
return (new XMLSerializer()).serializeToString(this);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
@@ -0,0 +1,3910 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xpath.js
|
|
3
|
+
*
|
|
4
|
+
* An XPath 1.0 library for JavaScript.
|
|
5
|
+
*
|
|
6
|
+
* Cameron McCormack <cam (at) mcc.id.au>
|
|
7
|
+
*
|
|
8
|
+
* This work is licensed under the Creative Commons Attribution-ShareAlike
|
|
9
|
+
* License. To view a copy of this license, visit
|
|
10
|
+
* http://creativecommons.org/licenses/by-sa/2.0/ or send a letter to Creative
|
|
11
|
+
* Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
|
|
12
|
+
*
|
|
13
|
+
* Revision 13: May 3, 2005
|
|
14
|
+
* Node tests are case insensitive now if working in an HTML DOM.
|
|
15
|
+
*
|
|
16
|
+
* Revision 12: April 26, 2005
|
|
17
|
+
* Updated licence. Slight code changes to enable use of Dean
|
|
18
|
+
* Edwards' script compression, http://dean.edwards.name/packer/ .
|
|
19
|
+
*
|
|
20
|
+
* Revision 11: April 23, 2005
|
|
21
|
+
* Fixed bug with 'and' and 'or' operators, fix thanks to
|
|
22
|
+
* Sandy McArthur <sandy (at) mcarthur.org>.
|
|
23
|
+
*
|
|
24
|
+
* Revision 10: April 15, 2005
|
|
25
|
+
* Added support for a virtual root node, supposedly helpful for
|
|
26
|
+
* implementing XForms. Fixed problem with QName node tests and
|
|
27
|
+
* the parent axis.
|
|
28
|
+
*
|
|
29
|
+
* Revision 9: March 17, 2005
|
|
30
|
+
* Namespace resolver tweaked so using the document node as the context
|
|
31
|
+
* for namespace lookups is equivalent to using the document element.
|
|
32
|
+
*
|
|
33
|
+
* Revision 8: February 13, 2005
|
|
34
|
+
* Handle implicit declaration of 'xmlns' namespace prefix.
|
|
35
|
+
* Fixed bug when comparing nodesets.
|
|
36
|
+
* Instance data can now be associated with a FunctionResolver, and
|
|
37
|
+
* workaround for MSXML not supporting 'localName' and 'getElementById',
|
|
38
|
+
* thanks to Grant Gongaware.
|
|
39
|
+
* Fix a few problems when the context node is the root node.
|
|
40
|
+
*
|
|
41
|
+
* Revision 7: February 11, 2005
|
|
42
|
+
* Default namespace resolver fix from Grant Gongaware
|
|
43
|
+
* <grant (at) gongaware.com>.
|
|
44
|
+
*
|
|
45
|
+
* Revision 6: February 10, 2005
|
|
46
|
+
* Fixed bug in 'number' function.
|
|
47
|
+
*
|
|
48
|
+
* Revision 5: February 9, 2005
|
|
49
|
+
* Fixed bug where text nodes not getting converted to string values.
|
|
50
|
+
*
|
|
51
|
+
* Revision 4: January 21, 2005
|
|
52
|
+
* Bug in 'name' function, fix thanks to Bill Edney.
|
|
53
|
+
* Fixed incorrect processing of namespace nodes.
|
|
54
|
+
* Fixed NamespaceResolver to resolve 'xml' namespace.
|
|
55
|
+
* Implemented union '|' operator.
|
|
56
|
+
*
|
|
57
|
+
* Revision 3: January 14, 2005
|
|
58
|
+
* Fixed bug with nodeset comparisons, bug lexing < and >.
|
|
59
|
+
*
|
|
60
|
+
* Revision 2: October 26, 2004
|
|
61
|
+
* QName node test namespace handling fixed. Few other bug fixes.
|
|
62
|
+
*
|
|
63
|
+
* Revision 1: August 13, 2004
|
|
64
|
+
* Bug fixes from William J. Edney <bedney (at) technicalpursuit.com>.
|
|
65
|
+
* Added minimal licence.
|
|
66
|
+
*
|
|
67
|
+
* Initial version: June 14, 2004
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
// XPathParser ///////////////////////////////////////////////////////////////
|
|
71
|
+
|
|
72
|
+
XPathParser.prototype = new Object();
|
|
73
|
+
XPathParser.prototype.constructor = XPathParser;
|
|
74
|
+
XPathParser.superclass = Object.prototype;
|
|
75
|
+
|
|
76
|
+
function XPathParser() {
|
|
77
|
+
this.init();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
XPathParser.prototype.init = function() {
|
|
81
|
+
this.reduceActions = [];
|
|
82
|
+
|
|
83
|
+
this.reduceActions[3] = function(rhs) {
|
|
84
|
+
return new OrOperation(rhs[0], rhs[2]);
|
|
85
|
+
};
|
|
86
|
+
this.reduceActions[5] = function(rhs) {
|
|
87
|
+
return new AndOperation(rhs[0], rhs[2]);
|
|
88
|
+
};
|
|
89
|
+
this.reduceActions[7] = function(rhs) {
|
|
90
|
+
return new EqualsOperation(rhs[0], rhs[2]);
|
|
91
|
+
};
|
|
92
|
+
this.reduceActions[8] = function(rhs) {
|
|
93
|
+
return new NotEqualOperation(rhs[0], rhs[2]);
|
|
94
|
+
};
|
|
95
|
+
this.reduceActions[10] = function(rhs) {
|
|
96
|
+
return new LessThanOperation(rhs[0], rhs[2]);
|
|
97
|
+
};
|
|
98
|
+
this.reduceActions[11] = function(rhs) {
|
|
99
|
+
return new GreaterThanOperation(rhs[0], rhs[2]);
|
|
100
|
+
};
|
|
101
|
+
this.reduceActions[12] = function(rhs) {
|
|
102
|
+
return new LessThanOrEqualOperation(rhs[0], rhs[2]);
|
|
103
|
+
};
|
|
104
|
+
this.reduceActions[13] = function(rhs) {
|
|
105
|
+
return new GreaterThanOrEqualOperation(rhs[0], rhs[2]);
|
|
106
|
+
};
|
|
107
|
+
this.reduceActions[15] = function(rhs) {
|
|
108
|
+
return new PlusOperation(rhs[0], rhs[2]);
|
|
109
|
+
};
|
|
110
|
+
this.reduceActions[16] = function(rhs) {
|
|
111
|
+
return new MinusOperation(rhs[0], rhs[2]);
|
|
112
|
+
};
|
|
113
|
+
this.reduceActions[18] = function(rhs) {
|
|
114
|
+
return new MultiplyOperation(rhs[0], rhs[2]);
|
|
115
|
+
};
|
|
116
|
+
this.reduceActions[19] = function(rhs) {
|
|
117
|
+
return new DivOperation(rhs[0], rhs[2]);
|
|
118
|
+
};
|
|
119
|
+
this.reduceActions[20] = function(rhs) {
|
|
120
|
+
return new ModOperation(rhs[0], rhs[2]);
|
|
121
|
+
};
|
|
122
|
+
this.reduceActions[22] = function(rhs) {
|
|
123
|
+
return new UnaryMinusOperation(rhs[1]);
|
|
124
|
+
};
|
|
125
|
+
this.reduceActions[24] = function(rhs) {
|
|
126
|
+
return new BarOperation(rhs[0], rhs[2]);
|
|
127
|
+
};
|
|
128
|
+
this.reduceActions[25] = function(rhs) {
|
|
129
|
+
return new PathExpr(undefined, undefined, rhs[0]);
|
|
130
|
+
};
|
|
131
|
+
this.reduceActions[27] = function(rhs) {
|
|
132
|
+
rhs[0].locationPath = rhs[2];
|
|
133
|
+
return rhs[0];
|
|
134
|
+
};
|
|
135
|
+
this.reduceActions[28] = function(rhs) {
|
|
136
|
+
rhs[0].locationPath = rhs[2];
|
|
137
|
+
rhs[0].locationPath.steps.unshift(new Step(Step.DESCENDANTORSELF, new NodeTest(NodeTest.NODE, undefined), []));
|
|
138
|
+
return rhs[0];
|
|
139
|
+
};
|
|
140
|
+
this.reduceActions[29] = function(rhs) {
|
|
141
|
+
return new PathExpr(rhs[0], [], undefined);
|
|
142
|
+
};
|
|
143
|
+
this.reduceActions[30] = function(rhs) {
|
|
144
|
+
if (Utilities.instance_of(rhs[0], PathExpr)) {
|
|
145
|
+
if (rhs[0].filterPredicates == undefined) {
|
|
146
|
+
rhs[0].filterPredicates = [];
|
|
147
|
+
}
|
|
148
|
+
rhs[0].filterPredicates.push(rhs[1]);
|
|
149
|
+
return rhs[0];
|
|
150
|
+
} else {
|
|
151
|
+
return new PathExpr(rhs[0], [rhs[1]], undefined);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
this.reduceActions[32] = function(rhs) {
|
|
155
|
+
return rhs[1];
|
|
156
|
+
};
|
|
157
|
+
this.reduceActions[33] = function(rhs) {
|
|
158
|
+
return new XString(rhs[0]);
|
|
159
|
+
};
|
|
160
|
+
this.reduceActions[34] = function(rhs) {
|
|
161
|
+
return new XNumber(rhs[0]);
|
|
162
|
+
};
|
|
163
|
+
this.reduceActions[36] = function(rhs) {
|
|
164
|
+
return new FunctionCall(rhs[0], []);
|
|
165
|
+
};
|
|
166
|
+
this.reduceActions[37] = function(rhs) {
|
|
167
|
+
return new FunctionCall(rhs[0], rhs[2]);
|
|
168
|
+
};
|
|
169
|
+
this.reduceActions[38] = function(rhs) {
|
|
170
|
+
return [ rhs[0] ];
|
|
171
|
+
};
|
|
172
|
+
this.reduceActions[39] = function(rhs) {
|
|
173
|
+
rhs[2].unshift(rhs[0]);
|
|
174
|
+
return rhs[2];
|
|
175
|
+
};
|
|
176
|
+
this.reduceActions[43] = function(rhs) {
|
|
177
|
+
return new LocationPath(true, []);
|
|
178
|
+
};
|
|
179
|
+
this.reduceActions[44] = function(rhs) {
|
|
180
|
+
rhs[1].absolute = true;
|
|
181
|
+
return rhs[1];
|
|
182
|
+
};
|
|
183
|
+
this.reduceActions[46] = function(rhs) {
|
|
184
|
+
return new LocationPath(false, [ rhs[0] ]);
|
|
185
|
+
};
|
|
186
|
+
this.reduceActions[47] = function(rhs) {
|
|
187
|
+
rhs[0].steps.push(rhs[2]);
|
|
188
|
+
return rhs[0];
|
|
189
|
+
};
|
|
190
|
+
this.reduceActions[49] = function(rhs) {
|
|
191
|
+
return new Step(rhs[0], rhs[1], []);
|
|
192
|
+
};
|
|
193
|
+
this.reduceActions[50] = function(rhs) {
|
|
194
|
+
return new Step(Step.CHILD, rhs[0], []);
|
|
195
|
+
};
|
|
196
|
+
this.reduceActions[51] = function(rhs) {
|
|
197
|
+
return new Step(rhs[0], rhs[1], rhs[2]);
|
|
198
|
+
};
|
|
199
|
+
this.reduceActions[52] = function(rhs) {
|
|
200
|
+
return new Step(Step.CHILD, rhs[0], rhs[1]);
|
|
201
|
+
};
|
|
202
|
+
this.reduceActions[54] = function(rhs) {
|
|
203
|
+
return [ rhs[0] ];
|
|
204
|
+
};
|
|
205
|
+
this.reduceActions[55] = function(rhs) {
|
|
206
|
+
rhs[1].unshift(rhs[0]);
|
|
207
|
+
return rhs[1];
|
|
208
|
+
};
|
|
209
|
+
this.reduceActions[56] = function(rhs) {
|
|
210
|
+
if (rhs[0] == "ancestor") {
|
|
211
|
+
return Step.ANCESTOR;
|
|
212
|
+
} else if (rhs[0] == "ancestor-or-self") {
|
|
213
|
+
return Step.ANCESTORORSELF;
|
|
214
|
+
} else if (rhs[0] == "attribute") {
|
|
215
|
+
return Step.ATTRIBUTE;
|
|
216
|
+
} else if (rhs[0] == "child") {
|
|
217
|
+
return Step.CHILD;
|
|
218
|
+
} else if (rhs[0] == "descendant") {
|
|
219
|
+
return Step.DESCENDANT;
|
|
220
|
+
} else if (rhs[0] == "descendant-or-self") {
|
|
221
|
+
return Step.DESCENDANTORSELF;
|
|
222
|
+
} else if (rhs[0] == "following") {
|
|
223
|
+
return Step.FOLLOWING;
|
|
224
|
+
} else if (rhs[0] == "following-sibling") {
|
|
225
|
+
return Step.FOLLOWINGSIBLING;
|
|
226
|
+
} else if (rhs[0] == "namespace") {
|
|
227
|
+
return Step.NAMESPACE;
|
|
228
|
+
} else if (rhs[0] == "parent") {
|
|
229
|
+
return Step.PARENT;
|
|
230
|
+
} else if (rhs[0] == "preceding") {
|
|
231
|
+
return Step.PRECEDING;
|
|
232
|
+
} else if (rhs[0] == "preceding-sibling") {
|
|
233
|
+
return Step.PRECEDINGSIBLING;
|
|
234
|
+
} else if (rhs[0] == "self") {
|
|
235
|
+
return Step.SELF;
|
|
236
|
+
}
|
|
237
|
+
return -1;
|
|
238
|
+
};
|
|
239
|
+
this.reduceActions[57] = function(rhs) {
|
|
240
|
+
return Step.ATTRIBUTE;
|
|
241
|
+
};
|
|
242
|
+
this.reduceActions[59] = function(rhs) {
|
|
243
|
+
if (rhs[0] == "comment") {
|
|
244
|
+
return new NodeTest(NodeTest.COMMENT, undefined);
|
|
245
|
+
} else if (rhs[0] == "text") {
|
|
246
|
+
return new NodeTest(NodeTest.TEXT, undefined);
|
|
247
|
+
} else if (rhs[0] == "processing-instruction") {
|
|
248
|
+
return new NodeTest(NodeTest.PI, undefined);
|
|
249
|
+
} else if (rhs[0] == "node") {
|
|
250
|
+
return new NodeTest(NodeTest.NODE, undefined);
|
|
251
|
+
}
|
|
252
|
+
return new NodeTest(-1, undefined);
|
|
253
|
+
};
|
|
254
|
+
this.reduceActions[60] = function(rhs) {
|
|
255
|
+
return new NodeTest(NodeTest.PI, rhs[2]);
|
|
256
|
+
};
|
|
257
|
+
this.reduceActions[61] = function(rhs) {
|
|
258
|
+
return rhs[1];
|
|
259
|
+
};
|
|
260
|
+
this.reduceActions[63] = function(rhs) {
|
|
261
|
+
rhs[1].absolute = true;
|
|
262
|
+
rhs[1].steps.unshift(new Step(Step.DESCENDANTORSELF, new NodeTest(NodeTest.NODE, undefined), []));
|
|
263
|
+
return rhs[1];
|
|
264
|
+
};
|
|
265
|
+
this.reduceActions[64] = function(rhs) {
|
|
266
|
+
rhs[0].steps.push(new Step(Step.DESCENDANTORSELF, new NodeTest(NodeTest.NODE, undefined), []));
|
|
267
|
+
rhs[0].steps.push(rhs[2]);
|
|
268
|
+
return rhs[0];
|
|
269
|
+
};
|
|
270
|
+
this.reduceActions[65] = function(rhs) {
|
|
271
|
+
return new Step(Step.SELF, new NodeTest(NodeTest.NODE, undefined), []);
|
|
272
|
+
};
|
|
273
|
+
this.reduceActions[66] = function(rhs) {
|
|
274
|
+
return new Step(Step.PARENT, new NodeTest(NodeTest.NODE, undefined), []);
|
|
275
|
+
};
|
|
276
|
+
this.reduceActions[67] = function(rhs) {
|
|
277
|
+
return new VariableReference(rhs[1]);
|
|
278
|
+
};
|
|
279
|
+
this.reduceActions[68] = function(rhs) {
|
|
280
|
+
return new NodeTest(NodeTest.NAMETESTANY, undefined);
|
|
281
|
+
};
|
|
282
|
+
this.reduceActions[69] = function(rhs) {
|
|
283
|
+
return new NodeTest(NodeTest.NAMETESTPREFIXANY, rhs[0].substring(0, rhs[0].indexOf(":") - 1));
|
|
284
|
+
};
|
|
285
|
+
this.reduceActions[70] = function(rhs) {
|
|
286
|
+
return new NodeTest(NodeTest.NAMETESTQNAME, rhs[0]);
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
XPathParser.actionTable = [
|
|
291
|
+
" s s sssssssss s ss s ss",
|
|
292
|
+
" s ",
|
|
293
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
294
|
+
" rrrrr ",
|
|
295
|
+
" s s sssssssss s ss s ss",
|
|
296
|
+
"rs rrrrrrrr s sssssrrrrrr rrs rs ",
|
|
297
|
+
" s s sssssssss s ss s ss",
|
|
298
|
+
" s ",
|
|
299
|
+
" s ",
|
|
300
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
301
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
302
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
303
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
304
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
305
|
+
" s ",
|
|
306
|
+
" s ",
|
|
307
|
+
" s s sssss s s ",
|
|
308
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
309
|
+
"a ",
|
|
310
|
+
"r s rr r ",
|
|
311
|
+
"r sr rr r ",
|
|
312
|
+
"r s rr s rr r ",
|
|
313
|
+
"r rssrr rss rr r ",
|
|
314
|
+
"r rrrrr rrrss rr r ",
|
|
315
|
+
"r rrrrrsss rrrrr rr r ",
|
|
316
|
+
"r rrrrrrrr rrrrr rr r ",
|
|
317
|
+
"r rrrrrrrr rrrrrs rr r ",
|
|
318
|
+
"r rrrrrrrr rrrrrr rr r ",
|
|
319
|
+
"r rrrrrrrr rrrrrr rr r ",
|
|
320
|
+
"r srrrrrrrr rrrrrrs rr sr ",
|
|
321
|
+
"r srrrrrrrr rrrrrrs rr r ",
|
|
322
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
323
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
324
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
325
|
+
"r rrrrrrrr rrrrrr rr r ",
|
|
326
|
+
"r rrrrrrrr rrrrrr rr r ",
|
|
327
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
328
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
329
|
+
" sssss ",
|
|
330
|
+
"r rrrrrrrrr rrrrrrr rr sr ",
|
|
331
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
332
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
333
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
334
|
+
" s ",
|
|
335
|
+
"r srrrrrrrr rrrrrrs rr r ",
|
|
336
|
+
"r rrrrrrrr rrrrr rr r ",
|
|
337
|
+
" s ",
|
|
338
|
+
" s ",
|
|
339
|
+
" rrrrr ",
|
|
340
|
+
" s s sssssssss s sss s ss",
|
|
341
|
+
"r srrrrrrrr rrrrrrs rr r ",
|
|
342
|
+
" s s sssssssss s ss s ss",
|
|
343
|
+
" s s sssssssss s ss s ss",
|
|
344
|
+
" s s sssssssss s ss s ss",
|
|
345
|
+
" s s sssssssss s ss s ss",
|
|
346
|
+
" s s sssssssss s ss s ss",
|
|
347
|
+
" s s sssssssss s ss s ss",
|
|
348
|
+
" s s sssssssss s ss s ss",
|
|
349
|
+
" s s sssssssss s ss s ss",
|
|
350
|
+
" s s sssssssss s ss s ss",
|
|
351
|
+
" s s sssssssss s ss s ss",
|
|
352
|
+
" s s sssssssss s ss s ss",
|
|
353
|
+
" s s sssssssss s ss s ss",
|
|
354
|
+
" s s sssssssss s ss s ss",
|
|
355
|
+
" s s sssssssss ss s ss",
|
|
356
|
+
" s s sssssssss s ss s ss",
|
|
357
|
+
" s s sssss s s ",
|
|
358
|
+
" s s sssss s s ",
|
|
359
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
360
|
+
" s s sssss s s ",
|
|
361
|
+
" s s sssss s s ",
|
|
362
|
+
"r rrrrrrrrr rrrrrrr rr sr ",
|
|
363
|
+
"r rrrrrrrrr rrrrrrr rr sr ",
|
|
364
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
365
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
366
|
+
" s ",
|
|
367
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
368
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
369
|
+
" rr ",
|
|
370
|
+
" s ",
|
|
371
|
+
" rs ",
|
|
372
|
+
"r sr rr r ",
|
|
373
|
+
"r s rr s rr r ",
|
|
374
|
+
"r rssrr rss rr r ",
|
|
375
|
+
"r rssrr rss rr r ",
|
|
376
|
+
"r rrrrr rrrss rr r ",
|
|
377
|
+
"r rrrrr rrrss rr r ",
|
|
378
|
+
"r rrrrr rrrss rr r ",
|
|
379
|
+
"r rrrrr rrrss rr r ",
|
|
380
|
+
"r rrrrrsss rrrrr rr r ",
|
|
381
|
+
"r rrrrrsss rrrrr rr r ",
|
|
382
|
+
"r rrrrrrrr rrrrr rr r ",
|
|
383
|
+
"r rrrrrrrr rrrrr rr r ",
|
|
384
|
+
"r rrrrrrrr rrrrr rr r ",
|
|
385
|
+
"r rrrrrrrr rrrrrr rr r ",
|
|
386
|
+
" r ",
|
|
387
|
+
" s ",
|
|
388
|
+
"r srrrrrrrr rrrrrrs rr r ",
|
|
389
|
+
"r srrrrrrrr rrrrrrs rr r ",
|
|
390
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
391
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
392
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
393
|
+
"r rrrrrrrrr rrrrrrr rr r ",
|
|
394
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
395
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
396
|
+
" s s sssssssss s ss s ss",
|
|
397
|
+
"r rrrrrrrrr rrrrrrr rr rr ",
|
|
398
|
+
" r "
|
|
399
|
+
];
|
|
400
|
+
|
|
401
|
+
XPathParser.actionTableNumber = [
|
|
402
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
403
|
+
" J ",
|
|
404
|
+
"a aaaaaaaaa aaaaaaa aa a ",
|
|
405
|
+
" YYYYY ",
|
|
406
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
407
|
+
"K1 KKKKKKKK . +*)('KKKKKK KK# K\" ",
|
|
408
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
409
|
+
" N ",
|
|
410
|
+
" O ",
|
|
411
|
+
"e eeeeeeeee eeeeeee ee ee ",
|
|
412
|
+
"f fffffffff fffffff ff ff ",
|
|
413
|
+
"d ddddddddd ddddddd dd dd ",
|
|
414
|
+
"B BBBBBBBBB BBBBBBB BB BB ",
|
|
415
|
+
"A AAAAAAAAA AAAAAAA AA AA ",
|
|
416
|
+
" P ",
|
|
417
|
+
" Q ",
|
|
418
|
+
" 1 . +*)(' # \" ",
|
|
419
|
+
"b bbbbbbbbb bbbbbbb bb b ",
|
|
420
|
+
" ",
|
|
421
|
+
"! S !! ! ",
|
|
422
|
+
"\" T\" \"\" \" ",
|
|
423
|
+
"$ V $$ U $$ $ ",
|
|
424
|
+
"& &ZY&& &XW && & ",
|
|
425
|
+
") ))))) )))\\[ )) ) ",
|
|
426
|
+
". ....._^] ..... .. . ",
|
|
427
|
+
"1 11111111 11111 11 1 ",
|
|
428
|
+
"5 55555555 55555` 55 5 ",
|
|
429
|
+
"7 77777777 777777 77 7 ",
|
|
430
|
+
"9 99999999 999999 99 9 ",
|
|
431
|
+
": c:::::::: ::::::b :: a: ",
|
|
432
|
+
"I fIIIIIIII IIIIIIe II I ",
|
|
433
|
+
"= ========= ======= == == ",
|
|
434
|
+
"? ????????? ??????? ?? ?? ",
|
|
435
|
+
"C CCCCCCCCC CCCCCCC CC CC ",
|
|
436
|
+
"J JJJJJJJJ JJJJJJ JJ J ",
|
|
437
|
+
"M MMMMMMMM MMMMMM MM M ",
|
|
438
|
+
"N NNNNNNNNN NNNNNNN NN N ",
|
|
439
|
+
"P PPPPPPPPP PPPPPPP PP P ",
|
|
440
|
+
" +*)(' ",
|
|
441
|
+
"R RRRRRRRRR RRRRRRR RR aR ",
|
|
442
|
+
"U UUUUUUUUU UUUUUUU UU U ",
|
|
443
|
+
"Z ZZZZZZZZZ ZZZZZZZ ZZ ZZ ",
|
|
444
|
+
"c ccccccccc ccccccc cc cc ",
|
|
445
|
+
" j ",
|
|
446
|
+
"L fLLLLLLLL LLLLLLe LL L ",
|
|
447
|
+
"6 66666666 66666 66 6 ",
|
|
448
|
+
" k ",
|
|
449
|
+
" l ",
|
|
450
|
+
" XXXXX ",
|
|
451
|
+
" 1 0 /.-,+*)(' & %$m # \"!",
|
|
452
|
+
"_ f________ ______e __ _ ",
|
|
453
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
454
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
455
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
456
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
457
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
458
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
459
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
460
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
461
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
462
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
463
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
464
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
465
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
466
|
+
" 1 0 /.-,+*)(' %$ # \"!",
|
|
467
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
468
|
+
" 1 . +*)(' # \" ",
|
|
469
|
+
" 1 . +*)(' # \" ",
|
|
470
|
+
"> >>>>>>>>> >>>>>>> >> >> ",
|
|
471
|
+
" 1 . +*)(' # \" ",
|
|
472
|
+
" 1 . +*)(' # \" ",
|
|
473
|
+
"Q QQQQQQQQQ QQQQQQQ QQ aQ ",
|
|
474
|
+
"V VVVVVVVVV VVVVVVV VV aV ",
|
|
475
|
+
"T TTTTTTTTT TTTTTTT TT T ",
|
|
476
|
+
"@ @@@@@@@@@ @@@@@@@ @@ @@ ",
|
|
477
|
+
" \x87 ",
|
|
478
|
+
"[ [[[[[[[[[ [[[[[[[ [[ [[ ",
|
|
479
|
+
"D DDDDDDDDD DDDDDDD DD DD ",
|
|
480
|
+
" HH ",
|
|
481
|
+
" \x88 ",
|
|
482
|
+
" F\x89 ",
|
|
483
|
+
"# T# ## # ",
|
|
484
|
+
"% V %% U %% % ",
|
|
485
|
+
"' 'ZY'' 'XW '' ' ",
|
|
486
|
+
"( (ZY(( (XW (( ( ",
|
|
487
|
+
"+ +++++ +++\\[ ++ + ",
|
|
488
|
+
"* ***** ***\\[ ** * ",
|
|
489
|
+
"- ----- ---\\[ -- - ",
|
|
490
|
+
", ,,,,, ,,,\\[ ,, , ",
|
|
491
|
+
"0 00000_^] 00000 00 0 ",
|
|
492
|
+
"/ /////_^] ///// // / ",
|
|
493
|
+
"2 22222222 22222 22 2 ",
|
|
494
|
+
"3 33333333 33333 33 3 ",
|
|
495
|
+
"4 44444444 44444 44 4 ",
|
|
496
|
+
"8 88888888 888888 88 8 ",
|
|
497
|
+
" ^ ",
|
|
498
|
+
" \x8a ",
|
|
499
|
+
"; f;;;;;;;; ;;;;;;e ;; ; ",
|
|
500
|
+
"< f<<<<<<<< <<<<<<e << < ",
|
|
501
|
+
"O OOOOOOOOO OOOOOOO OO O ",
|
|
502
|
+
"` ````````` ``````` `` ` ",
|
|
503
|
+
"S SSSSSSSSS SSSSSSS SS S ",
|
|
504
|
+
"W WWWWWWWWW WWWWWWW WW W ",
|
|
505
|
+
"\\ \\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\ \\\\ \\\\ ",
|
|
506
|
+
"E EEEEEEEEE EEEEEEE EE EE ",
|
|
507
|
+
" 1 0 /.-,+*)(' & %$ # \"!",
|
|
508
|
+
"] ]]]]]]]]] ]]]]]]] ]] ]] ",
|
|
509
|
+
" G "
|
|
510
|
+
];
|
|
511
|
+
|
|
512
|
+
XPathParser.gotoTable = [
|
|
513
|
+
"3456789:;<=>?@ AB CDEFGH IJ ",
|
|
514
|
+
" ",
|
|
515
|
+
" ",
|
|
516
|
+
" ",
|
|
517
|
+
"L456789:;<=>?@ AB CDEFGH IJ ",
|
|
518
|
+
" M EFGH IJ ",
|
|
519
|
+
" N;<=>?@ AB CDEFGH IJ ",
|
|
520
|
+
" ",
|
|
521
|
+
" ",
|
|
522
|
+
" ",
|
|
523
|
+
" ",
|
|
524
|
+
" ",
|
|
525
|
+
" ",
|
|
526
|
+
" ",
|
|
527
|
+
" ",
|
|
528
|
+
" ",
|
|
529
|
+
" S EFGH IJ ",
|
|
530
|
+
" ",
|
|
531
|
+
" ",
|
|
532
|
+
" ",
|
|
533
|
+
" ",
|
|
534
|
+
" ",
|
|
535
|
+
" ",
|
|
536
|
+
" ",
|
|
537
|
+
" ",
|
|
538
|
+
" ",
|
|
539
|
+
" ",
|
|
540
|
+
" ",
|
|
541
|
+
" ",
|
|
542
|
+
" e ",
|
|
543
|
+
" ",
|
|
544
|
+
" ",
|
|
545
|
+
" ",
|
|
546
|
+
" ",
|
|
547
|
+
" ",
|
|
548
|
+
" ",
|
|
549
|
+
" ",
|
|
550
|
+
" ",
|
|
551
|
+
" h J ",
|
|
552
|
+
" i j ",
|
|
553
|
+
" ",
|
|
554
|
+
" ",
|
|
555
|
+
" ",
|
|
556
|
+
" ",
|
|
557
|
+
" ",
|
|
558
|
+
" ",
|
|
559
|
+
" ",
|
|
560
|
+
" ",
|
|
561
|
+
" ",
|
|
562
|
+
"o456789:;<=>?@ ABpqCDEFGH IJ ",
|
|
563
|
+
" ",
|
|
564
|
+
" r6789:;<=>?@ AB CDEFGH IJ ",
|
|
565
|
+
" s789:;<=>?@ AB CDEFGH IJ ",
|
|
566
|
+
" t89:;<=>?@ AB CDEFGH IJ ",
|
|
567
|
+
" u89:;<=>?@ AB CDEFGH IJ ",
|
|
568
|
+
" v9:;<=>?@ AB CDEFGH IJ ",
|
|
569
|
+
" w9:;<=>?@ AB CDEFGH IJ ",
|
|
570
|
+
" x9:;<=>?@ AB CDEFGH IJ ",
|
|
571
|
+
" y9:;<=>?@ AB CDEFGH IJ ",
|
|
572
|
+
" z:;<=>?@ AB CDEFGH IJ ",
|
|
573
|
+
" {:;<=>?@ AB CDEFGH IJ ",
|
|
574
|
+
" |;<=>?@ AB CDEFGH IJ ",
|
|
575
|
+
" };<=>?@ AB CDEFGH IJ ",
|
|
576
|
+
" ~;<=>?@ AB CDEFGH IJ ",
|
|
577
|
+
" \x7f=>?@ AB CDEFGH IJ ",
|
|
578
|
+
"\x80456789:;<=>?@ AB CDEFGH IJ\x81",
|
|
579
|
+
" \x82 EFGH IJ ",
|
|
580
|
+
" \x83 EFGH IJ ",
|
|
581
|
+
" ",
|
|
582
|
+
" \x84 GH IJ ",
|
|
583
|
+
" \x85 GH IJ ",
|
|
584
|
+
" i \x86 ",
|
|
585
|
+
" i \x87 ",
|
|
586
|
+
" ",
|
|
587
|
+
" ",
|
|
588
|
+
" ",
|
|
589
|
+
" ",
|
|
590
|
+
" ",
|
|
591
|
+
" ",
|
|
592
|
+
" ",
|
|
593
|
+
" ",
|
|
594
|
+
" ",
|
|
595
|
+
" ",
|
|
596
|
+
" ",
|
|
597
|
+
" ",
|
|
598
|
+
" ",
|
|
599
|
+
" ",
|
|
600
|
+
" ",
|
|
601
|
+
" ",
|
|
602
|
+
" ",
|
|
603
|
+
" ",
|
|
604
|
+
" ",
|
|
605
|
+
" ",
|
|
606
|
+
" ",
|
|
607
|
+
" ",
|
|
608
|
+
" ",
|
|
609
|
+
" ",
|
|
610
|
+
" ",
|
|
611
|
+
" ",
|
|
612
|
+
" ",
|
|
613
|
+
" ",
|
|
614
|
+
" ",
|
|
615
|
+
" ",
|
|
616
|
+
" ",
|
|
617
|
+
" ",
|
|
618
|
+
"o456789:;<=>?@ AB\x8cqCDEFGH IJ ",
|
|
619
|
+
" ",
|
|
620
|
+
" "
|
|
621
|
+
];
|
|
622
|
+
|
|
623
|
+
XPathParser.productions = [
|
|
624
|
+
[1, 1, 2],
|
|
625
|
+
[2, 1, 3],
|
|
626
|
+
[3, 1, 4],
|
|
627
|
+
[3, 3, 3, -9, 4],
|
|
628
|
+
[4, 1, 5],
|
|
629
|
+
[4, 3, 4, -8, 5],
|
|
630
|
+
[5, 1, 6],
|
|
631
|
+
[5, 3, 5, -22, 6],
|
|
632
|
+
[5, 3, 5, -5, 6],
|
|
633
|
+
[6, 1, 7],
|
|
634
|
+
[6, 3, 6, -23, 7],
|
|
635
|
+
[6, 3, 6, -24, 7],
|
|
636
|
+
[6, 3, 6, -6, 7],
|
|
637
|
+
[6, 3, 6, -7, 7],
|
|
638
|
+
[7, 1, 8],
|
|
639
|
+
[7, 3, 7, -25, 8],
|
|
640
|
+
[7, 3, 7, -26, 8],
|
|
641
|
+
[8, 1, 9],
|
|
642
|
+
[8, 3, 8, -12, 9],
|
|
643
|
+
[8, 3, 8, -11, 9],
|
|
644
|
+
[8, 3, 8, -10, 9],
|
|
645
|
+
[9, 1, 10],
|
|
646
|
+
[9, 2, -26, 9],
|
|
647
|
+
[10, 1, 11],
|
|
648
|
+
[10, 3, 10, -27, 11],
|
|
649
|
+
[11, 1, 12],
|
|
650
|
+
[11, 1, 13],
|
|
651
|
+
[11, 3, 13, -28, 14],
|
|
652
|
+
[11, 3, 13, -4, 14],
|
|
653
|
+
[13, 1, 15],
|
|
654
|
+
[13, 2, 13, 16],
|
|
655
|
+
[15, 1, 17],
|
|
656
|
+
[15, 3, -29, 2, -30],
|
|
657
|
+
[15, 1, -15],
|
|
658
|
+
[15, 1, -16],
|
|
659
|
+
[15, 1, 18],
|
|
660
|
+
[18, 3, -13, -29, -30],
|
|
661
|
+
[18, 4, -13, -29, 19, -30],
|
|
662
|
+
[19, 1, 20],
|
|
663
|
+
[19, 3, 20, -31, 19],
|
|
664
|
+
[20, 1, 2],
|
|
665
|
+
[12, 1, 14],
|
|
666
|
+
[12, 1, 21],
|
|
667
|
+
[21, 1, -28],
|
|
668
|
+
[21, 2, -28, 14],
|
|
669
|
+
[21, 1, 22],
|
|
670
|
+
[14, 1, 23],
|
|
671
|
+
[14, 3, 14, -28, 23],
|
|
672
|
+
[14, 1, 24],
|
|
673
|
+
[23, 2, 25, 26],
|
|
674
|
+
[23, 1, 26],
|
|
675
|
+
[23, 3, 25, 26, 27],
|
|
676
|
+
[23, 2, 26, 27],
|
|
677
|
+
[23, 1, 28],
|
|
678
|
+
[27, 1, 16],
|
|
679
|
+
[27, 2, 16, 27],
|
|
680
|
+
[25, 2, -14, -3],
|
|
681
|
+
[25, 1, -32],
|
|
682
|
+
[26, 1, 29],
|
|
683
|
+
[26, 3, -20, -29, -30],
|
|
684
|
+
[26, 4, -21, -29, -15, -30],
|
|
685
|
+
[16, 3, -33, 30, -34],
|
|
686
|
+
[30, 1, 2],
|
|
687
|
+
[22, 2, -4, 14],
|
|
688
|
+
[24, 3, 14, -4, 23],
|
|
689
|
+
[28, 1, -35],
|
|
690
|
+
[28, 1, -2],
|
|
691
|
+
[17, 2, -36, -18],
|
|
692
|
+
[29, 1, -17],
|
|
693
|
+
[29, 1, -19],
|
|
694
|
+
[29, 1, -18]
|
|
695
|
+
];
|
|
696
|
+
|
|
697
|
+
XPathParser.DOUBLEDOT = 2;
|
|
698
|
+
XPathParser.DOUBLECOLON = 3;
|
|
699
|
+
XPathParser.DOUBLESLASH = 4;
|
|
700
|
+
XPathParser.NOTEQUAL = 5;
|
|
701
|
+
XPathParser.LESSTHANOREQUAL = 6;
|
|
702
|
+
XPathParser.GREATERTHANOREQUAL = 7;
|
|
703
|
+
XPathParser.AND = 8;
|
|
704
|
+
XPathParser.OR = 9;
|
|
705
|
+
XPathParser.MOD = 10;
|
|
706
|
+
XPathParser.DIV = 11;
|
|
707
|
+
XPathParser.MULTIPLYOPERATOR = 12;
|
|
708
|
+
XPathParser.FUNCTIONNAME = 13;
|
|
709
|
+
XPathParser.AXISNAME = 14;
|
|
710
|
+
XPathParser.LITERAL = 15;
|
|
711
|
+
XPathParser.NUMBER = 16;
|
|
712
|
+
XPathParser.ASTERISKNAMETEST = 17;
|
|
713
|
+
XPathParser.QNAME = 18;
|
|
714
|
+
XPathParser.NCNAMECOLONASTERISK = 19;
|
|
715
|
+
XPathParser.NODETYPE = 20;
|
|
716
|
+
XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL = 21;
|
|
717
|
+
XPathParser.EQUALS = 22;
|
|
718
|
+
XPathParser.LESSTHAN = 23;
|
|
719
|
+
XPathParser.GREATERTHAN = 24;
|
|
720
|
+
XPathParser.PLUS = 25;
|
|
721
|
+
XPathParser.MINUS = 26;
|
|
722
|
+
XPathParser.BAR = 27;
|
|
723
|
+
XPathParser.SLASH = 28;
|
|
724
|
+
XPathParser.LEFTPARENTHESIS = 29;
|
|
725
|
+
XPathParser.RIGHTPARENTHESIS = 30;
|
|
726
|
+
XPathParser.COMMA = 31;
|
|
727
|
+
XPathParser.AT = 32;
|
|
728
|
+
XPathParser.LEFTBRACKET = 33;
|
|
729
|
+
XPathParser.RIGHTBRACKET = 34;
|
|
730
|
+
XPathParser.DOT = 35;
|
|
731
|
+
XPathParser.DOLLAR = 36;
|
|
732
|
+
|
|
733
|
+
XPathParser.prototype.tokenize = function(s1) {
|
|
734
|
+
var types = [];
|
|
735
|
+
var values = [];
|
|
736
|
+
var s = s1 + '\0';
|
|
737
|
+
|
|
738
|
+
var pos = 0;
|
|
739
|
+
var c = s.charAt(pos++);
|
|
740
|
+
while (1) {
|
|
741
|
+
while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
|
|
742
|
+
c = s.charAt(pos++);
|
|
743
|
+
}
|
|
744
|
+
if (c == '\0' || pos >= s.length) {
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (c == '(') {
|
|
749
|
+
types.push(XPathParser.LEFTPARENTHESIS);
|
|
750
|
+
values.push(c);
|
|
751
|
+
c = s.charAt(pos++);
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
if (c == ')') {
|
|
755
|
+
types.push(XPathParser.RIGHTPARENTHESIS);
|
|
756
|
+
values.push(c);
|
|
757
|
+
c = s.charAt(pos++);
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
if (c == '[') {
|
|
761
|
+
types.push(XPathParser.LEFTBRACKET);
|
|
762
|
+
values.push(c);
|
|
763
|
+
c = s.charAt(pos++);
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
if (c == ']') {
|
|
767
|
+
types.push(XPathParser.RIGHTBRACKET);
|
|
768
|
+
values.push(c);
|
|
769
|
+
c = s.charAt(pos++);
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
if (c == '@') {
|
|
773
|
+
types.push(XPathParser.AT);
|
|
774
|
+
values.push(c);
|
|
775
|
+
c = s.charAt(pos++);
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (c == ',') {
|
|
779
|
+
types.push(XPathParser.COMMA);
|
|
780
|
+
values.push(c);
|
|
781
|
+
c = s.charAt(pos++);
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
if (c == '|') {
|
|
785
|
+
types.push(XPathParser.BAR);
|
|
786
|
+
values.push(c);
|
|
787
|
+
c = s.charAt(pos++);
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
if (c == '+') {
|
|
791
|
+
types.push(XPathParser.PLUS);
|
|
792
|
+
values.push(c);
|
|
793
|
+
c = s.charAt(pos++);
|
|
794
|
+
continue;
|
|
795
|
+
}
|
|
796
|
+
if (c == '-') {
|
|
797
|
+
types.push(XPathParser.MINUS);
|
|
798
|
+
values.push(c);
|
|
799
|
+
c = s.charAt(pos++);
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
if (c == '=') {
|
|
803
|
+
types.push(XPathParser.EQUALS);
|
|
804
|
+
values.push(c);
|
|
805
|
+
c = s.charAt(pos++);
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
if (c == '$') {
|
|
809
|
+
types.push(XPathParser.DOLLAR);
|
|
810
|
+
values.push(c);
|
|
811
|
+
c = s.charAt(pos++);
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (c == '.') {
|
|
816
|
+
c = s.charAt(pos++);
|
|
817
|
+
if (c == '.') {
|
|
818
|
+
types.push(XPathParser.DOUBLEDOT);
|
|
819
|
+
values.push("..");
|
|
820
|
+
c = s.charAt(pos++);
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
823
|
+
if (c >= '0' && c <= '9') {
|
|
824
|
+
var number = "." + c;
|
|
825
|
+
c = s.charAt(pos++);
|
|
826
|
+
while (c >= '0' && c <= '9') {
|
|
827
|
+
number += c;
|
|
828
|
+
c = s.charAt(pos++);
|
|
829
|
+
}
|
|
830
|
+
types.push(XPathParser.NUMBER);
|
|
831
|
+
values.push(number);
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
types.push(XPathParser.DOT);
|
|
835
|
+
values.push('.');
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (c == '\'' || c == '"') {
|
|
840
|
+
var delimiter = c;
|
|
841
|
+
var literal = "";
|
|
842
|
+
while ((c = s.charAt(pos++)) != delimiter) {
|
|
843
|
+
literal += c;
|
|
844
|
+
}
|
|
845
|
+
types.push(XPathParser.LITERAL);
|
|
846
|
+
values.push(literal);
|
|
847
|
+
c = s.charAt(pos++);
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
if (c >= '0' && c <= '9') {
|
|
852
|
+
var number = c;
|
|
853
|
+
c = s.charAt(pos++);
|
|
854
|
+
while (c >= '0' && c <= '9') {
|
|
855
|
+
number += c;
|
|
856
|
+
c = s.charAt(pos++);
|
|
857
|
+
}
|
|
858
|
+
if (c == '.') {
|
|
859
|
+
if (s.charAt(pos) >= '0' && s.charAt(pos) <= '9') {
|
|
860
|
+
number += c;
|
|
861
|
+
number += s.charAt(pos++);
|
|
862
|
+
c = s.charAt(pos++);
|
|
863
|
+
while (c >= '0' && c <= '9') {
|
|
864
|
+
number += c;
|
|
865
|
+
c = s.charAt(pos++);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
types.push(XPathParser.NUMBER);
|
|
870
|
+
values.push(number);
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
if (c == '*') {
|
|
875
|
+
if (types.length > 0) {
|
|
876
|
+
var last = types[types.length - 1];
|
|
877
|
+
if (last != XPathParser.AT
|
|
878
|
+
&& last != XPathParser.DOUBLECOLON
|
|
879
|
+
&& last != XPathParser.LEFTPARENTHESIS
|
|
880
|
+
&& last != XPathParser.LEFTBRACKET
|
|
881
|
+
&& last != XPathParser.AND
|
|
882
|
+
&& last != XPathParser.OR
|
|
883
|
+
&& last != XPathParser.MOD
|
|
884
|
+
&& last != XPathParser.DIV
|
|
885
|
+
&& last != XPathParser.MULTIPLYOPERATOR
|
|
886
|
+
&& last != XPathParser.SLASH
|
|
887
|
+
&& last != XPathParser.DOUBLESLASH
|
|
888
|
+
&& last != XPathParser.BAR
|
|
889
|
+
&& last != XPathParser.PLUS
|
|
890
|
+
&& last != XPathParser.MINUS
|
|
891
|
+
&& last != XPathParser.EQUALS
|
|
892
|
+
&& last != XPathParser.NOTEQUAL
|
|
893
|
+
&& last != XPathParser.LESSTHAN
|
|
894
|
+
&& last != XPathParser.LESSTHANOREQUAL
|
|
895
|
+
&& last != XPathParser.GREATERTHAN
|
|
896
|
+
&& last != XPathParser.GREATERTHANOREQUAL) {
|
|
897
|
+
types.push(XPathParser.MULTIPLYOPERATOR);
|
|
898
|
+
values.push(c);
|
|
899
|
+
c = s.charAt(pos++);
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
types.push(XPathParser.ASTERISKNAMETEST);
|
|
904
|
+
values.push(c);
|
|
905
|
+
c = s.charAt(pos++);
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (c == ':') {
|
|
910
|
+
if (s.charAt(pos) == ':') {
|
|
911
|
+
types.push(XPathParser.DOUBLECOLON);
|
|
912
|
+
values.push("::");
|
|
913
|
+
pos++;
|
|
914
|
+
c = s.charAt(pos++);
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
if (c == '/') {
|
|
920
|
+
c = s.charAt(pos++);
|
|
921
|
+
if (c == '/') {
|
|
922
|
+
types.push(XPathParser.DOUBLESLASH);
|
|
923
|
+
values.push("//");
|
|
924
|
+
c = s.charAt(pos++);
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
types.push(XPathParser.SLASH);
|
|
928
|
+
values.push('/');
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
if (c == '!') {
|
|
933
|
+
if (s.charAt(pos) == '=') {
|
|
934
|
+
types.push(XPathParser.NOTEQUAL);
|
|
935
|
+
values.push("!=");
|
|
936
|
+
pos++;
|
|
937
|
+
c = s.charAt(pos++);
|
|
938
|
+
continue;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
if (c == '<') {
|
|
943
|
+
if (s.charAt(pos) == '=') {
|
|
944
|
+
types.push(XPathParser.LESSTHANOREQUAL);
|
|
945
|
+
values.push("<=");
|
|
946
|
+
pos++;
|
|
947
|
+
c = s.charAt(pos++);
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
types.push(XPathParser.LESSTHAN);
|
|
951
|
+
values.push('<');
|
|
952
|
+
c = s.charAt(pos++);
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
if (c == '>') {
|
|
957
|
+
if (s.charAt(pos) == '=') {
|
|
958
|
+
types.push(XPathParser.GREATERTHANOREQUAL);
|
|
959
|
+
values.push(">=");
|
|
960
|
+
pos++;
|
|
961
|
+
c = s.charAt(pos++);
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
types.push(XPathParser.GREATERTHAN);
|
|
965
|
+
values.push('>');
|
|
966
|
+
c = s.charAt(pos++);
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
if (c == '_' || Utilities.isLetter(c.charCodeAt(0))) {
|
|
971
|
+
var name = c;
|
|
972
|
+
c = s.charAt(pos++);
|
|
973
|
+
while (Utilities.isNCNameChar(c.charCodeAt(0))) {
|
|
974
|
+
name += c;
|
|
975
|
+
c = s.charAt(pos++);
|
|
976
|
+
}
|
|
977
|
+
if (types.length > 0) {
|
|
978
|
+
var last = types[types.length - 1];
|
|
979
|
+
if (last != XPathParser.AT
|
|
980
|
+
&& last != XPathParser.DOUBLECOLON
|
|
981
|
+
&& last != XPathParser.LEFTPARENTHESIS
|
|
982
|
+
&& last != XPathParser.LEFTBRACKET
|
|
983
|
+
&& last != XPathParser.AND
|
|
984
|
+
&& last != XPathParser.OR
|
|
985
|
+
&& last != XPathParser.MOD
|
|
986
|
+
&& last != XPathParser.DIV
|
|
987
|
+
&& last != XPathParser.MULTIPLYOPERATOR
|
|
988
|
+
&& last != XPathParser.SLASH
|
|
989
|
+
&& last != XPathParser.DOUBLESLASH
|
|
990
|
+
&& last != XPathParser.BAR
|
|
991
|
+
&& last != XPathParser.PLUS
|
|
992
|
+
&& last != XPathParser.MINUS
|
|
993
|
+
&& last != XPathParser.EQUALS
|
|
994
|
+
&& last != XPathParser.NOTEQUAL
|
|
995
|
+
&& last != XPathParser.LESSTHAN
|
|
996
|
+
&& last != XPathParser.LESSTHANOREQUAL
|
|
997
|
+
&& last != XPathParser.GREATERTHAN
|
|
998
|
+
&& last != XPathParser.GREATERTHANOREQUAL) {
|
|
999
|
+
if (name == "and") {
|
|
1000
|
+
types.push(XPathParser.AND);
|
|
1001
|
+
values.push(name);
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
if (name == "or") {
|
|
1005
|
+
types.push(XPathParser.OR);
|
|
1006
|
+
values.push(name);
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
if (name == "mod") {
|
|
1010
|
+
types.push(XPathParser.MOD);
|
|
1011
|
+
values.push(name);
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
if (name == "div") {
|
|
1015
|
+
types.push(XPathParser.DIV);
|
|
1016
|
+
values.push(name);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
if (c == ':') {
|
|
1022
|
+
if (s.charAt(pos) == '*') {
|
|
1023
|
+
types.push(XPathParser.NCNAMECOLONASTERISK);
|
|
1024
|
+
values.push(name + ":*");
|
|
1025
|
+
pos++;
|
|
1026
|
+
c = s.charAt(pos++);
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
1029
|
+
if (s.charAt(pos) == '_' || Utilities.isLetter(s.charCodeAt(pos))) {
|
|
1030
|
+
name += ':';
|
|
1031
|
+
c = s.charAt(pos++);
|
|
1032
|
+
while (Utilities.isNCNameChar(c.charCodeAt(0))) {
|
|
1033
|
+
name += c;
|
|
1034
|
+
c = s.charAt(pos++);
|
|
1035
|
+
}
|
|
1036
|
+
if (c == '(') {
|
|
1037
|
+
types.push(XPathParser.FUNCTIONNAME);
|
|
1038
|
+
values.push(name);
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
types.push(XPathParser.QNAME);
|
|
1042
|
+
values.push(name);
|
|
1043
|
+
continue;
|
|
1044
|
+
}
|
|
1045
|
+
if (s.charAt(pos) == ':') {
|
|
1046
|
+
types.push(XPathParser.AXISNAME);
|
|
1047
|
+
values.push(name);
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (c == '(') {
|
|
1052
|
+
if (name == "comment" || name == "text" || name == "node") {
|
|
1053
|
+
types.push(XPathParser.NODETYPE);
|
|
1054
|
+
values.push(name);
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
if (name == "processing-instruction") {
|
|
1058
|
+
if (s.charAt(pos) == ')') {
|
|
1059
|
+
types.push(XPathParser.NODETYPE);
|
|
1060
|
+
} else {
|
|
1061
|
+
types.push(XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL);
|
|
1062
|
+
}
|
|
1063
|
+
values.push(name);
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
types.push(XPathParser.FUNCTIONNAME);
|
|
1067
|
+
values.push(name);
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
types.push(XPathParser.QNAME);
|
|
1071
|
+
values.push(name);
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
throw new Error("Unexpected character " + c);
|
|
1076
|
+
}
|
|
1077
|
+
types.push(1);
|
|
1078
|
+
values.push("[EOF]");
|
|
1079
|
+
return [types, values];
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
XPathParser.SHIFT = 's';
|
|
1083
|
+
XPathParser.REDUCE = 'r';
|
|
1084
|
+
XPathParser.ACCEPT = 'a';
|
|
1085
|
+
|
|
1086
|
+
XPathParser.prototype.parse = function(s) {
|
|
1087
|
+
var types;
|
|
1088
|
+
var values;
|
|
1089
|
+
var res = this.tokenize(s);
|
|
1090
|
+
if (res == undefined) {
|
|
1091
|
+
return undefined;
|
|
1092
|
+
}
|
|
1093
|
+
types = res[0];
|
|
1094
|
+
values = res[1];
|
|
1095
|
+
var tokenPos = 0;
|
|
1096
|
+
var state = [];
|
|
1097
|
+
var tokenType = [];
|
|
1098
|
+
var tokenValue = [];
|
|
1099
|
+
var s;
|
|
1100
|
+
var a;
|
|
1101
|
+
var t;
|
|
1102
|
+
|
|
1103
|
+
state.push(0);
|
|
1104
|
+
tokenType.push(1);
|
|
1105
|
+
tokenValue.push("_S");
|
|
1106
|
+
|
|
1107
|
+
a = types[tokenPos];
|
|
1108
|
+
t = values[tokenPos++];
|
|
1109
|
+
while (1) {
|
|
1110
|
+
s = state[state.length - 1];
|
|
1111
|
+
switch (XPathParser.actionTable[s].charAt(a - 1)) {
|
|
1112
|
+
case XPathParser.SHIFT:
|
|
1113
|
+
tokenType.push(-a);
|
|
1114
|
+
tokenValue.push(t);
|
|
1115
|
+
state.push(XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32);
|
|
1116
|
+
a = types[tokenPos];
|
|
1117
|
+
t = values[tokenPos++];
|
|
1118
|
+
break;
|
|
1119
|
+
case XPathParser.REDUCE:
|
|
1120
|
+
var num = XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][1];
|
|
1121
|
+
var rhs = [];
|
|
1122
|
+
for (var i = 0; i < num; i++) {
|
|
1123
|
+
tokenType.pop();
|
|
1124
|
+
rhs.unshift(tokenValue.pop());
|
|
1125
|
+
state.pop();
|
|
1126
|
+
}
|
|
1127
|
+
var s_ = state[state.length - 1];
|
|
1128
|
+
tokenType.push(XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][0]);
|
|
1129
|
+
if (this.reduceActions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32] == undefined) {
|
|
1130
|
+
tokenValue.push(rhs[0]);
|
|
1131
|
+
} else {
|
|
1132
|
+
tokenValue.push(this.reduceActions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32](rhs));
|
|
1133
|
+
}
|
|
1134
|
+
state.push(XPathParser.gotoTable[s_].charCodeAt(XPathParser.productions[XPathParser.actionTableNumber[s].charCodeAt(a - 1) - 32][0] - 2) - 33);
|
|
1135
|
+
break;
|
|
1136
|
+
case XPathParser.ACCEPT:
|
|
1137
|
+
return new XPath(tokenValue.pop());
|
|
1138
|
+
default:
|
|
1139
|
+
throw new Error("XPath parse error");
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
// XPath /////////////////////////////////////////////////////////////////////
|
|
1145
|
+
|
|
1146
|
+
XPath.prototype = new Object();
|
|
1147
|
+
XPath.prototype.constructor = XPath;
|
|
1148
|
+
XPath.superclass = Object.prototype;
|
|
1149
|
+
|
|
1150
|
+
function XPath(e) {
|
|
1151
|
+
this.expression = e;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
XPath.prototype.toString = function() {
|
|
1155
|
+
return this.expression.toString();
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
XPath.prototype.evaluate = function(c) {
|
|
1159
|
+
c.contextNode = c.expressionContextNode;
|
|
1160
|
+
c.contextSize = 1;
|
|
1161
|
+
c.contextPosition = 1;
|
|
1162
|
+
c.caseInsensitive = false;
|
|
1163
|
+
if (c.contextNode != null) {
|
|
1164
|
+
var doc = c.contextNode;
|
|
1165
|
+
if (doc.nodeType != 9 /*Node.DOCUMENT_NODE*/) {
|
|
1166
|
+
doc = doc.ownerDocument;
|
|
1167
|
+
}
|
|
1168
|
+
c.caseInsensitive = doc.implementation == null
|
|
1169
|
+
|| doc.implementation.hasFeature("HTML", "2.0");
|
|
1170
|
+
}
|
|
1171
|
+
return this.expression.evaluate(c);
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
XPath.XML_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
|
|
1175
|
+
XPath.XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
|
|
1176
|
+
|
|
1177
|
+
// Expression ////////////////////////////////////////////////////////////////
|
|
1178
|
+
|
|
1179
|
+
Expression.prototype = new Object();
|
|
1180
|
+
Expression.prototype.constructor = Expression;
|
|
1181
|
+
Expression.superclass = Object.prototype;
|
|
1182
|
+
|
|
1183
|
+
function Expression() {
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
Expression.prototype.init = function() {
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
Expression.prototype.toString = function() {
|
|
1190
|
+
return "<Expression>";
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
Expression.prototype.evaluate = function(c) {
|
|
1194
|
+
throw new Error("Could not evaluate expression.");
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
// UnaryOperation ////////////////////////////////////////////////////////////
|
|
1198
|
+
|
|
1199
|
+
UnaryOperation.prototype = new Expression();
|
|
1200
|
+
UnaryOperation.prototype.constructor = UnaryOperation;
|
|
1201
|
+
UnaryOperation.superclass = Expression.prototype;
|
|
1202
|
+
|
|
1203
|
+
function UnaryOperation(rhs) {
|
|
1204
|
+
if (arguments.length > 0) {
|
|
1205
|
+
this.init(rhs);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
UnaryOperation.prototype.init = function(rhs) {
|
|
1210
|
+
this.rhs = rhs;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// UnaryMinusOperation ///////////////////////////////////////////////////////
|
|
1214
|
+
|
|
1215
|
+
UnaryMinusOperation.prototype = new UnaryOperation();
|
|
1216
|
+
UnaryMinusOperation.prototype.constructor = UnaryMinusOperation;
|
|
1217
|
+
UnaryMinusOperation.superclass = UnaryOperation.prototype;
|
|
1218
|
+
|
|
1219
|
+
function UnaryMinusOperation(rhs) {
|
|
1220
|
+
if (arguments.length > 0) {
|
|
1221
|
+
this.init(rhs);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
UnaryMinusOperation.prototype.init = function(rhs) {
|
|
1226
|
+
UnaryMinusOperation.superclass.init.call(this, rhs);
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
UnaryMinusOperation.prototype.evaluate = function(c) {
|
|
1230
|
+
return this.rhs.evaluate(c).number().negate();
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
UnaryMinusOperation.prototype.toString = function() {
|
|
1234
|
+
return "-" + this.rhs.toString();
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// BinaryOperation ///////////////////////////////////////////////////////////
|
|
1238
|
+
|
|
1239
|
+
BinaryOperation.prototype = new Expression();
|
|
1240
|
+
BinaryOperation.prototype.constructor = BinaryOperation;
|
|
1241
|
+
BinaryOperation.superclass = Expression.prototype;
|
|
1242
|
+
|
|
1243
|
+
function BinaryOperation(lhs, rhs) {
|
|
1244
|
+
if (arguments.length > 0) {
|
|
1245
|
+
this.init(lhs, rhs);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
BinaryOperation.prototype.init = function(lhs, rhs) {
|
|
1250
|
+
this.lhs = lhs;
|
|
1251
|
+
this.rhs = rhs;
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
// OrOperation ///////////////////////////////////////////////////////////////
|
|
1255
|
+
|
|
1256
|
+
OrOperation.prototype = new BinaryOperation();
|
|
1257
|
+
OrOperation.prototype.constructor = OrOperation;
|
|
1258
|
+
OrOperation.superclass = BinaryOperation.prototype;
|
|
1259
|
+
|
|
1260
|
+
function OrOperation(lhs, rhs) {
|
|
1261
|
+
if (arguments.length > 0) {
|
|
1262
|
+
this.init(lhs, rhs);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
OrOperation.prototype.init = function(lhs, rhs) {
|
|
1267
|
+
OrOperation.superclass.init.call(this, lhs, rhs);
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
OrOperation.prototype.toString = function() {
|
|
1271
|
+
return "(" + this.lhs.toString() + " or " + this.rhs.toString() + ")";
|
|
1272
|
+
};
|
|
1273
|
+
|
|
1274
|
+
OrOperation.prototype.evaluate = function(c) {
|
|
1275
|
+
var b = this.lhs.evaluate(c).bool();
|
|
1276
|
+
if (b.booleanValue()) {
|
|
1277
|
+
return b;
|
|
1278
|
+
}
|
|
1279
|
+
return this.rhs.evaluate(c).bool();
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
// AndOperation //////////////////////////////////////////////////////////////
|
|
1283
|
+
|
|
1284
|
+
AndOperation.prototype = new BinaryOperation();
|
|
1285
|
+
AndOperation.prototype.constructor = AndOperation;
|
|
1286
|
+
AndOperation.superclass = BinaryOperation.prototype;
|
|
1287
|
+
|
|
1288
|
+
function AndOperation(lhs, rhs) {
|
|
1289
|
+
if (arguments.length > 0) {
|
|
1290
|
+
this.init(lhs, rhs);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
AndOperation.prototype.init = function(lhs, rhs) {
|
|
1295
|
+
AndOperation.superclass.init.call(this, lhs, rhs);
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1298
|
+
AndOperation.prototype.toString = function() {
|
|
1299
|
+
return "(" + this.lhs.toString() + " and " + this.rhs.toString() + ")";
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
AndOperation.prototype.evaluate = function(c) {
|
|
1303
|
+
var b = this.lhs.evaluate(c).bool();
|
|
1304
|
+
if (!b.booleanValue()) {
|
|
1305
|
+
return b;
|
|
1306
|
+
}
|
|
1307
|
+
return this.rhs.evaluate(c).bool();
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
// EqualsOperation ///////////////////////////////////////////////////////////
|
|
1311
|
+
|
|
1312
|
+
EqualsOperation.prototype = new BinaryOperation();
|
|
1313
|
+
EqualsOperation.prototype.constructor = EqualsOperation;
|
|
1314
|
+
EqualsOperation.superclass = BinaryOperation.prototype;
|
|
1315
|
+
|
|
1316
|
+
function EqualsOperation(lhs, rhs) {
|
|
1317
|
+
if (arguments.length > 0) {
|
|
1318
|
+
this.init(lhs, rhs);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
EqualsOperation.prototype.init = function(lhs, rhs) {
|
|
1323
|
+
EqualsOperation.superclass.init.call(this, lhs, rhs);
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
EqualsOperation.prototype.toString = function() {
|
|
1327
|
+
return "(" + this.lhs.toString() + " = " + this.rhs.toString() + ")";
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
EqualsOperation.prototype.evaluate = function(c) {
|
|
1331
|
+
return this.lhs.evaluate(c).equals(this.rhs.evaluate(c));
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
// NotEqualOperation /////////////////////////////////////////////////////////
|
|
1335
|
+
|
|
1336
|
+
NotEqualOperation.prototype = new BinaryOperation();
|
|
1337
|
+
NotEqualOperation.prototype.constructor = NotEqualOperation;
|
|
1338
|
+
NotEqualOperation.superclass = BinaryOperation.prototype;
|
|
1339
|
+
|
|
1340
|
+
function NotEqualOperation(lhs, rhs) {
|
|
1341
|
+
if (arguments.length > 0) {
|
|
1342
|
+
this.init(lhs, rhs);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
NotEqualOperation.prototype.init = function(lhs, rhs) {
|
|
1347
|
+
NotEqualOperation.superclass.init.call(this, lhs, rhs);
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
NotEqualOperation.prototype.toString = function() {
|
|
1351
|
+
return "(" + this.lhs.toString() + " != " + this.rhs.toString() + ")";
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
NotEqualOperation.prototype.evaluate = function(c) {
|
|
1355
|
+
return this.lhs.evaluate(c).notequal(this.rhs.evaluate(c));
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
// LessThanOperation /////////////////////////////////////////////////////////
|
|
1359
|
+
|
|
1360
|
+
LessThanOperation.prototype = new BinaryOperation();
|
|
1361
|
+
LessThanOperation.prototype.constructor = LessThanOperation;
|
|
1362
|
+
LessThanOperation.superclass = BinaryOperation.prototype;
|
|
1363
|
+
|
|
1364
|
+
function LessThanOperation(lhs, rhs) {
|
|
1365
|
+
if (arguments.length > 0) {
|
|
1366
|
+
this.init(lhs, rhs);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
LessThanOperation.prototype.init = function(lhs, rhs) {
|
|
1371
|
+
LessThanOperation.superclass.init.call(this, lhs, rhs);
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
LessThanOperation.prototype.evaluate = function(c) {
|
|
1375
|
+
return this.lhs.evaluate(c).lessthan(this.rhs.evaluate(c));
|
|
1376
|
+
};
|
|
1377
|
+
|
|
1378
|
+
LessThanOperation.prototype.toString = function() {
|
|
1379
|
+
return "(" + this.lhs.toString() + " < " + this.rhs.toString() + ")";
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
// GreaterThanOperation //////////////////////////////////////////////////////
|
|
1383
|
+
|
|
1384
|
+
GreaterThanOperation.prototype = new BinaryOperation();
|
|
1385
|
+
GreaterThanOperation.prototype.constructor = GreaterThanOperation;
|
|
1386
|
+
GreaterThanOperation.superclass = BinaryOperation.prototype;
|
|
1387
|
+
|
|
1388
|
+
function GreaterThanOperation(lhs, rhs) {
|
|
1389
|
+
if (arguments.length > 0) {
|
|
1390
|
+
this.init(lhs, rhs);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
GreaterThanOperation.prototype.init = function(lhs, rhs) {
|
|
1395
|
+
GreaterThanOperation.superclass.init.call(this, lhs, rhs);
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
GreaterThanOperation.prototype.evaluate = function(c) {
|
|
1399
|
+
return this.lhs.evaluate(c).greaterthan(this.rhs.evaluate(c));
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
GreaterThanOperation.prototype.toString = function() {
|
|
1403
|
+
return "(" + this.lhs.toString() + " > " + this.rhs.toString() + ")";
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
// LessThanOrEqualOperation //////////////////////////////////////////////////
|
|
1407
|
+
|
|
1408
|
+
LessThanOrEqualOperation.prototype = new BinaryOperation();
|
|
1409
|
+
LessThanOrEqualOperation.prototype.constructor = LessThanOrEqualOperation;
|
|
1410
|
+
LessThanOrEqualOperation.superclass = BinaryOperation.prototype;
|
|
1411
|
+
|
|
1412
|
+
function LessThanOrEqualOperation(lhs, rhs) {
|
|
1413
|
+
if (arguments.length > 0) {
|
|
1414
|
+
this.init(lhs, rhs);
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
LessThanOrEqualOperation.prototype.init = function(lhs, rhs) {
|
|
1419
|
+
LessThanOrEqualOperation.superclass.init.call(this, lhs, rhs);
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
LessThanOrEqualOperation.prototype.evaluate = function(c) {
|
|
1423
|
+
return this.lhs.evaluate(c).lessthanorequal(this.rhs.evaluate(c));
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
LessThanOrEqualOperation.prototype.toString = function() {
|
|
1427
|
+
return "(" + this.lhs.toString() + " <= " + this.rhs.toString() + ")";
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
// GreaterThanOrEqualOperation ///////////////////////////////////////////////
|
|
1431
|
+
|
|
1432
|
+
GreaterThanOrEqualOperation.prototype = new BinaryOperation();
|
|
1433
|
+
GreaterThanOrEqualOperation.prototype.constructor = GreaterThanOrEqualOperation;
|
|
1434
|
+
GreaterThanOrEqualOperation.superclass = BinaryOperation.prototype;
|
|
1435
|
+
|
|
1436
|
+
function GreaterThanOrEqualOperation(lhs, rhs) {
|
|
1437
|
+
if (arguments.length > 0) {
|
|
1438
|
+
this.init(lhs, rhs);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
GreaterThanOrEqualOperation.prototype.init = function(lhs, rhs) {
|
|
1443
|
+
GreaterThanOrEqualOperation.superclass.init.call(this, lhs, rhs);
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
GreaterThanOrEqualOperation.prototype.evaluate = function(c) {
|
|
1447
|
+
return this.lhs.evaluate(c).greaterthanorequal(this.rhs.evaluate(c));
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
GreaterThanOrEqualOperation.prototype.toString = function() {
|
|
1451
|
+
return "(" + this.lhs.toString() + " >= " + this.rhs.toString() + ")";
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
// PlusOperation /////////////////////////////////////////////////////////////
|
|
1455
|
+
|
|
1456
|
+
PlusOperation.prototype = new BinaryOperation();
|
|
1457
|
+
PlusOperation.prototype.constructor = PlusOperation;
|
|
1458
|
+
PlusOperation.superclass = BinaryOperation.prototype;
|
|
1459
|
+
|
|
1460
|
+
function PlusOperation(lhs, rhs) {
|
|
1461
|
+
if (arguments.length > 0) {
|
|
1462
|
+
this.init(lhs, rhs);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
PlusOperation.prototype.init = function(lhs, rhs) {
|
|
1467
|
+
PlusOperation.superclass.init.call(this, lhs, rhs);
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
PlusOperation.prototype.evaluate = function(c) {
|
|
1471
|
+
return this.lhs.evaluate(c).number().plus(this.rhs.evaluate(c).number());
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
PlusOperation.prototype.toString = function() {
|
|
1475
|
+
return "(" + this.lhs.toString() + " + " + this.rhs.toString() + ")";
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
// MinusOperation ////////////////////////////////////////////////////////////
|
|
1479
|
+
|
|
1480
|
+
MinusOperation.prototype = new BinaryOperation();
|
|
1481
|
+
MinusOperation.prototype.constructor = MinusOperation;
|
|
1482
|
+
MinusOperation.superclass = BinaryOperation.prototype;
|
|
1483
|
+
|
|
1484
|
+
function MinusOperation(lhs, rhs) {
|
|
1485
|
+
if (arguments.length > 0) {
|
|
1486
|
+
this.init(lhs, rhs);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
MinusOperation.prototype.init = function(lhs, rhs) {
|
|
1491
|
+
MinusOperation.superclass.init.call(this, lhs, rhs);
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1494
|
+
MinusOperation.prototype.evaluate = function(c) {
|
|
1495
|
+
return this.lhs.evaluate(c).number().minus(this.rhs.evaluate(c).number());
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
MinusOperation.prototype.toString = function() {
|
|
1499
|
+
return "(" + this.lhs.toString() + " - " + this.rhs.toString() + ")";
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
// MultiplyOperation /////////////////////////////////////////////////////////
|
|
1503
|
+
|
|
1504
|
+
MultiplyOperation.prototype = new BinaryOperation();
|
|
1505
|
+
MultiplyOperation.prototype.constructor = MultiplyOperation;
|
|
1506
|
+
MultiplyOperation.superclass = BinaryOperation.prototype;
|
|
1507
|
+
|
|
1508
|
+
function MultiplyOperation(lhs, rhs) {
|
|
1509
|
+
if (arguments.length > 0) {
|
|
1510
|
+
this.init(lhs, rhs);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
MultiplyOperation.prototype.init = function(lhs, rhs) {
|
|
1515
|
+
MultiplyOperation.superclass.init.call(this, lhs, rhs);
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
MultiplyOperation.prototype.evaluate = function(c) {
|
|
1519
|
+
return this.lhs.evaluate(c).number().multiply(this.rhs.evaluate(c).number());
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
MultiplyOperation.prototype.toString = function() {
|
|
1523
|
+
return "(" + this.lhs.toString() + " * " + this.rhs.toString() + ")";
|
|
1524
|
+
};
|
|
1525
|
+
|
|
1526
|
+
// DivOperation //////////////////////////////////////////////////////////////
|
|
1527
|
+
|
|
1528
|
+
DivOperation.prototype = new BinaryOperation();
|
|
1529
|
+
DivOperation.prototype.constructor = DivOperation;
|
|
1530
|
+
DivOperation.superclass = BinaryOperation.prototype;
|
|
1531
|
+
|
|
1532
|
+
function DivOperation(lhs, rhs) {
|
|
1533
|
+
if (arguments.length > 0) {
|
|
1534
|
+
this.init(lhs, rhs);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
DivOperation.prototype.init = function(lhs, rhs) {
|
|
1539
|
+
DivOperation.superclass.init.call(this, lhs, rhs);
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
DivOperation.prototype.evaluate = function(c) {
|
|
1543
|
+
return this.lhs.evaluate(c).number().div(this.rhs.evaluate(c).number());
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
DivOperation.prototype.toString = function() {
|
|
1547
|
+
return "(" + this.lhs.toString() + " div " + this.rhs.toString() + ")";
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
// ModOperation //////////////////////////////////////////////////////////////
|
|
1551
|
+
|
|
1552
|
+
ModOperation.prototype = new BinaryOperation();
|
|
1553
|
+
ModOperation.prototype.constructor = ModOperation;
|
|
1554
|
+
ModOperation.superclass = BinaryOperation.prototype;
|
|
1555
|
+
|
|
1556
|
+
function ModOperation(lhs, rhs) {
|
|
1557
|
+
if (arguments.length > 0) {
|
|
1558
|
+
this.init(lhs, rhs);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
ModOperation.prototype.init = function(lhs, rhs) {
|
|
1563
|
+
ModOperation.superclass.init.call(this, lhs, rhs);
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
ModOperation.prototype.evaluate = function(c) {
|
|
1567
|
+
return this.lhs.evaluate(c).number().mod(this.rhs.evaluate(c).number());
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
ModOperation.prototype.toString = function() {
|
|
1571
|
+
return "(" + this.lhs.toString() + " mod " + this.rhs.toString() + ")";
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
// BarOperation //////////////////////////////////////////////////////////////
|
|
1575
|
+
|
|
1576
|
+
BarOperation.prototype = new BinaryOperation();
|
|
1577
|
+
BarOperation.prototype.constructor = BarOperation;
|
|
1578
|
+
BarOperation.superclass = BinaryOperation.prototype;
|
|
1579
|
+
|
|
1580
|
+
function BarOperation(lhs, rhs) {
|
|
1581
|
+
if (arguments.length > 0) {
|
|
1582
|
+
this.init(lhs, rhs);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
BarOperation.prototype.init = function(lhs, rhs) {
|
|
1587
|
+
BarOperation.superclass.init.call(this, lhs, rhs);
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
BarOperation.prototype.evaluate = function(c) {
|
|
1591
|
+
return this.lhs.evaluate(c).nodeset().union(this.rhs.evaluate(c).nodeset());
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1594
|
+
BarOperation.prototype.toString = function() {
|
|
1595
|
+
return this.lhs.toString() + " | " + this.rhs.toString();
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
// PathExpr //////////////////////////////////////////////////////////////////
|
|
1599
|
+
|
|
1600
|
+
PathExpr.prototype = new Expression();
|
|
1601
|
+
PathExpr.prototype.constructor = PathExpr;
|
|
1602
|
+
PathExpr.superclass = Expression.prototype;
|
|
1603
|
+
|
|
1604
|
+
function PathExpr(filter, filterPreds, locpath) {
|
|
1605
|
+
if (arguments.length > 0) {
|
|
1606
|
+
this.init(filter, filterPreds, locpath);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
PathExpr.prototype.init = function(filter, filterPreds, locpath) {
|
|
1611
|
+
PathExpr.superclass.init.call(this);
|
|
1612
|
+
this.filter = filter;
|
|
1613
|
+
this.filterPredicates = filterPreds;
|
|
1614
|
+
this.locationPath = locpath;
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
PathExpr.prototype.evaluate = function(c) {
|
|
1618
|
+
var nodes;
|
|
1619
|
+
var xpc = new XPathContext();
|
|
1620
|
+
xpc.variableResolver = c.variableResolver;
|
|
1621
|
+
xpc.functionResolver = c.functionResolver;
|
|
1622
|
+
xpc.namespaceResolver = c.namespaceResolver;
|
|
1623
|
+
xpc.expressionContextNode = c.expressionContextNode;
|
|
1624
|
+
xpc.virtualRoot = c.virtualRoot;
|
|
1625
|
+
xpc.caseInsensitive = c.caseInsensitive;
|
|
1626
|
+
if (this.filter == null) {
|
|
1627
|
+
nodes = [ c.contextNode ];
|
|
1628
|
+
} else {
|
|
1629
|
+
var ns = this.filter.evaluate(c);
|
|
1630
|
+
if (!Utilities.instance_of(ns, XNodeSet)) {
|
|
1631
|
+
if (this.filterPredicates != null && this.filterPredicates.length > 0 || this.locationPath != null) {
|
|
1632
|
+
throw new Error("Path expression filter must evaluate to a nodset if predicates or location path are used");
|
|
1633
|
+
}
|
|
1634
|
+
return ns;
|
|
1635
|
+
}
|
|
1636
|
+
nodes = ns.toArray();
|
|
1637
|
+
if (this.filterPredicates != null) {
|
|
1638
|
+
// apply each of the predicates in turn
|
|
1639
|
+
for (var j = 0; j < this.filterPredicates.length; j++) {
|
|
1640
|
+
var pred = this.filterPredicates[j];
|
|
1641
|
+
var newNodes = [];
|
|
1642
|
+
xpc.contextSize = nodes.length;
|
|
1643
|
+
for (xpc.contextPosition = 1; xpc.contextPosition <= xpc.contextSize; xpc.contextPosition++) {
|
|
1644
|
+
xpc.contextNode = nodes[xpc.contextPosition - 1];
|
|
1645
|
+
if (this.predicateMatches(pred, xpc)) {
|
|
1646
|
+
newNodes.push(xpc.contextNode);
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
nodes = newNodes;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
if (this.locationPath != null) {
|
|
1654
|
+
if (this.locationPath.absolute) {
|
|
1655
|
+
if (nodes[0].nodeType != 9 /*Node.DOCUMENT_NODE*/) {
|
|
1656
|
+
if (xpc.virtualRoot != null) {
|
|
1657
|
+
nodes = [ xpc.virtualRoot ];
|
|
1658
|
+
} else {
|
|
1659
|
+
nodes = [ nodes[0].ownerDocument ];
|
|
1660
|
+
}
|
|
1661
|
+
} else {
|
|
1662
|
+
nodes = [ nodes[0] ];
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
for (var i = 0; i < this.locationPath.steps.length; i++) {
|
|
1666
|
+
var step = this.locationPath.steps[i];
|
|
1667
|
+
var newNodes = [];
|
|
1668
|
+
for (var j = 0; j < nodes.length; j++) {
|
|
1669
|
+
xpc.contextNode = nodes[j];
|
|
1670
|
+
switch (step.axis) {
|
|
1671
|
+
case Step.ANCESTOR:
|
|
1672
|
+
// look at all the ancestor nodes
|
|
1673
|
+
if (xpc.contextNode === xpc.virtualRoot) {
|
|
1674
|
+
break;
|
|
1675
|
+
}
|
|
1676
|
+
var m;
|
|
1677
|
+
if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
|
|
1678
|
+
m = this.getOwnerElement(xpc.contextNode);
|
|
1679
|
+
} else {
|
|
1680
|
+
m = xpc.contextNode.parentNode;
|
|
1681
|
+
}
|
|
1682
|
+
while (m != null) {
|
|
1683
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1684
|
+
newNodes.push(m);
|
|
1685
|
+
}
|
|
1686
|
+
if (m === xpc.virtualRoot) {
|
|
1687
|
+
break;
|
|
1688
|
+
}
|
|
1689
|
+
m = m.parentNode;
|
|
1690
|
+
}
|
|
1691
|
+
break;
|
|
1692
|
+
|
|
1693
|
+
case Step.ANCESTORORSELF:
|
|
1694
|
+
// look at all the ancestor nodes and the current node
|
|
1695
|
+
for (var m = xpc.contextNode; m != null; m = m.nodeType == 2 /*Node.ATTRIBUTE_NODE*/ ? this.getOwnerElement(m) : m.parentNode) {
|
|
1696
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1697
|
+
newNodes.push(m);
|
|
1698
|
+
}
|
|
1699
|
+
if (m === xpc.virtualRoot) {
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
break;
|
|
1704
|
+
|
|
1705
|
+
case Step.ATTRIBUTE:
|
|
1706
|
+
// look at the attributes
|
|
1707
|
+
var nnm = xpc.contextNode.attributes;
|
|
1708
|
+
if (nnm != null) {
|
|
1709
|
+
for (var k = 0; k < nnm.length; k++) {
|
|
1710
|
+
var m = nnm.item(k);
|
|
1711
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1712
|
+
newNodes.push(m);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
break;
|
|
1717
|
+
|
|
1718
|
+
case Step.CHILD:
|
|
1719
|
+
// look at all child elements
|
|
1720
|
+
for (var m = xpc.contextNode.firstChild; m != null; m = m.nextSibling) {
|
|
1721
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1722
|
+
newNodes.push(m);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
break;
|
|
1726
|
+
|
|
1727
|
+
case Step.DESCENDANT:
|
|
1728
|
+
// look at all descendant nodes
|
|
1729
|
+
var st = [ xpc.contextNode.firstChild ];
|
|
1730
|
+
while (st.length > 0) {
|
|
1731
|
+
for (var m = st.pop(); m != null; ) {
|
|
1732
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1733
|
+
newNodes.push(m);
|
|
1734
|
+
}
|
|
1735
|
+
if (m.firstChild != null) {
|
|
1736
|
+
st.push(m.nextSibling);
|
|
1737
|
+
m = m.firstChild;
|
|
1738
|
+
} else {
|
|
1739
|
+
m = m.nextSibling;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
break;
|
|
1744
|
+
|
|
1745
|
+
case Step.DESCENDANTORSELF:
|
|
1746
|
+
// look at self
|
|
1747
|
+
if (step.nodeTest.matches(xpc.contextNode, xpc)) {
|
|
1748
|
+
newNodes.push(xpc.contextNode);
|
|
1749
|
+
}
|
|
1750
|
+
// look at all descendant nodes
|
|
1751
|
+
var st = [ xpc.contextNode.firstChild ];
|
|
1752
|
+
while (st.length > 0) {
|
|
1753
|
+
for (var m = st.pop(); m != null; ) {
|
|
1754
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1755
|
+
newNodes.push(m);
|
|
1756
|
+
}
|
|
1757
|
+
if (m.firstChild != null) {
|
|
1758
|
+
st.push(m.nextSibling);
|
|
1759
|
+
m = m.firstChild;
|
|
1760
|
+
} else {
|
|
1761
|
+
m = m.nextSibling;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
break;
|
|
1766
|
+
|
|
1767
|
+
case Step.FOLLOWING:
|
|
1768
|
+
if (xpc.contextNode === xpc.virtualRoot) {
|
|
1769
|
+
break;
|
|
1770
|
+
}
|
|
1771
|
+
var st = [];
|
|
1772
|
+
if (xpc.contextNode.firstChild != null) {
|
|
1773
|
+
st.unshift(xpc.contextNode.firstChild);
|
|
1774
|
+
} else {
|
|
1775
|
+
st.unshift(xpc.contextNode.nextSibling);
|
|
1776
|
+
}
|
|
1777
|
+
for (var m = xpc.contextNode.parentNode; m != null && m.nodeType != 9 /*Node.DOCUMENT_NODE*/ && m !== xpc.virtualRoot; m = m.parentNode) {
|
|
1778
|
+
st.unshift(m.nextSibling);
|
|
1779
|
+
}
|
|
1780
|
+
do {
|
|
1781
|
+
for (var m = st.pop(); m != null; ) {
|
|
1782
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1783
|
+
newNodes.push(m);
|
|
1784
|
+
}
|
|
1785
|
+
if (m.firstChild != null) {
|
|
1786
|
+
st.push(m.nextSibling);
|
|
1787
|
+
m = m.firstChild;
|
|
1788
|
+
} else {
|
|
1789
|
+
m = m.nextSibling;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
} while (st.length > 0);
|
|
1793
|
+
break;
|
|
1794
|
+
|
|
1795
|
+
case Step.FOLLOWINGSIBLING:
|
|
1796
|
+
if (xpc.contextNode === xpc.virtualRoot) {
|
|
1797
|
+
break;
|
|
1798
|
+
}
|
|
1799
|
+
for (var m = xpc.contextNode.nextSibling; m != null; m = m.nextSibling) {
|
|
1800
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1801
|
+
newNodes.push(m);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
break;
|
|
1805
|
+
|
|
1806
|
+
case Step.NAMESPACE:
|
|
1807
|
+
var n = {};
|
|
1808
|
+
if (xpc.contextNode.nodeType == 1 /*Node.ELEMENT_NODE*/) {
|
|
1809
|
+
n["xml"] = XPath.XML_NAMESPACE_URI;
|
|
1810
|
+
n["xmlns"] = XPath.XMLNS_NAMESPACE_URI;
|
|
1811
|
+
for (var m = xpc.contextNode; m != null && m.nodeType == 1 /*Node.ELEMENT_NODE*/; m = m.parentNode) {
|
|
1812
|
+
for (var k = 0; k < m.attributes.length; k++) {
|
|
1813
|
+
var attr = m.attributes.item(k);
|
|
1814
|
+
var nm = String(attr.name);
|
|
1815
|
+
if (nm == "xmlns") {
|
|
1816
|
+
if (n[""] == undefined) {
|
|
1817
|
+
n[""] = attr.value;
|
|
1818
|
+
}
|
|
1819
|
+
} else if (nm.length > 6 && nm.substring(0, 6) == "xmlns:") {
|
|
1820
|
+
var pre = nm.substring(6, nm.length);
|
|
1821
|
+
if (n[pre] == undefined) {
|
|
1822
|
+
n[pre] = attr.value;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
for (var pre in n) {
|
|
1828
|
+
var nsn = new NamespaceNode(pre, n[pre], xpc.contextNode);
|
|
1829
|
+
if (step.nodeTest.matches(nsn, xpc)) {
|
|
1830
|
+
newNodes.push(nsn);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
break;
|
|
1835
|
+
|
|
1836
|
+
case Step.PARENT:
|
|
1837
|
+
m = null;
|
|
1838
|
+
if (xpc.contextNode !== xpc.virtualRoot) {
|
|
1839
|
+
if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
|
|
1840
|
+
m = this.getOwnerElement(xpc.contextNode);
|
|
1841
|
+
} else {
|
|
1842
|
+
m = xpc.contextNode.parentNode;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
if (m != null && step.nodeTest.matches(m, xpc)) {
|
|
1846
|
+
newNodes.push(m);
|
|
1847
|
+
}
|
|
1848
|
+
break;
|
|
1849
|
+
|
|
1850
|
+
case Step.PRECEDING:
|
|
1851
|
+
var st;
|
|
1852
|
+
if (xpc.virtualRoot != null) {
|
|
1853
|
+
st = [ xpc.virtualRoot ];
|
|
1854
|
+
} else {
|
|
1855
|
+
st = xpc.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/
|
|
1856
|
+
? [ xpc.contextNode ]
|
|
1857
|
+
: [ xpc.contextNode.ownerDocument ];
|
|
1858
|
+
}
|
|
1859
|
+
outer: while (st.length > 0) {
|
|
1860
|
+
for (var m = st.pop(); m != null; ) {
|
|
1861
|
+
if (m == xpc.contextNode) {
|
|
1862
|
+
break outer;
|
|
1863
|
+
}
|
|
1864
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1865
|
+
newNodes.unshift(m);
|
|
1866
|
+
}
|
|
1867
|
+
if (m.firstChild != null) {
|
|
1868
|
+
st.push(m.nextSibling);
|
|
1869
|
+
m = m.firstChild;
|
|
1870
|
+
} else {
|
|
1871
|
+
m = m.nextSibling;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
break;
|
|
1876
|
+
|
|
1877
|
+
case Step.PRECEDINGSIBLING:
|
|
1878
|
+
if (xpc.contextNode === xpc.virtualRoot) {
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
for (var m = xpc.contextNode.previousSibling; m != null; m = m.previousSibling) {
|
|
1882
|
+
if (step.nodeTest.matches(m, xpc)) {
|
|
1883
|
+
newNodes.push(m);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
break;
|
|
1887
|
+
|
|
1888
|
+
case Step.SELF:
|
|
1889
|
+
if (step.nodeTest.matches(xpc.contextNode, xpc)) {
|
|
1890
|
+
newNodes.push(xpc.contextNode);
|
|
1891
|
+
}
|
|
1892
|
+
break;
|
|
1893
|
+
|
|
1894
|
+
default:
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
nodes = newNodes;
|
|
1898
|
+
// apply each of the predicates in turn
|
|
1899
|
+
for (var j = 0; j < step.predicates.length; j++) {
|
|
1900
|
+
var pred = step.predicates[j];
|
|
1901
|
+
var newNodes = [];
|
|
1902
|
+
xpc.contextSize = nodes.length;
|
|
1903
|
+
for (xpc.contextPosition = 1; xpc.contextPosition <= xpc.contextSize; xpc.contextPosition++) {
|
|
1904
|
+
xpc.contextNode = nodes[xpc.contextPosition - 1];
|
|
1905
|
+
if (this.predicateMatches(pred, xpc)) {
|
|
1906
|
+
newNodes.push(xpc.contextNode);
|
|
1907
|
+
} else {
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
nodes = newNodes;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
var ns = new XNodeSet();
|
|
1915
|
+
ns.addArray(nodes);
|
|
1916
|
+
return ns;
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
PathExpr.prototype.predicateMatches = function(pred, c) {
|
|
1920
|
+
var res = pred.evaluate(c);
|
|
1921
|
+
if (Utilities.instance_of(res, XNumber)) {
|
|
1922
|
+
return c.contextPosition == res.numberValue();
|
|
1923
|
+
}
|
|
1924
|
+
return res.booleanValue();
|
|
1925
|
+
};
|
|
1926
|
+
|
|
1927
|
+
PathExpr.prototype.toString = function() {
|
|
1928
|
+
if (this.filter != undefined) {
|
|
1929
|
+
var s = this.filter.toString();
|
|
1930
|
+
if (Utilities.instance_of(this.filter, XString)) {
|
|
1931
|
+
s = "'" + s + "'";
|
|
1932
|
+
}
|
|
1933
|
+
if (this.filterPredicates != undefined) {
|
|
1934
|
+
for (var i = 0; i < this.filterPredicates.length; i++) {
|
|
1935
|
+
s = s + "[" + this.filterPredicates[i].toString() + "]";
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
if (this.locationPath != undefined) {
|
|
1939
|
+
if (!this.locationPath.absolute) {
|
|
1940
|
+
s += "/";
|
|
1941
|
+
}
|
|
1942
|
+
s += this.locationPath.toString();
|
|
1943
|
+
}
|
|
1944
|
+
return s;
|
|
1945
|
+
}
|
|
1946
|
+
return this.locationPath.toString();
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
PathExpr.prototype.getOwnerElement = function(n) {
|
|
1950
|
+
// DOM 2 has ownerElement
|
|
1951
|
+
if (n.ownerElement) {
|
|
1952
|
+
return n.ownerElement;
|
|
1953
|
+
}
|
|
1954
|
+
// DOM 1 Internet Explorer can use selectSingleNode (ironically)
|
|
1955
|
+
if (n.selectSingleNode) {
|
|
1956
|
+
return n.selectSingleNode("..");
|
|
1957
|
+
}
|
|
1958
|
+
// Other DOM 1 implementations must use this egregious search
|
|
1959
|
+
var doc = n.nodeType == 9 /*Node.DOCUMENT_NODE*/
|
|
1960
|
+
? n
|
|
1961
|
+
: n.ownerDocument;
|
|
1962
|
+
var elts = doc.getElementsByTagName("*");
|
|
1963
|
+
for (var i = 0; i < elts.length; i++) {
|
|
1964
|
+
var elt = elts.item(i);
|
|
1965
|
+
var nnm = elt.attributes;
|
|
1966
|
+
for (var j = 0; j < nnm.length; j++) {
|
|
1967
|
+
var an = nnm.item(j);
|
|
1968
|
+
if (an === n) {
|
|
1969
|
+
return elt;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
return null;
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
// LocationPath //////////////////////////////////////////////////////////////
|
|
1977
|
+
|
|
1978
|
+
LocationPath.prototype = new Object();
|
|
1979
|
+
LocationPath.prototype.constructor = LocationPath;
|
|
1980
|
+
LocationPath.superclass = Object.prototype;
|
|
1981
|
+
|
|
1982
|
+
function LocationPath(abs, steps) {
|
|
1983
|
+
if (arguments.length > 0) {
|
|
1984
|
+
this.init(abs, steps);
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
LocationPath.prototype.init = function(abs, steps) {
|
|
1989
|
+
this.absolute = abs;
|
|
1990
|
+
this.steps = steps;
|
|
1991
|
+
};
|
|
1992
|
+
|
|
1993
|
+
LocationPath.prototype.toString = function() {
|
|
1994
|
+
var s;
|
|
1995
|
+
if (this.absolute) {
|
|
1996
|
+
s = "/";
|
|
1997
|
+
} else {
|
|
1998
|
+
s = "";
|
|
1999
|
+
}
|
|
2000
|
+
for (var i = 0; i < this.steps.length; i++) {
|
|
2001
|
+
if (i != 0) {
|
|
2002
|
+
s += "/";
|
|
2003
|
+
}
|
|
2004
|
+
s += this.steps[i].toString();
|
|
2005
|
+
}
|
|
2006
|
+
return s;
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
// Step //////////////////////////////////////////////////////////////////////
|
|
2010
|
+
|
|
2011
|
+
Step.prototype = new Object();
|
|
2012
|
+
Step.prototype.constructor = Step;
|
|
2013
|
+
Step.superclass = Object.prototype;
|
|
2014
|
+
|
|
2015
|
+
function Step(axis, nodetest, preds) {
|
|
2016
|
+
if (arguments.length > 0) {
|
|
2017
|
+
this.init(axis, nodetest, preds);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
Step.prototype.init = function(axis, nodetest, preds) {
|
|
2022
|
+
this.axis = axis;
|
|
2023
|
+
this.nodeTest = nodetest;
|
|
2024
|
+
this.predicates = preds;
|
|
2025
|
+
};
|
|
2026
|
+
|
|
2027
|
+
Step.prototype.toString = function() {
|
|
2028
|
+
var s;
|
|
2029
|
+
switch (this.axis) {
|
|
2030
|
+
case Step.ANCESTOR:
|
|
2031
|
+
s = "ancestor";
|
|
2032
|
+
break;
|
|
2033
|
+
case Step.ANCESTORORSELF:
|
|
2034
|
+
s = "ancestor-or-self";
|
|
2035
|
+
break;
|
|
2036
|
+
case Step.ATTRIBUTE:
|
|
2037
|
+
s = "attribute";
|
|
2038
|
+
break;
|
|
2039
|
+
case Step.CHILD:
|
|
2040
|
+
s = "child";
|
|
2041
|
+
break;
|
|
2042
|
+
case Step.DESCENDANT:
|
|
2043
|
+
s = "descendant";
|
|
2044
|
+
break;
|
|
2045
|
+
case Step.DESCENDANTORSELF:
|
|
2046
|
+
s = "descendant-or-self";
|
|
2047
|
+
break;
|
|
2048
|
+
case Step.FOLLOWING:
|
|
2049
|
+
s = "following";
|
|
2050
|
+
break;
|
|
2051
|
+
case Step.FOLLOWINGSIBLING:
|
|
2052
|
+
s = "following-sibling";
|
|
2053
|
+
break;
|
|
2054
|
+
case Step.NAMESPACE:
|
|
2055
|
+
s = "namespace";
|
|
2056
|
+
break;
|
|
2057
|
+
case Step.PARENT:
|
|
2058
|
+
s = "parent";
|
|
2059
|
+
break;
|
|
2060
|
+
case Step.PRECEDING:
|
|
2061
|
+
s = "preceding";
|
|
2062
|
+
break;
|
|
2063
|
+
case Step.PRECEDINGSIBLING:
|
|
2064
|
+
s = "preceding-sibling";
|
|
2065
|
+
break;
|
|
2066
|
+
case Step.SELF:
|
|
2067
|
+
s = "self";
|
|
2068
|
+
break;
|
|
2069
|
+
}
|
|
2070
|
+
s += "::";
|
|
2071
|
+
s += this.nodeTest.toString();
|
|
2072
|
+
for (var i = 0; i < this.predicates.length; i++) {
|
|
2073
|
+
s += "[" + this.predicates[i].toString() + "]";
|
|
2074
|
+
}
|
|
2075
|
+
return s;
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
Step.ANCESTOR = 0;
|
|
2079
|
+
Step.ANCESTORORSELF = 1;
|
|
2080
|
+
Step.ATTRIBUTE = 2;
|
|
2081
|
+
Step.CHILD = 3;
|
|
2082
|
+
Step.DESCENDANT = 4;
|
|
2083
|
+
Step.DESCENDANTORSELF = 5;
|
|
2084
|
+
Step.FOLLOWING = 6;
|
|
2085
|
+
Step.FOLLOWINGSIBLING = 7;
|
|
2086
|
+
Step.NAMESPACE = 8;
|
|
2087
|
+
Step.PARENT = 9;
|
|
2088
|
+
Step.PRECEDING = 10;
|
|
2089
|
+
Step.PRECEDINGSIBLING = 11;
|
|
2090
|
+
Step.SELF = 12;
|
|
2091
|
+
|
|
2092
|
+
// NodeTest //////////////////////////////////////////////////////////////////
|
|
2093
|
+
|
|
2094
|
+
NodeTest.prototype = new Object();
|
|
2095
|
+
NodeTest.prototype.constructor = NodeTest;
|
|
2096
|
+
NodeTest.superclass = Object.prototype;
|
|
2097
|
+
|
|
2098
|
+
function NodeTest(type, value) {
|
|
2099
|
+
if (arguments.length > 0) {
|
|
2100
|
+
this.init(type, value);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
NodeTest.prototype.init = function(type, value) {
|
|
2105
|
+
this.type = type;
|
|
2106
|
+
this.value = value;
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
NodeTest.prototype.toString = function() {
|
|
2110
|
+
switch (this.type) {
|
|
2111
|
+
case NodeTest.NAMETESTANY:
|
|
2112
|
+
return "*";
|
|
2113
|
+
case NodeTest.NAMETESTPREFIXANY:
|
|
2114
|
+
return this.value + ":*";
|
|
2115
|
+
case NodeTest.NAMETESTQNAME:
|
|
2116
|
+
return this.value;
|
|
2117
|
+
case NodeTest.COMMENT:
|
|
2118
|
+
return "comment()";
|
|
2119
|
+
case NodeTest.TEXT:
|
|
2120
|
+
return "text()";
|
|
2121
|
+
case NodeTest.PI:
|
|
2122
|
+
if (this.value != undefined) {
|
|
2123
|
+
return "processing-instruction(\"" + this.value + "\")";
|
|
2124
|
+
}
|
|
2125
|
+
return "processing-instruction()";
|
|
2126
|
+
case NodeTest.NODE:
|
|
2127
|
+
return "node()";
|
|
2128
|
+
}
|
|
2129
|
+
return "<unknown nodetest type>";
|
|
2130
|
+
};
|
|
2131
|
+
|
|
2132
|
+
NodeTest.prototype.matches = function(n, xpc) {
|
|
2133
|
+
switch (this.type) {
|
|
2134
|
+
case NodeTest.NAMETESTANY:
|
|
2135
|
+
if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
|
|
2136
|
+
|| n.nodeType == 1 /*Node.ELEMENT_NODE*/
|
|
2137
|
+
|| n.nodeType == NodeTest.NAMESPACE_NODE) {
|
|
2138
|
+
return true;
|
|
2139
|
+
}
|
|
2140
|
+
return false;
|
|
2141
|
+
case NodeTest.NAMETESTPREFIXANY:
|
|
2142
|
+
if ((n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/ || n.nodeType == 1 /*Node.ELEMENT_NODE*/)
|
|
2143
|
+
&& n.namespaceURI == xpc.namespaceResolver.getNamespace(this.value, xpc.expressionContextNode)) {
|
|
2144
|
+
return true;
|
|
2145
|
+
}
|
|
2146
|
+
return false;
|
|
2147
|
+
case NodeTest.NAMETESTQNAME:
|
|
2148
|
+
if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
|
|
2149
|
+
|| n.nodeType == 1 /*Node.ELEMENT_NODE*/
|
|
2150
|
+
|| n.nodeType == NodeTest.NAMESPACE_NODE) {
|
|
2151
|
+
var test = Utilities.resolveQName(this.value, xpc.namespaceResolver, xpc.expressionContextNode, false);
|
|
2152
|
+
test[0] = String(test[0]);
|
|
2153
|
+
if (test[0] == "") {
|
|
2154
|
+
test[0] = null;
|
|
2155
|
+
}
|
|
2156
|
+
var node = Utilities.resolveQName(n.nodeName, xpc.namespaceResolver, xpc.contextNode, true);
|
|
2157
|
+
node[0] = String(node[0]);
|
|
2158
|
+
if (node[0] == "") {
|
|
2159
|
+
node[0] = null;
|
|
2160
|
+
}
|
|
2161
|
+
if (xpc.caseInsensitive) {
|
|
2162
|
+
return test[0] == node[0] && String(test[1]).toLowerCase() == String(node[1]).toLowerCase();
|
|
2163
|
+
}
|
|
2164
|
+
return test[0] == node[0] && test[1] == node[1];
|
|
2165
|
+
}
|
|
2166
|
+
return false;
|
|
2167
|
+
case NodeTest.COMMENT:
|
|
2168
|
+
return n.nodeType == 8 /*Node.COMMENT_NODE*/;
|
|
2169
|
+
case NodeTest.TEXT:
|
|
2170
|
+
return n.nodeType == 3 /*Node.TEXT_NODE*/ || n.nodeType == 4 /*Node.CDATA_SECTION_NODE*/;
|
|
2171
|
+
case NodeTest.PI:
|
|
2172
|
+
return n.nodeType == 7 /*Node.PROCESSING_INSTRUCTION_NODE*/
|
|
2173
|
+
&& (this.value == null || n.nodeName == this.value);
|
|
2174
|
+
case NodeTest.NODE:
|
|
2175
|
+
return n.nodeType == 9 /*Node.DOCUMENT_NODE*/
|
|
2176
|
+
|| n.nodeType == 1 /*Node.ELEMENT_NODE*/
|
|
2177
|
+
|| n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
|
|
2178
|
+
|| n.nodeType == 3 /*Node.TEXT_NODE*/
|
|
2179
|
+
|| n.nodeType == 4 /*Node.CDATA_SECTION_NODE*/
|
|
2180
|
+
|| n.nodeType == 8 /*Node.COMMENT_NODE*/
|
|
2181
|
+
|| n.nodeType == 7 /*Node.PROCESSING_INSTRUCTION_NODE*/;
|
|
2182
|
+
}
|
|
2183
|
+
return false;
|
|
2184
|
+
};
|
|
2185
|
+
|
|
2186
|
+
NodeTest.NAMETESTANY = 0;
|
|
2187
|
+
NodeTest.NAMETESTPREFIXANY = 1;
|
|
2188
|
+
NodeTest.NAMETESTQNAME = 2;
|
|
2189
|
+
NodeTest.COMMENT = 3;
|
|
2190
|
+
NodeTest.TEXT = 4;
|
|
2191
|
+
NodeTest.PI = 5;
|
|
2192
|
+
NodeTest.NODE = 6;
|
|
2193
|
+
|
|
2194
|
+
NodeTest.NAMESPACE_NODE = 1024;
|
|
2195
|
+
|
|
2196
|
+
// VariableReference /////////////////////////////////////////////////////////
|
|
2197
|
+
|
|
2198
|
+
VariableReference.prototype = new Expression();
|
|
2199
|
+
VariableReference.prototype.constructor = VariableReference;
|
|
2200
|
+
VariableReference.superclass = Expression.prototype;
|
|
2201
|
+
|
|
2202
|
+
function VariableReference(v) {
|
|
2203
|
+
if (arguments.length > 0) {
|
|
2204
|
+
this.init(v);
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
VariableReference.prototype.init = function(v) {
|
|
2209
|
+
this.variable = v;
|
|
2210
|
+
};
|
|
2211
|
+
|
|
2212
|
+
VariableReference.prototype.toString = function() {
|
|
2213
|
+
return "$" + this.variable;
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2216
|
+
VariableReference.prototype.evaluate = function(c) {
|
|
2217
|
+
return c.variableResolver.getVariable(this.variable, c);
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
// FunctionCall //////////////////////////////////////////////////////////////
|
|
2221
|
+
|
|
2222
|
+
FunctionCall.prototype = new Expression();
|
|
2223
|
+
FunctionCall.prototype.constructor = FunctionCall;
|
|
2224
|
+
FunctionCall.superclass = Expression.prototype;
|
|
2225
|
+
|
|
2226
|
+
function FunctionCall(fn, args) {
|
|
2227
|
+
if (arguments.length > 0) {
|
|
2228
|
+
this.init(fn, args);
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
FunctionCall.prototype.init = function(fn, args) {
|
|
2233
|
+
this.functionName = fn;
|
|
2234
|
+
this.arguments = args;
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
FunctionCall.prototype.toString = function() {
|
|
2238
|
+
var s = this.functionName + "(";
|
|
2239
|
+
for (var i = 0; i < this.arguments.length; i++) {
|
|
2240
|
+
if (i > 0) {
|
|
2241
|
+
s += ", ";
|
|
2242
|
+
}
|
|
2243
|
+
s += this.arguments[i].toString();
|
|
2244
|
+
}
|
|
2245
|
+
return s + ")";
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
FunctionCall.prototype.evaluate = function(c) {
|
|
2249
|
+
var f = c.functionResolver.getFunction(this.functionName, c);
|
|
2250
|
+
if (f == undefined) {
|
|
2251
|
+
throw new Error("Unknown function " + this.functionName);
|
|
2252
|
+
}
|
|
2253
|
+
var a = [c].concat(this.arguments);
|
|
2254
|
+
return f.apply(c.functionResolver.thisArg, a);
|
|
2255
|
+
};
|
|
2256
|
+
|
|
2257
|
+
// XString ///////////////////////////////////////////////////////////////////
|
|
2258
|
+
|
|
2259
|
+
XString.prototype = new Expression();
|
|
2260
|
+
XString.prototype.constructor = XString;
|
|
2261
|
+
XString.superclass = Expression.prototype;
|
|
2262
|
+
|
|
2263
|
+
function XString(s) {
|
|
2264
|
+
if (arguments.length > 0) {
|
|
2265
|
+
this.init(s);
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
XString.prototype.init = function(s) {
|
|
2270
|
+
this.str = s;
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2273
|
+
XString.prototype.toString = function() {
|
|
2274
|
+
return this.str;
|
|
2275
|
+
};
|
|
2276
|
+
|
|
2277
|
+
XString.prototype.evaluate = function(c) {
|
|
2278
|
+
return this;
|
|
2279
|
+
};
|
|
2280
|
+
|
|
2281
|
+
XString.prototype.string = function() {
|
|
2282
|
+
return this;
|
|
2283
|
+
};
|
|
2284
|
+
|
|
2285
|
+
XString.prototype.number = function() {
|
|
2286
|
+
return new XNumber(this.str);
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2289
|
+
XString.prototype.bool = function() {
|
|
2290
|
+
return new XBoolean(this.str);
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
XString.prototype.nodeset = function() {
|
|
2294
|
+
throw new Error("Cannot convert string to nodeset");
|
|
2295
|
+
};
|
|
2296
|
+
|
|
2297
|
+
XString.prototype.stringValue = function() {
|
|
2298
|
+
return this.str;
|
|
2299
|
+
};
|
|
2300
|
+
|
|
2301
|
+
XString.prototype.numberValue = function() {
|
|
2302
|
+
return this.number().numberValue();
|
|
2303
|
+
};
|
|
2304
|
+
|
|
2305
|
+
XString.prototype.booleanValue = function() {
|
|
2306
|
+
return this.bool().booleanValue();
|
|
2307
|
+
};
|
|
2308
|
+
|
|
2309
|
+
XString.prototype.equals = function(r) {
|
|
2310
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2311
|
+
return this.bool().equals(r);
|
|
2312
|
+
}
|
|
2313
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2314
|
+
return this.number().equals(r);
|
|
2315
|
+
}
|
|
2316
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2317
|
+
return r.compareWithString(this, Operators.equals);
|
|
2318
|
+
}
|
|
2319
|
+
return new XBoolean(this.str == r.str);
|
|
2320
|
+
};
|
|
2321
|
+
|
|
2322
|
+
XString.prototype.notequal = function(r) {
|
|
2323
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2324
|
+
return this.bool().notequal(r);
|
|
2325
|
+
}
|
|
2326
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2327
|
+
return this.number().notequal(r);
|
|
2328
|
+
}
|
|
2329
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2330
|
+
return r.compareWithString(this, Operators.notequal);
|
|
2331
|
+
}
|
|
2332
|
+
return new XBoolean(this.str != r.str);
|
|
2333
|
+
};
|
|
2334
|
+
|
|
2335
|
+
XString.prototype.lessthan = function(r) {
|
|
2336
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2337
|
+
return r.compareWithNumber(this.number(), Operators.greaterthanorequal);
|
|
2338
|
+
}
|
|
2339
|
+
return this.number().lessthan(r.number());
|
|
2340
|
+
};
|
|
2341
|
+
|
|
2342
|
+
XString.prototype.greaterthan = function(r) {
|
|
2343
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2344
|
+
return r.compareWithNumber(this.number(), Operators.lessthanorequal);
|
|
2345
|
+
}
|
|
2346
|
+
return this.number().greaterthan(r.number());
|
|
2347
|
+
};
|
|
2348
|
+
|
|
2349
|
+
XString.prototype.lessthanorequal = function(r) {
|
|
2350
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2351
|
+
return r.compareWithNumber(this.number(), Operators.greaterthan);
|
|
2352
|
+
}
|
|
2353
|
+
return this.number().lessthanorequal(r.number());
|
|
2354
|
+
};
|
|
2355
|
+
|
|
2356
|
+
XString.prototype.greaterthanorequal = function(r) {
|
|
2357
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2358
|
+
return r.compareWithNumber(this.number(), Operators.lessthan);
|
|
2359
|
+
}
|
|
2360
|
+
return this.number().greaterthanorequal(r.number());
|
|
2361
|
+
};
|
|
2362
|
+
|
|
2363
|
+
// XNumber ///////////////////////////////////////////////////////////////////
|
|
2364
|
+
|
|
2365
|
+
XNumber.prototype = new Expression();
|
|
2366
|
+
XNumber.prototype.constructor = XNumber;
|
|
2367
|
+
XNumber.superclass = Expression.prototype;
|
|
2368
|
+
|
|
2369
|
+
function XNumber(n) {
|
|
2370
|
+
if (arguments.length > 0) {
|
|
2371
|
+
this.init(n);
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
XNumber.prototype.init = function(n) {
|
|
2376
|
+
this.num = Number(n);
|
|
2377
|
+
};
|
|
2378
|
+
|
|
2379
|
+
XNumber.prototype.toString = function() {
|
|
2380
|
+
return this.num;
|
|
2381
|
+
};
|
|
2382
|
+
|
|
2383
|
+
XNumber.prototype.evaluate = function(c) {
|
|
2384
|
+
return this;
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
XNumber.prototype.string = function() {
|
|
2388
|
+
return new XString(this.num);
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2391
|
+
XNumber.prototype.number = function() {
|
|
2392
|
+
return this;
|
|
2393
|
+
};
|
|
2394
|
+
|
|
2395
|
+
XNumber.prototype.bool = function() {
|
|
2396
|
+
return new XBoolean(this.num);
|
|
2397
|
+
};
|
|
2398
|
+
|
|
2399
|
+
XNumber.prototype.nodeset = function() {
|
|
2400
|
+
throw new Error("Cannot convert number to nodeset");
|
|
2401
|
+
};
|
|
2402
|
+
|
|
2403
|
+
XNumber.prototype.stringValue = function() {
|
|
2404
|
+
return this.string().stringValue();
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
XNumber.prototype.numberValue = function() {
|
|
2408
|
+
return this.num;
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
XNumber.prototype.booleanValue = function() {
|
|
2412
|
+
return this.bool().booleanValue();
|
|
2413
|
+
};
|
|
2414
|
+
|
|
2415
|
+
XNumber.prototype.negate = function() {
|
|
2416
|
+
return new XNumber(-this.num);
|
|
2417
|
+
};
|
|
2418
|
+
|
|
2419
|
+
XNumber.prototype.equals = function(r) {
|
|
2420
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2421
|
+
return this.bool().equals(r);
|
|
2422
|
+
}
|
|
2423
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2424
|
+
return this.equals(r.number());
|
|
2425
|
+
}
|
|
2426
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2427
|
+
return r.compareWithNumber(this, Operators.equals);
|
|
2428
|
+
}
|
|
2429
|
+
return new XBoolean(this.num == r.num);
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2432
|
+
XNumber.prototype.notequal = function(r) {
|
|
2433
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2434
|
+
return this.bool().notequal(r);
|
|
2435
|
+
}
|
|
2436
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2437
|
+
return this.notequal(r.number());
|
|
2438
|
+
}
|
|
2439
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2440
|
+
return r.compareWithNumber(this, Operators.notequal);
|
|
2441
|
+
}
|
|
2442
|
+
return new XBoolean(this.num != r.num);
|
|
2443
|
+
};
|
|
2444
|
+
|
|
2445
|
+
XNumber.prototype.lessthan = function(r) {
|
|
2446
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2447
|
+
return r.compareWithNumber(this, Operators.greaterthanorequal);
|
|
2448
|
+
}
|
|
2449
|
+
if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
|
|
2450
|
+
return this.lessthan(r.number());
|
|
2451
|
+
}
|
|
2452
|
+
return new XBoolean(this.num < r.num);
|
|
2453
|
+
};
|
|
2454
|
+
|
|
2455
|
+
XNumber.prototype.greaterthan = function(r) {
|
|
2456
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2457
|
+
return r.compareWithNumber(this, Operators.lessthanorequal);
|
|
2458
|
+
}
|
|
2459
|
+
if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
|
|
2460
|
+
return this.greaterthan(r.number());
|
|
2461
|
+
}
|
|
2462
|
+
return new XBoolean(this.num > r.num);
|
|
2463
|
+
};
|
|
2464
|
+
|
|
2465
|
+
XNumber.prototype.lessthanorequal = function(r) {
|
|
2466
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2467
|
+
return r.compareWithNumber(this, Operators.greaterthan);
|
|
2468
|
+
}
|
|
2469
|
+
if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
|
|
2470
|
+
return this.lessthanorequal(r.number());
|
|
2471
|
+
}
|
|
2472
|
+
return new XBoolean(this.num <= r.num);
|
|
2473
|
+
};
|
|
2474
|
+
|
|
2475
|
+
XNumber.prototype.greaterthanorequal = function(r) {
|
|
2476
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2477
|
+
return r.compareWithNumber(this, Operators.lessthan);
|
|
2478
|
+
}
|
|
2479
|
+
if (Utilities.instance_of(r, XBoolean) || Utilities.instance_of(r, XString)) {
|
|
2480
|
+
return this.greaterthanorequal(r.number());
|
|
2481
|
+
}
|
|
2482
|
+
return new XBoolean(this.num >= r.num);
|
|
2483
|
+
};
|
|
2484
|
+
|
|
2485
|
+
XNumber.prototype.plus = function(r) {
|
|
2486
|
+
return new XNumber(this.num + r.num);
|
|
2487
|
+
};
|
|
2488
|
+
|
|
2489
|
+
XNumber.prototype.minus = function(r) {
|
|
2490
|
+
return new XNumber(this.num - r.num);
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2493
|
+
XNumber.prototype.multiply = function(r) {
|
|
2494
|
+
return new XNumber(this.num * r.num);
|
|
2495
|
+
};
|
|
2496
|
+
|
|
2497
|
+
XNumber.prototype.div = function(r) {
|
|
2498
|
+
return new XNumber(this.num / r.num);
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
XNumber.prototype.mod = function(r) {
|
|
2502
|
+
return new XNumber(this.num % r.num);
|
|
2503
|
+
};
|
|
2504
|
+
|
|
2505
|
+
// XBoolean //////////////////////////////////////////////////////////////////
|
|
2506
|
+
|
|
2507
|
+
XBoolean.prototype = new Expression();
|
|
2508
|
+
XBoolean.prototype.constructor = XBoolean;
|
|
2509
|
+
XBoolean.superclass = Expression.prototype;
|
|
2510
|
+
|
|
2511
|
+
function XBoolean(b) {
|
|
2512
|
+
if (arguments.length > 0) {
|
|
2513
|
+
this.init(b);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
XBoolean.prototype.init = function(b) {
|
|
2518
|
+
this.b = Boolean(b);
|
|
2519
|
+
};
|
|
2520
|
+
|
|
2521
|
+
XBoolean.prototype.toString = function() {
|
|
2522
|
+
return this.b.toString();
|
|
2523
|
+
};
|
|
2524
|
+
|
|
2525
|
+
XBoolean.prototype.evaluate = function(c) {
|
|
2526
|
+
return this;
|
|
2527
|
+
};
|
|
2528
|
+
|
|
2529
|
+
XBoolean.prototype.string = function() {
|
|
2530
|
+
return new XString(this.b);
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
XBoolean.prototype.number = function() {
|
|
2534
|
+
return new XNumber(this.b);
|
|
2535
|
+
};
|
|
2536
|
+
|
|
2537
|
+
XBoolean.prototype.bool = function() {
|
|
2538
|
+
return this;
|
|
2539
|
+
};
|
|
2540
|
+
|
|
2541
|
+
XBoolean.prototype.nodeset = function() {
|
|
2542
|
+
throw new Error("Cannot convert boolean to nodeset");
|
|
2543
|
+
};
|
|
2544
|
+
|
|
2545
|
+
XBoolean.prototype.stringValue = function() {
|
|
2546
|
+
return this.string().stringValue();
|
|
2547
|
+
};
|
|
2548
|
+
|
|
2549
|
+
XBoolean.prototype.numberValue = function() {
|
|
2550
|
+
return this.num().numberValue();
|
|
2551
|
+
};
|
|
2552
|
+
|
|
2553
|
+
XBoolean.prototype.booleanValue = function() {
|
|
2554
|
+
return this.b;
|
|
2555
|
+
};
|
|
2556
|
+
|
|
2557
|
+
XBoolean.prototype.not = function() {
|
|
2558
|
+
return new XBoolean(!this.b);
|
|
2559
|
+
};
|
|
2560
|
+
|
|
2561
|
+
XBoolean.prototype.equals = function(r) {
|
|
2562
|
+
if (Utilities.instance_of(r, XString) || Utilities.instance_of(r, XNumber)) {
|
|
2563
|
+
return this.equals(r.bool());
|
|
2564
|
+
}
|
|
2565
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2566
|
+
return r.compareWithBoolean(this, Operators.equals);
|
|
2567
|
+
}
|
|
2568
|
+
return new XBoolean(this.b == r.b);
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2571
|
+
XBoolean.prototype.notequal = function(r) {
|
|
2572
|
+
if (Utilities.instance_of(r, XString) || Utilities.instance_of(r, XNumber)) {
|
|
2573
|
+
return this.notequal(r.bool());
|
|
2574
|
+
}
|
|
2575
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2576
|
+
return r.compareWithBoolean(this, Operators.notequal);
|
|
2577
|
+
}
|
|
2578
|
+
return new XBoolean(this.b != r.b);
|
|
2579
|
+
};
|
|
2580
|
+
|
|
2581
|
+
XBoolean.prototype.lessthan = function(r) {
|
|
2582
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2583
|
+
return r.compareWithNumber(this.number(), Operators.greaterthanorequal);
|
|
2584
|
+
}
|
|
2585
|
+
return this.number().lessthan(r.number());
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
XBoolean.prototype.greaterthan = function(r) {
|
|
2589
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2590
|
+
return r.compareWithNumber(this.number(), Operators.lessthanorequal);
|
|
2591
|
+
}
|
|
2592
|
+
return this.number().greaterthan(r.number());
|
|
2593
|
+
};
|
|
2594
|
+
|
|
2595
|
+
XBoolean.prototype.lessthanorequal = function(r) {
|
|
2596
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2597
|
+
return r.compareWithNumber(this.number(), Operators.greaterthan);
|
|
2598
|
+
}
|
|
2599
|
+
return this.number().lessthanorequal(r.number());
|
|
2600
|
+
};
|
|
2601
|
+
|
|
2602
|
+
XBoolean.prototype.greaterthanorequal = function(r) {
|
|
2603
|
+
if (Utilities.instance_of(r, XNodeSet)) {
|
|
2604
|
+
return r.compareWithNumber(this.number(), Operators.lessthan);
|
|
2605
|
+
}
|
|
2606
|
+
return this.number().greaterthanorequal(r.number());
|
|
2607
|
+
};
|
|
2608
|
+
|
|
2609
|
+
// XNodeSet //////////////////////////////////////////////////////////////////
|
|
2610
|
+
|
|
2611
|
+
XNodeSet.prototype = new Expression();
|
|
2612
|
+
XNodeSet.prototype.constructor = XNodeSet;
|
|
2613
|
+
XNodeSet.superclass = Expression.prototype;
|
|
2614
|
+
|
|
2615
|
+
function XNodeSet() {
|
|
2616
|
+
this.init();
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
XNodeSet.prototype.init = function() {
|
|
2620
|
+
this.tree = null;
|
|
2621
|
+
this.size = 0;
|
|
2622
|
+
};
|
|
2623
|
+
|
|
2624
|
+
XNodeSet.prototype.toString = function() {
|
|
2625
|
+
var p = this.first();
|
|
2626
|
+
if (p == null) {
|
|
2627
|
+
return "";
|
|
2628
|
+
}
|
|
2629
|
+
return this.stringForNode(p);
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
XNodeSet.prototype.evaluate = function(c) {
|
|
2633
|
+
return this;
|
|
2634
|
+
};
|
|
2635
|
+
|
|
2636
|
+
XNodeSet.prototype.string = function() {
|
|
2637
|
+
return new XString(this.toString());
|
|
2638
|
+
};
|
|
2639
|
+
|
|
2640
|
+
XNodeSet.prototype.stringValue = function() {
|
|
2641
|
+
return this.toString();
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
XNodeSet.prototype.number = function() {
|
|
2645
|
+
return new XNumber(this.string());
|
|
2646
|
+
};
|
|
2647
|
+
|
|
2648
|
+
XNodeSet.prototype.numberValue = function() {
|
|
2649
|
+
return Number(this.string());
|
|
2650
|
+
};
|
|
2651
|
+
|
|
2652
|
+
XNodeSet.prototype.bool = function() {
|
|
2653
|
+
return new XBoolean(this.tree != null);
|
|
2654
|
+
};
|
|
2655
|
+
|
|
2656
|
+
XNodeSet.prototype.booleanValue = function() {
|
|
2657
|
+
return this.tree != null;
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
XNodeSet.prototype.nodeset = function() {
|
|
2661
|
+
return this;
|
|
2662
|
+
};
|
|
2663
|
+
|
|
2664
|
+
XNodeSet.prototype.stringForNode = function(n) {
|
|
2665
|
+
if (n.nodeType == 9 /*Node.DOCUMENT_NODE*/) {
|
|
2666
|
+
n = n.documentElement;
|
|
2667
|
+
}
|
|
2668
|
+
if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) {
|
|
2669
|
+
return this.stringForNodeRec(n);
|
|
2670
|
+
}
|
|
2671
|
+
if (n.isNamespaceNode) {
|
|
2672
|
+
return n.namespace;
|
|
2673
|
+
}
|
|
2674
|
+
return n.nodeValue;
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
XNodeSet.prototype.stringForNodeRec = function(n) {
|
|
2678
|
+
var s = "";
|
|
2679
|
+
for (var n2 = n.firstChild; n2 != null; n2 = n2.nextSibling) {
|
|
2680
|
+
if (n2.nodeType == 3 /*Node.TEXT_NODE*/) {
|
|
2681
|
+
s += n2.nodeValue;
|
|
2682
|
+
} else if (n2.nodeType == 1 /*Node.ELEMENT_NODE*/) {
|
|
2683
|
+
s += this.stringForNodeRec(n2);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
return s;
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2689
|
+
XNodeSet.prototype.first = function() {
|
|
2690
|
+
var p = this.tree;
|
|
2691
|
+
if (p == null) {
|
|
2692
|
+
return null;
|
|
2693
|
+
}
|
|
2694
|
+
while (p.left != null) {
|
|
2695
|
+
p = p.left;
|
|
2696
|
+
}
|
|
2697
|
+
return p.node;
|
|
2698
|
+
};
|
|
2699
|
+
|
|
2700
|
+
XNodeSet.prototype.add = function(n) {
|
|
2701
|
+
if (this.tree == null) {
|
|
2702
|
+
this.tree = new Object();
|
|
2703
|
+
this.tree.node = n;
|
|
2704
|
+
this.tree.left = null;
|
|
2705
|
+
this.tree.right = null;
|
|
2706
|
+
this.size = 1;
|
|
2707
|
+
return;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
var p = this.tree;
|
|
2711
|
+
while (1) {
|
|
2712
|
+
var o = this.order(n, p.node);
|
|
2713
|
+
if (o == 0) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
if (o > 0) {
|
|
2717
|
+
if (p.right == null) {
|
|
2718
|
+
p.right = new Object();
|
|
2719
|
+
p.right.node = n;
|
|
2720
|
+
p.right.left = null;
|
|
2721
|
+
p.right.right = null;
|
|
2722
|
+
this.size++;
|
|
2723
|
+
return;
|
|
2724
|
+
}
|
|
2725
|
+
p = p.right;
|
|
2726
|
+
} else {
|
|
2727
|
+
if (p.left == null) {
|
|
2728
|
+
p.left = new Object();
|
|
2729
|
+
p.left.node = n;
|
|
2730
|
+
p.left.left = null;
|
|
2731
|
+
p.left.right = null;
|
|
2732
|
+
this.size++;
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
p = p.left;
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
|
|
2740
|
+
XNodeSet.prototype.addArray = function(ns) {
|
|
2741
|
+
for (var i = 0; i < ns.length; i++) {
|
|
2742
|
+
this.add(ns[i]);
|
|
2743
|
+
}
|
|
2744
|
+
};
|
|
2745
|
+
|
|
2746
|
+
XNodeSet.prototype.toArray = function() {
|
|
2747
|
+
var a = [];
|
|
2748
|
+
this.toArrayRec(this.tree, a);
|
|
2749
|
+
return a;
|
|
2750
|
+
};
|
|
2751
|
+
|
|
2752
|
+
XNodeSet.prototype.toArrayRec = function(t, a) {
|
|
2753
|
+
if (t != null) {
|
|
2754
|
+
this.toArrayRec(t.left, a);
|
|
2755
|
+
a.push(t.node);
|
|
2756
|
+
this.toArrayRec(t.right, a);
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
|
|
2760
|
+
XNodeSet.prototype.order = function(n1, n2) {
|
|
2761
|
+
if (n1 == n2) {
|
|
2762
|
+
return 0;
|
|
2763
|
+
}
|
|
2764
|
+
var d1 = 0;
|
|
2765
|
+
var d2 = 0;
|
|
2766
|
+
for (var m1 = n1; m1 != null; m1 = m1.parentNode) {
|
|
2767
|
+
d1++;
|
|
2768
|
+
}
|
|
2769
|
+
for (var m2 = n2; m2 != null; m2 = m2.parentNode) {
|
|
2770
|
+
d2++;
|
|
2771
|
+
}
|
|
2772
|
+
if (d1 > d2) {
|
|
2773
|
+
while (d1 > d2) {
|
|
2774
|
+
n1 = n1.parentNode;
|
|
2775
|
+
d1--;
|
|
2776
|
+
}
|
|
2777
|
+
if (n1 == n2) {
|
|
2778
|
+
return 1;
|
|
2779
|
+
}
|
|
2780
|
+
} else if (d2 > d1) {
|
|
2781
|
+
while (d2 > d1) {
|
|
2782
|
+
n2 = n2.parentNode;
|
|
2783
|
+
d2--;
|
|
2784
|
+
}
|
|
2785
|
+
if (n1 == n2) {
|
|
2786
|
+
return -1;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
while (n1.parentNode != n2.parentNode) {
|
|
2790
|
+
n1 = n1.parentNode;
|
|
2791
|
+
n2 = n2.parentNode;
|
|
2792
|
+
}
|
|
2793
|
+
while (n1.previousSibling != null && n2.previousSibling != null) {
|
|
2794
|
+
n1 = n1.previousSibling;
|
|
2795
|
+
n2 = n2.previousSibling;
|
|
2796
|
+
}
|
|
2797
|
+
if (n1.previousSibling == null) {
|
|
2798
|
+
return -1;
|
|
2799
|
+
}
|
|
2800
|
+
return 1;
|
|
2801
|
+
};
|
|
2802
|
+
|
|
2803
|
+
XNodeSet.prototype.compareWithString = function(r, o) {
|
|
2804
|
+
var a = this.toArray();
|
|
2805
|
+
for (var i = 0; i < a.length; i++) {
|
|
2806
|
+
var n = a[i];
|
|
2807
|
+
var l = new XString(this.stringForNode(n));
|
|
2808
|
+
var res = o(l, r);
|
|
2809
|
+
if (res.booleanValue()) {
|
|
2810
|
+
return res;
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
return new XBoolean(false);
|
|
2814
|
+
};
|
|
2815
|
+
|
|
2816
|
+
XNodeSet.prototype.compareWithNumber = function(r, o) {
|
|
2817
|
+
var a = this.toArray();
|
|
2818
|
+
for (var i = 0; i < a.length; i++) {
|
|
2819
|
+
var n = a[i];
|
|
2820
|
+
var l = new XNumber(this.stringForNode(n));
|
|
2821
|
+
var res = o(l, r);
|
|
2822
|
+
if (res.booleanValue()) {
|
|
2823
|
+
return res;
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
return new XBoolean(false);
|
|
2827
|
+
};
|
|
2828
|
+
|
|
2829
|
+
XNodeSet.prototype.compareWithBoolean = function(r, o) {
|
|
2830
|
+
return o(this.bool(), r);
|
|
2831
|
+
};
|
|
2832
|
+
|
|
2833
|
+
XNodeSet.prototype.compareWithNodeSet = function(r, o) {
|
|
2834
|
+
var a = this.toArray();
|
|
2835
|
+
for (var i = 0; i < a.length; i++) {
|
|
2836
|
+
var n = a[i];
|
|
2837
|
+
var l = new XString(this.stringForNode(n));
|
|
2838
|
+
var b = r.toArray();
|
|
2839
|
+
for (var j = 0; j < b.length; j++) {
|
|
2840
|
+
var n2 = b[j];
|
|
2841
|
+
var r = new XString(this.stringForNode(n2));
|
|
2842
|
+
var res = o(l, r);
|
|
2843
|
+
if (res.booleanValue()) {
|
|
2844
|
+
return res;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
return new XBoolean(false);
|
|
2849
|
+
};
|
|
2850
|
+
|
|
2851
|
+
XNodeSet.prototype.equals = function(r) {
|
|
2852
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2853
|
+
return this.compareWithString(r, Operators.equals);
|
|
2854
|
+
}
|
|
2855
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2856
|
+
return this.compareWithNumber(r, Operators.equals);
|
|
2857
|
+
}
|
|
2858
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2859
|
+
return this.compareWithBoolean(r, Operators.equals);
|
|
2860
|
+
}
|
|
2861
|
+
return this.compareWithNodeSet(r, Operators.equals);
|
|
2862
|
+
};
|
|
2863
|
+
|
|
2864
|
+
XNodeSet.prototype.notequal = function(r) {
|
|
2865
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2866
|
+
return this.compareWithString(r, Operators.notequal);
|
|
2867
|
+
}
|
|
2868
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2869
|
+
return this.compareWithNumber(r, Operators.notequal);
|
|
2870
|
+
}
|
|
2871
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2872
|
+
return this.compareWithBoolean(r, Operators.notequal);
|
|
2873
|
+
}
|
|
2874
|
+
return this.compareWithNodeSet(r, Operators.notequal);
|
|
2875
|
+
};
|
|
2876
|
+
|
|
2877
|
+
XNodeSet.prototype.lessthan = function(r) {
|
|
2878
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2879
|
+
return this.compareWithNumber(r.number(), Operators.lessthan);
|
|
2880
|
+
}
|
|
2881
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2882
|
+
return this.compareWithNumber(r, Operators.lessthan);
|
|
2883
|
+
}
|
|
2884
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2885
|
+
return this.compareWithBoolean(r, Operators.lessthan);
|
|
2886
|
+
}
|
|
2887
|
+
return this.compareWithNodeSet(r, Operators.lessthan);
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2890
|
+
XNodeSet.prototype.greaterthan = function(r) {
|
|
2891
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2892
|
+
return this.compareWithNumber(r.number(), Operators.greaterthan);
|
|
2893
|
+
}
|
|
2894
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2895
|
+
return this.compareWithNumber(r, Operators.greaterthan);
|
|
2896
|
+
}
|
|
2897
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2898
|
+
return this.compareWithBoolean(r, Operators.greaterthan);
|
|
2899
|
+
}
|
|
2900
|
+
return this.compareWithNodeSet(r, Operators.greaterthan);
|
|
2901
|
+
};
|
|
2902
|
+
|
|
2903
|
+
XNodeSet.prototype.lessthanorequal = function(r) {
|
|
2904
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2905
|
+
return this.compareWithNumber(r.number(), Operators.lessthanorequal);
|
|
2906
|
+
}
|
|
2907
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2908
|
+
return this.compareWithNumber(r, Operators.lessthanorequal);
|
|
2909
|
+
}
|
|
2910
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2911
|
+
return this.compareWithBoolean(r, Operators.lessthanorequal);
|
|
2912
|
+
}
|
|
2913
|
+
return this.compareWithNodeSet(r, Operators.lessthanorequal);
|
|
2914
|
+
};
|
|
2915
|
+
|
|
2916
|
+
XNodeSet.prototype.greaterthanorequal = function(r) {
|
|
2917
|
+
if (Utilities.instance_of(r, XString)) {
|
|
2918
|
+
return this.compareWithNumber(r.number(), Operators.greaterthanorequal);
|
|
2919
|
+
}
|
|
2920
|
+
if (Utilities.instance_of(r, XNumber)) {
|
|
2921
|
+
return this.compareWithNumber(r, Operators.greaterthanorequal);
|
|
2922
|
+
}
|
|
2923
|
+
if (Utilities.instance_of(r, XBoolean)) {
|
|
2924
|
+
return this.compareWithBoolean(r, Operators.greaterthanorequal);
|
|
2925
|
+
}
|
|
2926
|
+
return this.compareWithNodeSet(r, Operators.greaterthanorequal);
|
|
2927
|
+
};
|
|
2928
|
+
|
|
2929
|
+
XNodeSet.prototype.union = function(r) {
|
|
2930
|
+
var ns = new XNodeSet();
|
|
2931
|
+
ns.tree = this.tree;
|
|
2932
|
+
ns.size = this.size;
|
|
2933
|
+
ns.addArray(r.toArray());
|
|
2934
|
+
return ns;
|
|
2935
|
+
};
|
|
2936
|
+
|
|
2937
|
+
// NamespaceNode /////////////////////////////////////////////////////////////
|
|
2938
|
+
|
|
2939
|
+
NamespaceNode.prototype = new Object();
|
|
2940
|
+
NamespaceNode.prototype.constructor = NamespaceNode;
|
|
2941
|
+
NamespaceNode.superclass = Object.prototype;
|
|
2942
|
+
|
|
2943
|
+
function NamespaceNode(pre, ns, p) {
|
|
2944
|
+
this.isNamespaceNode = true;
|
|
2945
|
+
this.prefix = pre;
|
|
2946
|
+
this.namespace = ns;
|
|
2947
|
+
this.parentNode = p;
|
|
2948
|
+
this.localName = pre;
|
|
2949
|
+
this.nodeType = NodeTest.NAMESPACE_NODE;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
NamespaceNode.prototype.toString = function() {
|
|
2953
|
+
return "{ \"" + this.prefix + "\", \"" + this.namespace + "\" }";
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2956
|
+
// Operators /////////////////////////////////////////////////////////////////
|
|
2957
|
+
|
|
2958
|
+
var Operators = new Object();
|
|
2959
|
+
|
|
2960
|
+
Operators.equals = function(l, r) {
|
|
2961
|
+
return l.equals(r);
|
|
2962
|
+
};
|
|
2963
|
+
|
|
2964
|
+
Operators.notequal = function(l, r) {
|
|
2965
|
+
return l.notequal(r);
|
|
2966
|
+
};
|
|
2967
|
+
|
|
2968
|
+
Operators.lessthan = function(l, r) {
|
|
2969
|
+
return l.lessthan(r);
|
|
2970
|
+
};
|
|
2971
|
+
|
|
2972
|
+
Operators.greaterthan = function(l, r) {
|
|
2973
|
+
return l.greaterthan(r);
|
|
2974
|
+
};
|
|
2975
|
+
|
|
2976
|
+
Operators.lessthanorequal = function(l, r) {
|
|
2977
|
+
return l.lessthanorequal(r);
|
|
2978
|
+
};
|
|
2979
|
+
|
|
2980
|
+
Operators.greaterthanorequal = function(l, r) {
|
|
2981
|
+
return l.greaterthanorequal(r);
|
|
2982
|
+
};
|
|
2983
|
+
|
|
2984
|
+
// XPathContext //////////////////////////////////////////////////////////////
|
|
2985
|
+
|
|
2986
|
+
XPathContext.prototype = new Object();
|
|
2987
|
+
XPathContext.prototype.constructor = XPathContext;
|
|
2988
|
+
XPathContext.superclass = Object.prototype;
|
|
2989
|
+
|
|
2990
|
+
function XPathContext(vr, nr, fr) {
|
|
2991
|
+
this.variableResolver = vr != null ? vr : new VariableResolver();
|
|
2992
|
+
this.namespaceResolver = nr != null ? nr : new NamespaceResolver();
|
|
2993
|
+
this.functionResolver = fr != null ? fr : new FunctionResolver();
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
// VariableResolver //////////////////////////////////////////////////////////
|
|
2997
|
+
|
|
2998
|
+
VariableResolver.prototype = new Object();
|
|
2999
|
+
VariableResolver.prototype.constructor = VariableResolver;
|
|
3000
|
+
VariableResolver.superclass = Object.prototype;
|
|
3001
|
+
|
|
3002
|
+
function VariableResolver() {
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
VariableResolver.prototype.getVariable = function(vn, c) {
|
|
3006
|
+
var parts = Utilities.splitQName(vn);
|
|
3007
|
+
if (parts[0] != null) {
|
|
3008
|
+
parts[0] = c.namespaceResolver.getNamespace(parts[0], c.expressionContextNode);
|
|
3009
|
+
}
|
|
3010
|
+
return this.getVariableWithName(parts[0], parts[1], c.expressionContextNode);
|
|
3011
|
+
};
|
|
3012
|
+
|
|
3013
|
+
VariableResolver.prototype.getVariableWithName = function(ns, ln, c) {
|
|
3014
|
+
return null;
|
|
3015
|
+
};
|
|
3016
|
+
|
|
3017
|
+
// FunctionResolver //////////////////////////////////////////////////////////
|
|
3018
|
+
|
|
3019
|
+
FunctionResolver.prototype = new Object();
|
|
3020
|
+
FunctionResolver.prototype.constructor = FunctionResolver;
|
|
3021
|
+
FunctionResolver.superclass = Object.prototype;
|
|
3022
|
+
|
|
3023
|
+
function FunctionResolver(thisArg) {
|
|
3024
|
+
this.thisArg = thisArg != null ? thisArg : Functions;
|
|
3025
|
+
this.functions = new Object();
|
|
3026
|
+
this.addStandardFunctions();
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3029
|
+
FunctionResolver.prototype.addStandardFunctions = function() {
|
|
3030
|
+
this.functions["{}last"] = Functions.last;
|
|
3031
|
+
this.functions["{}position"] = Functions.position;
|
|
3032
|
+
this.functions["{}count"] = Functions.count;
|
|
3033
|
+
this.functions["{}id"] = Functions.id;
|
|
3034
|
+
this.functions["{}local-name"] = Functions.localName;
|
|
3035
|
+
this.functions["{}namespace-uri"] = Functions.namespaceURI;
|
|
3036
|
+
this.functions["{}name"] = Functions.name;
|
|
3037
|
+
this.functions["{}string"] = Functions.string;
|
|
3038
|
+
this.functions["{}concat"] = Functions.concat;
|
|
3039
|
+
this.functions["{}starts-with"] = Functions.startsWith;
|
|
3040
|
+
this.functions["{}contains"] = Functions.contains;
|
|
3041
|
+
this.functions["{}substring-before"] = Functions.substringBefore;
|
|
3042
|
+
this.functions["{}substring-after"] = Functions.substringAfter;
|
|
3043
|
+
this.functions["{}substring"] = Functions.substring;
|
|
3044
|
+
this.functions["{}string-length"] = Functions.stringLength;
|
|
3045
|
+
this.functions["{}normalize-space"] = Functions.normalizeSpace;
|
|
3046
|
+
this.functions["{}translate"] = Functions.translate;
|
|
3047
|
+
this.functions["{}boolean"] = Functions.boolean_;
|
|
3048
|
+
this.functions["{}not"] = Functions.not;
|
|
3049
|
+
this.functions["{}true"] = Functions.true_;
|
|
3050
|
+
this.functions["{}false"] = Functions.false_;
|
|
3051
|
+
this.functions["{}lang"] = Functions.lang;
|
|
3052
|
+
this.functions["{}number"] = Functions.number;
|
|
3053
|
+
this.functions["{}sum"] = Functions.sum;
|
|
3054
|
+
this.functions["{}floor"] = Functions.floor;
|
|
3055
|
+
this.functions["{}ceiling"] = Functions.ceiling;
|
|
3056
|
+
this.functions["{}round"] = Functions.round;
|
|
3057
|
+
};
|
|
3058
|
+
|
|
3059
|
+
FunctionResolver.prototype.addFunction = function(ns, ln, f) {
|
|
3060
|
+
this.functions["{" + ns + "}" + ln] = f;
|
|
3061
|
+
};
|
|
3062
|
+
|
|
3063
|
+
FunctionResolver.prototype.getFunction = function(fn, c) {
|
|
3064
|
+
var parts = Utilities.resolveQName(fn, c.namespaceResolver, c.contextNode, false);
|
|
3065
|
+
return this.getFunctionWithName(parts[0], parts[1], c.contextNode);
|
|
3066
|
+
};
|
|
3067
|
+
|
|
3068
|
+
FunctionResolver.prototype.getFunctionWithName = function(ns, ln, c) {
|
|
3069
|
+
return this.functions["{" + ns + "}" + ln];
|
|
3070
|
+
};
|
|
3071
|
+
|
|
3072
|
+
// NamespaceResolver /////////////////////////////////////////////////////////
|
|
3073
|
+
|
|
3074
|
+
NamespaceResolver.prototype = new Object();
|
|
3075
|
+
NamespaceResolver.prototype.constructor = NamespaceResolver;
|
|
3076
|
+
NamespaceResolver.superclass = Object.prototype;
|
|
3077
|
+
|
|
3078
|
+
function NamespaceResolver() {
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
NamespaceResolver.prototype.getNamespace = function(prefix, n) {
|
|
3082
|
+
if (prefix == "xml") {
|
|
3083
|
+
return XPath.XML_NAMESPACE_URI;
|
|
3084
|
+
} else if (prefix == "xmlns") {
|
|
3085
|
+
return XPath.XMLNS_NAMESPACE_URI;
|
|
3086
|
+
}
|
|
3087
|
+
if (n.nodeType == 9 /*Node.DOCUMENT_NODE*/) {
|
|
3088
|
+
n = n.documentElement;
|
|
3089
|
+
} else if (n.nodeType != 1 /*Node.ELEMENT_NODE*/) {
|
|
3090
|
+
n = n.parentNode;
|
|
3091
|
+
}
|
|
3092
|
+
while (n != null && n.nodeType == 1 /*Node.ELEMENT_NODE*/) {
|
|
3093
|
+
var nnm = n.attributes;
|
|
3094
|
+
for (var i = 0; i < nnm.length; i++) {
|
|
3095
|
+
var a = nnm.item(i);
|
|
3096
|
+
var aname = a.nodeName;
|
|
3097
|
+
if (aname == "xmlns" && prefix == ""
|
|
3098
|
+
|| aname == "xmlns:" + prefix) {
|
|
3099
|
+
return a.nodeValue;
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
n = n.parentNode;
|
|
3103
|
+
}
|
|
3104
|
+
return null;
|
|
3105
|
+
};
|
|
3106
|
+
|
|
3107
|
+
// Functions /////////////////////////////////////////////////////////////////
|
|
3108
|
+
|
|
3109
|
+
Functions = new Object();
|
|
3110
|
+
|
|
3111
|
+
Functions.last = function() {
|
|
3112
|
+
var c = arguments[0];
|
|
3113
|
+
if (arguments.length != 1) {
|
|
3114
|
+
throw new Error("Function last expects ()");
|
|
3115
|
+
}
|
|
3116
|
+
return new XNumber(c.contextSize);
|
|
3117
|
+
};
|
|
3118
|
+
|
|
3119
|
+
Functions.position = function() {
|
|
3120
|
+
var c = arguments[0];
|
|
3121
|
+
if (arguments.length != 1) {
|
|
3122
|
+
throw new Error("Function position expects ()");
|
|
3123
|
+
}
|
|
3124
|
+
return new XNumber(c.contextPosition);
|
|
3125
|
+
};
|
|
3126
|
+
|
|
3127
|
+
Functions.count = function() {
|
|
3128
|
+
var c = arguments[0];
|
|
3129
|
+
var ns;
|
|
3130
|
+
if (arguments.length != 2 || !Utilities.instance_of(ns = arguments[1].evaluate(c), XNodeSet)) {
|
|
3131
|
+
throw new Error("Function count expects (node-set)");
|
|
3132
|
+
}
|
|
3133
|
+
return new XNumber(ns.size);
|
|
3134
|
+
};
|
|
3135
|
+
|
|
3136
|
+
Functions.id = function() {
|
|
3137
|
+
var c = arguments[0];
|
|
3138
|
+
var id;
|
|
3139
|
+
if (arguments.length != 2) {
|
|
3140
|
+
throw new Error("Function id expects (object)");
|
|
3141
|
+
}
|
|
3142
|
+
id = arguments[1].evaluate(c);
|
|
3143
|
+
if (Utilities.instance_of(id, XNodeSet)) {
|
|
3144
|
+
id = id.toArray().join(" ");
|
|
3145
|
+
} else {
|
|
3146
|
+
id = id.stringValue();
|
|
3147
|
+
}
|
|
3148
|
+
var ids = id.split(/[\x0d\x0a\x09\x20]+/);
|
|
3149
|
+
var count = 0;
|
|
3150
|
+
var ns = new XNodeSet();
|
|
3151
|
+
var doc = c.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/
|
|
3152
|
+
? c.contextNode
|
|
3153
|
+
: c.contextNode.ownerDocument;
|
|
3154
|
+
for (var i = 0; i < ids.length; i++) {
|
|
3155
|
+
var n;
|
|
3156
|
+
if (doc.getElementById) {
|
|
3157
|
+
n = doc.getElementById(ids[i]);
|
|
3158
|
+
} else {
|
|
3159
|
+
n = Utilities.getElementById(doc, ids[i]);
|
|
3160
|
+
}
|
|
3161
|
+
if (n != null) {
|
|
3162
|
+
ns.add(n);
|
|
3163
|
+
count++;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
return ns;
|
|
3167
|
+
};
|
|
3168
|
+
|
|
3169
|
+
Functions.localName = function() {
|
|
3170
|
+
var c = arguments[0];
|
|
3171
|
+
var n;
|
|
3172
|
+
if (arguments.length == 1) {
|
|
3173
|
+
n = c.contextNode;
|
|
3174
|
+
} else if (arguments.length == 2) {
|
|
3175
|
+
n = arguments[1].evaluate(c).first();
|
|
3176
|
+
} else {
|
|
3177
|
+
throw new Error("Function local-name expects (node-set?)");
|
|
3178
|
+
}
|
|
3179
|
+
if (n == null) {
|
|
3180
|
+
return new XString("");
|
|
3181
|
+
}
|
|
3182
|
+
return new XString(n.localName ? n.localName : n.baseName);
|
|
3183
|
+
};
|
|
3184
|
+
|
|
3185
|
+
Functions.namespaceURI = function() {
|
|
3186
|
+
var c = arguments[0];
|
|
3187
|
+
var n;
|
|
3188
|
+
if (arguments.length == 1) {
|
|
3189
|
+
n = c.contextNode;
|
|
3190
|
+
} else if (arguments.length == 2) {
|
|
3191
|
+
n = arguments[1].evaluate(c).first();
|
|
3192
|
+
} else {
|
|
3193
|
+
throw new Error("Function namespace-uri expects (node-set?)");
|
|
3194
|
+
}
|
|
3195
|
+
if (n == null) {
|
|
3196
|
+
return new XString("");
|
|
3197
|
+
}
|
|
3198
|
+
return new XString(n.namespaceURI);
|
|
3199
|
+
};
|
|
3200
|
+
|
|
3201
|
+
Functions.name = function() {
|
|
3202
|
+
var c = arguments[0];
|
|
3203
|
+
var n;
|
|
3204
|
+
if (arguments.length == 1) {
|
|
3205
|
+
n = c.contextNode;
|
|
3206
|
+
} else if (arguments.length == 2) {
|
|
3207
|
+
n = arguments[1].evaluate(c).first();
|
|
3208
|
+
} else {
|
|
3209
|
+
throw new Error("Function name expects (node-set?)");
|
|
3210
|
+
}
|
|
3211
|
+
if (n == null) {
|
|
3212
|
+
return new XString("");
|
|
3213
|
+
}
|
|
3214
|
+
if (n.nodeType == 1 /*Node.ELEMENT_NODE*/ || n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
|
|
3215
|
+
return new XString(n.nodeName);
|
|
3216
|
+
} else if (n.localName == null) {
|
|
3217
|
+
return new XString("");
|
|
3218
|
+
} else {
|
|
3219
|
+
return new XString(n.localName);
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3222
|
+
|
|
3223
|
+
Functions.string = function() {
|
|
3224
|
+
var c = arguments[0];
|
|
3225
|
+
if (arguments.length == 1) {
|
|
3226
|
+
return XNodeSet.prototype.stringForNode(c.contextNode);
|
|
3227
|
+
} else if (arguments.length == 2) {
|
|
3228
|
+
return arguments[1].evaluate(c).string();
|
|
3229
|
+
}
|
|
3230
|
+
throw new Error("Function string expects (object?)");
|
|
3231
|
+
};
|
|
3232
|
+
|
|
3233
|
+
Functions.concat = function() {
|
|
3234
|
+
var c = arguments[0];
|
|
3235
|
+
if (arguments.length < 3) {
|
|
3236
|
+
throw new Error("Function concat expects (string, string, string*)");
|
|
3237
|
+
}
|
|
3238
|
+
var s = "";
|
|
3239
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3240
|
+
s += arguments[i].evaluate(c).stringValue();
|
|
3241
|
+
}
|
|
3242
|
+
return new XString(s);
|
|
3243
|
+
};
|
|
3244
|
+
|
|
3245
|
+
Functions.startsWith = function() {
|
|
3246
|
+
var c = arguments[0];
|
|
3247
|
+
if (arguments.length != 3) {
|
|
3248
|
+
throw new Error("Function startsWith expects (string, string)");
|
|
3249
|
+
}
|
|
3250
|
+
var s1 = arguments[1].evaluate(c).stringValue();
|
|
3251
|
+
var s2 = arguments[2].evaluate(c).stringValue();
|
|
3252
|
+
return new XBoolean(s1.substring(0, s2.length) == prefix);
|
|
3253
|
+
};
|
|
3254
|
+
|
|
3255
|
+
Functions.contains = function() {
|
|
3256
|
+
var c = arguments[0];
|
|
3257
|
+
if (arguments.length != 3) {
|
|
3258
|
+
throw new Error("Function contains expects (string, string)");
|
|
3259
|
+
}
|
|
3260
|
+
var s1 = arguments[1].evaluate(c).stringValue();
|
|
3261
|
+
var s2 = arguments[2].evaluate(c).stringValue();
|
|
3262
|
+
return new XBoolean(s1.indexOf(s2) != -1);
|
|
3263
|
+
};
|
|
3264
|
+
|
|
3265
|
+
Functions.substringBefore = function() {
|
|
3266
|
+
var c = arguments[0];
|
|
3267
|
+
if (arguments.length != 3) {
|
|
3268
|
+
throw new Error("Function substring-before expects (string, string)");
|
|
3269
|
+
}
|
|
3270
|
+
var s1 = arguments[1].evaluate(c).stringValue();
|
|
3271
|
+
var s2 = arguments[2].evaluate(c).stringValue();
|
|
3272
|
+
return new XString(s1.substring(0, s1.indexOf(s2)));
|
|
3273
|
+
};
|
|
3274
|
+
|
|
3275
|
+
Functions.substringAfter = function() {
|
|
3276
|
+
var c = arguments[0];
|
|
3277
|
+
if (arguments.length != 3) {
|
|
3278
|
+
throw new Error("Function substring-after expects (string, string)");
|
|
3279
|
+
}
|
|
3280
|
+
var s1 = arguments[1].evaluate(c).stringValue();
|
|
3281
|
+
var s2 = arguments[2].evaluate(c).stringValue();
|
|
3282
|
+
if (s2.length == 0) {
|
|
3283
|
+
return new XString(s1);
|
|
3284
|
+
}
|
|
3285
|
+
var i = s1.indexOf(s2);
|
|
3286
|
+
if (i == -1) {
|
|
3287
|
+
return new XString("");
|
|
3288
|
+
}
|
|
3289
|
+
return new XString(s1.substring(s1.indexOf(s2) + 1));
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3292
|
+
Functions.substring = function() {
|
|
3293
|
+
var c = arguments[0];
|
|
3294
|
+
if (!(arguments.length == 3 || arguments.length == 4)) {
|
|
3295
|
+
throw new Error("Function substring expects (string, number, number?)");
|
|
3296
|
+
}
|
|
3297
|
+
var s = arguments[1].evaluate(c).stringValue();
|
|
3298
|
+
var n1 = Math.round(arguments[2].evaluate(c).numberValue()) - 1;
|
|
3299
|
+
var n2 = arguments.length == 4 ? n1 + Math.round(arguments[3].evaluate(c).numberValue()) : undefined;
|
|
3300
|
+
return new XString(s.substring(n1, n2));
|
|
3301
|
+
};
|
|
3302
|
+
|
|
3303
|
+
Functions.stringLength = function() {
|
|
3304
|
+
var c = arguments[0];
|
|
3305
|
+
var s;
|
|
3306
|
+
if (arguments.length == 2) {
|
|
3307
|
+
s = XNodeSet.prototype.stringForNode(c.contextNode);
|
|
3308
|
+
} else if (arguments.length == 3) {
|
|
3309
|
+
s = arguments[1].evaluate(c).stringValue();
|
|
3310
|
+
} else {
|
|
3311
|
+
throw new Error("Function string-length expects (string?)");
|
|
3312
|
+
}
|
|
3313
|
+
return new XNumber(s.length);
|
|
3314
|
+
};
|
|
3315
|
+
|
|
3316
|
+
Functions.normalizeSpace = function() {
|
|
3317
|
+
var c = arguments[0];
|
|
3318
|
+
var s;
|
|
3319
|
+
if (arguments.length == 1) {
|
|
3320
|
+
s = XNodeSet.prototype.stringForNode(c.contextNode);
|
|
3321
|
+
} else if (arguments.length == 2) {
|
|
3322
|
+
s = arguments[1].evaluate(c).stringValue();
|
|
3323
|
+
} else {
|
|
3324
|
+
throw new Error("Function normalize-space expects (string?)");
|
|
3325
|
+
}
|
|
3326
|
+
var i = 0;
|
|
3327
|
+
var j = s.length - 1;
|
|
3328
|
+
while (Utilities.isSpace(s.charCodeAt(j))) {
|
|
3329
|
+
j--;
|
|
3330
|
+
}
|
|
3331
|
+
var t = "";
|
|
3332
|
+
while (i <= j && Utilities.isSpace(s.charCodeAt(i))) {
|
|
3333
|
+
i++;
|
|
3334
|
+
}
|
|
3335
|
+
while (i <= j) {
|
|
3336
|
+
if (Utilities.isSpace(s.charCodeAt(i))) {
|
|
3337
|
+
t += " ";
|
|
3338
|
+
while (i <= j && Utilities.isSpace(s.charCodeAt(i))) {
|
|
3339
|
+
i++;
|
|
3340
|
+
}
|
|
3341
|
+
} else {
|
|
3342
|
+
t += s.charAt(i);
|
|
3343
|
+
i++;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
return new XString(t);
|
|
3347
|
+
};
|
|
3348
|
+
|
|
3349
|
+
Functions.translate = function() {
|
|
3350
|
+
var c = arguments[0];
|
|
3351
|
+
if (arguments.length != 4) {
|
|
3352
|
+
throw new Error("Function translate expects (string, string, string)");
|
|
3353
|
+
}
|
|
3354
|
+
var s1 = arguments[1].evaluate(c).stringValue();
|
|
3355
|
+
var s2 = arguments[2].evaluate(c).stringValue();
|
|
3356
|
+
var s3 = arguments[3].evaluate(c).stringValue();
|
|
3357
|
+
var map = [];
|
|
3358
|
+
for (var i = 0; i < s2.length; i++) {
|
|
3359
|
+
var j = s2.charCodeAt(i);
|
|
3360
|
+
if (map[j] == undefined) {
|
|
3361
|
+
var k = i > s3.length ? "" : s3.charAt(i);
|
|
3362
|
+
map[j] = k;
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
var t = "";
|
|
3366
|
+
for (var i = 0; i < s1.length; i++) {
|
|
3367
|
+
var c = s1.charCodeAt(i);
|
|
3368
|
+
var r = map[c];
|
|
3369
|
+
if (r == undefined) {
|
|
3370
|
+
t += s1.charAt(i);
|
|
3371
|
+
} else {
|
|
3372
|
+
t += r;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
return new XString(t);
|
|
3376
|
+
};
|
|
3377
|
+
|
|
3378
|
+
Functions.boolean_ = function() {
|
|
3379
|
+
var c = arguments[0];
|
|
3380
|
+
if (arguments.length != 2) {
|
|
3381
|
+
throw new Error("Function boolean expects (object)");
|
|
3382
|
+
}
|
|
3383
|
+
return arguments[1].evaluate(c).bool();
|
|
3384
|
+
};
|
|
3385
|
+
|
|
3386
|
+
Functions.not = function() {
|
|
3387
|
+
var c = arguments[0];
|
|
3388
|
+
if (arguments.length != 2) {
|
|
3389
|
+
throw new Error("Function not expects (object)");
|
|
3390
|
+
}
|
|
3391
|
+
return arguments[1].evaluate(c).bool().not();
|
|
3392
|
+
};
|
|
3393
|
+
|
|
3394
|
+
Functions.true_ = function() {
|
|
3395
|
+
if (arguments.length != 1) {
|
|
3396
|
+
throw new Error("Function true expects ()");
|
|
3397
|
+
}
|
|
3398
|
+
return new XBoolean(true);
|
|
3399
|
+
};
|
|
3400
|
+
|
|
3401
|
+
Functions.false_ = function() {
|
|
3402
|
+
if (arguments.length != 1) {
|
|
3403
|
+
throw new Error("Function false expects ()");
|
|
3404
|
+
}
|
|
3405
|
+
return new XBoolean(false);
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3408
|
+
Functions.lang = function() {
|
|
3409
|
+
var c = arguments[0];
|
|
3410
|
+
if (arguments.length != 2) {
|
|
3411
|
+
throw new Error("Function lang expects (string)");
|
|
3412
|
+
}
|
|
3413
|
+
var lang;
|
|
3414
|
+
for (var n = c.contextNode; n != null && n.nodeType != 9 /*Node.DOCUMENT_NODE*/; n = n.parentNode) {
|
|
3415
|
+
var a = n.getAttributeNS(XPath.XML_NAMESPACE_URI, "lang");
|
|
3416
|
+
if (a != null) {
|
|
3417
|
+
lang = String(a);
|
|
3418
|
+
break;
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
if (lang == null) {
|
|
3422
|
+
return new XBoolean(false);
|
|
3423
|
+
}
|
|
3424
|
+
var s = arguments[1].evaluate(c).stringValue();
|
|
3425
|
+
return new XBoolean(lang.substring(0, s.length) == s
|
|
3426
|
+
&& (lang.length == s.length || lang.charAt(s.length) == '-'));
|
|
3427
|
+
};
|
|
3428
|
+
|
|
3429
|
+
Functions.number = function() {
|
|
3430
|
+
var c = arguments[0];
|
|
3431
|
+
if (!(arguments.length == 1 || arguments.length == 2)) {
|
|
3432
|
+
throw new Error("Function number expects (object?)");
|
|
3433
|
+
}
|
|
3434
|
+
if (arguments.length == 1) {
|
|
3435
|
+
return new XNumber(XNodeSet.prototype.stringForNode(c.contextNode));
|
|
3436
|
+
}
|
|
3437
|
+
return arguments[1].evaluate(c).number();
|
|
3438
|
+
};
|
|
3439
|
+
|
|
3440
|
+
Functions.sum = function() {
|
|
3441
|
+
var c = arguments[0];
|
|
3442
|
+
var ns;
|
|
3443
|
+
if (arguments.length != 2 || !Utilities.instance_of((ns = arguments[1].evaluate(c)), XNodeSet)) {
|
|
3444
|
+
throw new Error("Function sum expects (node-set)");
|
|
3445
|
+
}
|
|
3446
|
+
ns = ns.toArray();
|
|
3447
|
+
var n = 0;
|
|
3448
|
+
for (var i = 0; i < ns.length; i++) {
|
|
3449
|
+
n += new XNumber(XNodeSet.prototype.stringForNode(ns[i])).numberValue();
|
|
3450
|
+
}
|
|
3451
|
+
return new XNumber(n);
|
|
3452
|
+
};
|
|
3453
|
+
|
|
3454
|
+
Functions.floor = function() {
|
|
3455
|
+
var c = arguments[0];
|
|
3456
|
+
if (arguments.length != 2) {
|
|
3457
|
+
throw new Error("Function floor expects (number)");
|
|
3458
|
+
}
|
|
3459
|
+
return new XNumber(Math.floor(arguments[1].evaluate(c).numberValue()));
|
|
3460
|
+
};
|
|
3461
|
+
|
|
3462
|
+
Functions.ceiling = function() {
|
|
3463
|
+
var c = arguments[0];
|
|
3464
|
+
if (arguments.length != 2) {
|
|
3465
|
+
throw new Error("Function ceiling expects (number)");
|
|
3466
|
+
}
|
|
3467
|
+
return new XNumber(Math.ceil(arguments[1].evaluate(c).numberValue()));
|
|
3468
|
+
};
|
|
3469
|
+
|
|
3470
|
+
Functions.round = function() {
|
|
3471
|
+
var c = arguments[0];
|
|
3472
|
+
if (arguments.length != 2) {
|
|
3473
|
+
throw new Error("Function round expects (number)");
|
|
3474
|
+
}
|
|
3475
|
+
return new XNumber(Math.round(arguments[1].evaluate(c).numberValue()));
|
|
3476
|
+
};
|
|
3477
|
+
|
|
3478
|
+
// Utilities /////////////////////////////////////////////////////////////////
|
|
3479
|
+
|
|
3480
|
+
Utilities = new Object();
|
|
3481
|
+
|
|
3482
|
+
Utilities.splitQName = function(qn) {
|
|
3483
|
+
var i = qn.indexOf(":");
|
|
3484
|
+
if (i == -1) {
|
|
3485
|
+
return [ null, qn ];
|
|
3486
|
+
}
|
|
3487
|
+
return [ qn.substring(0, i), qn.substring(i + 1) ];
|
|
3488
|
+
};
|
|
3489
|
+
|
|
3490
|
+
Utilities.resolveQName = function(qn, nr, n, useDefault) {
|
|
3491
|
+
var parts = Utilities.splitQName(qn);
|
|
3492
|
+
if (parts[0] != null) {
|
|
3493
|
+
parts[0] = nr.getNamespace(parts[0], n);
|
|
3494
|
+
} else {
|
|
3495
|
+
if (useDefault) {
|
|
3496
|
+
parts[0] = nr.getNamespace("", n);
|
|
3497
|
+
if (parts[0] == null) {
|
|
3498
|
+
parts[0] = "";
|
|
3499
|
+
}
|
|
3500
|
+
} else {
|
|
3501
|
+
parts[0] = "";
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
return parts;
|
|
3505
|
+
};
|
|
3506
|
+
|
|
3507
|
+
Utilities.isSpace = function(c) {
|
|
3508
|
+
return c == 0x9 || c == 0xd || c == 0xa || c == 0x20;
|
|
3509
|
+
};
|
|
3510
|
+
|
|
3511
|
+
Utilities.isLetter = function(c) {
|
|
3512
|
+
return c >= 0x0041 && c <= 0x005A ||
|
|
3513
|
+
c >= 0x0061 && c <= 0x007A ||
|
|
3514
|
+
c >= 0x00C0 && c <= 0x00D6 ||
|
|
3515
|
+
c >= 0x00D8 && c <= 0x00F6 ||
|
|
3516
|
+
c >= 0x00F8 && c <= 0x00FF ||
|
|
3517
|
+
c >= 0x0100 && c <= 0x0131 ||
|
|
3518
|
+
c >= 0x0134 && c <= 0x013E ||
|
|
3519
|
+
c >= 0x0141 && c <= 0x0148 ||
|
|
3520
|
+
c >= 0x014A && c <= 0x017E ||
|
|
3521
|
+
c >= 0x0180 && c <= 0x01C3 ||
|
|
3522
|
+
c >= 0x01CD && c <= 0x01F0 ||
|
|
3523
|
+
c >= 0x01F4 && c <= 0x01F5 ||
|
|
3524
|
+
c >= 0x01FA && c <= 0x0217 ||
|
|
3525
|
+
c >= 0x0250 && c <= 0x02A8 ||
|
|
3526
|
+
c >= 0x02BB && c <= 0x02C1 ||
|
|
3527
|
+
c == 0x0386 ||
|
|
3528
|
+
c >= 0x0388 && c <= 0x038A ||
|
|
3529
|
+
c == 0x038C ||
|
|
3530
|
+
c >= 0x038E && c <= 0x03A1 ||
|
|
3531
|
+
c >= 0x03A3 && c <= 0x03CE ||
|
|
3532
|
+
c >= 0x03D0 && c <= 0x03D6 ||
|
|
3533
|
+
c == 0x03DA ||
|
|
3534
|
+
c == 0x03DC ||
|
|
3535
|
+
c == 0x03DE ||
|
|
3536
|
+
c == 0x03E0 ||
|
|
3537
|
+
c >= 0x03E2 && c <= 0x03F3 ||
|
|
3538
|
+
c >= 0x0401 && c <= 0x040C ||
|
|
3539
|
+
c >= 0x040E && c <= 0x044F ||
|
|
3540
|
+
c >= 0x0451 && c <= 0x045C ||
|
|
3541
|
+
c >= 0x045E && c <= 0x0481 ||
|
|
3542
|
+
c >= 0x0490 && c <= 0x04C4 ||
|
|
3543
|
+
c >= 0x04C7 && c <= 0x04C8 ||
|
|
3544
|
+
c >= 0x04CB && c <= 0x04CC ||
|
|
3545
|
+
c >= 0x04D0 && c <= 0x04EB ||
|
|
3546
|
+
c >= 0x04EE && c <= 0x04F5 ||
|
|
3547
|
+
c >= 0x04F8 && c <= 0x04F9 ||
|
|
3548
|
+
c >= 0x0531 && c <= 0x0556 ||
|
|
3549
|
+
c == 0x0559 ||
|
|
3550
|
+
c >= 0x0561 && c <= 0x0586 ||
|
|
3551
|
+
c >= 0x05D0 && c <= 0x05EA ||
|
|
3552
|
+
c >= 0x05F0 && c <= 0x05F2 ||
|
|
3553
|
+
c >= 0x0621 && c <= 0x063A ||
|
|
3554
|
+
c >= 0x0641 && c <= 0x064A ||
|
|
3555
|
+
c >= 0x0671 && c <= 0x06B7 ||
|
|
3556
|
+
c >= 0x06BA && c <= 0x06BE ||
|
|
3557
|
+
c >= 0x06C0 && c <= 0x06CE ||
|
|
3558
|
+
c >= 0x06D0 && c <= 0x06D3 ||
|
|
3559
|
+
c == 0x06D5 ||
|
|
3560
|
+
c >= 0x06E5 && c <= 0x06E6 ||
|
|
3561
|
+
c >= 0x0905 && c <= 0x0939 ||
|
|
3562
|
+
c == 0x093D ||
|
|
3563
|
+
c >= 0x0958 && c <= 0x0961 ||
|
|
3564
|
+
c >= 0x0985 && c <= 0x098C ||
|
|
3565
|
+
c >= 0x098F && c <= 0x0990 ||
|
|
3566
|
+
c >= 0x0993 && c <= 0x09A8 ||
|
|
3567
|
+
c >= 0x09AA && c <= 0x09B0 ||
|
|
3568
|
+
c == 0x09B2 ||
|
|
3569
|
+
c >= 0x09B6 && c <= 0x09B9 ||
|
|
3570
|
+
c >= 0x09DC && c <= 0x09DD ||
|
|
3571
|
+
c >= 0x09DF && c <= 0x09E1 ||
|
|
3572
|
+
c >= 0x09F0 && c <= 0x09F1 ||
|
|
3573
|
+
c >= 0x0A05 && c <= 0x0A0A ||
|
|
3574
|
+
c >= 0x0A0F && c <= 0x0A10 ||
|
|
3575
|
+
c >= 0x0A13 && c <= 0x0A28 ||
|
|
3576
|
+
c >= 0x0A2A && c <= 0x0A30 ||
|
|
3577
|
+
c >= 0x0A32 && c <= 0x0A33 ||
|
|
3578
|
+
c >= 0x0A35 && c <= 0x0A36 ||
|
|
3579
|
+
c >= 0x0A38 && c <= 0x0A39 ||
|
|
3580
|
+
c >= 0x0A59 && c <= 0x0A5C ||
|
|
3581
|
+
c == 0x0A5E ||
|
|
3582
|
+
c >= 0x0A72 && c <= 0x0A74 ||
|
|
3583
|
+
c >= 0x0A85 && c <= 0x0A8B ||
|
|
3584
|
+
c == 0x0A8D ||
|
|
3585
|
+
c >= 0x0A8F && c <= 0x0A91 ||
|
|
3586
|
+
c >= 0x0A93 && c <= 0x0AA8 ||
|
|
3587
|
+
c >= 0x0AAA && c <= 0x0AB0 ||
|
|
3588
|
+
c >= 0x0AB2 && c <= 0x0AB3 ||
|
|
3589
|
+
c >= 0x0AB5 && c <= 0x0AB9 ||
|
|
3590
|
+
c == 0x0ABD ||
|
|
3591
|
+
c == 0x0AE0 ||
|
|
3592
|
+
c >= 0x0B05 && c <= 0x0B0C ||
|
|
3593
|
+
c >= 0x0B0F && c <= 0x0B10 ||
|
|
3594
|
+
c >= 0x0B13 && c <= 0x0B28 ||
|
|
3595
|
+
c >= 0x0B2A && c <= 0x0B30 ||
|
|
3596
|
+
c >= 0x0B32 && c <= 0x0B33 ||
|
|
3597
|
+
c >= 0x0B36 && c <= 0x0B39 ||
|
|
3598
|
+
c == 0x0B3D ||
|
|
3599
|
+
c >= 0x0B5C && c <= 0x0B5D ||
|
|
3600
|
+
c >= 0x0B5F && c <= 0x0B61 ||
|
|
3601
|
+
c >= 0x0B85 && c <= 0x0B8A ||
|
|
3602
|
+
c >= 0x0B8E && c <= 0x0B90 ||
|
|
3603
|
+
c >= 0x0B92 && c <= 0x0B95 ||
|
|
3604
|
+
c >= 0x0B99 && c <= 0x0B9A ||
|
|
3605
|
+
c == 0x0B9C ||
|
|
3606
|
+
c >= 0x0B9E && c <= 0x0B9F ||
|
|
3607
|
+
c >= 0x0BA3 && c <= 0x0BA4 ||
|
|
3608
|
+
c >= 0x0BA8 && c <= 0x0BAA ||
|
|
3609
|
+
c >= 0x0BAE && c <= 0x0BB5 ||
|
|
3610
|
+
c >= 0x0BB7 && c <= 0x0BB9 ||
|
|
3611
|
+
c >= 0x0C05 && c <= 0x0C0C ||
|
|
3612
|
+
c >= 0x0C0E && c <= 0x0C10 ||
|
|
3613
|
+
c >= 0x0C12 && c <= 0x0C28 ||
|
|
3614
|
+
c >= 0x0C2A && c <= 0x0C33 ||
|
|
3615
|
+
c >= 0x0C35 && c <= 0x0C39 ||
|
|
3616
|
+
c >= 0x0C60 && c <= 0x0C61 ||
|
|
3617
|
+
c >= 0x0C85 && c <= 0x0C8C ||
|
|
3618
|
+
c >= 0x0C8E && c <= 0x0C90 ||
|
|
3619
|
+
c >= 0x0C92 && c <= 0x0CA8 ||
|
|
3620
|
+
c >= 0x0CAA && c <= 0x0CB3 ||
|
|
3621
|
+
c >= 0x0CB5 && c <= 0x0CB9 ||
|
|
3622
|
+
c == 0x0CDE ||
|
|
3623
|
+
c >= 0x0CE0 && c <= 0x0CE1 ||
|
|
3624
|
+
c >= 0x0D05 && c <= 0x0D0C ||
|
|
3625
|
+
c >= 0x0D0E && c <= 0x0D10 ||
|
|
3626
|
+
c >= 0x0D12 && c <= 0x0D28 ||
|
|
3627
|
+
c >= 0x0D2A && c <= 0x0D39 ||
|
|
3628
|
+
c >= 0x0D60 && c <= 0x0D61 ||
|
|
3629
|
+
c >= 0x0E01 && c <= 0x0E2E ||
|
|
3630
|
+
c == 0x0E30 ||
|
|
3631
|
+
c >= 0x0E32 && c <= 0x0E33 ||
|
|
3632
|
+
c >= 0x0E40 && c <= 0x0E45 ||
|
|
3633
|
+
c >= 0x0E81 && c <= 0x0E82 ||
|
|
3634
|
+
c == 0x0E84 ||
|
|
3635
|
+
c >= 0x0E87 && c <= 0x0E88 ||
|
|
3636
|
+
c == 0x0E8A ||
|
|
3637
|
+
c == 0x0E8D ||
|
|
3638
|
+
c >= 0x0E94 && c <= 0x0E97 ||
|
|
3639
|
+
c >= 0x0E99 && c <= 0x0E9F ||
|
|
3640
|
+
c >= 0x0EA1 && c <= 0x0EA3 ||
|
|
3641
|
+
c == 0x0EA5 ||
|
|
3642
|
+
c == 0x0EA7 ||
|
|
3643
|
+
c >= 0x0EAA && c <= 0x0EAB ||
|
|
3644
|
+
c >= 0x0EAD && c <= 0x0EAE ||
|
|
3645
|
+
c == 0x0EB0 ||
|
|
3646
|
+
c >= 0x0EB2 && c <= 0x0EB3 ||
|
|
3647
|
+
c == 0x0EBD ||
|
|
3648
|
+
c >= 0x0EC0 && c <= 0x0EC4 ||
|
|
3649
|
+
c >= 0x0F40 && c <= 0x0F47 ||
|
|
3650
|
+
c >= 0x0F49 && c <= 0x0F69 ||
|
|
3651
|
+
c >= 0x10A0 && c <= 0x10C5 ||
|
|
3652
|
+
c >= 0x10D0 && c <= 0x10F6 ||
|
|
3653
|
+
c == 0x1100 ||
|
|
3654
|
+
c >= 0x1102 && c <= 0x1103 ||
|
|
3655
|
+
c >= 0x1105 && c <= 0x1107 ||
|
|
3656
|
+
c == 0x1109 ||
|
|
3657
|
+
c >= 0x110B && c <= 0x110C ||
|
|
3658
|
+
c >= 0x110E && c <= 0x1112 ||
|
|
3659
|
+
c == 0x113C ||
|
|
3660
|
+
c == 0x113E ||
|
|
3661
|
+
c == 0x1140 ||
|
|
3662
|
+
c == 0x114C ||
|
|
3663
|
+
c == 0x114E ||
|
|
3664
|
+
c == 0x1150 ||
|
|
3665
|
+
c >= 0x1154 && c <= 0x1155 ||
|
|
3666
|
+
c == 0x1159 ||
|
|
3667
|
+
c >= 0x115F && c <= 0x1161 ||
|
|
3668
|
+
c == 0x1163 ||
|
|
3669
|
+
c == 0x1165 ||
|
|
3670
|
+
c == 0x1167 ||
|
|
3671
|
+
c == 0x1169 ||
|
|
3672
|
+
c >= 0x116D && c <= 0x116E ||
|
|
3673
|
+
c >= 0x1172 && c <= 0x1173 ||
|
|
3674
|
+
c == 0x1175 ||
|
|
3675
|
+
c == 0x119E ||
|
|
3676
|
+
c == 0x11A8 ||
|
|
3677
|
+
c == 0x11AB ||
|
|
3678
|
+
c >= 0x11AE && c <= 0x11AF ||
|
|
3679
|
+
c >= 0x11B7 && c <= 0x11B8 ||
|
|
3680
|
+
c == 0x11BA ||
|
|
3681
|
+
c >= 0x11BC && c <= 0x11C2 ||
|
|
3682
|
+
c == 0x11EB ||
|
|
3683
|
+
c == 0x11F0 ||
|
|
3684
|
+
c == 0x11F9 ||
|
|
3685
|
+
c >= 0x1E00 && c <= 0x1E9B ||
|
|
3686
|
+
c >= 0x1EA0 && c <= 0x1EF9 ||
|
|
3687
|
+
c >= 0x1F00 && c <= 0x1F15 ||
|
|
3688
|
+
c >= 0x1F18 && c <= 0x1F1D ||
|
|
3689
|
+
c >= 0x1F20 && c <= 0x1F45 ||
|
|
3690
|
+
c >= 0x1F48 && c <= 0x1F4D ||
|
|
3691
|
+
c >= 0x1F50 && c <= 0x1F57 ||
|
|
3692
|
+
c == 0x1F59 ||
|
|
3693
|
+
c == 0x1F5B ||
|
|
3694
|
+
c == 0x1F5D ||
|
|
3695
|
+
c >= 0x1F5F && c <= 0x1F7D ||
|
|
3696
|
+
c >= 0x1F80 && c <= 0x1FB4 ||
|
|
3697
|
+
c >= 0x1FB6 && c <= 0x1FBC ||
|
|
3698
|
+
c == 0x1FBE ||
|
|
3699
|
+
c >= 0x1FC2 && c <= 0x1FC4 ||
|
|
3700
|
+
c >= 0x1FC6 && c <= 0x1FCC ||
|
|
3701
|
+
c >= 0x1FD0 && c <= 0x1FD3 ||
|
|
3702
|
+
c >= 0x1FD6 && c <= 0x1FDB ||
|
|
3703
|
+
c >= 0x1FE0 && c <= 0x1FEC ||
|
|
3704
|
+
c >= 0x1FF2 && c <= 0x1FF4 ||
|
|
3705
|
+
c >= 0x1FF6 && c <= 0x1FFC ||
|
|
3706
|
+
c == 0x2126 ||
|
|
3707
|
+
c >= 0x212A && c <= 0x212B ||
|
|
3708
|
+
c == 0x212E ||
|
|
3709
|
+
c >= 0x2180 && c <= 0x2182 ||
|
|
3710
|
+
c >= 0x3041 && c <= 0x3094 ||
|
|
3711
|
+
c >= 0x30A1 && c <= 0x30FA ||
|
|
3712
|
+
c >= 0x3105 && c <= 0x312C ||
|
|
3713
|
+
c >= 0xAC00 && c <= 0xD7A3 ||
|
|
3714
|
+
c >= 0x4E00 && c <= 0x9FA5 ||
|
|
3715
|
+
c == 0x3007 ||
|
|
3716
|
+
c >= 0x3021 && c <= 0x3029;
|
|
3717
|
+
};
|
|
3718
|
+
|
|
3719
|
+
Utilities.isNCNameChar = function(c) {
|
|
3720
|
+
return c >= 0x0030 && c <= 0x0039
|
|
3721
|
+
|| c >= 0x0660 && c <= 0x0669
|
|
3722
|
+
|| c >= 0x06F0 && c <= 0x06F9
|
|
3723
|
+
|| c >= 0x0966 && c <= 0x096F
|
|
3724
|
+
|| c >= 0x09E6 && c <= 0x09EF
|
|
3725
|
+
|| c >= 0x0A66 && c <= 0x0A6F
|
|
3726
|
+
|| c >= 0x0AE6 && c <= 0x0AEF
|
|
3727
|
+
|| c >= 0x0B66 && c <= 0x0B6F
|
|
3728
|
+
|| c >= 0x0BE7 && c <= 0x0BEF
|
|
3729
|
+
|| c >= 0x0C66 && c <= 0x0C6F
|
|
3730
|
+
|| c >= 0x0CE6 && c <= 0x0CEF
|
|
3731
|
+
|| c >= 0x0D66 && c <= 0x0D6F
|
|
3732
|
+
|| c >= 0x0E50 && c <= 0x0E59
|
|
3733
|
+
|| c >= 0x0ED0 && c <= 0x0ED9
|
|
3734
|
+
|| c >= 0x0F20 && c <= 0x0F29
|
|
3735
|
+
|| c == 0x002E
|
|
3736
|
+
|| c == 0x002D
|
|
3737
|
+
|| c == 0x005F
|
|
3738
|
+
|| Utilities.isLetter(c)
|
|
3739
|
+
|| c >= 0x0300 && c <= 0x0345
|
|
3740
|
+
|| c >= 0x0360 && c <= 0x0361
|
|
3741
|
+
|| c >= 0x0483 && c <= 0x0486
|
|
3742
|
+
|| c >= 0x0591 && c <= 0x05A1
|
|
3743
|
+
|| c >= 0x05A3 && c <= 0x05B9
|
|
3744
|
+
|| c >= 0x05BB && c <= 0x05BD
|
|
3745
|
+
|| c == 0x05BF
|
|
3746
|
+
|| c >= 0x05C1 && c <= 0x05C2
|
|
3747
|
+
|| c == 0x05C4
|
|
3748
|
+
|| c >= 0x064B && c <= 0x0652
|
|
3749
|
+
|| c == 0x0670
|
|
3750
|
+
|| c >= 0x06D6 && c <= 0x06DC
|
|
3751
|
+
|| c >= 0x06DD && c <= 0x06DF
|
|
3752
|
+
|| c >= 0x06E0 && c <= 0x06E4
|
|
3753
|
+
|| c >= 0x06E7 && c <= 0x06E8
|
|
3754
|
+
|| c >= 0x06EA && c <= 0x06ED
|
|
3755
|
+
|| c >= 0x0901 && c <= 0x0903
|
|
3756
|
+
|| c == 0x093C
|
|
3757
|
+
|| c >= 0x093E && c <= 0x094C
|
|
3758
|
+
|| c == 0x094D
|
|
3759
|
+
|| c >= 0x0951 && c <= 0x0954
|
|
3760
|
+
|| c >= 0x0962 && c <= 0x0963
|
|
3761
|
+
|| c >= 0x0981 && c <= 0x0983
|
|
3762
|
+
|| c == 0x09BC
|
|
3763
|
+
|| c == 0x09BE
|
|
3764
|
+
|| c == 0x09BF
|
|
3765
|
+
|| c >= 0x09C0 && c <= 0x09C4
|
|
3766
|
+
|| c >= 0x09C7 && c <= 0x09C8
|
|
3767
|
+
|| c >= 0x09CB && c <= 0x09CD
|
|
3768
|
+
|| c == 0x09D7
|
|
3769
|
+
|| c >= 0x09E2 && c <= 0x09E3
|
|
3770
|
+
|| c == 0x0A02
|
|
3771
|
+
|| c == 0x0A3C
|
|
3772
|
+
|| c == 0x0A3E
|
|
3773
|
+
|| c == 0x0A3F
|
|
3774
|
+
|| c >= 0x0A40 && c <= 0x0A42
|
|
3775
|
+
|| c >= 0x0A47 && c <= 0x0A48
|
|
3776
|
+
|| c >= 0x0A4B && c <= 0x0A4D
|
|
3777
|
+
|| c >= 0x0A70 && c <= 0x0A71
|
|
3778
|
+
|| c >= 0x0A81 && c <= 0x0A83
|
|
3779
|
+
|| c == 0x0ABC
|
|
3780
|
+
|| c >= 0x0ABE && c <= 0x0AC5
|
|
3781
|
+
|| c >= 0x0AC7 && c <= 0x0AC9
|
|
3782
|
+
|| c >= 0x0ACB && c <= 0x0ACD
|
|
3783
|
+
|| c >= 0x0B01 && c <= 0x0B03
|
|
3784
|
+
|| c == 0x0B3C
|
|
3785
|
+
|| c >= 0x0B3E && c <= 0x0B43
|
|
3786
|
+
|| c >= 0x0B47 && c <= 0x0B48
|
|
3787
|
+
|| c >= 0x0B4B && c <= 0x0B4D
|
|
3788
|
+
|| c >= 0x0B56 && c <= 0x0B57
|
|
3789
|
+
|| c >= 0x0B82 && c <= 0x0B83
|
|
3790
|
+
|| c >= 0x0BBE && c <= 0x0BC2
|
|
3791
|
+
|| c >= 0x0BC6 && c <= 0x0BC8
|
|
3792
|
+
|| c >= 0x0BCA && c <= 0x0BCD
|
|
3793
|
+
|| c == 0x0BD7
|
|
3794
|
+
|| c >= 0x0C01 && c <= 0x0C03
|
|
3795
|
+
|| c >= 0x0C3E && c <= 0x0C44
|
|
3796
|
+
|| c >= 0x0C46 && c <= 0x0C48
|
|
3797
|
+
|| c >= 0x0C4A && c <= 0x0C4D
|
|
3798
|
+
|| c >= 0x0C55 && c <= 0x0C56
|
|
3799
|
+
|| c >= 0x0C82 && c <= 0x0C83
|
|
3800
|
+
|| c >= 0x0CBE && c <= 0x0CC4
|
|
3801
|
+
|| c >= 0x0CC6 && c <= 0x0CC8
|
|
3802
|
+
|| c >= 0x0CCA && c <= 0x0CCD
|
|
3803
|
+
|| c >= 0x0CD5 && c <= 0x0CD6
|
|
3804
|
+
|| c >= 0x0D02 && c <= 0x0D03
|
|
3805
|
+
|| c >= 0x0D3E && c <= 0x0D43
|
|
3806
|
+
|| c >= 0x0D46 && c <= 0x0D48
|
|
3807
|
+
|| c >= 0x0D4A && c <= 0x0D4D
|
|
3808
|
+
|| c == 0x0D57
|
|
3809
|
+
|| c == 0x0E31
|
|
3810
|
+
|| c >= 0x0E34 && c <= 0x0E3A
|
|
3811
|
+
|| c >= 0x0E47 && c <= 0x0E4E
|
|
3812
|
+
|| c == 0x0EB1
|
|
3813
|
+
|| c >= 0x0EB4 && c <= 0x0EB9
|
|
3814
|
+
|| c >= 0x0EBB && c <= 0x0EBC
|
|
3815
|
+
|| c >= 0x0EC8 && c <= 0x0ECD
|
|
3816
|
+
|| c >= 0x0F18 && c <= 0x0F19
|
|
3817
|
+
|| c == 0x0F35
|
|
3818
|
+
|| c == 0x0F37
|
|
3819
|
+
|| c == 0x0F39
|
|
3820
|
+
|| c == 0x0F3E
|
|
3821
|
+
|| c == 0x0F3F
|
|
3822
|
+
|| c >= 0x0F71 && c <= 0x0F84
|
|
3823
|
+
|| c >= 0x0F86 && c <= 0x0F8B
|
|
3824
|
+
|| c >= 0x0F90 && c <= 0x0F95
|
|
3825
|
+
|| c == 0x0F97
|
|
3826
|
+
|| c >= 0x0F99 && c <= 0x0FAD
|
|
3827
|
+
|| c >= 0x0FB1 && c <= 0x0FB7
|
|
3828
|
+
|| c == 0x0FB9
|
|
3829
|
+
|| c >= 0x20D0 && c <= 0x20DC
|
|
3830
|
+
|| c == 0x20E1
|
|
3831
|
+
|| c >= 0x302A && c <= 0x302F
|
|
3832
|
+
|| c == 0x3099
|
|
3833
|
+
|| c == 0x309A
|
|
3834
|
+
|| c == 0x00B7
|
|
3835
|
+
|| c == 0x02D0
|
|
3836
|
+
|| c == 0x02D1
|
|
3837
|
+
|| c == 0x0387
|
|
3838
|
+
|| c == 0x0640
|
|
3839
|
+
|| c == 0x0E46
|
|
3840
|
+
|| c == 0x0EC6
|
|
3841
|
+
|| c == 0x3005
|
|
3842
|
+
|| c >= 0x3031 && c <= 0x3035
|
|
3843
|
+
|| c >= 0x309D && c <= 0x309E
|
|
3844
|
+
|| c >= 0x30FC && c <= 0x30FE;
|
|
3845
|
+
};
|
|
3846
|
+
|
|
3847
|
+
Utilities.coalesceText = function(n) {
|
|
3848
|
+
for (var m = n.firstChild; m != null; m = m.nextSibling) {
|
|
3849
|
+
if (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) {
|
|
3850
|
+
var s = m.nodeValue;
|
|
3851
|
+
var first = m;
|
|
3852
|
+
m = m.nextSibling;
|
|
3853
|
+
while (m != null && (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/)) {
|
|
3854
|
+
s += m.nodeValue;
|
|
3855
|
+
var del = m;
|
|
3856
|
+
m = m.nextSibling;
|
|
3857
|
+
del.parentNode.removeChild(del);
|
|
3858
|
+
}
|
|
3859
|
+
if (first.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) {
|
|
3860
|
+
var p = first.parentNode;
|
|
3861
|
+
if (first.nextSibling == null) {
|
|
3862
|
+
p.removeChild(first);
|
|
3863
|
+
p.appendChild(p.ownerDocument.createTextNode(s));
|
|
3864
|
+
} else {
|
|
3865
|
+
var next = first.nextSibling;
|
|
3866
|
+
p.removeChild(first);
|
|
3867
|
+
p.insertBefore(p.ownerDocument.createTextNode(s), next);
|
|
3868
|
+
}
|
|
3869
|
+
} else {
|
|
3870
|
+
first.nodeValue = s;
|
|
3871
|
+
}
|
|
3872
|
+
if (m == null) {
|
|
3873
|
+
break;
|
|
3874
|
+
}
|
|
3875
|
+
} else if (m.nodeType == 1 /*Node.ELEMENT_NODE*/) {
|
|
3876
|
+
Utilities.coalesceText(m);
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
};
|
|
3880
|
+
|
|
3881
|
+
Utilities.instance_of = function(o, c) {
|
|
3882
|
+
while (o != null) {
|
|
3883
|
+
if (o.constructor === c) {
|
|
3884
|
+
return true;
|
|
3885
|
+
}
|
|
3886
|
+
if (o === Object) {
|
|
3887
|
+
return false;
|
|
3888
|
+
}
|
|
3889
|
+
o = o.constructor.superclass;
|
|
3890
|
+
}
|
|
3891
|
+
return false;
|
|
3892
|
+
};
|
|
3893
|
+
|
|
3894
|
+
Utilities.getElementById = function(n, id) {
|
|
3895
|
+
// Note that this does not check the DTD to check for actual
|
|
3896
|
+
// attributes of type ID, so this may be a bit wrong.
|
|
3897
|
+
if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) {
|
|
3898
|
+
if (n.getAttribute("id") == id
|
|
3899
|
+
|| n.getAttributeNS(null, "id") == id) {
|
|
3900
|
+
return n;
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
for (var m = n.firstChild; m != null; m = m.nextSibling) {
|
|
3904
|
+
var res = Utilities.getElementById(m, id);
|
|
3905
|
+
if (res != null) {
|
|
3906
|
+
return res;
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
return null;
|
|
3910
|
+
};
|