static org.cote.js.xml
version 1.9.18
A library for making XMLHTTP Requests.
This class participates in the engine library.
Index
Example Index
Object Index
- private XmlHttp: Object representing a pooled XMLHTTP resource
- public XmlObject: Object passed to the event handler following an XML request using getXml or postXml.
Property Index
- public ax_http_control: Specifies the name of the registered ActiveX control to use for XML requests.
- public ax_http_control: Specifies the name of the registered ActiveX control to use for XML requests.
- public gadget_base_path: Specifies the base path to use when operating in Gadget mode. The base path should be in the format of a file URI, such as file:///c:/....
- public gadget_control: Specifies the name of the registered ActiveX control to use for XML requests when in Gadget mode.
- public gadget_mode: Specifies whether the xml package is operating in a mode that better supports Windows Sidebar Gadgets.
Method Index
- private _request_xmlhttp: Assembles and opens an XMLHTTP Request.
- public clear: Clears the request maps and caches.
- public clearCache: Clears the response cache.
- public getCacheEnabled
- public getCDATAValue: Returns a concatenation of all CDATA values that are immediate children of the specified node.
- public getInnerText: Returns a concatenation of text nodes belonging to all children of the specified node.
- public getPoolEnabled
- public getXml: Retrieve an XML document from the specified path.
- public getXmlHttpArray
- private getXmlHttpObjectFromPool: Retrieves the next available XmlHttp object from the pool of available resources.
- public newXmlDocument
- private newXmlHttpObject: Creates a new XMLHTTPRequest object.
- public postXml: Posts an XML document to the specified path and returns any XML response.
- public queryNode: Returns a DOM Node selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
- public queryNodes: Returns an array of DOM Nodes selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
- public removeChildren: Removes all child nodes of the specified node.
- public resetXmlHttpObjectPool: Resets the current pool with new instances of XMLHttpRequest objects.
- private returnXmlHttpObjectToPool: Returns an in-use XmlHttp object to the pool of available resources.
- public selectNodes: Returns an array of DOM Nodes selected from the specified document and based on the specified path.
- public selectSingleNode: Returns a DOM Node selected from the specified document and based on the specified path.
- public serialize: Returns a string representation of the specified node and its children.
- public setCacheEnabled
- public setInnerXHTML: Copies the child nodes of the specified source node into the specified target node.
- public setPoolEnabled
- public testXmlHttpObject: Tests whether an XMLHTTPRequest object can be created.
- public transformNode: Transforms the specified Document with the specified XSL document.
Examples
Asynchronous GET
Make an asynchronous request for an XML document.
Syntax
[int] = getXml(path,custom_handler,1,{optional_id});
Example Code
function HandleXml(s,v){
var oXml = v.xdom;
}
org.cote.js.xml.getXml("/Data/Test1.xml",HandleXml,1);Asynchronous POST
Asynchronously post data to the server.
Syntax
[int] = postXml(path,data,custom_handler,1,{optional_id});
Example Code
function HandleXml(s,v){
var oResponseXml = v.xdom;
}
var oPostThis = org.cote.js.xml.newXmlDocument("Request");
var oResponseXml = org.cote.js.xml.postXml("/Data/TestData.aspx",oPostThis,HandlePostXml,1);Cached Asynchronous GET
Asynchronously request an XML document, and cached the result for later referal.
Syntax
[int] = getXml(path,custom_handler,1,request_id,1);
Example Code
function HandleXml(s,v){
var oXml = v.xdom;
}
org.cote.js.xml.getXml("/Data/Test1.xml",HandleXml,1,"cache-me",1);Synchronous GET
Make a synchronous request for an XML document.
Syntax
[xml_dom_object] = getXml(path);
Example Code
var oXml = org.cote.js.xml.getXml("/Data/Test1.xml");Synchronous POST
Synchronously post data to the server.
Syntax
[xml_dom_object] = postXml(path,data);
Example Code
var oPostThis = org.cote.js.xml.newXmlDocument("Request");
var oData = oPostThis.createElement("data");
oData.setAttribute("id","data-id");
oData.setAttribute("value","data-value");
oPostThis.documentElement.appendChild(oData);
var oResponseXml = org.cote.js.xml.postXml("/Data/TestData.aspx",oPostThis);Objects
XmlHttp
Object representing a pooled XMLHTTP resource Object is private and should not be directly referenced.
Properties
- xml_object as object: An XMLHttp object.
- in_use as boolean: Bit indicating whether the object is in use.
- vid as int: Integer identifying the variant object identifier.
- handler as function: Anonymous wrapper to invoke the internal readystate or complete handler for the specified identifier.
XmlObject
Object passed to the event handler following an XML request using getXml or postXml.
Properties
- xdom as XMLDocument: An XML Document object.
- id as String: Identifier used to distinguish the request for this XML Document from other requests.
Properties
ax_http_control
Specifies the name of the registered ActiveX control to use for XML requests.
Syntax
String = org.cote.js.xml.ax_http_control
org.cote.js.xml.ax_http_control = String
ax_http_control
Specifies the name of the registered ActiveX control to use for XML requests.
Syntax
String = org.cote.js.xml.ax_http_control
org.cote.js.xml.ax_http_control = String
gadget_base_path
Specifies the base path to use when operating in Gadget mode. The base path should be in the format of a file URI, such as file:///c:/....
Syntax
String = org.cote.js.xml.gadget_base_path
org.cote.js.xml.gadget_base_path = String
gadget_control
Specifies the name of the registered ActiveX control to use for XML requests when in Gadget mode.
Syntax
String = org.cote.js.xml.gadget_control
org.cote.js.xml.gadget_control = String
gadget_mode
Specifies whether the xml package is operating in a mode that better supports Windows Sidebar Gadgets.
Syntax
boolean = org.cote.js.xml.gadget_mode
org.cote.js.xml.gadget_mode = boolean
Methods
_request_xmlhttp
Assembles and opens an XMLHTTP Request. Method is private and should not be directly referenced.
Syntax
v = _request_xmlhttp(
p, h, a, i, x, d, c
)
Parameters
- p as String : Path to the XML data source.
- h as function (optional): Handler invoked for asynchronous requests.
- a as boolean (optional): Bit indicating whether the request is asynchronous.
- i as String (optional): Identifier used to track the request and retrieve cached results.
- x as boolean (optional): Bit indicating whether the request is a post.
- d as XMLDocument (optional): XML Document to send with post request.
- c as boolean (optional): Bit indicating whether the response should be cached.
Returns
v as variant: Returns a boolean value for asynchronous requests, and an XML Document for synchronous requests.
clear
Clears the request maps and caches.
Syntax
void clear(
)
clearCache
Clears the response cache.
Syntax
void clearCache(
)
getCacheEnabled
Syntax
b = getCacheEnabled(
)
Returns
b as boolean: boolean indicating whether caching is enabled.
getCDATAValue
Returns a concatenation of all CDATA values that are immediate children of the specified node.
Syntax
v = getCDATAValue(
n
)
Parameters
- n as DOMNode : XML DOM Node.
Returns
v as String: Returns a concatenation of all child CDATA values.
getInnerText
Returns a concatenation of text nodes belonging to all children of the specified node.
Syntax
sTxt = getInnerText(
n
)
Parameters
Returns
sTxt as String: Returns the inner text of the specified node.
getPoolEnabled
Syntax
b = getPoolEnabled(
)
Returns
b as boolean: boolean indicating whether pooling is enabled.
getXml
Retrieve an XML document from the specified path.
Syntax
v = getXml(
p, h, a, i, c
)
Parameters
- p as String : Path of the XML source. If specifying the server, note the server name and port must match the context host name and port.
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
- c as boolean (optional): Bit indicating whether the response should be cached.
Returns
v as variant: Returns boolean for asynchronous operations, and an XMLDocument object for synchronous operations.
getXmlHttpArray
Syntax
aXml = getXmlHttpArray(
)
Returns
aXml as array: Array of XmlHttp objects.
getXmlHttpObjectFromPool
Retrieves the next available XmlHttp object from the pool of available resources. Method is private and should not be directly referenced.
Syntax
oXml = getXmlHttpObjectFromPool(
y
)
Parameters
- y as boolean : Bit indicating whether the pool object is requested for asynchronous operation.
Returns
oXml as XmlHttp: An XmlHttp object.
newXmlDocument
Syntax
oXml = newXmlDocument(
s
)
Parameters
- s as String : Name of root node to create in new document.
Returns
oXml as XMLDocument: XMLDocument object.
newXmlHttpObject
Creates a new XMLHTTPRequest object. Method is private and should not be directly referenced.
Syntax
v = newXmlHttpObject(
b, i, z
)
Parameters
- b as boolean : Bit indicating whether to wrap the new object in an internal XmlHttp object for use with pooling.
- i as int : Pool index to set on new XmlHttp object.
- z as boolean : Bit indicating whether this is a test operation, and to return true if the object was created, or false otherwise.
Returns
v as variant: Return value is determined by the specified parameters.
postXml
Posts an XML document to the specified path and returns any XML response.
Syntax
v = postXml(
p, d, h, a, i
)
Parameters
- p as String : Path of the XML source. If specifying the server, note the server name and port must match the context host name and port.
- d as XMLDocument : XMLDocument to post the server
- h as function (optional): Function to invoke when a response is received.
- a as boolean (optional): Bit indicating whether the request is an asynchronous operation.
- i as String (optional): Identifier to assign to the request.
Returns
v as variant: Returns boolean for asynchronous operations, and an XMLDocument object for synchronous operations.
queryNode
Returns a DOM Node selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
Syntax
aNodes = queryNode(
d, p, n, a, v
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : Parent element name.
- n as String (optional): Element name. Defaults to parent if not specified.
- a as String (optional): Attribute name.
- v as String (optional): Attribute value.
Returns
aNodes as DOMNode: Returns a DOM Node based on the specified parent node name, node name, and attribute name and value.
queryNodes
Returns an array of DOM Nodes selected from the specified document and based on the specified parent node name, node name, and attribute name and values.
Syntax
aNodes = queryNodes(
d, p, n, a, v
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : Parent element name.
- n as String (optional): Element name. Defaults to parent if not specified.
- a as String (optional): Attribute name.
- v as String (optional): Attribute value.
Returns
aNodes as array: Returns an array of DOM Nodes based on the specified parent node name, node name, and attribute name and value.
removeChildren
Removes all child nodes of the specified node.
Syntax
void removeChildren(
o
)
Parameters
resetXmlHttpObjectPool
Resets the current pool with new instances of XMLHttpRequest objects.
Syntax
void resetXmlHttpObjectPool(
)
returnXmlHttpObjectToPool
Returns an in-use XmlHttp object to the pool of available resources. Method is private and should not be directly referenced.
Syntax
void returnXmlHttpObjectToPool(
i, y
)
Parameters
- i as int : Pool index of the XmlHttp object to be returned.
- y as boolean : Bit indicating whether the pool object was requested for asynchronous operation.
selectNodes
Returns an array of DOM Nodes selected from the specified document and based on the specified path.
Syntax
aNodes = selectNodes(
d, p, c
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : XPath query.
- c as DOMNode : Context node.
Returns
aNodes as array: Returns an array of DOM Nodes based on the specified xpath query.
selectSingleNode
Returns a DOM Node selected from the specified document and based on the specified path.
Syntax
v = selectSingleNode(
d, p, c
)
Parameters
- d as XMLDocument : XMLDocument.
- p as String : XPath query.
- c as DOMNode : Context node.
Returns
v as String: Returns a DOM Node based on the specified xpath query.
serialize
Returns a string representation of the specified node and its children.
Syntax
s = serialize(
n
)
Parameters
- n as DOMNode : XML DOM Node.
Returns
s as String: String representation of the specified node.
setCacheEnabled
Syntax
void setCacheEnabled(
b
)
Parameters
- b as boolean : boolean indicating whether caching is enabled.
setInnerXHTML
Copies the child nodes of the specified source node into the specified target node.
Syntax
v = setInnerXHTML(
t, s, p, d, z, c, h, ch
)
Parameters
- t as DOMNode : DOM Node into which the source node children will be copied.
- s as DOMNode : DOM Node from which nodes will be copied into the target node.
- p as boolean (optional): Bit indicating whether to keep the children of the target node, or to remove them before copying in the new contents.
- d as Document (optional): Document object to use when creating elements for the target node.
- z as boolean (optional): Bit indicating whether recursion should be blocked.
- c as boolean (optional): Bit indicating whether whitespace should be preserved.
- h as boolean (optional): Bit indicating whether HTML source nodes should be cloned instead of incrementally recreated.
- ch as function (optional): Optional callback handler for substituting values prior to copying. Useful for templates.
Returns
v as variant: Depending on the type of copy operation, returns a reference to the newly created node.
setPoolEnabled
Syntax
void setPoolEnabled(
b
)
Parameters
- b as boolean : boolean indicating whether pooling is enabled.
testXmlHttpObject
Tests whether an XMLHTTPRequest object can be created.
Syntax
b = testXmlHttpObject(
)
Returns
b as boolean: Bit indicating whether a new XMLHTTPRequest object was created.
transformNode
Transforms the specified Document with the specified XSL document.
Syntax
v = transformNode(
x, s, n, i, j, p
)
Parameters
- x as variant : XML Document to be transformed. If specified as a string, the string is used as a path to request the XML Document.
- s as Document : XSL Document to transform the XML Document. If specified as a string, the string is used as a path to request the XSL Document.
- n as DOMNode (optional): DOMNode to transform.
- i as String (optional): Identifier used when requesting the XML Document.
- j as String (optional): Identifier used when requesting the XSL Document.
- p as boolean (optional): Bit indicating whether a request for the XSL Document should be cached.
Returns
v as variant: Depending on the type of copy operation, returns a reference to the newly created node.