Module : lang.xml

Module Overview

This module provides lang library operations on xml values defined by the language specification 2019R3.

Objects

$anonType$9

Functions

appendChildren

Append children to an XML if its an element type XML. Error otherwise. New children will be appended at the end of the existing children.

concat

Concatenates xml and string values.

copy

Make a deep copy of an XML.

createComment

Constructs an xml sequence consisting of only a comment item.

createElement

Constructs an xml sequence consisting of only a new element item.

createProcessingInstruction

Constructs an xml sequence consisting of only a processing instruction item.

elements

Selects the elements from an xml value.

filter

Selects the items from an xml sequence for which a function returns true. This represents each item in the same way as the iterator function.

forEach

Applies a function to each item in an xml sequence. This represents each item in the same way as the iterator function.

fromString

Constructs an xml value from a string. This parses the string using the content production of the XML 1.0 Recommendation.

getAttributes

Returns the map representing the attributes of elem. This includes namespace attributes. The keys in the map are the expanded names of the attributes. Panics if isElement(elem) is not true.

getChildren

Returns the children of elem. Panics if isElement(elem) is not true.

getContent

Returns the content of a text or processing instruction or comment item.

getElementName

Get the fully qualified name of the element as a string. Returns an empty string if the XML is not a singleton.

getItemType

Get the type of a XML as a string. If the XML is singleton, type can be one of 'element', 'text', 'comment' or 'pi'. Returns an empty string if the XML is not a singleton.

getName

Returns a string giving the expanded name of elem.

getTarget

Returns the target part of the processing instruction.

getTextValue

Get the text value of a XML. If the XML is a sequence, concatenation of the text values of the members of the sequence is returned. If the XML is an element, then the text value of the sequence of children is returned. If the XML is a text item, then the text is returned. Otherwise, an empty string is returned.

isComment

Tests whether an xml value is a singleton consisting of only a comment item.

isElement

Tests whether an xml value is a singleton consisting of only an element item.

isEmpty

Check whether the XML sequence is empty.

isProcessingInstruction

Tests whether an xml value is a singleton consisting of only a processing instruction item.

isSingleton

Check whether the XML sequence contains only a single element.

isText

Tests whether an xml sequence consists of zero or more character items.

iterator

Returns an iterator over the xml items of x

length

Returns number of xml items in x.

map

Applies a function to each item in an xml sequence, and returns an xml sequence of the results. This represents each item in the same way as the iterator function.

removeAttribute

Remove an attribute from an XML.

removeChildren

Remove children matching the given name from an XML. This operation has no effect if the XML is not an element type XML.

select

Get all the items that are of element type, and matches the given qualified name, in an XML sequence.

selectDescendants

Searches in children recursively for elements matching the qualified name and returns a sequence containing them all. Does not search within a matched result.

setAttributes

Sets the attributes to the provided attributes map.

setChildren

Sets the children of elem to children. Panics if isElement(elem) is not true.

setName

Change the name of element elem to xName.

slice

Returns a subsequence of an xml value.

strip

Strips the insignificant parts of the an xml value. Comment items, processing instruction items are considered insignificant. After removal of comments and processing instructions, the text is grouped into the biggest possible chunks (i.e. only elements cause division into multiple chunks) and a chunk is considered insignificant if the entire chunk is whitespace.

Constants

XML_ELEMENT
XML_SEQUENCE
XML_TEXT
XML_COMMENT
XML_PI

Types

XMLType