Class: CmlDomUtils

Kekule.IO. CmlDomUtils

new CmlDomUtils()

A help class to do some DOM work on CML
Source:

Methods

(static) analysisCmlFormulaConciseValue(value) → {Hash}

Split a CML formula concise value to an array. For example, 'S 1 O 4 -2' will be transformed to: {'isotopes': [{'elementType': 'S', 'count': 1}, {'elementType': 'O', 'count': 4}], 'formalCharge': -2}
Parameters:
Name Type Description
value String
Source:
Returns:
Type
Hash

(static) fetchCmlElemAttributeValuesToJson(elem, filter, mergeSameNameTypedElem, domHelper) → {Hash}

Fetch all attribute values of CML element into an JSON object, including typed or typed array child elements.
Parameters:
Name Type Description
elem Object
filter Int
mergeSameNameTypedElem Bool If multiple child typed elements has same builtin, whether merge their values
domHelper Kekule.DomHelper
Source:
Returns:
Each item is a hash: {name: value}.
Type
Hash

(static) getCmlElemAttribute(elem, attribName, filter) → {Variant}

Get attribute value of elem. If attribName not found in elem's attributes, this method will automatically check child , or elements.
Parameters:
Name Type Description
elem Object
attribName String
filter Int
Source:
Returns:
Value of attribute.
Type
Variant

(static) getCmlId(elem) → {String}

Get Id of CML element
Parameters:
Name Type Description
elem Object
Source:
Returns:
Type
String

(static) getCmlTitle(elem) → {String}

Get title of CML element
Parameters:
Name Type Description
elem Object
Source:
Returns:
Type
String

(static) getCmlTypedElem(parent, builtinName, filter) → {Object}

Get child typed element with specified builtinName.
Parameters:
Name Type Description
parent Object
builtinName String
filter Int
Source:
Returns:
Element found or null.
Type
Object

(static) getCmlTypedElems(parent, builtinName, filter) → {Array}

Get all child typed elements with specified builtinName.
Parameters:
Name Type Description
parent Object
builtinName String
filter Int
Source:
Returns:
Elements found or null.
Type
Array

(static) getCmlTypedElemValue(parent, builtinName, filter) → {Variant}

Get value of child typed element with specified builtinName.
Parameters:
Name Type Description
parent Object
builtinName String
filter Int
Source:
Returns:
Value found or null.
Type
Variant

(static) getMultipleCmlElemAttribute(elem, attribName, filter) → {Variant}

Get attribute values of (may) multiple elem. If attribName not found in elem's attributes, this method will automatically check child , or elements.
Parameters:
Name Type Description
elem Object
attribName String
filter Int
Source:
Returns:
Value of attribute.
Type
Variant

(static) getMultipleCmlTypedElemValues(parent, builtinName, filter) → {Variant}

Get value of child typed elements (maybe multiple) with specified builtinName.
Parameters:
Name Type Description
parent Object
builtinName String
filter Int
Source:
Returns:
Value found (array) or null.
Type
Variant

(static) hasDirectCmlTypedArrayElemChildren(elem, namespaceURI) → {Bool}

Check if an element has direct , or children
Parameters:
Name Type Description
elem Object
namespaceURI String
Source:
Returns:
Type
Bool

(static) hasDirectCmlTypedElemChildren(elem, namespaceURI) → {Bool}

Check if an element has direct or children
Parameters:
Name Type Description
elem Object
namespaceURI String
Source:
Returns:
Type
Bool

(static) isCmlBuiltInMarkedElem(elem, namespaceURI) → {Bool}

Check if an element has builtin attribute.
Parameters:
Name Type Description
elem Object
namespaceURI String Can be null.
Source:
Returns:
Type
Bool

(static) isCmlTypedArrayElem(elem, namespaceURI) → {Bool}

Check if an element is , or
Parameters:
Name Type Description
elem Object
namespaceURI String Can be null.
Source:
Returns:
Type
Bool

(static) isCmlTypedElem(elem, namespaceURI) → {Bool}

Check if an element is or
Parameters:
Name Type Description
elem Object
namespaceURI String Can be null.
Source:
Returns:
Type
Bool

(static) isScalarElem(elem, namespaceURI) → {Bool}

Check is element is
Parameters:
Name Type Description
elem Object
namespaceURI String Can be null.
Source:
Returns:
Type
Bool

(static) mergeToCmlArrayValue(arrayObj) → {String}

Merge an array to a CML array string.
Parameters:
Name Type Description
arrayObj Array
Source:
Returns:
Type
String

(static) setCmlId(id, elem)

Get Id attribute of CML element
Parameters:
Name Type Description
id String
elem Object
Source:

(static) setCmlTitle(elem) → {String}

Set title attribute of CML element
Parameters:
Name Type Description
elem Object
Source:
Returns:
Type
String

(static) splitCmlArrayValue(value) → {Array}

Split a CML array string to a JavaScript array
Parameters:
Name Type Description
value Object
Source:
Returns:
Type
Array