XML document, element, attribute, parser-result, and serialization helpers.
XMLDocument: document record with field root. The XML declaration is not stored.XMLAttribute: attribute record with fields name and value.XMLElement: element record with fields name, attributes, and children.XMLVALUE_ELEMENT and XMLVALUE_CHARDATA: tags for XMLValue.XMLValue: tagged child value that stores one child element or one character-data string.XMLParserResult: parse result with fields success, finished, errorInfo, and xml.XMLParserPosition: parser position with column, line, offset, currentSymbol, and currentCodepoint.XMLParserErrorInfo: error record with message and position.success: TRUE when lexical and structural parsing succeed and FALSE on invalid UTF-8 input or XML failure.finished: TRUE when the whole source is consumed after one successful document parse and FALSE when trailing input remains.errorInfo.message: parser failure description when success is FALSE.errorInfo.position: parser position at failure, or the first unparsed position when finished is FALSE.xml: parsed XMLDocument when success is TRUE. When finished is FALSE, it still contains the first parsed document.errorInfo.position.offset is meaningful; line and column are not derived.parseElementFromOpenTag: lower-level helper that parses one element after the opening < has already been consumed and the current parser position points to the first name character.parseStringToXMLImpl: lower-level helper underlying parseStringToXML. It parses one document from one already split UTF-8 source and one current parser position into supplied result objects.XMLDocument.&, >, <, and ".', numeric character references, document type declarations, CDATA sections, and processing instructions in element content are unsupported.(source -- result)Parses one accepted UTF-8 source into XMLParserResult.
StringView, Text, and String.String.makeStringView before UTF-8 splitting begins.XMLParserResult.(xml -- string)Serializes one XMLDocument to a formatted String.
XMLElement tree only; the XML declaration and comments are not re-emitted."Xml" use
"control" use
{} () {} [
result: " " parseStringToXML;
@result.@success TRUE same printStack _:;
@result.@finished TRUE same printStack _:;
@result.@xml.@[email protected] 1 same printStack _:;
@result.@[email protected] 1 same printStack _:;
] "main" exportFunction
TRUE
TRUE
TRUE
TRUE
"Xml" use
"control" use
{} () {} [
trailing: " x" parseStringToXML;
@trailing.@success TRUE same printStack _:;
@trailing.@finished FALSE same printStack _:;
duplicate: "" parseStringToXML;
@duplicate.@success FALSE same printStack _:;
spaces: " " parseStringToXML;
@spaces.@[email protected] 0 same printStack _:;
apos: "' " parseStringToXML;
@apos.@success FALSE same printStack _:;
] "main" exportFunction
TRUE
TRUE
TRUE
TRUE
TRUE
"Xml" use
"String" use
"control" use
{} Int32 {} [
result: " " parseStringToXML;
("success=" result.success LF
"finished=" result.finished LF
"attrs=" result.xml.root.attributes.size LF
"children=" result.xml.root.children.size LF) printList
0
] "main" exportFunction
success=TRUE
finished=TRUE
attrs=1
children=1