Namespace: EMLUtilities

EMLUtilities

A generic utility object that contains functions used throughout MetacatUI to perform useful functions related to EML, but not used to store or manipulate any state about the application.
Since:
  • 2.34.0
Source:

Methods

cleanXMLText(value) → {*}

Clean text so it can be safely serialized into EML XML.
Parameters:
Name Type Description
value * Candidate text value.
Since:
  • 2.39.0
Source:
Returns:
Cleaned text, or the original non-string value.
Type
*

getParentEML(model, maxTriesopt) → {EML211|false}

Climbs up the model hierarchy until it finds the EML model
Parameters:
Name Type Attributes Description
model Backbone.Model The starting model
maxTries number <optional>
The maximum number of levels to climb
Source:
Returns:
- Returns the EML 211 Model or null if not found
Type
EML211 | false

isDateFormatValid(dateString) → {boolean}

Validate a year with four digits or a YYYY-MM-DD calendar date.
Parameters:
Name Type Description
dateString string Date text to check
Since:
  • 2.41.0
Source:
Returns:
True if the format and calendar date are valid
Type
boolean

markRootDataPackageChanged()

Mark the active package as edited after an EML model or view change.
Since:
  • 2.39.0
Source:

parseTime(time) → {Object|null}

Parse an EML xs:time value without rounding fractional seconds or assuming a time zone when none is given.
Parameters:
Name Type Description
time string HH:MM:SS with optional fractional seconds and Z or a signed HH:MM offset. Surrounding whitespace is trimmed before parsing
Since:
  • 2.41.0
Source:
See:
Returns:
Parsed time, or null for an invalid value. seconds counts whole seconds from midnight (86400 for 24:00:00); fraction contains the digits after the decimal point, or ""; offset is seconds ahead of UTC, or null if no time zone is given
Type
Object | null

serializeDOM(dom) → {string}

Serialize a DOM element to a string, removing the XML declaration and any namespace declarations. Namespaces are added to the elements because the codebase currently combines older ways of handling XML (using jQuery's parseHTML and document.createElement) with newer ways (using DOMParser). While we transition to using modern methods, this function can be used to clean up the serialized XML.
Parameters:
Name Type Description
dom Element The DOM element to serialize
Since:
  • 2.35.0
Source:
Returns:
The serialized XML string
Type
string