adding a format to parsing OGC service exceptions (WMS 1.1 WMS 1.3 WFS 1.0 and OWSCommon 1.0 and 1.1) and hooking it up into the GetCapabilities parsers, r=tschaub (closes #2234)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12074 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2011-06-08 14:39:12 +00:00
parent 9d5ab38fc0
commit 2b04fd6c34
15 changed files with 505 additions and 17 deletions

View File

@@ -296,6 +296,7 @@
"OpenLayers/Format/SLD.js",
"OpenLayers/Format/SLD/v1.js",
"OpenLayers/Format/SLD/v1_0_0.js",
"OpenLayers/Format/OWSCommon.js",
"OpenLayers/Format/OWSCommon/v1.js",
"OpenLayers/Format/OWSCommon/v1_0_0.js",
"OpenLayers/Format/OWSCommon/v1_1_0.js",
@@ -334,6 +335,7 @@
"OpenLayers/Format/XLS.js",
"OpenLayers/Format/XLS/v1.js",
"OpenLayers/Format/XLS/v1_1_0.js",
"OpenLayers/Format/OGCExceptionReport.js",
"OpenLayers/Layer/WFS.js",
"OpenLayers/Control/GetFeature.js",
"OpenLayers/Control/MouseToolbar.js",

View File

@@ -0,0 +1,110 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OWSCommon/v1_0_0.js
* @requires OpenLayers/Format/OWSCommon/v1_1_0.js
*/
/**
* Class: OpenLayers.Format.OGCExceptionReport
* Class to read exception reports for various OGC services and versions.
*
* Inherits from:
* - <OpenLayers.Format.XML>
*/
OpenLayers.Format.OGCExceptionReport = OpenLayers.Class(OpenLayers.Format.XML, {
/**
* Property: namespaces
* {Object} Mapping of namespace aliases to namespace URIs.
*/
namespaces: {
ogc: "http://www.opengis.net/ogc"
},
/**
* Property: regExes
* Compiled regular expressions for manipulating strings.
*/
regExes: {
trimSpace: (/^\s*|\s*$/g),
removeSpace: (/\s*/g),
splitSpace: (/\s+/),
trimComma: (/\s*,\s*/g)
},
/**
* Property: defaultPrefix
*/
defaultPrefix: "ogc",
/**
* Constructor: OpenLayers.Format.OGCExceptionReport
* Create a new parser for OGC exception reports.
*
* Parameters:
* options - {Object} An optional object whose properties will be set on
* this instance.
*/
/**
* APIMethod: read
* Read OGC exception report data from a string, and return an object with
* information about the exceptions.
*
* Parameters:
* data - {String} or {DOMElement} data to read/parse.
*
* Returns:
* {Object} Information about the exceptions that occurred.
*/
read: function(data) {
var result;
if(typeof data == "string") {
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
}
var root = data.documentElement;
var exceptionInfo = {exceptionReport: null};
if (root) {
this.readChildNodes(data, exceptionInfo);
if (exceptionInfo.exceptionReport === null) {
// fall-back to OWSCommon since this is a common output format for exceptions
// we cannot easily use the ows readers directly since they differ for 1.0 and 1.1
exceptionInfo = new OpenLayers.Format.OWSCommon().read(data);
}
}
return exceptionInfo;
},
/**
* Property: readers
* Contains public functions, grouped by namespace prefix, that will
* be applied when a namespaced node is found matching the function
* name. The function will be applied in the scope of this parser
* with two arguments: the node being read and a context object passed
* from the parent.
*/
readers: {
"ogc": {
"ServiceExceptionReport": function(node, obj) {
obj.exceptionReport = {exceptions: []};
this.readChildNodes(node, obj.exceptionReport);
},
"ServiceException": function(node, exceptionReport) {
var exception = {
code: node.getAttribute("code"),
locator: node.getAttribute("locator"),
text: this.getChildValue(node)
};
exceptionReport.exceptions.push(exception);
}
}
},
CLASS_NAME: "OpenLayers.Format.OGCExceptionReport"
});

View File

@@ -0,0 +1,91 @@
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Format/XML.js
*/
/**
* Class: OpenLayers.Format.OWSCommon
* Read OWSCommon. Create a new instance with the <OpenLayers.Format.OWSCommon>
* constructor.
*
* Inherits from:
* - <OpenLayers.Format.XML>
*/
OpenLayers.Format.OWSCommon = OpenLayers.Class(OpenLayers.Format.XML, {
/**
* APIProperty: defaultVersion
* {String} Version number to assume if none found. Default is "1.0.0".
*/
defaultVersion: "1.0.0",
/**
* APIProperty: version
* {String} Specify a version string if one is known.
*/
version: null,
/**
* Property: parser
* {Object} Instance of the versioned parser. Cached for multiple read and
* write calls of the same version.
*/
parser: null,
/**
* Constructor: OpenLayers.Format.OWSCommon
* Create a new parser for OWSCommon.
*
* Parameters:
* options - {Object} An optional object whose properties will be set on
* this instance.
*/
/**
* APIMethod: read
* Read an OWSCommon document and return an object.
*
* Parameters:
* data - {String | DOMElement} Data to read.
* options - {Object} Options for the reader.
*
* Returns:
* {Object} An object representing the structure of the document.
*/
read: function(data, options) {
if(typeof data == "string") {
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
}
var root = data.documentElement;
var version = this.version;
if(!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;
}
}
if(!this.parser || this.parser.VERSION != version) {
var format = OpenLayers.Format.OWSCommon[
"v" + version.replace(/\./g, "_")
];
if(!format) {
throw "Can't find a OWSCommon parser for version " +
version;
}
this.parser = new format(this.options);
}
var ows = this.parser.read(data, options);
return ows;
},
CLASS_NAME: "OpenLayers.Format.OWSCommon"
});

