Module: odatajs/xml

odatajs/xml

Source:

Methods

<inner> hasLeadingOrTrailingWhitespace(text) → {Boolean}

Checks whether the specified string has leading or trailing spaces.
Parameters:
Name Type Description
text String String to check.
Source:
Returns:
true if text has any leading or trailing whitespace; false otherwise.
Type
Boolean

<inner> isWhitespace(text) → {Boolean}

Determines whether the specified text is empty or whitespace.
Parameters:
Name Type Description
text String Value to inspect.
Source:
Returns:
true if the text value is empty or all whitespace; false otherwise.
Type
Boolean

<inner> isWhitespacePreserveContext(domElement) → {Boolean}

Determines whether the specified element has xml:space='preserve' applied.
Parameters:
Name Type Description
domElement Element to inspect.
Source:
Returns:
Whether xml:space='preserve' is in effect.
Type
Boolean

<inner> isXmlNSDeclaration(domAttribute) → {Boolean}

Determines whether the attribute is a XML namespace declaration.
Parameters:
Name Type Description
domAttribute Element to inspect.
Source:
Returns:
True if the attribute is a namespace declaration (its name is 'xmlns' or starts with 'xmlns:'; false otherwise.
Type
Boolean

<inner> msXmlDom() → {Object}

Creates an configures new MSXML 6.0 or MSXML 3.0 ActiveX object.
Source:
Returns:
New MSXML 3.0 ActiveX object. This function will try to create a new MSXML 6.0 ActiveX object. If it fails then it will fallback to create a new MSXML 3.0 ActiveX object. Any exception that happens during the creation of the MSXML 6.0 will be handled by the function while the ones that happend during the creation of the MSXML 3.0 will be thrown.
Type
Object

<inner> msXmlDom3() → {Object}

Creates an configures new MSXML 3.0 ActiveX object.
Source:
Returns:
New MSXML 3.0 ActiveX object. This function throws any exception that occurs during the creation of the MSXML 3.0 ActiveX object.
Type
Object

<inner> msXmlParse() → {Object}

Parses an XML string using the MSXML DOM.
Source:
Returns:
New MSXML DOMDocument node representing the parsed XML string. This function throws any exception that occurs during the creation of the MSXML ActiveX object. It also will throw an exception in case of a parsing error.
Type
Object

<inner> safeSetProperty(obj, name, value)

Safely set as property in an object by invoking obj.setProperty.
Parameters:
Name Type Description
obj Object that exposes a setProperty method.
name String Property name
value Property value.
Source:

<inner> xmlAppendChild(parent, child)

Appends a child node or a string value to a parent DOM node.
Parameters:
Name Type Description
parent DOM node to which the child will be appended.
child Child DOM node or string value to append to the parent.
Source:
Returns:
The parent with the appended child or string value. If child is a string value, then a new DOM text node is going to be created for it and then appended to the parent.

<inner> xmlAppendChildren(parent, children)

Appends a collection of child nodes or string values to a parent DOM node.
Parameters:
Name Type Description
parent DOM node to which the children will be appended.
children Array Array containing DOM nodes or string values that will be appended to the parent.
Source:
Returns:
The parent with the appended children or string values. If a value in the children collection is a string, then a new DOM text node is going to be created for it and then appended to the parent.

<inner> xmlAppendText(domNode, textNode)

Appends a text node into the specified DOM element node.
Parameters:
Name Type Description
domNode DOM node for the element.
textNode String Text to append as a child of element.
Source:

<inner> xmlAttributeNode(domNode, localName, nsURI)

Gets an attribute node from a DOM element.
Parameters:
Name Type Description
domNode DOM node for the owning element.
localName String Local name of the attribute.
nsURI String Namespace URI of the attribute.
Source:
Returns:
The attribute node, null if not found.

<inner> xmlAttributes(element, onAttributeCallback)

Iterates through the XML element's attributes and invokes the callback function for each one.
Parameters:
Name Type Description
element Wrapped element to iterate over.
onAttributeCallback function Callback function to invoke with wrapped attribute nodes.
Source:

<inner> xmlAttributeValue(domNode, localName, nsURI) → {String}

Returns the value of a DOM element's attribute.
Parameters:
Name Type Description
domNode DOM node for the owning element.
localName String Local name of the attribute.
nsURI String Namespace URI of the attribute.
Source:
Returns:
- The attribute value, null if not found (may be null)
Type
String

<inner> xmlBaseURI(domNode, baseURI) → {String}

Gets the value of the xml:base attribute on the specified element.
Parameters:
Name Type Argument Description
domNode Element to get xml:base attribute value from.
baseURI <optional>
Base URI used to normalize the value of the xml:base attribute ( may be null)
Source:
Returns:
Value of the xml:base attribute if found; the baseURI or null otherwise.
Type
String

<inner> xmlChildElements(domNode, onElementCallback)

Iterates through the XML element's child DOM elements and invokes the callback function for each one.
Parameters:
Name Type Description
domNode DOM Node containing the DOM elements to iterate over.
onElementCallback function Callback function to invoke for each child DOM element.
Source:

<inner> xmlDom()

Creates a new empty DOM document node.
Source:
Returns:
New DOM document node. This function will first try to create a native DOM document using the browsers createDocument function. If the browser doesn't support this but supports ActiveXObject, then an attempt to create an MSXML 6.0 DOM will be made. If this attempt fails too, then an attempt for creating an MXSML 3.0 DOM will be made. If this last attemp fails or the browser doesn't support ActiveXObject then an exception will be thrown.

<inner> xmlFindElementByPath(root, namespaceURI, path)

Gets the descendant element under root that corresponds to the specified path and namespace URI.
Parameters:
Name Type Description
root DOM element node from which to get the descendant element.
namespaceURI String The namespace URI of the element to match.
path String Path to the desired descendant element.
Source:
Returns:
The element specified by path and namespace URI. All the elements in the path are matched against namespaceURI. The function will stop searching on the first element that doesn't match the namespace and the path.

<inner> xmlFindNodeByPath(root, namespaceURI, path)

Gets the DOM element or DOM attribute node under root that corresponds to the specified path and namespace URI.
Parameters:
Name Type Description
root DOM element node from which to get the descendant node.
namespaceURI String The namespace URI of the node to match.
path String Path to the desired descendant node.
Source:
Returns:
The node specified by path and namespace URI. This function will traverse the path and match each node associated to a path segement against the namespace URI. The traversal stops when the whole path has been exahusted or a node that doesn't belogong the specified namespace is encountered. The last segment of the path may be decorated with a starting @ character to indicate that the desired node is a DOM attribute.

<inner> xmlFirstChildElement(domNode, namespaceURI, localName)

Returns the first child DOM element under the specified DOM node that matches the specified namespace URI and local name.
Parameters:
Name Type Argument Description
domNode DOM node from which the child DOM element is going to be retrieved.
namespaceURI String <optional>
-
localName String <optional>
-
Source:
Returns:
The node's first child DOM element that matches the specified namespace URI and local name; null otherwise.

<inner> xmlFirstDescendantElement(domNode, namespaceURI, localName)

Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.
Parameters:
Name Type Argument Description
domNode DOM node from which the descendant DOM element is going to be retrieved.
namespaceURI String <optional>
-
localName String <optional>
-
Source:
Returns:
The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.

<inner> xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, recursive)

Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.
Parameters:
Name Type Argument Description
domNode DOM node from which the descendant DOM element is going to be retrieved.
namespaceURI String <optional>
-
localName String <optional>
-
recursive Boolean - True if the search should include all the descendants of the DOM node. - False if the search should be scoped only to the direct children of the DOM node.
Source:
Returns:
The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.

<inner> xmlInnerText(xmlElement) → {String}

Gets the concatenated value of all immediate child text and CDATA nodes for the specified element.
Parameters:
Name Type Description
xmlElement Element to get values for.
Source:
Returns:
Text for all direct children.
Type
String

<inner> xmlLocalName(domNode) → {String}

Returns the localName of a XML node.
Parameters:
Name Type Description
domNode DOM node to get the value from.
Source:
Returns:
localName of domNode.
Type
String

<inner> xmlNamespaceURI(domNode) → {String}

Returns the namespace URI of a XML node.
Parameters:
Name Type Description
domNode DOM node to get the value from.
Source:
Returns:
Namespace URI of domNode.
Type
String

<inner> xmlNewAttribute(dom, namespaceURI, qualifiedName, value)

Creates a new DOM attribute node.
Parameters:
Name Type Description
dom DOM document used to create the attribute.
namespaceURI String Namespace URI.
qualifiedName String Qualified OData name
value String Value of the new attribute
Source:
Returns:
DOM attribute node for the namespace declaration.

<inner> xmlNewElement(dom, namespaceURI, qualifiedName, children)

Creates a new DOM element node.
Parameters:
Name Type Argument Description
dom DOM document used to create the DOM element.
namespaceURI String Namespace URI of the new DOM element.
qualifiedName String Qualified name in the form of "prefix:name" of the new DOM element.
children Array <optional>
Collection of child DOM nodes or string values that are going to be appended to the new DOM element.
Source:
Returns:
New DOM element. If a value in the children collection is a string, then a new DOM text node is going to be created for it and then appended to the new DOM element.

