Jump to navigation

Namespace: xml

Numbas.xml

Members

(static) examXML :XMLDocument

XML for the current exam

Type:
Source:

(static) templates :Object.<XMLDocument>

XSLT stylesheets

Type:
Source:

Methods

(static) getTextContent(elem) → {String}

Get all the text belonging to an element

Parameters:
Name Type Description
elem Element
Returns:
Type Description
String
Source:

(static) isEmpty(node) → {Boolean}

Is the given node empty? True if it has no children.

Parameters:
Name Type Description
node Element
Returns:
Type Description
Boolean
Source:

(static) loadFunctions(xml) → {Array.<Numbas.jme.variables.func_data>}

Load user-defined functions from an XML node

Parameters:
Name Type Description
xml Element
Returns:
Type Description
Array.<Numbas.jme.variables.func_data>
Source:

(static) loadVariables(xml, scope) → {Array.<Numbas.jme.variables.variable_data_dict>}

Load variable definitions from an XML node

Parameters:
Name Type Description
xml Element
scope Numbas.jme.Scope

scope to compile relative to

Returns:
Type Description
Array.<Numbas.jme.variables.variable_data_dict>
Source:

(static) loadXML(xmlstring) → {XMLDocument}

Load in a single XML document

Parameters:
Name Type Description
xmlstring String
Returns:
Type Description
XMLDocument
Source:

(static) loadXMLDocs()

Load in all the XSLT/XML documents from Numbas.rawxml

Source:

(static) localise(template) → {Element}

Replace every <localise> tag with its contents, run through localisation, i.e. get localised strings.

Parameters:
Name Type Description
template Element
Returns:
Type Description
Element
Source:

(static) serializeMessage(node) → {String}

Lots of the time we have a message stored inside content/html/.. structure.

This pulls the message out and serializes it so it can be inserted easily with jQuery

Parameters:
Name Type Description
node Element
Returns:
Type Description
String
Source:

(static) setTextContent(elem, text)

Set the text content of an element

Parameters:
Name Type Description
elem Element
text String
Source:

(static) tryGetAttribute(obj, xmlroot, elem, names, altnamesopt, options) → {Object}

Try to get attributes from an XML node, and use them to fill in an object's properties if they're present. If obj is null, then the loaded value is just returned.

Parameters:
Name Type Attributes Description
obj Object

object to fill up

xmlroot Element

root XML element

elem Element | String

either an XML node to get attributes from, or an XPath query to get the element from xmlroot

names Array.<String>

names of attributes to load

altnames Array.<String> <optional>

names of object properties to associate with attribute names. If undefined, the attribute name is used.

options Numbas.xml.tryGetAttribute_options
Returns:
Type Description
Object
  • The last attribute loaded.
Source:

Type Definitions

tryGetAttribute_options

Type:
Properties:
Name Type Description
string Boolean

Always return the attribute as a string.

Source: