24
Copyright © 2015 Open Geospatial Consortium.
results in unnecessary repetition of the “Keywords” word that can probably be simplified. Please note that some XML elements can already be plural resulting in JSON plural
names even if they are not arrays. The fact that the name is plural cannot be used as a way to anticipate if a key is an array. In many senses objects and arrays are considered
equivalent in JavaScript an array is considered an object with numeric members so identifying an array is not completely straightforward. Proof of this is that the JavaScript
operator “typeof” returns “object” both for “objects” and “arrays”.
var fruits = [Banana, Orange, Apple, Mango]; typeof fruits; typeof returns object
To solve this problem you can create your own isArray function
1
:
function isArraymyArray { return myArray.constructor.toString.indexOfArray -1;
}
6.1.1.2 Mixed elements
OGC 14-009r1 Section 6.1.3 states: “For this XML mixed element the text node will be transformed into a JSON object where the name is the parent XML element name and the
value is the text node contents.”
For example, the following XML fragment:
branch olive=true not empty
leafgreenleaf peach type=redsomepeach
branch
results in:
branch : { branch : not empty,
olive : true, leaf : green,
peach : { peach : some,
type : red }
}
1
http:www.w3schools.comjsjs_arrays.asp
Copyright © 2015 Open Geospatial Consortium.
25
NOTE: the line peach : some, is missing in the original example.
To access the text node you simple repeated the name of the node: branch.branch The section 6.1.3 in OGC 14-009r1 does not state that a combination of a XML element
containing a text node and one of more attributes is in the scope of the same problem even if these cases cannot be called a mixed XML element. This case is much more
common in the OGC. For example, this situation is already present in WFS Capabilities documents such as this one:
http:cida.usgs.govnwcgeoserverNHDPlusFlowlinesows?service=WFSversion=1.0. 0request=GetCapabilities:
ogc:Function_Name nArgs=1absogc:Function_Name
that will end in:
ogc_Function_Name: {
ogc_Function_Name: abs; nArgs:1
}
6.1.1.3 NULL elements
OGC 14-009r1 Section 6.2.4 says: “The XML empty elements must be explicitly transformed to the null JSON object.”
This way an XML fragment like this:
tree value=false child
tree
is transformed into this:
tree : { child : null
}
In this explanation, it would be good to add this similar case:
Get onlineResource=http:cida.usgs.gov:80nwcgeoserverNHDPlusFlow
lineswfs?request=GetCapabilities
In this case there is no need to generate a null element and the transformation would be:
Get: