17
17
*/
18
18
OpenLayers . Format . WFSDescribeFeatureType = OpenLayers . Class (
19
19
OpenLayers . Format . XML , {
20
+
21
+ /**
22
+ * Property: regExes
23
+ * Compiled regular expressions for manipulating strings.
24
+ */
25
+ regExes : {
26
+ trimSpace : ( / ^ \s * | \s * $ / g)
27
+ } ,
20
28
21
29
/**
22
30
* Property: namespaces
@@ -52,15 +60,16 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
52
60
complexTypes : complexTypes ,
53
61
customTypes : customTypes
54
62
} ;
63
+ var i , len ;
55
64
56
65
this . readChildNodes ( node , schema ) ;
57
66
58
67
var attributes = node . attributes ;
59
68
var attr , name ;
60
- for ( var i = 0 , len = attributes . length ; i < len ; ++ i ) {
69
+ for ( i = 0 , len = attributes . length ; i < len ; ++ i ) {
61
70
attr = attributes [ i ] ;
62
71
name = attr . name ;
63
- if ( name . indexOf ( "xmlns" ) == 0 ) {
72
+ if ( name . indexOf ( "xmlns" ) === 0 ) {
64
73
this . setNamespace ( name . split ( ":" ) [ 1 ] || "" , attr . value ) ;
65
74
} else {
66
75
obj [ name ] = attr . value ;
@@ -71,7 +80,7 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
71
80
72
81
// map complexTypes to names of customTypes
73
82
var complexType , customType ;
74
- for ( var i = 0 , len = complexTypes . length ; i < len ; ++ i ) {
83
+ for ( i = 0 , len = complexTypes . length ; i < len ; ++ i ) {
75
84
complexType = complexTypes [ i ] ;
76
85
customType = customTypes [ complexType . typeName ] ;
77
86
if ( customTypes [ complexType . typeName ] ) {
@@ -103,6 +112,7 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
103
112
obj . properties = sequence . elements ;
104
113
} ,
105
114
"element" : function ( node , obj ) {
115
+ var type ;
106
116
if ( obj . elements ) {
107
117
var element = { } ;
108
118
var attributes = node . attributes ;
@@ -112,7 +122,7 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
112
122
element [ attr . name ] = attr . value ;
113
123
}
114
124
115
- var type = element . type ;
125
+ type = element . type ;
116
126
if ( ! type ) {
117
127
type = { } ;
118
128
this . readChildNodes ( node , type ) ;
@@ -122,17 +132,38 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class(
122
132
var fullType = type . base || type ;
123
133
element . localType = fullType . split ( ":" ) . pop ( ) ;
124
134
obj . elements . push ( element ) ;
135
+ this . readChildNodes ( node , element ) ;
125
136
}
126
137
127
138
if ( obj . complexTypes ) {
128
- var type = node . getAttribute ( "type" ) ;
139
+ type = node . getAttribute ( "type" ) ;
129
140
var localType = type . split ( ":" ) . pop ( ) ;
130
141
obj . customTypes [ localType ] = {
131
142
"name" : node . getAttribute ( "name" ) ,
132
143
"type" : type
133
144
} ;
134
145
}
135
146
} ,
147
+ "annotation" : function ( node , obj ) {
148
+ obj . annotation = { } ;
149
+ this . readChildNodes ( node , obj . annotation ) ;
150
+ } ,
151
+ "appinfo" : function ( node , obj ) {
152
+ if ( ! obj . appinfo ) {
153
+ obj . appinfo = [ ] ;
154
+ }
155
+ obj . appinfo . push ( this . getChildValue ( node ) ) ;
156
+ } ,
157
+ "documentation" : function ( node , obj ) {
158
+ if ( ! obj . documentation ) {
159
+ obj . documentation = [ ] ;
160
+ }
161
+ var value = this . getChildValue ( node ) ;
162
+ obj . documentation . push ( {
163
+ lang : node . getAttribute ( "xml:lang" ) ,
164
+ textContent : value . replace ( this . regExes . trimSpace , "" )
165
+ } ) ;
166
+ } ,
136
167
"simpleType" : function ( node , obj ) {
137
168
this . readChildNodes ( node , obj ) ;
138
169
} ,
0 commit comments