[OpenLayers-Commits] r12058 - in
sandbox/bartvde/exception/openlayers: lib/OpenLayers/Format
lib/OpenLayers/Format/OWSCommon tests tests/Format/OWSCommon
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Tue Jun 7 13:41:12 EDT 2011
Author: bartvde
Date: 2011-06-07 10:41:11 -0700 (Tue, 07 Jun 2011)
New Revision: 12058
Added:
sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_1_0.html
Modified:
sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon.js
sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js
sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_0_0.js
sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js
sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_0_0.html
sandbox/bartvde/exception/openlayers/tests/list-tests.html
Log:
more work on the exception formats
Modified: sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js
===================================================================
--- sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js 2011-06-07 16:49:54 UTC (rev 12057)
+++ sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1.js 2011-06-07 17:41:11 UTC (rev 12058)
@@ -51,18 +51,18 @@
*/
readers: {
"ows": {
- "ExceptionReport": function(node, obj) {
- obj.exceptionReport = {};
- this.readChildNodes(node, obj.exceptionReport);
- },
"Exception": function(node, exceptionReport) {
- exceptionReport.exception = {
- code: node.getAttribute('exceptionCode')
+ var exception = {
+ code: node.getAttribute('exceptionCode'),
+ locator: node.getAttribute('locator'),
+ texts: []
};
- this.readChildNodes(node, exceptionReport.exception);
+ exceptionReport.exceptions.push(exception);
+ this.readChildNodes(node, exception);
},
"ExceptionText": function(node, exception) {
- exception.text = this.getChildValue(node);
+ var text = this.getChildValue(node);
+ exception.texts.push(text);
},
"ServiceIdentification": function(node, obj) {
obj.serviceIdentification = {};
Modified: sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_0_0.js
===================================================================
--- sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_0_0.js 2011-06-07 16:49:54 UTC (rev 12057)
+++ sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_0_0.js 2011-06-07 17:41:11 UTC (rev 12058)
@@ -31,7 +31,16 @@
* from the parent.
*/
readers: {
- "ows": OpenLayers.Format.OWSCommon.v1.prototype.readers["ows"]
+ "ows": OpenLayers.Util.applyDefaults({
+ "ExceptionReport": function(node, obj) {
+ obj.exceptionReport = {
+ version: node.getAttribute('version'),
+ language: node.getAttribute('language'),
+ exceptions: []
+ };
+ this.readChildNodes(node, obj.exceptionReport);
+ }
+ }, OpenLayers.Format.OWSCommon.v1.prototype.readers.ows)
},
/**
@@ -41,7 +50,7 @@
* node names they produce.
*/
writers: {
- "ows": OpenLayers.Format.OWSCommon.v1.prototype.writers["ows"]
+ "ows": OpenLayers.Format.OWSCommon.v1.prototype.writers.ows
},
CLASS_NAME: "OpenLayers.Format.OWSCommon.v1_0_0"
Modified: sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js
===================================================================
--- sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js 2011-06-07 16:49:54 UTC (rev 12057)
+++ sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon/v1_1_0.js 2011-06-07 17:41:11 UTC (rev 12058)
@@ -32,6 +32,14 @@
*/
readers: {
"ows": OpenLayers.Util.applyDefaults({
+ "ExceptionReport": function(node, obj) {
+ obj.exceptionReport = {
+ version: node.getAttribute('version'),
+ language: node.getAttribute('xml:lang'),
+ exceptions: []
+ };
+ this.readChildNodes(node, obj.exceptionReport);
+ },
"AllowedValues": function(node, parameter) {
parameter.allowedValues = {};
this.readChildNodes(node, parameter.allowedValues);
Modified: sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon.js
===================================================================
--- sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon.js 2011-06-07 16:49:54 UTC (rev 12057)
+++ sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/OWSCommon.js 2011-06-07 17:41:11 UTC (rev 12058)
@@ -63,7 +63,12 @@
var root = data.documentElement;
var version = this.version;
if(!version) {
- version = root.getAttribute("version");
+ // remember version does not correspond to the OWS version
+ // it corresponds to the WMS/WFS/WCS etc. request version
+ var uri = root.getAttribute("xmlns:ows");
+ if (uri.substring(uri.lastIndexOf("/")+1) === "1.1") {
+ version ="1.1.0";
+ }
if(!version) {
version = this.defaultVersion;
}
Modified: sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_0_0.html
===================================================================
--- sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_0_0.html 2011-06-07 16:49:54 UTC (rev 12057)
+++ sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_0_0.html 2011-06-07 17:41:11 UTC (rev 12058)
@@ -4,21 +4,27 @@
<script type="text/javascript">
function test_read_exception(t) {
- t.plan(2);
+ t.plan(6);
var text = '<?xml version="1.0" encoding="UTF-8"?>' +
-'<ows:ExceptionReport version="1.0.0"' +
+'<ows:ExceptionReport language="en" version="1.0.0"' +
' xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">' +
-' <ows:Exception exceptionCode="InvalidParameterValue">' +
+' <ows:Exception locator="foo" exceptionCode="InvalidParameterValue">' +
' <ows:ExceptionText>Update error: Error occured updating features</ows:ExceptionText>' +
+' <ows:ExceptionText>Second exception line</ows:ExceptionText>' +
' </ows:Exception>' +
'</ows:ExceptionReport>';
var format = new OpenLayers.Format.OWSCommon();
var result = format.read(text);
- var exception = result.exceptionReport.exception;
+ var report = result.exceptionReport;
+ t.eq(report.version, "1.0.0", "Version parsed correctly");
+ t.eq(report.language, "en", "Language parsed correctly");
+ var exception = report.exceptions[0];
t.eq(exception.code, "InvalidParameterValue", "exceptionCode properly parsed");
- t.eq(exception.text, "Update error: Error occured updating features", "ExceptionText correctly parsed");
+ t.eq(exception.locator, "foo", "locator properly parsed");
+ t.eq(exception.texts[0], "Update error: Error occured updating features", "ExceptionText correctly parsed");
+ t.eq(exception.texts[1], "Second exception line", "Second ExceptionText correctly parsed");
}
</script>
Added: sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_1_0.html
===================================================================
--- sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_1_0.html (rev 0)
+++ sandbox/bartvde/exception/openlayers/tests/Format/OWSCommon/v1_1_0.html 2011-06-07 17:41:11 UTC (rev 12058)
@@ -0,0 +1,34 @@
+<html>
+<head>
+ <script src="../../OLLoader.js"></script>
+ <script type="text/javascript">
+
+ function test_read_exception(t) {
+ t.plan(6);
+ var text = '<?xml version="1.0" encoding="UTF-8"?>' +
+'<ows:ExceptionReport xml:lang="en" version="1.0.0"' +
+' xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"' +
+' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/1.1">' +
+' <ows:Exception locator="foo" exceptionCode="InvalidParameterValue">' +
+' <ows:ExceptionText>Update error: Error occured updating features</ows:ExceptionText>' +
+' <ows:ExceptionText>Second exception line</ows:ExceptionText>' +
+' </ows:Exception>' +
+'</ows:ExceptionReport>';
+
+ var format = new OpenLayers.Format.OWSCommon();
+ var result = format.read(text);
+ var report = result.exceptionReport;
+ t.eq(report.version, "1.0.0", "Version parsed correctly");
+ t.eq(report.language, "en", "Language parsed correctly");
+ var exception = report.exceptions[0];
+ t.eq(exception.code, "InvalidParameterValue", "exceptionCode properly parsed");
+ t.eq(exception.locator, "foo", "locator properly parsed");
+ t.eq(exception.texts[0], "Update error: Error occured updating features", "ExceptionText correctly parsed");
+ t.eq(exception.texts[1], "Second exception line", "Second ExceptionText correctly parsed");
+ }
+
+ </script>
+</head>
+<body>
+</body>
+</html>
Modified: sandbox/bartvde/exception/openlayers/tests/list-tests.html
===================================================================
--- sandbox/bartvde/exception/openlayers/tests/list-tests.html 2011-06-07 16:49:54 UTC (rev 12057)
+++ sandbox/bartvde/exception/openlayers/tests/list-tests.html 2011-06-07 17:41:11 UTC (rev 12058)
@@ -105,6 +105,7 @@
<li>Format/SOSGetFeatureOfInterest.html</li>
<li>Format/OWSContext/v0_3_1.html</li>
<li>Format/OWSCommon/v1_0_0.html</li>
+ <li>Format/OWSCommon/v1_1_0.html</li>
<li>Format/XLS/v1_1_0.html</li>
<li>Format/XML.html</li>
<li>Geometry.html</li>
More information about the Commits
mailing list