<inner> xmlNewFragment(dom, text)

Creates a new DOM document fragment node for the specified xml text.
Parameters:
Name Type Description
dom DOM document from which the fragment node is going to be created.
text String XML text to be represented by the XmlFragment.
Source:
Returns:
New DOM document fragment object.

<inner> xmlNewNodeByPath(dom, root, namespaceURI, prefix, path)

Creates a new DOM element or DOM attribute node as specified by path and appends it to the DOM tree pointed by root.
Parameters:
Name Type Description
dom DOM document used to create the new node.
root DOM element node used as root of the subtree on which the new nodes are going to be created.
namespaceURI String Namespace URI of the new DOM element or attribute.
prefix String Prefix used to qualify the name of the new DOM element or attribute.
path String Path string describing the location of the new DOM element or attribute from the root element.
Source:
Returns:
DOM element or attribute node for the last segment of the path. This function will traverse the path and will create a new DOM element with the specified namespace URI and prefix for each segment that doesn't have a matching element under root. The last segment of the path may be decorated with a starting @ character. In this case a new DOM attribute node will be created.

<inner> xmlNewNSDeclaration(dom, namespaceURI, prefix)

Creates a namespace declaration attribute.
Parameters:
Name Type Description
dom DOM document used to create the attribute.
namespaceURI String Namespace URI.
prefix String Namespace prefix.
Source:
Returns:
DOM attribute node for the namespace declaration.

<inner> xmlNewText(dom, text)

Creates new DOM text node.
Parameters:
Name Type Description
dom DOM document used to create the text node.
text String Text value for the DOM text node.
Source:
Returns:
DOM text node.

<inner> xmlNodeValue(domNode)

Returns the value or the inner text of a XML node.
Parameters:
Name Type Description
domNode DOM node to get the value from.
Source:
Returns:
Value of the domNode or the inner text if domNode represents a DOM element node.

<inner> xmlParse(text)

Returns an XML DOM document from the specified text.
Parameters:
Name Type Description
text String Document text.
Source:
Returns:
XML DOM document. This function will throw an exception in case of a parse error

<inner> xmlQualifiedName(prefix, name) → {String}

Builds a XML qualified name string in the form of "prefix:name".
Parameters:
Name Type Description
prefix String Prefix string (may be null)
name String Name string to qualify with the prefix.
Source:
Returns:
Qualified name.
Type
String

<inner> xmlSerialize(domNode) → {String}

Returns the text representation of the document to which the specified node belongs.
Parameters:
Name Type Description
domNode Wrapped element in the document to serialize.
Source:
Returns:
Serialized document.
Type
String

<inner> xmlSerializeDescendants(domNode) → {String}

Returns the XML representation of the all the descendants of the node.
Parameters:
Name Type Description
domNode Node to serialize.
Source:
Returns:
The XML representation of all the descendants of the node.
Type
String

<inner> xmlSerializeNode(domNode) → {String}

Returns the XML representation of the node and all its descendants.
Parameters:
Name Type Description
domNode Node to serialize
Source:
Returns:
The XML representation of the node and all its descendants.
Type
String

<inner> xmlSiblingElement(domNode, namespaceURI, localName)

Returns the next sibling DOM element of the specified DOM node.
Parameters:
Name Type Argument Description
domNode DOM node from which the next sibling is going to be retrieved.
namespaceURI String <optional>
-
localName String <optional>
-
Source:
Returns:
The node's next sibling DOM element, null if there is none.

<inner> xmlThrowParserError(exceptionOrReason, srcText, errorXmlText)

Throws a new exception containing XML parsing error information.
Parameters:
Name Type Description
exceptionOrReason String indicating the reason of the parsing failure or Object detailing the parsing error.
srcText String String indicating the part of the XML string that caused the parsing error.
errorXmlText String XML string for wich the parsing failed.
Source:

<inner> xmlTraverse(domNode, recursive, onChildCallback) → {String}

Walks through the descendants of the domNode and invokes a callback for each node.
Parameters:
Name Type Description
domNode DOM node whose descendants are going to be traversed.
recursive Boolean - True if the traversal should include all the descenants of the DOM node. - False if the traversal should be scoped only to the direct children of the DOM node.
onChildCallback Boolean Called for each child
Source:
Returns:
Namespace URI of node.
Type
String