1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
|
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_read_WFSDescribeFeatureType(t) {
t.plan(39);
var parser = new OpenLayers.Format.WFSDescribeFeatureType();
// single typeName from UMN Mapserver
var text =
'<?xml version="1.0" encoding="ISO-8859-1" ?>' +
'<schema' +
' targetNamespace="http://mapserver.gis.umn.edu/mapserver" ' +
' xmlns:rws="http://mapserver.gis.umn.edu/mapserver" ' +
' xmlns:ogc="http://www.opengis.net/ogc"' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
' xmlns="http://www.w3.org/2001/XMLSchema"' +
' xmlns:gml="http://www.opengis.net/gml"' +
' elementFormDefault="qualified" version="0.1" >' +
' <import namespace="http://www.opengis.net/gml"' +
' schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd" />' +
' <element name="AAA64" ' +
' type="rws:AAA64Type" ' +
' substitutionGroup="gml:_Feature" />' +
' <complexType name="AAA64Type">' +
' <complexContent>' +
' <extension base="gml:AbstractFeatureType">' +
' <sequence>' +
' <element name="geometry" type="gml:MultiLineStringPropertyType" minOccurs="0" maxOccurs="1"/>' +
' <element name="OBJECTID" type="string"/>' +
' <element name="ROUTE" type="string"/>' +
' <element name="ROUTE_CH" type="string"/>' +
' <element name="COUNT" type="string"/>' +
' <element name="BEHEERDER" type="string"/>' +
' <element name="LENGTH" type="string"/>' +
' <element name="SHAPE" type="string"/>' +
' <element name="SE_ANNO_CAD_DATA" type="string"/>' +
' </sequence>' +
' </extension>' +
' </complexContent>' +
' </complexType>' +
'</schema>';
var res = parser.read(text);
t.eq(res.featureTypes.length, 1,
"There is only 1 typename, so length should be 1");
t.eq(res.featureTypes[0].properties[0].type, 'gml:MultiLineStringPropertyType',
"The first attribute is of type multi line string");
t.eq(res.featureTypes[0].properties[2].name, 'ROUTE',
"The third attribute is named ROUTE");
t.eq(res.featureTypes[0].properties[2].type, 'string',
"The third attribute is of type string");
// three typeNames in one response from UMN Mapserver
text =
'<?xml version="1.0" encoding="ISO-8859-1" ?>' +
'<schema' +
' targetNamespace="http://mapserver.gis.umn.edu/mapserver" ' +
' xmlns:rws="http://mapserver.gis.umn.edu/mapserver" ' +
' xmlns:ogc="http://www.opengis.net/ogc"' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
' xmlns="http://www.w3.org/2001/XMLSchema"' +
' xmlns:gml="http://www.opengis.net/gml"' +
' elementFormDefault="qualified" version="0.1" >' +
' <import namespace="http://www.opengis.net/gml"' +
' schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd" />' +
' <element name="KGNAT.VKUNSTWERK" ' +
' type="rws:KGNAT.VKUNSTWERKType" ' +
' substitutionGroup="gml:_Feature" />' +
' <complexType name="KGNAT.VKUNSTWERKType">' +
' <complexContent>' +
' <extension base="gml:AbstractFeatureType">' +
' <sequence>' +
' <element name="geometry" type="gml:MultiPolygonPropertyType" minOccurs="0" maxOccurs="1"/>' +
' <element name="OBJECTID" type="string"/>' +
' <element name="OBJECTSUBCATEGORIE" type="string"/>' +
' <element name="DIENSTCODE" type="string"/>' +
' <element name="DISTRICTNAAM" type="string"/>' +
' <element name="CODEBPN" type="string"/>' +
' <element name="WSD" type="string"/>' +
' <element name="SUBCAT" type="string"/>' +
' <element name="ZIJDE" type="string"/>' +
' <element name="KM" type="string"/>' +
' <element name="ELEMENTCODE" type="string"/>' +
' <element name="COMPLEXCODE" type="string"/>' +
' <element name="BEHEEROBJECTCODE" type="string"/>' +
' <element name="BEGINDATUM" type="string"/>' +
' <element name="NAAMCONTACTPERSOON" type="string"/>' +
' <element name="KMTOT" type="string"/>' +
' <element name="HOOFDWATERSYSTEEM" type="string"/>' +
' <element name="WATERSYSTEEMNAAM" type="string"/>' +
' <element name="OBJECTNAAM" type="string"/>' +
' <element name="HERKOMST" type="string"/>' +
' <element name="BEHEERSREGIME" type="string"/>' +
' <element name="VERSIE" type="string"/>' +
' <element name="KWALITEITSNIVEAU" type="string"/>' +
' <element name="STICHTINGSJAAR" type="string"/>' +
' <element name="OBJECTTYPE" type="string"/>' +
' <element name="OPMERKING" type="string"/>' +
' <element name="OPPERVLAKTE" type="string"/>' +
' <element name="SE_ANNO_CAD_DATA" type="string"/>' +
' <element name="SHAPE" type="string"/>' +
' </sequence>' +
' </extension>' +
' </complexContent>' +
' </complexType>' +
' <element name="KGNAT.LKUNSTWERK" ' +
' type="rws:KGNAT.LKUNSTWERKType" ' +
' substitutionGroup="gml:_Feature" />' +
' <complexType name="KGNAT.LKUNSTWERKType">' +
' <complexContent>' +
' <extension base="gml:AbstractFeatureType">' +
' <sequence>' +
' <element name="geometry" type="gml:MultiLineStringPropertyType" minOccurs="0" maxOccurs="1"/>' +
' <element name="OBJECTID" type="string"/>' +
' <element name="OBJECTSUBCATEGORIE" type="string"/>' +
' <element name="DIENSTCODE" type="string"/>' +
' <element name="DISTRICTNAAM" type="string"/>' +
' <element name="CODEBPN" type="string"/>' +
' <element name="WSD" type="string"/>' +
' <element name="SUBCAT" type="string"/>' +
' <element name="ZIJDE" type="string"/>' +
' <element name="KM" type="string"/>' +
' <element name="ELEMENTCODE" type="string"/>' +
' <element name="COMPLEXCODE" type="string"/>' +
' <element name="BEHEEROBJECTCODE" type="string"/>' +
' <element name="BEGINDATUM" type="string"/>' +
' <element name="NAAMCONTACTPERSOON" type="string"/>' +
' <element name="KMTOT" type="string"/>' +
' <element name="HOOFDWATERSYSTEEM" type="string"/>' +
' <element name="WATERSYSTEEMNAAM" type="string"/>' +
' <element name="OBJECTNAAM" type="string"/>' +
' <element name="HERKOMST" type="string"/>' +
' <element name="BEHEERSREGIME" type="string"/>' +
' <element name="VERSIE" type="string"/>' +
' <element name="KWALITEITSNIVEAU" type="string"/>' +
' <element name="STICHTINGSJAAR" type="string"/>' +
' <element name="OBJECTTYPE" type="string"/>' +
' <element name="OPMERKING" type="string"/>' +
' <element name="LENGTE" type="string"/>' +
' <element name="SE_ANNO_CAD_DATA" type="string"/>' +
' <element name="SHAPE" type="string"/>' +
' </sequence>' +
' </extension>' +
' </complexContent>' +
' </complexType>' +
' <element name="KGNAT.PKUNSTWERK" ' +
' type="rws:KGNAT.PKUNSTWERKType" ' +
' substitutionGroup="gml:_Feature" />' +
' <complexType name="KGNAT.PKUNSTWERKType">' +
' <complexContent>' +
' <extension base="gml:AbstractFeatureType">' +
' <sequence>' +
' <element name="geometry" type="gml:MultiPointPropertyType" minOccurs="0" maxOccurs="1"/>' +
' <element name="OBJECTID" type="string"/>' +
' <element name="OBJECTSUBCATEGORIE" type="string"/>' +
' <element name="DIENSTCODE" type="string"/>' +
' <element name="DISTRICTNAAM" type="string"/>' +
' <element name="CODEBPN" type="string"/>' +
' <element name="WSD" type="string"/>' +
' <element name="SUBCAT" type="string"/>' +
' <element name="ZIJDE" type="string"/>' +
' <element name="KM" type="string"/>' +
' <element name="ELEMENTCODE" type="string"/>' +
' <element name="COMPLEXCODE" type="string"/>' +
' <element name="BEHEEROBJECTCODE" type="string"/>' +
' <element name="BEGINDATUM" type="string"/>' +
' <element name="NAAMCONTACTPERSOON" type="string"/>' +
' <element name="KMTOT" type="string"/>' +
' <element name="HOOFDWATERSYSTEEM" type="string"/>' +
' <element name="WATERSYSTEEMNAAM" type="string"/>' +
' <element name="OBJECTNAAM" type="string"/>' +
' <element name="HERKOMST" type="string"/>' +
' <element name="BEHEERSREGIME" type="string"/>' +
' <element name="VERSIE" type="string"/>' +
' <element name="KWALITEITSNIVEAU" type="string"/>' +
' <element name="STICHTINGSJAAR" type="string"/>' +
' <element name="OBJECTTYPE" type="string"/>' +
' <element name="OPMERKING" type="string"/>' +
' <element name="X" type="string"/>' +
' <element name="Y" type="string"/>' +
' <element name="SE_ANNO_CAD_DATA" type="string"/>' +
' <element name="SHAPE" type="string"/>' +
' </sequence>' +
' </extension>' +
' </complexContent>' +
' </complexType>' +
'</schema>';
parser = new OpenLayers.Format.WFSDescribeFeatureType();
res = parser.read(text);
t.eq(res.featureTypes.length, 3,
"There are 3 typenames, so length should be 3");
t.eq(res.featureTypes[0].typeName, 'KGNAT.VKUNSTWERK',
"There name of the first typename is KGNAT.VKUNSTWERK");
t.eq(res.featureTypes[2].properties.length, 30,
"We expect 30 attributes in the third typename");
t.eq(res.featureTypes[2].properties[1].name, 'OBJECTID',
"The second attribute has name OBJECTID");
t.eq(res.featureTypes[2].properties[1].type, 'string',
"The second attribute has type string");
t.eq(res.targetNamespace, 'http://mapserver.gis.umn.edu/mapserver',
"The targetNamespace should be http://mapserver.gis.umn.edu/mapserver");
t.eq(res.targetPrefix, 'rws', "the targetPrefix should be rws");
// response from Ionic WFS, taken from:
// http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?service=WFS&request=DescribeFeatureType&version=1.0.0&typename=wfs:highways
text =
"<?xml version='1.0' encoding='utf-8' ?>" +
' <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.ionicsoft.com/wfs" targetNamespace="http://www.ionicsoft.com/wfs" xmlns:xlink="http://www.w3.org/1999/xlink" elementFormDefault="qualified" version="0.1">' +
' <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>' +
' <xsd:element name="highways" substitutionGroup="gml:_Feature" type="wfs:highways"/>' +
' <xsd:complexType name="highways">' +
' <xsd:complexContent>' +
' <xsd:extension base="gml:AbstractFeatureType">' +
' <xsd:sequence>' +
' <xsd:element name="ROUTE_" minOccurs="0" nillable="true" type="xsd:int"/>' +
' <xsd:element name="ROUTE_ID" minOccurs="0" nillable="true" type="xsd:int"/>' +
' <xsd:element name="RT_NUMBER" minOccurs="0" nillable="true" type="xsd:string"/>' +
' <xsd:element name="GEOMETRY" minOccurs="0" nillable="true" type="gml:GeometryAssociationType"/>' +
' </xsd:sequence>' +
' </xsd:extension>' +
' </xsd:complexContent>' +
' </xsd:complexType>' +
' </xsd:schema>';
parser = new OpenLayers.Format.WFSDescribeFeatureType();
res = parser.read(text);
t.eq(res.featureTypes.length, 1,
"There is 1 typename, so length should be 1");
t.eq(res.featureTypes[0].typeName, "highways",
"The name of the typename is highways");
t.eq(res.featureTypes[0].properties.length, 4,
"We expect 4 attributes in the first typename");
t.eq(res.featureTypes[0].properties[1].name, 'ROUTE_ID',
"The second attribute has name ROUTE_ID");
t.eq(res.featureTypes[0].properties[1].type, 'xsd:int',
"The second attribute has type integer");
t.eq(parseInt(res.featureTypes[0].properties[1].minOccurs), 0,
"The second attribute has minOccurs 0");
t.eq(res.targetNamespace, 'http://www.ionicsoft.com/wfs',
"The targetNamespace should be http://www.ionicsoft.com/wfs");
t.eq(res.targetPrefix, 'wfs', "the targetPrefix should be wfs");
// GeoServer tests
function geoServerTests(text) {
parser = new OpenLayers.Format.WFSDescribeFeatureType();
res = parser.read(text);
t.eq(res.featureTypes.length, 1,
"There is 1 typename, so length should be 1");
t.eq(res.featureTypes[0].typeName, "railroads",
"The name of the typeName is railroads");
t.eq(res.featureTypes[0].properties.length, 2,
"We expect 2 attributes in the typename");
t.eq(res.featureTypes[0].properties[0].name, 'cat',
"The first attribute has name cat");
t.eq(res.featureTypes[0].properties[0].type.split(":")[1], 'long',
"The first attribute has type long with a prefix");
t.eq(res.featureTypes[0].properties[0].localType, 'long',
"The first attribute has localType long");
t.eq(res.targetNamespace, 'http://opengeo.org',
"The targetNamespace should be http://opengeo.org");
t.eq(res.targetPrefix, 'opengeo', "the targetPrefix should be opengeo");
}
// Read Geoserver WFS 1.0.0 response
// Taken from: http://demo.opengeo.org/geoserver/wfs?service=WFS&request=DescribeFeatureType&typename=opengeo:railroads&version=1.0.0
text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<xs:schema targetNamespace="http://opengeo.org" xmlns:opengeo="http://opengeo.org" xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">' +
' <xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://demo.opengeo.org:80/geoserver/schemas/gml/2.1.2.1/feature.xsd"/>' +
' <xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" name="railroads_Type">' +
' <xs:complexContent>' +
' <xs:extension base="gml:AbstractFeatureType">' +
' <xs:sequence>' +
' <xs:element name="cat" minOccurs="0" nillable="true" type="xs:long"/>' +
' <xs:element name="the_geom" minOccurs="0" nillable="true" type="gml:MultiLineStringPropertyType"/>' +
' </xs:sequence>' +
' </xs:extension>' +
' </xs:complexContent>' +
' </xs:complexType>' +
' <xs:element name="railroads" type="opengeo:railroads_Type" substitutionGroup="gml:_Feature"/>' +
'</xs:schema>';
geoServerTests(text);
// Read GeoServer WFS 1.1.0 response
// taken from http://demo.opengeo.org/geoserver/wfs?service=WFS&request=DescribeFeatureType&typename=opengeo:railroads&version=1.1.0
text =
'<?xml version="1.0" encoding="UTF-8"?>' +
' <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:opengeo="http://opengeo.org" elementFormDefault="qualified" targetNamespace="http://opengeo.org">' +
' <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://demo.opengeo.org:80/geoserver/wfs/schemas/gml/3.1.1/base/gml.xsd"/>' +
' <xsd:complexType name="railroadsType">' +
' <xsd:complexContent>' +
' <xsd:extension base="gml:AbstractFeatureType">' +
' <xsd:sequence>' +
' <xsd:element maxOccurs="1" minOccurs="0" name="cat" nillable="true" type="xsd:long"/>' +
' <xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiLineStringPropertyType"/>' +
' </xsd:sequence>' +
' </xsd:extension>' +
' </xsd:complexContent>' +
' </xsd:complexType>' +
' <xsd:element name="railroads" substitutionGroup="gml:_Feature" type="opengeo:railroadsType"/>' +
' </xsd:schema>';
geoServerTests(text);
// Another GeoServer response with type restrictions
// taken from http://sigma.openplans.org/geoserver/wfs?service=WFS&request=DescribeFeatureType&typename=topp:states&version=1.0.0
text = '<?xml version="1.0" encoding="UTF-8"?><xs:schema targetNamespace="http://www.openplans.org/topp" xmlns:topp="http://www.openplans.org/topp" xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0"><xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://sigma.openplans.org:80/geoserver/schemas/gml/2.1.2.1/feature.xsd"/><xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" name="states_Type"><xs:complexContent><xs:extension base="gml:AbstractFeatureType"><xs:sequence><xs:element name="the_geom" minOccurs="0" nillable="true" type="gml:MultiPolygonPropertyType"/><xs:element name="STATE_NAME" minOccurs="0" nillable="true"><xs:simpleType><xs:restriction base="xs:string"><xs:maxLength value="25"/></xs:restriction></xs:simpleType></xs:element><xs:element name="STATE_FIPS" minOccurs="0" nillable="true"><xs:simpleType><xs:restriction base="xs:string"><xs:maxLength value="2"/></xs:restriction></xs:simpleType></xs:element><xs:element name="SUB_REGION" minOccurs="0" nillable="true"><xs:simpleType><xs:restriction base="xs:string"><xs:maxLength value="7"/></xs:restriction></xs:simpleType></xs:element><xs:element name="STATE_ABBR" minOccurs="0" nillable="true"><xs:simpleType><xs:restriction base="xs:string"><xs:maxLength value="2"/></xs:restriction></xs:simpleType></xs:element><xs:element name="LAND_KM" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="WATER_KM" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="PERSONS" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="FAMILIES" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="HOUSHOLD" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="MALE" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="FEMALE" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="WORKERS" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="DRVALONE" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="CARPOOL" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="PUBTRANS" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="EMPLOYED" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="UNEMPLOY" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="SERVICE" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="MANUAL" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="P_MALE" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="P_FEMALE" minOccurs="0" nillable="true" type="xs:double"/><xs:element name="SAMP_POP" minOccurs="0" nillable="true" type="xs:double"/></xs:sequence></xs:extension></xs:complexContent></xs:complexType><xs:element name="states" type="topp:states_Type" substitutionGroup="gml:_Feature"/></xs:schema>';
parser = new OpenLayers.Format.WFSDescribeFeatureType();
res = parser.read(text);
t.eq(res.featureTypes[0].properties[1].name, "STATE_NAME",
"name of 2nd property of 1st featureType should be 'STATE_NAME'");
t.eq(res.featureTypes[0].properties[1].type, "xs:string",
"type of 2nd property of 1st featureType should be 'xs:string'");
t.eq(res.featureTypes[0].properties[1].localType, "string",
"localType of 2nd property of 1st featureType should be 'string'");
t.eq(res.featureTypes[0].properties[1].restriction.maxLength, "25",
"the maxLength restriction should be 25");
}
function test_readRestriction(t) {
t.plan(2);
var text =
'<restriction xmlns="http://www.w3.org/2001/XMLSchema" base="xs:string">' +
' <enumeration value="One"/>' +
' <enumeration value="Two"/>' +
'</restriction>';
var doc = OpenLayers.Format.XML.prototype.read(text).documentElement;
var obj = {};
new OpenLayers.Format.WFSDescribeFeatureType().readRestriction(doc, obj);
t.eq(obj.enumeration.length, 2, "enumeration has a length of 2");
t.eq(obj.enumeration[1], "Two", "2nd enumeration value is 'Two'");
// other functionality of readRestriction already tested in the last
// GeoServer example above
}
function test_read_exception(t) {
t.plan(1);
var text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<ows:ExceptionReport version="1.0.0"' +
' xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/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="NoApplicableCode">' +
' <ows:ExceptionText>Could not find type: {http://geonode.org/}_map_4_annotations</ows:ExceptionText>' +
' </ows:Exception>' +
'</ows:ExceptionReport>';
var format = new OpenLayers.Format.WFSDescribeFeatureType();
var obj = format.read(text);
t.ok(!!obj.error, "Error reported correctly");
}
function test_read_annotation(t) {
t.plan(2);
var text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
' xmlns:analytics="http://opengeo.org/analytics" xmlns:cite="http://www.opengeospatial.net/cite"' +
' xmlns:gml="http://www.opengis.net/gml" xmlns:it.geosolutions="http://www.geo-solutions.it"' +
' xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org"' +
' xmlns:sde="http://geoserver.sf.net" xmlns:sf="http://www.openplans.org/spearfish"' +
' xmlns:tiger="http://www.census.gov" xmlns:tike="http://opengeo.org/#tike"' +
' xmlns:topp="http://www.openplans.org/topp" xmlns:usgs="http://www.usgs.gov/"' +
' xmlns:za="http://opengeo.org/za" elementFormDefault="qualified"' +
' targetNamespace="http://www.openplans.org/topp">' +
' <xsd:import namespace="http://www.opengis.net/gml"' +
' schemaLocation="http://demo.opengeo.org/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>' +
' <xsd:complexType name="statesType">' +
' <xsd:complexContent>' +
' <xsd:extension base="gml:AbstractFeatureType">' +
' <xsd:sequence>' +
' <xsd:element maxOccurs="1" minOccurs="0" name="PERSONS" nillable="true" type="xsd:double">' +
' <xsd:annotation>' +
' <xsd:appinfo>{"title":{"en":"Population"}}</xsd:appinfo>' +
' <xsd:documentation xml:lang="en"> Number of persons living in the state' +
' </xsd:documentation>' +
' </xsd:annotation>' +
' </xsd:element>' +
' </xsd:sequence>' +
' </xsd:extension>' +
' </xsd:complexContent>' +
' </xsd:complexType>' +
' <xsd:element name="states" substitutionGroup="gml:_Feature" type="topp:statesType"/>' +
'</xsd:schema>';
var format = new OpenLayers.Format.WFSDescribeFeatureType();
var res = format.read(text);
var property = res.featureTypes[0].properties[0];
t.eq(property.annotation.appinfo[0], '{"title":{"en":"Population"}}', "appinfo read correctly");
t.eq(property.annotation.documentation[0], {lang: "en", textContent: 'Number of persons living in the state'}, "documentation read correctly");
}
</script>
</head>
<body>
</body>
</html>
|