View File

@@ -4,13 +4,9 @@
* full text of the license. */
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OWSCommon.js
*/
if (!OpenLayers.Format.OWSCommon) {
OpenLayers.Format.OWSCommon = {};
}
/**
* Class: OpenLayers.Format.OWSCommon.v1
* Common readers and writers for OWSCommon v1.X formats
@@ -28,6 +24,23 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
trimComma: (/\s*,\s*/g)
},
/**
* Method: read
*
* Parameters:
* data - {DOMElement} An OWSCommon document element.
* options - {Object} Options for the reader.
*
* Returns:
* {Object} An object representing the OWSCommon document.
*/
read: function(data, options) {
options = OpenLayers.Util.applyDefaults(options, this.options);
var ows = {};
this.readChildNodes(data, ows);
return ows;
},
/**
* Property: readers
* Contains public functions, grouped by namespace prefix, that will
@@ -38,6 +51,19 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
*/
readers: {
"ows": {
"Exception": function(node, exceptionReport) {
var exception = {
code: node.getAttribute('exceptionCode'),
locator: node.getAttribute('locator'),
texts: []
};
exceptionReport.exceptions.push(exception);
this.readChildNodes(node, exception);
},
"ExceptionText": function(node, exception) {
var text = this.getChildValue(node);
exception.texts.push(text);
},
"ServiceIdentification": function(node, obj) {
obj.serviceIdentification = {};
this.readChildNodes(node, obj.serviceIdentification);

View File

@@ -9,8 +9,7 @@
/**
* Class: OpenLayers.Format.OWSCommon.v1_0_0
* Parser for OWS Common version 1.0.0 which can be used by other parsers.
* It is not intended to be used on its own.
* Parser for OWS Common version 1.0.0.
*/
OpenLayers.Format.OWSCommon.v1_0_0 = OpenLayers.Class(OpenLayers.Format.OWSCommon.v1, {
@@ -19,7 +18,7 @@ OpenLayers.Format.OWSCommon.v1_0_0 = OpenLayers.Class(OpenLayers.Format.OWSCommo
* {Object} Mapping of namespace aliases to namespace URIs.
*/
namespaces: {
ows: "http://www.opengis.net/ows/1.0",
ows: "http://www.opengis.net/ows",
xlink: "http://www.w3.org/1999/xlink"
},
@@ -32,7 +31,16 @@ OpenLayers.Format.OWSCommon.v1_0_0 = OpenLayers.Class(OpenLayers.Format.OWSCommo
* 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)
},
/**
@@ -42,9 +50,9 @@ OpenLayers.Format.OWSCommon.v1_0_0 = OpenLayers.Class(OpenLayers.Format.OWSCommo
* 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_1_0"
CLASS_NAME: "OpenLayers.Format.OWSCommon.v1_0_0"
});

View File

@@ -9,8 +9,7 @@
/**
* Class: OpenLayers.Format.OWSCommon.v1_1_0
* Parser for OWS Common version 1.1.0 which can be used by other parsers.
* It is not intended to be used on its own.
* Parser for OWS Common version 1.1.0.
*/
OpenLayers.Format.OWSCommon.v1_1_0 = OpenLayers.Class(OpenLayers.Format.OWSCommon.v1, {
@@ -33,6 +32,14 @@ OpenLayers.Format.OWSCommon.v1_1_0 = OpenLayers.Class(OpenLayers.Format.OWSCommo
*/
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);

View File

@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OGCExceptionReport.js
*/
/**
@@ -67,6 +68,11 @@ OpenLayers.Format.WFSCapabilities = OpenLayers.Class(OpenLayers.Format.XML, {
}
var parser = new constr(this.options);
var capabilities = parser.read(data);
if (capabilities.service === undefined) {
// an error must have happened, so parse it and report back
var format = new OpenLayers.Format.OGCExceptionReport();
capabilities.error = format.read(data);
}
capabilities.version = version;
return capabilities;
},

View File

@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Format/WMSCapabilities.js
* @requires OpenLayers/Format/OGCExceptionReport.js
* @requires OpenLayers/Format/XML.js
*/
@@ -60,15 +61,20 @@ OpenLayers.Format.WMSCapabilities.v1 = OpenLayers.Class(
if(typeof data == "string") {
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
}
var raw = data;
if(data && data.nodeType == 9) {
data = data.documentElement;
}
var capabilities = {};
this.readNode(data, capabilities);
// postprocess the layer list
this.postProcessLayers(capabilities);
if (capabilities.service === undefined) {
// an exception must have occurred, so parse it
var parser = new OpenLayers.Format.OGCExceptionReport();
capabilities.error = parser.read(raw);
} else {
// postprocess the layer list
this.postProcessLayers(capabilities);
}
return capabilities;
},

View File

@@ -0,0 +1,100 @@
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_read_exception(t) {
t.plan(21);
// OCG WMS 1.3.0 exceptions
var text = '<?xml version="1.0" encoding="UTF-8"?> ' +
'<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xsi:schemaLocation="http://www.opengis.net/ogc' +
' http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">' +
' <ServiceException> Plain text message about an error. </ServiceException>' +
' <ServiceException code="InvalidUpdateSequence"> Another error message, this one with a service exception code supplied. </ServiceException>' +
' <ServiceException>' +
' <![CDATA[ Error in module <foo.c>, line 42' +
'A message that includes angle brackets in text must be enclosed in a Character Data Section as in this example. All XML-like markup is ignored except for this sequence of three closing characters:' +
']]>' +
' </ServiceException>' +
' <ServiceException>' +
' <![CDATA[ <Module>foo.c</Module> <Error>An error occurred</Error> <Explanation>Similarly, actual XML can be enclosed in a CDATA section. A generic parser will ignore that XML, but application-specific software may choose to process it.</Explanation> ]]>' +
' </ServiceException>' +
'</ServiceExceptionReport>';
var parser = new OpenLayers.Format.OGCExceptionReport();
var result = parser.read(text);
var exceptions = result.exceptionReport.exceptions;
var testWMS = function(exceptions) {
t.eq(exceptions.length, 4, "We expect 4 exception messages");
t.eq(exceptions[0].text, " Plain text message about an error. ", "First error message correctly parsed");
t.eq(exceptions[1].code, "InvalidUpdateSequence", "Code of second error message correctly parsed");
t.eq(exceptions[1].text, " Another error message, this one with a service exception code supplied. ", "Text of second error message correctly parsed");
t.eq(OpenLayers.String.trim(exceptions[2].text), "Error in module <foo.c>, line 42A message that includes angle brackets in text must be enclosed in a Character Data Section as in this example. All XML-like markup is ignored except for this sequence of three closing characters:", "Third message correctly parsed");
t.eq(OpenLayers.String.trim(exceptions[3].text), "<Module>foo.c</Module> <Error>An error occurred</Error> <Explanation>Similarly, actual XML can be enclosed in a CDATA section. A generic parser will ignore that XML, but application-specific software may choose to process it.</Explanation>", "Fourth message correctly parsed");
};
testWMS(exceptions);
// OGC WMS 1.1.1 exceptions
text = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/WMS_exception_1_1_1.dtd"> ' +
'<ServiceExceptionReport version="1.1.1">' +
' <ServiceException> Plain text message about an error. </ServiceException>' +
' <ServiceException code="InvalidUpdateSequence"> Another error message, this one with a service exception code supplied. </ServiceException>' +
' <ServiceException>' +
' <![CDATA[ Error in module <foo.c>, line 42' +
'A message that includes angle brackets in text must be enclosed in a Character Data Section as in this example. All XML-like markup is ignored except for this sequence of three closing characters:' +
']]>' +
' </ServiceException>' +
' <ServiceException>' +
' <![CDATA[ <Module>foo.c</Module> <Error>An error occurred</Error> <Explanation>Similarly, actual XML can be enclosed in a CDATA section. A generic parser will ignore that XML, but application-specific software may choose to process it.</Explanation> ]]>' +
' </ServiceException>' +
'</ServiceExceptionReport>';
result = parser.read(text);
exceptions = result.exceptionReport.exceptions;
testWMS(exceptions);
// OGC WFS 1.0.0 exceptions
text = '<?xml version="1.0" ?> ' +
'<ServiceExceptionReport version="1.2.0" xmlns="http://www.opengis.net/ogc"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">' +
' <ServiceException code="999" locator="INSERT STMT 01"> parse error: missing closing tag for element WKB_GEOM </ServiceException>' +
'</ServiceExceptionReport>';
result = parser.read(text);
t.eq(result.exceptionReport.exceptions[0].code, "999", "code parsed correctly");
t.eq(result.exceptionReport.exceptions[0].locator, "INSERT STMT 01", "locator parsed correctly");
t.eq(result.exceptionReport.exceptions[0].text, " parse error: missing closing tag for element WKB_GEOM ", "error text parsed correctly");
// OGC WFS 1.1.0 exceptions that use OWSCommon 1.0
text = '<?xml version="1.0" encoding="UTF-8"?>' +
'<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 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 result = parser.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>

View File

@@ -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 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 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>

View File

@@ -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>

View File

@@ -3,6 +3,23 @@
<script src="../../OLLoader.js"></script>
<script type="text/javascript">
function test_read_exception(t) {
t.plan(1);
var parser = new OpenLayers.Format.WFSCapabilities();
var text = '<?xml version="1.0" encoding="UTF-8"?>' +
'<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 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 obj = parser.read(text);
t.ok(!!obj.error, "Error reported correctly");
}
function test_read(t) {
t.plan(33);

View File

@@ -3,6 +3,15 @@
<script src="../../OLLoader.js"></script>
<script type="text/javascript">
function test_read_exception(t) {
t.plan(1);
var xml = document.getElementById("exceptionsample").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var format = new OpenLayers.Format.WMSCapabilities();
var obj = format.read(doc);
t.ok(!!obj.error, "Error reported correctly");
}
function test_read(t) {
t.plan(23);
@@ -678,6 +687,12 @@ Changes:
</Capability>
</WMT_MS_Capabilities>
--></div>
<div id="exceptionsample"><!--
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/WMS_exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1"><ServiceException> Plain text message about an error. </ServiceException>
</ServiceExceptionReport>
--></div>
<!--
GeoServer example below taken from
http://publicus.opengeo.org/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities

View File

@@ -3,6 +3,15 @@
<script src="../../OLLoader.js"></script>
<script type="text/javascript">
function test_read_exception(t) {
t.plan(1);
var xml = document.getElementById("exceptionsample").firstChild.nodeValue;
var doc = new OpenLayers.Format.XML().read(xml);
var format = new OpenLayers.Format.WMSCapabilities();
var obj = format.read(doc);
t.ok(!!obj.error, "Error reported correctly");
}
function test_layers(t) {
t.plan(22);
@@ -280,6 +289,26 @@
</head>
<body>
<div id="exceptionsample"><!--
<?xml version='1.0' encoding="UTF-8"?>
<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
<ServiceException> Plain text message about an error. </ServiceException>
<ServiceException code="InvalidUpdateSequence"> Another error message, this one with a service
exception code supplied. </ServiceException>
<ServiceException>
<![CDATA[ Error in module <foo.c>, line 42
A message that includes angle brackets in text must be enclosed in a Character Data Section as in this example. All XML-like markup is ignored except for this sequence of three closing characters:
]]>
</ServiceException>
<ServiceException>
<![CDATA[ <Module>foo.c</Module> <Error>An error occurred</Error> <Explanation>Similarly, actual XML can be enclosed in a CDATA section. A generic parser will ignore that XML, but application-specific software may choose to process it.</Explanation> ]]>
</ServiceException>
</ServiceExceptionReport>
--></div>
<!--
OGC example below taken from
http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xml

View File

@@ -104,6 +104,9 @@
<li>Format/SOSGetObservation.html</li>
<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/OGCExceptionReport.html</li>
<li>Format/XLS/v1_1_0.html</li>
<li>Format/XML.html</li>
<li>Geometry.html</li>