UNPKG

wps-js-52-north

Version:

Web Processing Service JavaScrict library

1,629 lines (1,278 loc) 118 kB
/* Simple JavaScript Inheritance * By John Resig http://ejohn.org/ * MIT Licensed. */ // Inspired by base2 and Prototype (function() { var initializing = false, fnTest = /xyz/.test(function() { xyz; }) ? /\b_super\b/ : /.*/; // The base Class implementation (does nothing) this.Class = function() { }; // Create a new Class that inherits from this class Class.extend = function(prop) { var _super = this.prototype; // Instantiate a base class (but only create the instance, // don't run the init constructor) initializing = true; var prototype = new this(); initializing = false; // Copy the properties over onto the new prototype for ( var name in prop) { // Check if we're overwriting an existing function prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn) { return function() { var tmp = this._super; // Add a new ._super() method that is the same method // but on the super-class this._super = _super[name]; // The method only need to be bound temporarily, so we // remove it when we're done executing var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } // The dummy class constructor function Class() { // All construction is actually done in the init method if (!initializing && this.init) this.init.apply(this, arguments); } // Populate our constructed prototype object Class.prototype = prototype; // Enforce the constructor to be what we expect Class.prototype.constructor = Class; // And make this class extendable Class.extend = arguments.callee; return Class; }; })(); var WPS_VERSION_1_0_0 = "1.0.0" var WPS_VERSION_2_0_0 = "2.0.0" var GET_CAPABILITIES_TYPE = "GetCapabilities"; var DESCRIBE_PROCESS_TYPE = "DescribeProcess"; var EXECUTE_TYPE = "Execute"; var GET_STATUS_TYPE = "GetStatus"; var GET_RESULT_TYPE = "GetResult"; var OWS_11_NAMESPACE = "http://www.opengis.net/ows/1.1"; var WPS_100_NAMESPACE = "http://www.opengis.net/wps/1.0.0"; var METHOD_POST = "POST"; var METHOD_GET = "GET"; var PARAM_WPS_REQUEST_URL = "wpsRequestUrl"; var PARAM_WPS_REQUEST_TYPE = "wpsRequestType"; var USE_PROXY = false; var PROXY_URL = ""; var PROXY_TYPE = ""; var USER_TEMPLATE_CAPABILITIES_MARKUP = null; var USER_TEMPLATE_PROCESS_DESCRIPTION_MARKUP = null; var USER_TEMPLATE_EXECUTE_RESPONSE_MARKUP = null; var DATA_TYPE_LITERAL = "LITERAL"; var DATA_TYPE_COMPLEX = "COMPLEX"; var DATA_TYPE_BBOX = "BBOX"; function wpsResetSetup() { USE_PROXY = false; PROXY_URL = ""; PROXY_TYPE = ""; USER_TEMPLATE_CAPABILITIES_MARKUP = null; USER_TEMPLATE_PROCESS_DESCRIPTION_MARKUP = null; USER_TEMPLATE_EXECUTE_RESPONSE_MARKUP = null; } function equalsString(a, b) { if (!a) { return false; } if (!b) { return false; } return jQuery.trim(a).localeCompare(jQuery.trim(b)) == 0; } function stringStartsWith(target, sub) { return target.indexOf(sub) == 0; } function fillXMLTemplate(template, properties) { var result = template; for (var key in properties) { if (properties.hasOwnProperty(key)) { result = result.replace("${"+key+"}", properties[key]); } } return result; } function isImageMimetype(mimetype) { return ($.inArray(mimetype, imageMimetypes) > -1); } function stringify(format){ return '{"mimeType" : "' + (format.mimeType ? format.mimeType : "") + '", "schema" : "' + (format.schema ? format.schema : "") + '", "encoding" : "' + (format.encoding ? format.encoding : "") + '"}'; } function escapeCharactersForSelect(id){ var result = id.replace(/\./g,"\\."); return result; } var BaseResponse = Class.extend({ init : function(responseDocument) { /* * represents the raw response document returned by the WPS */ this.responseDocument = responseDocument; }, getRawResponseDocument : function() { return this.responseDocument; } }); var CapabilitiesResponse = BaseResponse .extend({ /* * { "capabilities":{ "serviceIdentification":{ "title":"52°North WPS 3.3.2-SNAPSHOT", "abstractValue":"Service based on the 52°North implementation of WPS 1.0.0", "keywords":[ "WPS", "geospatial", "geoprocessing" ], "serviceType":"WPS", "serviceTypeVersions":[ "ServiceTypeVersion":"1.0.0" ] "fees":"NONE", "accessConstraints":"NONE" }, "serviceProvider":{ "providerName":"52North", "providerSite":"http://www.52north.org/", "serviceContact":{ "individualName":"", "contactInfo":{ "address":{ "deliveryPoint":"", "city":"", "administrativeArea":"", "postalCode":"", "country":"", "electronicMailAddress":"" } } } }, "operations":[ { "DCP":{ "HTTP":{ "get":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService?", "post":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService" } }, "name":"GetCapabilities" }, { "DCP":{ "HTTP":{ "get":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService?", "post":"http://geostatistics.demo.52north.org:80/wps/WebProcessingService" } }, "name":"DescribeProcess" } ], "processes":[ { "title":"org.n52.wps.server.algorithm.CSWLoDEnablerStarter", "identifier":"org.n52.wps.server.algorithm.CSWLoDEnablerStarter", "processVersion":"1.1.0", "jobControlOptions":"sync-execute async-execute", "outputTransmission":"value reference" }, { "title":"org.n52.wps.server.algorithm.JTSConvexHullAlgorithm", "identifier":"org.n52.wps.server.algorithm.JTSConvexHullAlgorithm", "processVersion":"1.1.0", "jobControlOptions":"sync-execute async-execute", "outputTransmission":"value reference" } ], "service":"WPS", "version":"2.0.0" } } */ init : function(wpsResponse) { this.responseDocument = wpsResponse; /* * create an empty new instance of capabilities object */ this.capabilities = new Object(); /* * service and version */ this.capabilities.service = "WPS"; this.capabilities.version = ""; /* * service identification */ this.capabilities.serviceIdentification = new Object(); this.capabilities.serviceIdentification.title = ""; this.capabilities.serviceIdentification.abstractValue = ""; this.capabilities.serviceIdentification.keywords = new Array; this.capabilities.serviceIdentification.serviceType = "WPS"; this.capabilities.serviceIdentification.serviceTypeVersions = new Array; this.capabilities.serviceIdentification.fees = ""; this.capabilities.serviceIdentification.accessConstraints = ""; /* * service provider */ this.capabilities.serviceProvider = new Object(); this.capabilities.serviceProvider.providerName = ""; this.capabilities.serviceProvider.providerSite = ""; this.capabilities.serviceProvider.serviceContact = new Object(); this.capabilities.serviceProvider.serviceContact.individualName = ""; this.capabilities.serviceProvider.serviceContact.contactInfo = new Object(); this.capabilities.serviceProvider.serviceContact.contactInfo.address = new Object(); this.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint = ""; this.capabilities.serviceProvider.serviceContact.contactInfo.address.city = ""; this.capabilities.serviceProvider.serviceContact.contactInfo.address.administrativeArea = ""; this.capabilities.serviceProvider.serviceContact.contactInfo.address.postalCode = ""; this.capabilities.serviceProvider.serviceContact.contactInfo.address.country = ""; this.capabilities.serviceProvider.serviceContact.contactInfo.address.electronicMailAddress = ""; /* * operations with one dummy entry */ this.capabilities.operations = new Array(1); this.capabilities.operations[0] = this.createOperation("dummy", "dummyGet", "dummyPost"); /* * languages */ this.capabilities.languages = new Array(); /* * processes and dummy entry */ this.capabilities.processes = new Array(1); this.capabilities.processes[0] = this.createProcess("title", "id", "procVersion", "jobCOntrolOptions", "outputTransmission"); /* * now let child classes fill this empty instance with values */ this.instantiate(wpsResponse); }, instantiate : function(wpsResponse) { // override this method in child classes to properly set the // values }, createProcess : function(title, identifier, processVersion, jobControlOutputs, outputTransmission) { var process = new Object(); process.title = title; process.identifier = identifier; process.processVersion = processVersion; process.jobControlOptions = jobControlOutputs; process.outputTransmission = outputTransmission; return process; }, createOperation : function(name, getUrl, postUrl) { var operation = new Object(); operation.DCP = new Object(); operation.DCP.HTTP = new Object(); operation.DCP.HTTP.name = name; operation.DCP.HTTP.get = getUrl; operation.DCP.HTTP.post = postUrl; return operation; }, createArrayFromTextValues : function(nodes){ var array = new Array(); for (var int = 0; int < nodes.length; int++) { var textValue = $(nodes[int]).text(); array[int] = textValue; } return array; } }); /** * nearly all values are equal fpr WPS 1.0 and WPS 2.0. Thus most of them are hardcoded here! * Only some different values have to be set individually */ var CapabilitiesResponse_xml = CapabilitiesResponse.extend({ /** * @wpsResponse should be an XML v2.0.0 WPS Capabilities document */ instantiate : function(wpsResponse){ /* * set values */ var xmlCapabilities = $(wpsResponse).find("wps\\:Capabilities, Capabilities"); /* * version and service */ this.capabilities.version = xmlCapabilities.attr("version"); this.capabilities.service = xmlCapabilities.attr("service"); /* * service identification */ var xmlServiceIdentification = xmlCapabilities.find("ows\\:ServiceIdentification, ServiceIdentification"); this.capabilities.serviceIdentification.title = xmlServiceIdentification.find("ows\\:Title , Title").text(); this.capabilities.serviceIdentification.abstractValue = xmlServiceIdentification.find("ows\\:Abstract, Abstract").text(); this.capabilities.serviceIdentification.keywords = this.createArrayFromTextValues(xmlServiceIdentification.find("ows\\:Keyword, Keyword")); this.capabilities.serviceIdentification.serviceType = xmlServiceIdentification.find("ows\\:ServiceType, ServiceType").text(); this.capabilities.serviceIdentification.serviceTypeVersions = this.createArrayFromTextValues(xmlServiceIdentification.find("ows\\:ServiceTypeVersion, ServiceTypeVersion")); this.capabilities.serviceIdentification.fees = xmlServiceIdentification.find("ows\\:Fees, Fees").text(); this.capabilities.serviceIdentification.accessConstraints = xmlServiceIdentification.find("ows\\:AccessConstraints, AccessConstraints").text(); /* * service provider */ var xmlServiceProvider = $(xmlCapabilities).find("ows\\:ServiceProvider, ServiceProvider"); this.capabilities.serviceProvider.providerName = xmlServiceProvider.find("ows\\:ProviderName, ProviderName").text() || undefined; var providerSiteNode=xmlServiceProvider.find("ows\\:ProviderSite, ProviderSite") || undefined; this.capabilities.serviceProvider.providerSite = providerSiteNode.attr("href") || providerSiteNode.attr("xlin\\:href") || providerSiteNode.attr("xlink\\:href") || undefined; var serviceContact = xmlServiceProvider.find("ows\\:ServiceContact, ServiceContact") || undefined; this.capabilities.serviceProvider.serviceContact.individualName = serviceContact.find("ows\\:IndividualName, IndividualName").text() || undefined; var address = serviceContact.find("ows\\:Address, Address"); this.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint = address.find("ows\\:DeliveryPoint, DeliveryPoint").text() || undefined; this.capabilities.serviceProvider.serviceContact.contactInfo.address.city = address.find("ows\\:City, City").text() || undefined; this.capabilities.serviceProvider.serviceContact.contactInfo.address.administrativeArea = address.find("ows\\:AdministrativeArea, AdministrativeArea").text() || undefined; this.capabilities.serviceProvider.serviceContact.contactInfo.address.postalCode = address.find("ows\\:PostalCode, PostalCode").text() || undefined; this.capabilities.serviceProvider.serviceContact.contactInfo.address.country = address.find("ows\\:Country, Country").text() || undefined; this.capabilities.serviceProvider.serviceContact.contactInfo.address.electronicMailAddress = address.find("ows\\:ElectronicMailAddress, ElectronicMailAddress").text() || undefined; /* * operations */ var operationsMetadata = xmlCapabilities.find("ows\\:OperationsMetadata, OperationsMetadata"); this.capabilities.operations = this.createOperationsArray(operationsMetadata.find("ows\\:Operation, Operation")); /* * languages */ var languages = this.extractAllLanguages(xmlCapabilities); this.capabilities.languages = this.createArrayFromTextValues(languages.find("ows\\:Language, Language")); /* * processes */ var processOfferings = this.extractProcessOfferings(xmlCapabilities); this.capabilities.processes = this.createProcessesArray(this.extractAllProcesses(processOfferings)); }, /** * extracts all languages. * * Differs for each WPS version */ extractAllLanguages : function(xmlCapabilities){ /* * override in child class */ }, /** * extracts process offering xml node. * * Differs for each WPS version */ extractProcessOfferings : function(xmlCapabilities){ /* * override in child class */ return xmlCapabilities.find("wps\\:Contents, Contents"); }, /** * extracts all process xml nodes. * * Differs for each WPS version */ extractAllProcesses : function(processOfferingsXml){ /* * override in child class */ }, createOperationsArray : function(nodes){ var array = new Array(nodes.length); for (var int = 0; int < nodes.length; int++) { var xmlOperation = $(nodes[int]); var name = xmlOperation.attr("name"); var getUrlNode=xmlOperation.find("ows\\:Get, Get"); var getUrl = getUrlNode.attr("href") || getUrlNode.attr("xlin\\:href") || getUrlNode.attr("xlink\\:href"); var PostUrlNode=xmlOperation.find("ows\\:Post, Post"); var postUrl = PostUrlNode.attr("href") || PostUrlNode.attr("xlin\\:href") || PostUrlNode.attr("xlink\\:href"); array[int] = this.createOperation(name, getUrl, postUrl); } return array; }, createProcessesArray : function(nodes){ var array = new Array(nodes.length); for (var int = 0; int < nodes.length; int++) { var xmlProcess = $(nodes[int]); var title = xmlProcess.find("ows\\:Title, Title").text(); var identifier = xmlProcess.find("ows\\:Identifier, Identifier").text(); var processVersion = xmlProcess.attr("processVersion") || xmlProcess.attr("wps\\:processVersion"); var jobControlOutputs = this.extractJobControlOptions(xmlProcess); var outputTransmission = this.extractOutputTransmission(xmlProcess); array[int] = this.createProcess(title, identifier, processVersion, jobControlOutputs, outputTransmission); } return array; }, /** * extracts jobControlOptions parameter. * * Differs for each WPS version */ extractJobControlOptions : function(xmlProcess){ /* * override in child class */ }, /** * extracts outputTransmission parameter. * * Differs for each WPS version */ extractOutputTransmission : function(xmlProcess){ /* * override in child class */ } }); var CapabilitiesResponse_v1_xml = CapabilitiesResponse_xml.extend({ extractAllLanguages : function(xmlCapabilities){ return xmlCapabilities.find("wps\\:Languages, Languages").find("wps\\:Supported, Supported"); }, extractProcessOfferings : function(xmlCapabilities){ /* * override in child class */ return xmlCapabilities.find("wps\\:ProcessOfferings, ProcessOfferings"); }, extractAllProcesses : function(processOfferingsXml){ return processOfferingsXml.find("wps\\:Process, Process"); }, extractJobControlOptions : function(xmlProcess){ /* * override in child class */ return "For WPS 1.0 please execute a DescribeProcess request with this process identifier. This parameter will be included in the returned process description!"; }, extractOutputTransmission : function(xmlProcess){ return "For WPS 1.0 please execute a DescribeProcess request with this process identifier. This parameter will be included in the returned process description!"; } }); var CapabilitiesResponse_v2_xml = CapabilitiesResponse_xml.extend({ extractAllLanguages : function(xmlCapabilities){ return xmlCapabilities.find("ows\\:Languages, Languages"); }, extractProcessOfferings : function(xmlCapabilities){ return xmlCapabilities.find("wps\\:Contents, Contents"); }, extractAllProcesses : function(processOfferingsXml){ return processOfferingsXml.find("wps\\:ProcessSummary, ProcessSummary"); }, extractJobControlOptions : function(xmlProcess){ return xmlProcess.attr("jobControlOptions"); }, extractOutputTransmission : function(xmlProcess){ return xmlProcess.attr("outputTransmission"); } }); var DescribeProcessResponse = BaseResponse.extend({ init : function(wpsResponse) { this.responseDocument = wpsResponse; /* * empty process description */ this.processOffering = new Object(); /* * service and version */ this.processOffering.service = "WPS"; this.processOffering.version = ""; /* * process */ this.processOffering.process = new Object(); this.processOffering.process.title = ""; this.processOffering.process.abstractValue = ""; this.processOffering.process.identifier = ""; this.processOffering.process.inputs = new Array(); this.processOffering.process.outputs = new Array(); /* * attributes */ this.processOffering.processVersion = ""; this.processOffering.jobControlOptions = []; this.processOffering.outputTransmissionModes = []; this.instantiate(wpsResponse); }, instantiate: function(wpsResponse){ /* * override this method in child classes to instantiate the object */ }, createLiteralDataInput : function(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray, literalDataDomainArray) { var literalDataInput = new Object(); this.instantiateCommonInputValues(title, abstractValue, identifier, minOccurs, maxOccurs, literalDataInput); //TODO what about metadata node? literalDataInput.literalData = new Object(); literalDataInput.literalData.formats = formatArray; literalDataInput.literalData.literalDataDomains = literalDataDomainArray; return literalDataInput; }, createComplexDataInput : function(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray) { var complexDataInput = new Object(); this.instantiateCommonInputValues(title, abstractValue, identifier, minOccurs, maxOccurs, complexDataInput); //TODO what about metadata node? complexDataInput.complexData = new Object(); complexDataInput.complexData.formats = formatArray; return complexDataInput; }, createBboxInput : function(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray, crsArray) { var bboxInput = new Object(); this.instantiateCommonInputValues(title, abstractValue, identifier, minOccurs, maxOccurs, bboxInput); //TODO what about metadata node? bboxInput.boundingBoxData = new Object(); bboxInput.boundingBoxData.formats = formatArray; bboxInput.boundingBoxData.supportedCRSs = crsArray; return bboxInput; }, createFormat : function(mimeType, encoding, schema) { var format = new Object(); format.mimeType = mimeType; format.encoding = encoding; format.schema = schema; return format; }, instantiateCommonInputValues : function(title, abstractValue, identifier, minOccurs, maxOccurs, inputObject) { inputObject.title = title; inputObject.abstractValue = abstractValue; inputObject.identifier = identifier; inputObject.minOccurs = minOccurs; inputObject.maxOccurs = maxOccurs; }, instantiateCommonOutputValues : function(title, abstractValue, identifier, outputObject){ outputObject.title = title; outputObject.abstractValue = abstractValue; outputObject.identifier = identifier; }, createLiteralDataOutput : function(title, abstractValue, identifier, formatArray, literalDataDomainArray) { var literalDataOutput = new Object(); this.instantiateCommonOutputValues(title, abstractValue, identifier, literalDataOutput); //TODO what about metadata node? literalDataOutput.literalData = new Object(); literalDataOutput.literalData.formats = formatArray; literalDataOutput.literalData.literalDataDomains = literalDataDomainArray; return literalDataOutput; }, createComplexDataOutput : function(title, abstractValue, identifier, formatArray) { var complexDataOutput = new Object(); this.instantiateCommonOutputValues(title, abstractValue, identifier, complexDataOutput); //TODO what about metadata node? complexDataOutput.complexData = new Object(); complexDataOutput.complexData.formats = formatArray; return complexDataOutput; }, createBboxOutput : function(title, abstractValue, identifier, formatArray, crsArray) { var bboxOutput = new Object(); this.instantiateCommonOutputValues(title, abstractValue, identifier, bboxOutput); //TODO what about metadata node? bboxOutput.boundingBoxData = new Object(); bboxOutput.boundingBoxData.formats = formatArray; bboxOutput.boundingBoxData.supportedCRSs = crsArray; return bboxOutput; }, }); /* * definition of parameter names and values that will be used for * generating the process description. Values will have standard values * for WPS 2.0. * * In subclasses, these values shall be overridden to alter the values!!!! */ var PROCESS_OFFERING_VERSION = "2.0.0"; var PROCESS_OFFERING_XML_TAG_NAME = "wps\\:ProcessOffering, ProcessOffering"; var PROCESS_VERSION_ATTR_NAME = "processVersion"; var PROCESS_VERSION_ATTR_NAME_WITH_NS = "wps\\:processVersion"; var JOB_CONTROL_OPTIONS_ATTR_NAME = "jobControlOptions"; var JOB_CONTROL_OPTIONS_ATTR_NAME_WITH_NS = "wps\\:jobControlOptions"; var OUTPUT_TRANSMISSION_ATTR_NAME = "outputTransmission"; var OUTPUT_TRANSMISSION_ATTR_NAME_WITH_NS = "wps\\:outputTransmission"; var PROCESS_TAG_NAME = "wps\\:Process, Process"; var TITLE_TAG_NAME = "ows\\:Title, Title"; var ABSTRACT_TAG_NAME = "ows\\:Abstract, Abstract"; var IDENTIFIER_TAG_NAME = "ows\\:Identifier, Identifier"; var PROCESS_INPUT_TAG_NAME = "wps\\:Input, Input"; var PROCESS_OUTPUT_TAG_NAME = "wps\\:Output, Output"; var LITERAL_DATA_TAG_NAME = "wps\\:LiteralData, ns\\:LiteralData, LiteralData"; var COMPLEX_DATA_TAG_NAME = "wps\\:ComplexData, ns\\:ComplexData, ComplexData"; var BBOX_DATA_TAG_NAME = "wps\\:BoundingBoxData, ns\\:BoundingBoxData, BoundingBoxData"; var LITERAL_DATA_OUTPUT_TAG_NAME = "wps\\:LiteralData, ns\\:LiteralData, LiteralData"; var COMPLEX_DATA_OUTPUT_TAG_NAME = "wps\\:ComplexData, ns\\:ComplexData, ComplexData"; var BBOX_DATA_OUTPUT_TAG_NAME = "wps\\:BoundingBoxData, ns\\:BoundingBoxData, BoundingBoxData"; var MIN_OCCURS_ATTR_NAME = "minOccurs"; var MIN_OCCURS_ATTR_NAME_WITH_NS = "wps\\:minOccurs"; var MAX_OCCURS_ATTR_NAME = "maxOccurs"; var MAX_OCCURS_ATTR_NAME_WITH_NS = "wps\\:maxOccurs"; var FORMAT_TAG_NAME = "ns\\:Format, wps\\:Format, Format"; var FORMAT_MIME_TYPE_ATTR_NAME = "mimeType"; var FORMAT_ENCODING_ATTR_NAME = "encoding"; var FORMAT_SCHEMA_ATTR_NAME = "schema"; var LITERAL_DATA_DOMAIN_TAG_NAME = "wps\\:LiteralDataDomain, LiteralDataDomain"; var LITERAL_DATA_ANY_VALUE_TAG_NAME = "ows\\:AnyValue, AnyValue"; var LITERAL_DATA_ALLOWED_VALUES_TAG_NAME = "ows\\:AllowedValues, AllowedValues"; var LITERAL_DATA_ALLOWED_VALUES_VALUE_TAG_NAME = "ows\\:Value, Value"; var LITERAL_DATA_ALLOWED_VALUES_RANGE_TAG_NAME = "ows\\:Range, Range"; var LITERAL_DATA_ALLOWED_VALUES_RANGE_MINIMUM_VALUE_TAG_NAME = "ows\\:MinimumValue, MinimumValue"; var LITERAL_DATA_ALLOWED_VALUES_RANGE_MAXIMUM_VALUE_TAG_NAME = "ows\\:MaximumValue, MaximumValue"; var LITERAL_DATA_DATA_TYPE_TAG_NAME = "ows\\:DataType, DataType"; var LITERAL_DATA_VALUES_REFERENCE_TAG_NAME = "ows\\:ValuesReference, ValuesReference"; var LITERAL_DATA_REFERENCE_ATTR_NAME = "reference"; var LITERAL_DATA_REFERENCE_ATTR_NAME_WITH_NS = "ows\\:reference"; var LITERAL_DATA_DEFAULT_VALUE_TAG_NAME = "ows\\:DefaultValue, DefaultValue"; var LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME = "ows\\:UOM, UOM"; //var SUPPORTED_CRS_TAG_NAME = "SupportedCRS"; var CRS_TAG_NAME = "ows\\:CRS, wps\\:CRS, CRS"; var DescribeProcessResponse_xml = DescribeProcessResponse.extend({ instantiate : function(wpsResponse) { /* * in child classes, this method may change certain values * of the above listed variables, that are used to extract * information out of the XML document */ this.resetParameterVariables(); /* * version */ this.processOffering.version = PROCESS_OFFERING_VERSION; var processOfferingXml = $(wpsResponse).find(PROCESS_OFFERING_XML_TAG_NAME); /* processOfferingXml */ this.processOffering.processVersion = processOfferingXml.attr(PROCESS_VERSION_ATTR_NAME) || processOfferingXml.attr(PROCESS_VERSION_ATTR_NAME_WITH_NS); this.processOffering.jobControlOptions = this.createJobControlOptions(processOfferingXml); this.processOffering.outputTransmissionModes = this.createOutputTransmissionModes(processOfferingXml); /* * process */ // var processXml = processOfferingXml.find(PROCESS_TAG_NAME); /* * .find(selector) will return more instances of title, abstract and identifier * than just the ones for the process. * * Instead it will also include objects for each Input and Output. * * Hence we simply take the first returned objects, as those will be the process level. */ this.processOffering.process.title = $(processOfferingXml.find(TITLE_TAG_NAME)[0]).text(); this.processOffering.process.abstractValue = $(processOfferingXml.find(ABSTRACT_TAG_NAME)[0]).text() || undefined; this.processOffering.process.identifier = $(processOfferingXml.find(IDENTIFIER_TAG_NAME)[0]).text(); /* * TODO how to deal with nested input and nested output??? * */ this.processOffering.process.inputs = this.createInputs(processOfferingXml.find(PROCESS_INPUT_TAG_NAME)); this.processOffering.process.outputs = this.createOutputs(processOfferingXml.find(PROCESS_OUTPUT_TAG_NAME)); }, /** * in child classes this method should be overridden in order to reset parameter values */ resetParameterVariables : function(){ /* * here do noting */ }, createJobControlOptions : function(processOfferingXml){ /* * must be overridden in child classes * * it differs fpr various WPS version! */ }, createOutputTransmissionModes : function(processOfferingXml){ /* * must be overridden in child classes * * it differs for various WPS version! */ }, createInputs : function(xmlNodes){ var array = new Array(xmlNodes.length); for (var index = 0; index < xmlNodes.length; index++) { var inputXml = $(xmlNodes[index]); if(inputXml.find(LITERAL_DATA_TAG_NAME).length > 0) array[index] = this.createLiteralDataInputFromXml(inputXml); else if (inputXml.find(COMPLEX_DATA_TAG_NAME).length > 0) array[index] = this.createComplexDataInputFromXml(inputXml); else if (inputXml.find(BBOX_DATA_TAG_NAME).length > 0) array[index] = this.createBboxDataInputFromXml(inputXml); /* * nested input! */ else if(inputXml.find(PROCESS_INPUT_TAG_NAME).length > 0) array[index] = this.createInputs(inputXml); } return array; }, createLiteralDataInputFromXml : function(xmlNode) { var minOccurs = xmlNode.attr(MIN_OCCURS_ATTR_NAME) || xmlNode.attr(MIN_OCCURS_ATTR_NAME_WITH_NS); var maxOccurs = xmlNode.attr(MAX_OCCURS_ATTR_NAME) || xmlNode.attr(MAX_OCCURS_ATTR_NAME_WITH_NS); var title = xmlNode.find(TITLE_TAG_NAME).text(); var abstractValue = xmlNode.find(ABSTRACT_TAG_NAME).text() || undefined; var identifier = xmlNode.find(IDENTIFIER_TAG_NAME).text(); /* * literal data input */ var formatNodes = this.extractFormatNodes(xmlNode); /* * in WPS 1.0 there is no format for a literal input! * * but in WPS 2.0 there is! * * Hence, we just add an "|| undefined" */ var formatArray = this.createFormatArray(formatNodes) || undefined; var literalDataDomainArray = this.createLiteralDataDomainArray(xmlNode.find(LITERAL_DATA_TAG_NAME)); // this.createLiteralDataDomainArray(xmlNode.find(LITERAL_DATA_DOMAIN_TAG_NAME)); return this.createLiteralDataInput(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray, literalDataDomainArray); }, /** * extracts all Format nodes. Varies for different WPS version */ extractFormatNodes : function(xmlNode){ /* * override in child classes */ }, createLiteralDataDomainArray : function(literalDataDomainXml){ /* * for various WPS version, this call produces different results! */ return this.createAllLiteralDataDomainObjects(literalDataDomainXml); }, /** * create all literal data domain object. * for differnt WPS version, the number of allowed instances varies. In WPS 1.0 * only one occurence is allowed, whereas in WPS 2.0 a new Tag called "LiteralDataDomain" * is introduced which may occur multiple times! * * Hence we override this method in child classes to provide the correct results! */ createAllLiteralDataDomainObjects : function(literalDataXml){ /* * override in child methods! */ }, /** * regardsles of the WPS version, this method should provide the expected results * to instantiate an instance of literalDataObject! */ createLiteralDataDomainObject : function(literalDataDomain_xml){ var literalDataDomainObject = new Object(); /* * on of the three tags for allowed value specification can occur: * * 1: AnyValue * * 2: AllowedValues * * 3: ValuesReference */ literalDataDomainObject.anyValue = false; if(literalDataDomain_xml.find(LITERAL_DATA_ANY_VALUE_TAG_NAME).length > 0) literalDataDomainObject.anyValue = true; else if(literalDataDomain_xml.find(LITERAL_DATA_ALLOWED_VALUES_TAG_NAME).length > 0) literalDataDomainObject.allowedValues = this.createAllowedValues(literalDataDomain_xml.find(LITERAL_DATA_ALLOWED_VALUES_TAG_NAME)); else literalDataDomainObject.valuesReference = literalDataDomain_xml.find(LITERAL_DATA_VALUES_REFERENCE_TAG_NAME).text(); var dataType_xml = literalDataDomain_xml.find(LITERAL_DATA_DATA_TYPE_TAG_NAME); var dataTypeObject = new Object(); dataTypeObject.type = dataType_xml.text() || undefined; dataTypeObject.reference = dataType_xml.attr(LITERAL_DATA_REFERENCE_ATTR_NAME) || dataType_xml.attr(LITERAL_DATA_REFERENCE_ATTR_NAME_WITH_NS); literalDataDomainObject.dataType = dataTypeObject; literalDataDomainObject.defaultValue = literalDataDomain_xml.find(LITERAL_DATA_DEFAULT_VALUE_TAG_NAME).text() || undefined; /* * uom = unit of measure * * TODO create new extraction method that is overridden in child classes */ literalDataDomainObject.unitOfMeasure = this.extractUnitOfMeasure(literalDataDomain_xml); return literalDataDomainObject; }, /** * extracts the unit of measure. * * Differs for different WPS versions */ extractUnitOfMeasure : function(literalDataXml){ /* * override in child classes! */ }, createAllowedValues : function(allowedValues_xml){ /* * if allowedValues_xml actually exists: * * allowedValues_xml might either be an array of "Value"-tags or * * have a child node called "Range". */ var object = new Object(); var values_xml = allowedValues_xml.find(LITERAL_DATA_ALLOWED_VALUES_VALUE_TAG_NAME); var numberOfValues = values_xml.length; /* * case Value array */ if (numberOfValues > 0){ /* * return an array with all values */ object.values = new Array(numberOfValues); for (var i=0; i < numberOfValues; i++){ object.values[i] = $(values_xml[i]).text(); } } /* * case Range child node */ else{ object.range = new Object(); var range_xml = allowedValues_xml.find(LITERAL_DATA_ALLOWED_VALUES_RANGE_TAG_NAME); object.range.minimumValue = range_xml.find(LITERAL_DATA_ALLOWED_VALUES_RANGE_MINIMUM_VALUE_TAG_NAME).text(); object.range.maximumValue = range_xml.find(LITERAL_DATA_ALLOWED_VALUES_RANGE_MAXIMUM_VALUE_TAG_NAME).text(); } return object; }, createComplexDataInputFromXml : function(xmlNode) { var minOccurs = xmlNode.attr(MIN_OCCURS_ATTR_NAME) || xmlNode.attr(MIN_OCCURS_ATTR_NAME_WITH_NS); var maxOccurs = xmlNode.attr(MAX_OCCURS_ATTR_NAME) || xmlNode.attr(MAX_OCCURS_ATTR_NAME_WITH_NS); var title = xmlNode.find(TITLE_TAG_NAME).text(); var abstractValue = xmlNode.find(ABSTRACT_TAG_NAME).text() || undefined; var identifier = xmlNode.find(IDENTIFIER_TAG_NAME).text(); /* * complex data input */ var formatNodes = this.extractFormatNodes(xmlNode); var formatArray = this.createFormatArray(formatNodes); return this.createComplexDataInput(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray); }, createBboxDataInputFromXml : function(xmlNode) { var minOccurs = xmlNode.attr(MIN_OCCURS_ATTR_NAME) || xmlNode.attr(MIN_OCCURS_ATTR_NAME_WITH_NS); var maxOccurs = xmlNode.attr(MAX_OCCURS_ATTR_NAME) || xmlNode.attr(MAX_OCCURS_ATTR_NAME_WITH_NS); var title = xmlNode.find(TITLE_TAG_NAME).text(); var abstractValue = xmlNode.find(ABSTRACT_TAG_NAME).text() || undefined; var identifier = xmlNode.find(IDENTIFIER_TAG_NAME).text(); //TODO BBOX var formatNodes = this.extractFormatNodes(xmlNode); /* * in WPS 1.0 there is no format for a bbox input! * * but in WPS 2.0 there is! * * Hence, we just add an "|| undefined" */ var formatArray = this.createFormatArray(formatNodes) || undefined; var supportedCRSs = this.createCrsArray(xmlNode.find(CRS_TAG_NAME)); return this.createBboxInput(title, abstractValue, identifier, minOccurs, maxOccurs, formatArray, supportedCRSs); }, createCrsArray : function(supportedCRSs_xml){ var supportedCrsArray = new Array(supportedCRSs_xml.length); for (var index = 0; index < supportedCRSs_xml.length; index++) { supportedCrsArray[index] = $(supportedCRSs_xml[index]).text(); } return supportedCrsArray; }, createFormatArray : function(formatNodes) { if(formatNodes.length == 0) return undefined; var formatArray = new Array(); for (var index = 0; index < formatNodes.length; index++) { var formatXml = $(formatNodes[index]); var mimeType = this.extractMimeType(formatXml); var encoding = this.extractEncoding(formatXml); var schema = this.extractSchema(formatXml); formatArray[index] = this.createFormat(mimeType, encoding, schema); } return formatArray; }, /** * override in child method to extract the mime type from the format xml node. * * Differs for various WPS versions. */ extractMimeType : function(formatXml){ }, /** * override in child method to extract the encoding from the format xml node. * * Differs for various WPS versions. */ extractEncoding : function(formatXml){ }, /** * override in child method to extract the schema from the format xml node. * * Differs for various WPS versions. */ extractSchema : function(formatXml){ }, createOutputs : function (outputNodes){ var array = new Array(outputNodes.length); for (var index = 0; index < outputNodes.length; index++) { var OutputXml = $(outputNodes[index]); if(OutputXml.find(LITERAL_DATA_OUTPUT_TAG_NAME).length > 0) array[index] = this.createLiteralDataOutputFromXml(OutputXml); else if (OutputXml.find(COMPLEX_DATA_OUTPUT_TAG_NAME).length > 0) array[index] = this.createComplexDataOutputFromXml(OutputXml); else if (OutputXml.find(BBOX_DATA_OUTPUT_TAG_NAME).length > 0) array[index] = this.createBboxDataOutputFromXml(OutputXml); /* * nested output! */ else if (OutputXml.find(PROCESS_OUTPUT_TAG_NAME).length > 0) array[index] = this.createOutputs(OutputXml); } return array; }, /** * TODO outputs vary... no format for literal data but multiple UOMs... */ createLiteralDataOutputFromXml : function(outputXml){ var title = outputXml.find(TITLE_TAG_NAME).text(); var abstractValue = outputXml.find(ABSTRACT_TAG_NAME).text() || undefined; var identifier = outputXml.find(IDENTIFIER_TAG_NAME).text(); /* * literal data input */ var formatNodes = this.extractFormatNodes(outputXml); /* * in WPS 1.0 there is no format for a literal otput! * * but in WPS 2.0 there is! * * Hence, we just add an "|| undefined" */ var formatArray = this.createFormatArray(formatNodes) ||undefined; var literalDataDomainArray = this.createLiteralDataDomainArray(outputXml.find(LITERAL_DATA_TAG_NAME)); return this.createLiteralDataOutput(title, abstractValue, identifier, formatArray, literalDataDomainArray); }, createComplexDataOutputFromXml : function(outputXml) { var title = outputXml.find(TITLE_TAG_NAME).text(); var abstractValue = outputXml.find(ABSTRACT_TAG_NAME).text() || undefined; var identifier = outputXml.find(IDENTIFIER_TAG_NAME).text(); /* * complex data input */ var formatNodes = this.extractFormatNodes(outputXml); var formatArray = this.createFormatArray(formatNodes); return this.createComplexDataOutput(title, abstractValue, identifier, formatArray); }, createBboxDataOutputFromXml : function(outputXml) { var title = outputXml.find(TITLE_TAG_NAME).text(); var abstractValue = outputXml.find(ABSTRACT_TAG_NAME).text() || undefined; var identifier = outputXml.find(IDENTIFIER_TAG_NAME).text(); var formatNodes = this.extractFormatNodes(outputXml); /* * in WPS 1.0 there is no format for a bbox output! * * but in WPS 2.0 there is! * * Hence, we just add an "|| undefined" */ var formatArray = this.createFormatArray(formatNodes) || undefined; var supportedCRSs = this.createCrsArray(outputXml.find(CRS_TAG_NAME)); return this.createBboxOutput(title, abstractValue, identifier, formatArray, supportedCRSs); } }); /* * Override existing variables to match WPS 1.0 documents */ var DescribeProcessResponse_v1_xml = DescribeProcessResponse_xml.extend({ /* * possibly, some methods have to be overridden, to parse WPS 1.0 documents */ resetParameterVariables : function(){ PROCESS_OFFERING_VERSION = "1.0.0"; PROCESS_OFFERING_XML_TAG_NAME = "wps\\:ProcessDescription, ProcessDescription"; FORMAT_MIME_TYPE_ATTR_NAME = "ows\\:MimeType, MimeType"; FORMAT_ENCODING_ATTR_NAME = "ows\\:Encoding, Encoding"; FORMAT_SCHEMA_ATTR_NAME = "ows\\:Schema, Schema"; LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME = "ows\\:UOM, UOM"; //SUPPORTED_CRS_TAG_NAME = "SupportedCRS"; CRS_TAG_NAME = "ows\\:CRS, CRS"; LITERAL_DATA_OUTPUT_TAG_NAME = "wps\\:LiteralOutput, LiteralOutput"; COMPLEX_DATA_OUTPUT_TAG_NAME = "wps\\:ComplexOutput, ComplexOutput"; BBOX_DATA_OUTPUT_TAG_NAME = "wps\\:BoundingBoxOutput, BoundingBoxOutput"; }, createJobControlOptions : function(processOfferingXml){ /* * TODO for WPS 1.0 this attribut does not exist! * But we have the attributes "storeSupported" * if true, then async-execution and stored as reference! * * if false, then only sync-execution and return in document is possible. */ var storeSupported = processOfferingXml.attr("storeSupported") || false; if (storeSupported) return ["sync-execute", "async-execute"]; else return ["sync-execute"]; }, createOutputTransmissionModes : function(processOfferingXml){ /* * TODO for WPS 1.0 this attribut does not exist! * But we have the attributes "storeSupported" * if true, then async-execution and stored as reference! * * if false, then only sync-execution and return in document is possible. */ var storeSupported = processOfferingXml.attr("storeSupported") || false; if (storeSupported) return ["value", "reference"]; else return ["value"]; }, /** * in WPS 1.0 is encoded as Tag */ extractMimeType : function(formatXml){ return formatXml.find(FORMAT_MIME_TYPE_ATTR_NAME).text(); }, /** * in WPS 1.0 is encoded as Tag */ extractEncoding : function(formatXml){ return formatXml.find(FORMAT_ENCODING_ATTR_NAME).text() || undefined; }, /** * in WPS 1.0 is encoded as Tag */ extractSchema : function(formatXml){ return formatXml.find(FORMAT_SCHEMA_ATTR_NAME).text() || undefined; }, /** * extracts the unit of measure. * * in WPS 1.0 it is a bit tricky. WPS 1.0 defines a single LiteralData object which has a single UOMs object, * which is split up into a single Default and a single Supported node. Standard contains a single UOM, * whereas Supported defines a list of supported UOMs... * * However, this conceptually differs from WPS 2.0 where there is a completely new node named LiteralDataDomain, * which may occur multiple times! Each LiteralDataDomain object contains only ONE UOM node. * * This API returns documents closely modeled to the WPS 2.0 standard. Hence, we need one UOM per LiteralDatDomain. * Thus, we just use the Default UOM of WPS 1.0 and loose all others. */ extractUnitOfMeasure : function(literalDataXml){ return literalDataXml.find("ows\\:UOMs, UOMs").find("ows\\:Default, Default").find(LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME).text() || undefined; }, extractFormatNodes : function(xmlNode){ /* * in WPS 1.0 formats are split up in a Supported and a Default subtag. * To not have them listed twice, we just extract all Format Nodes from * the Supported subtag. */ return xmlNode.find("ows\\:Supported, Supported").find(FORMAT_TAG_NAME); }, createAllLiteralDataDomainObjects : function(literalDataXml){ /* * here, in WPS 1.0, we have no subTag called LiteralDataDomain * (which in WPS 2.0 may occur multiple times!). * * In WPS 1.0 the difference is, that there are multiple UOMs. * However, since this API encodes the description closely to * the WPS 2.0 standard, we only take the default UOM from WPS 1.0! * * Hence, we just create on single object which holds the information. * The remaining UOMs are lost! */ var literalDataDomainArray = new Array(1); literalDataDomainArray[0] = this.createLiteralDataDomainObject($(literalDataXml)); return literalDataDomainArray; } }); var DescribeProcessResponse_v2_xml = DescribeProcessResponse_xml.extend({ /* * override any method whose implementation differs for various WPS version! */ resetParameterVariables : function(){ /* * Override existing variables */ PROCESS_OFFERING_VERSION = "2.0.0"; PROCESS_OFFERING_XML_TAG_NAME = "wps\\:ProcessOffering, ProcessOffering"; JOB_CONTROL_OPTIONS_ATTR_NAME = "jobControlOptions"; JOB_CONTROL_OPTIONS_ATTR_NAME_WITH_NS = "wps\\:jobControlOptions"; OUTPUT_TRANSMISSION_ATTR_NAME = "outputTransmission"; OUTPUT_TRANSMISSION_ATTR_NAME_WITH_NS = "wps\\:outputTransmission"; FORMAT_MIME_TYPE_ATTR_NAME = "mimeType"; FORMAT_ENCODING_ATTR_NAME = "encoding"; FORMAT_SCHEMA_ATTR_NAME = "schema"; LITERAL_DATA_DOMAIN_TAG_NAME = "wps\\:LiteralDataDomain, LiteralDataDomain"; LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME = "ows\\:UOM, UOM"; LITERAL_DATA_OUTPUT_TAG_NAME = "wps\\:LiteralData, ns\\:LiteralData, LiteralData"; COMPLEX_DATA_OUTPUT_TAG_NAME = "wps\\:ComplexData, ns\\:ComplexData, ComplexData"; BBOX_DATA_OUTPUT_TAG_NAME = "wps\\:BoundingBoxData, ns\\:BoundingBoxData, BoundingBoxData"; CRS_TAG_NAME = "ows\\:SupportedCRS, wps\\:SupportedCRS, SupportedCRS"; }, createJobControlOptions : function(processOfferingXml){ var jobControlOptionsString = processOfferingXml.attr(JOB_CONTROL_OPTIONS_ATTR_NAME) || processOfferingXml.attr(JOB_CONTROL_OPTIONS_ATTR_NAME_WITH_NS); /* * the string holds job control options separated by whitespace */ return jobControlOptionsString.split(" "); }, createOutputTransmissionModes : function(processOfferingXml){ var outputTransmissionString = processOfferingXml.attr(OUTPUT_TRANSMISSION_ATTR_NAME) || processOfferingXml.attr(OUTPUT_TRANSMISSION_ATTR_NAME_WITH_NS); /* * the string holds transmission modes separated by whitespace */ return outputTransmissionString.split(" "); }, /** * in WPS 2.0 is encoded as attribute */ extractMimeType : function(formatXml){ return formatXml.attr(FORMAT_MIME_TYPE_ATTR_NAME); }, /** * in WPS 2.0 is encoded as attribute */ extractEncoding : function(formatXml){ return formatXml.attr(FORMAT_ENCODING_ATTR_NAME) || undefined; }, /** * in WPS 2.0 is encoded as attribute */ extractSchema : function(formatXml){ return formatXml.attr(FORMAT_SCHEMA_ATTR_NAME) || undefined; }, /** * create all literal data domain object. * in WPS 2.0 a new Tag called "LiteralDataDomain" * is introduced which may occur multiple times! */ createAllLiteralDataDomainObjects : function(literalDataXml){ var literalDataDomain_xmlNodes = literalDataXml.find(LITERAL_DATA_DOMAIN_TAG_NAME); var literalDataDomainArray = new Array(literalDataDomain_xmlNodes.length); for(var index = 0; index < literalDataDomain_xmlNodes.length; index++){ literalDataDomainArray[index] = this.createLiteralDataDomainObject($(literalDataDomain_xmlNodes[index])); } return literalDataDomainArray; }, /** * extracts the unit of measure. */ extractUnitOfMeasure : function(literalDataXml){ return literalDataXml.find(LITERAL_DATA_UNIT_OF_MEASURE_TAG_NAME).text() || undefined; }, extractFormatNodes : function(xmlNode){ /* * simply use all occurrences */ return xmlNode.find(FORMAT_TAG_NAME); } }); var ExecuteResponse = BaseResponse.extend({ init : function(wpsResponse) { this.responseDocument = wpsResponse; /* * executeResponse can be instantiated differentely, depending on the * WPS version and executionMode * * Hence, we specify some common parameters, that indicate how to * interpret the response */ this.executeResponse = { /* * type shall be used to indicate the type of document */ type : "", serviceVersion : "", /* * document will have varying properties as it will be instantiated * differently according to the type */ responseDocument : {} }; this.instantiate(wpsResponse); }, instantiate : function(wpsResponse) { /* * override this method in child classes to instantiate the object */ }, /** * will have different properties, depending on the WPS version! */ instantiateResultDocument : function() { this.executeResponse.resultDocument = { }; }, /** * only relevant for WPS 2.0 */ instantiateStatusInfoDocument : function() { }, }); /** * Inspects XML response of WPS 1.0 execute request */ var ExecuteResponse_v1_xml = ExecuteResponse .extend({ instantiate : function(wpsResponse) { if ($(wpsResponse).find("wps\\:ExecuteResponse, ExecuteResponse").length > 0) { /* * response document! * * set the common response parameters */ this.executeResponse.serviceVersion = "1.0.0"; this.executeResponse.type = "responseDocument"; this.instantiateResponseDocument(wpsResponse); } else { /* * raw output */ this.executeResponse.serviceVersion = "1.0.0"; this.executeResponse.type = "rawOutput"; /* * check whether response is an XML document. * In that case return the xmlString, * else return the response directly */ var rawOutput; if(!(typeof wpsResponse === 'string') && ($(wpsResponse).length > 0)) rawOutput = (new XMLSerializer()).serializeToString(wpsResponse); else rawOutput = wpsResponse; this.executeResponse.responseDocument = rawOutput; } }, instantiateResponseDocument : function(wpsResponse) { var executeResponse_xmlNode = $(wpsResponse).find( "wps\\:ExecuteResponse, ExecuteResponse"); /* * service */ var service = "WPS"; var version = "1.0.0"; var lang = executeResponse_xmlNode.attr("lang") || executeResponse_xmlNode.attr("xml\\:lang"); /* * statusLocation may not exist */ var statusLoca