Functions -
lang.xml
concat | Concatenates xml and string values. |
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. Each item is represented as a singleton value. |
forEach | Applies a function to each item in an xml sequence. Each item is represented as a singleton value. |
fromString | Constructs an xml value from a string.
This parses the string using the |
get | Returns the item of |
getAttributes | Returns the map representing the attributes of |
getChildren | Returns the children of |
getContent | Returns the content of a text or processing instruction or comment item. |
getName | Returns a string giving the expanded name of |
getTarget | Returns the target part of the processing instruction. |
iterator | Returns an iterator over the xml items of |
length | Returns number of xml items in |
map | Applies a function to each item in an xml sequence, and returns an xml sequence of the results. Each item is represented as a singleton value. |
setChildren | Sets the children of |
setName | Change the name of element |
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. |
Concatenates xml and string values.
Parameters
- xs xml | string[]
-
xml or string items to concatenate
-
Return Type
(xml) an xml sequence that is the concatenation of all the
xs
; an empty xml sequence if thexs
are empty
Constructs an xml sequence consisting of only a comment item.
Parameters
- content string
-
the content of the comment to be constructed.
-
Return Type
(Comment) an xml sequence consisting of a comment with content
content
Constructs an xml sequence consisting of only a new element item.
Parameters
- name string
-
the name of the new element
- children xml (default concat())
-
the children of the new element
-
Return Type
(Element) an xml sequence consisting of only a new xml element with name
name
, no attributes, and childrenchildren
Constructs an xml sequence consisting of only a processing instruction item.
Parameters
- target string
-
the target part of the processing instruction to be constructed
- content string
-
the content part of the processing instruction to be constructed
-
Return Type
(ProcessingInstruction) an xml sequence consisting of a processing instruction with target
target
and contentcontent
Selects the elements from an xml value.
Parameters
- x xml
-
the xml value
-
Return Type
(xml) an xml sequence consisting of all the element items in
x
Selects the items from an xml sequence for which a function returns true. Each item is represented as a singleton value.
Parameters
- x xml
-
xml value
-
func
function(ItemType) returns (boolean)
-
a predicate to apply to each item to test whether it should be selected
-
Return Type
(xml) new xml sequence containing items in
x
for whichfunc
evaluates to true
Applies a function to each item in an xml sequence. Each item is represented as a singleton value.
Parameters
- x xml
-
the xml value
-
func
function(ItemType) returns (())
-
a function to apply to each item in
x
Constructs an xml value from a string.
This parses the string using the content
production of the
XML 1.0 Recommendation.
Parameters
- s string
-
a string in XML format
-
Return Type
(xml | error) xml value resulting from parsing
s
, or an error
Returns the item of x
with index i
.
This differs from x[i]
in that it panics if
x
does not have an item with index i
.
Parameters
- x xml
-
the xml sequence
- i int
-
the index
-
Return Type
(xml) the item with index
i
inx
Returns the map representing the attributes of elem
.
This includes namespace attributes.
The keys in the map are the expanded names of the attributes.
Parameters
- x Element
-
xml element
-
Return Type
(map) attributes of
x
Returns the children of elem
.
Parameters
- elem Element
-
xml element
-
Return Type
(xml) children of
elem
Returns the content of a text or processing instruction or comment item.
Parameters
- x Text | ProcessingInstruction | Comment
-
xml item
-
Return Type
(string) the content of
x
Returns a string giving the expanded name of elem
.
Parameters
- elem Element
-
xml element
-
Return Type
(string) element name
Returns the target part of the processing instruction.
Parameters
- x ProcessingInstruction
-
xml processing instruction item
-
Return Type
(string) target part of
x
Returns an iterator over the xml items of x
Parameters
- x xml
-
xml sequence to iterate over
-
Return Type
($anonType$7) iterator object Each item is represented by an xml singleton.
Returns number of xml items in x
.
Parameters
- x xml
-
xml item
-
Return Type
(int) number of XML items in
x
Applies a function to each item in an xml sequence, and returns an xml sequence of the results. Each item is represented as a singleton value.
Parameters
- x xml
-
the xml value
-
func
function(ItemType) returns (XmlType)
-
a function to apply to each child or
item
-
Return Type
(xml) new xml value containing result of applying
func
to each child oritem
Sets the children of elem
to children
.
This panics if it would result in the element structure
becoming cyclic.
Change the name of element elem
to xName
.
Returns a subsequence of an xml value.
Parameters
- x xml
-
the xml value
- startIndex int
-
start index, inclusive
- endIndex int (default x.length(x))
-
end index, exclusive
-
Return Type
(xml) a subsequence of
x
consisting of items with index >= startIndex and < endIndex
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.
Parameters
- x xml
-
the xml value
-
Return Type
(xml) x
with insignificant parts removed