Package xml
SLPackage #sleela 2.5 (lib/xml/SLPackage.sleela)
SLPackage class
Defines the SLeeLa standard-library package for xml -- the Document Object Model (DOM) family. Exposes the package to the SLeeLa compiler, Loader, and Nordshrift.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
packageName | String packageName | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
configure | void configure(String name) | No description in source. |
name | String name() | No description in source. |
available | boolean available() | No description in source. |
SLXmlAspect #sleela 2.5 (lib/xml/SLXmlAspect.sleela)
SLXmlAspect class
Defines SLXmlAspect -- the conformance-aspect and quality register for the xml DOM family. It catalogues the measurable "aspects" an XML processor can satisfy (well-formedness, validity, namespace-awareness, DOM conformance, round-trip fidelity) and rates the quality with which this library addresses each, so a caller can reason about the library's standing.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
WELL_FORMED | static final int WELL_FORMED = 0 | ---- the catalogued aspects ---- |
DOM | static final int DOM = 1 | No description in source. |
NAMESPACES | static final int NAMESPACES = 2 | No description in source. |
SERIALIZATION | static final int SERIALIZATION = 3 | No description in source. |
VALIDITY | static final int VALIDITY = 4 | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
count | int count() | No description in source. |
nameOf | String nameOf(int aspect) | The human name of an aspect id. |
itemOf | String itemOf(int aspect) | The governing standards item for an aspect (a real, citable instrument). |
qualityOf | int qualityOf(int aspect) | Honest quality score (0..10) for how fully THIS library addresses an aspect. well-formedness, DOM, namespaces, and serialization are implemented and exercised by the demo; DTD/schema validity is not yet implemented, so it reports a low, honest score rather than a fabricated one. |
bandOf | String bandOf(int score) | A one-word quality band for a score. |
isAddressed | boolean isAddressed(int aspect) | True when this library implements the aspect to at least a usable degree. |
overallQualityX10 | int overallQualityX10() | The mean quality across all catalogued aspects, scaled x10 to stay integer (e.g. 68 means an average quality of 6.8 / 10). |
SLXmlAttribute #sleela 2.5 (lib/xml/SLXmlAttribute.sleela)
SLXmlAttribute class
Defines SLXmlAttribute -- a single name/value attribute on a DOM element, with namespace-aware prefix/local parts.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
qname | String qname | The qualified name exactly as given (e.g. "xml:lang"). |
value | String value | The unescaped string value. |
valueCellView | String[] valueCellView | No description in source. |
valueHasCells | boolean valueHasCells = false | No description in source. |
nsPrefix | String nsPrefix = "" | No description in source. |
nsLocal | String nsLocal = "" | No description in source. |
split | boolean split = false | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
set | void set(String qualifiedName, String v) | Build an attribute from a qualified name and value. |
setValueCells | void setValueCells(String[] cells) | Attach a char-cell view of the value for correct escaping on output. |
hasCells | boolean hasCells() | No description in source. |
valueCells | String[] valueCells() | No description in source. |
getName | String getName() | No description in source. |
getValue | String getValue() | No description in source. |
setValue | void setValue(String v) | No description in source. |
setQualified | void setQualified(String prefixPart, String localPart, String v) | Record an explicit prefix/local split (skips cell scanning). |
resolveFromCells | void resolveFromCells(String[] cells) | Decompose qname into prefix/local over a supplied char-cell view (the cells of qname, one glyph per cell). Finds the first ":" cell. Real char-level. |
joinRange | String joinRange(String[] cells, int from, int to) | Rejoin cells in [from,to) into a String (real; mirrors substringCells). |
prefix | String prefix() | Namespace prefix ("" when unprefixed or not yet resolved). |
localName | String localName() | Local name ("" when not yet resolved; equals qname for a bare name). |
isNamespaceDeclaration | boolean isNamespaceDeclaration() | True when this attribute declares a namespace (xmlns or xmlns:prefix). |
sameReference | boolean sameReference(SLXmlAttribute other) | No description in source. |
equals | boolean equals(SLXmlAttribute other) | No description in source. |
sameSubject | boolean sameSubject(SLXmlAttribute other) | Alias, mirroring SLXmlNode.sameSubject (identical to equals here). |
strEq | boolean strEq(String a, String b) | Null-safe, case-sensitive string equality (two nulls are equal). |
SLXmlDocument #sleela 2.5 (lib/xml/SLXmlDocument.sleela)
SLXmlDocument class
Defines SLXmlDocument -- the DOM document. It owns the single root element, carries the XML declaration (version/encoding/standalone), acts as the factory for new nodes (createElement/createTextNode/...), and offers the document-level queries getElementById-style lookup and getElementsByTagName.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
xmlVersion | String xmlVersion = "1.0" | ---- XML declaration + root ---- |
encoding | String encoding = "UTF-8" | No description in source. |
standalone | boolean standalone = true | No description in source. |
root | SLXmlNode root | No description in source. |
writer | SLXmlSerializer writer | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
create | void create() | Build an empty document with a default declaration and a wired serializer. |
getXmlVersion | String getXmlVersion() | No description in source. |
setXmlVersion | void setXmlVersion(String v) | No description in source. |
getEncoding | String getEncoding() | No description in source. |
setEncoding | void setEncoding(String v) | No description in source. |
getStandalone | boolean getStandalone() | No description in source. |
setStandalone | void setStandalone(boolean v) | No description in source. |
createElement | SLXmlNode createElement(String tag) | No description in source. |
createTextNode | SLXmlNode createTextNode(String value) | No description in source. |
createCDataSection | SLXmlNode createCDataSection(String value) | No description in source. |
createComment | SLXmlNode createComment(String value) | No description in source. |
createProcessingInstruction | SLXmlNode createProcessingInstruction(String target, String value) | No description in source. |
setDocumentElement | SLXmlNode setDocumentElement(SLXmlNode element) | Install `element` as the single document element and return it. |
newRoot | SLXmlNode newRoot(String tag) | Create, install, and return a root element named `tag`. |
documentElement | SLXmlNode documentElement() | No description in source. |
hasRoot | boolean hasRoot() | No description in source. |
getElementsByTagName | SLXmlNode getElementsByTagName(String tag) | Every element in the document with tag `tag` (document order), collected into a throwaway element whose children are the matches. "*" matches all. Returns an element node acting as a NodeList; read it with childCount()/ childAt(). Returns an empty collection when there is no root. |
getElementById | SLXmlNode getElementById(String id) | The first element whose "id" attribute equals `id`, or null (DOM-style getElementById; this DOM treats the literal attribute name "id"). |
findById | SLXmlNode findById(SLXmlNode e, String id) | No description in source. |
elementCount | int elementCount() | Total number of element nodes in the document (root included). |
depth | int depth() | Nesting depth of the document element (0 when empty). |
declaration | String declaration() | The XML declaration line (<?xml version="1.0" encoding="UTF-8" ...?>). |
toXml | String toXml() | The whole document as compact well-formed XML (declaration + tree). |
toPrettyXml | String toPrettyXml() | The whole document, pretty-printed (declaration on its own line). |
sameReference | boolean sameReference(SLXmlDocument other) | No description in source. |
equals | boolean equals(SLXmlDocument other) | No description in source. |
sameStructure | boolean sameStructure(SLXmlDocument other) | Alias reading as "the same structure". |
SLXmlNode #sleela 2.5 (lib/xml/SLXmlNode.sleela)
SLXmlNode class
Defines SLXmlNode -- the central DOM node. An element node owns an ordered list of child nodes and a list of attributes; text/CDATA/comment/PI nodes carry character data. This is the mutable tree a document, parser, and serializer all operate on.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
kind | int kind | ---- node identity ---- nodeType: one of the SLXmlNodeType codes (1 element, 3 text, ...). |
nodeName | String nodeName | For an element: the tag name. For leaves: a conventional "#text" etc. |
data | String data | Character data for text/CDATA/comment/PI leaves (unescaped). "" otherwise. |
dataCellView | String[] dataCellView | No description in source. |
dataHasCells | boolean dataHasCells = false | No description in source. |
children | SLXmlNode[] children = new SLXmlNode[0] | No description in source. |
childN | int childN = 0 | No description in source. |
attrs | SLXmlAttribute[] attrs = new SLXmlAttribute[0] | No description in source. |
attrN | int attrN = 0 | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
ensureStores | void ensureStores() | Ensure the backing stores exist (defensive; the field initializers already allocate them, so this is a no-op for a normally `new`-ed node). |
asElement | void asElement(String tag) | Make this an element node named `tag`. |
asText | void asText(String value) | Make this a text node holding `value`. |
asCData | void asCData(String value) | Make this a CDATA section holding `value`. |
asProcessingInstruction | void asProcessingInstruction(String target, String value) | Make this a processing instruction with target `target` and data `value`. |
asComment | void asComment(String value) | Make this a comment holding `value`. |
setDataCells | void setDataCells(String[] cells) | Attach a char-cell view of this node's data so the serializer can escape it. |
hasDataCells | boolean hasDataCells() | No description in source. |
dataCells | String[] dataCells() | No description in source. |
nodeType | int nodeType() | ---- identity accessors ---- |
name | String name() | No description in source. |
nodeValue | String nodeValue() | No description in source. |
setNodeValue | void setNodeValue(String v) | No description in source. |
isElement | boolean isElement() | No description in source. |
isText | boolean isText() | No description in source. |
isCharacterData | boolean isCharacterData() | No description in source. |
appendChild | SLXmlNode appendChild(SLXmlNode child) | Append a child node and return it (DOM appendChild returns the child). Reuses a freed slot when capacity exceeds the live count; else grows. |
childCount | int childCount() | No description in source. |
childAt | SLXmlNode childAt(int index) | The child at `index`, or null when out of range. |
firstChild | SLXmlNode firstChild() | No description in source. |
lastChild | SLXmlNode lastChild() | No description in source. |
removeChild | SLXmlNode removeChild(int index) | Remove the child at `index`, preserving the order of the rest. Returns the removed node, or null when the index is invalid. |
addElement | SLXmlNode addElement(String tag) | Convenience: create, append, and return a child element. |
addText | SLXmlNode addText(String value) | Convenience: append a text node with `value` (emitted verbatim). |
addTextCells | SLXmlNode addTextCells(String value, String[] cells) | Convenience: append a text node whose `cells` are the glyphs of its value, so the serializer escapes & < > correctly. `value` is the rejoined text. |
addComment | SLXmlNode addComment(String value) | Convenience: append a comment node. |
attributeCount | int attributeCount() | No description in source. |
attributeIndex | int attributeIndex(String qn) | Index of the attribute whose qualified name equals `qn`, or -1. |
hasAttribute | boolean hasAttribute(String qn) | No description in source. |
getAttribute | String getAttribute(String qn) | The value of attribute `qn`, or null when it is absent. |
setAttribute | void setAttribute(String qn, String value) | Set attribute `qn` to `value`, replacing an existing one or appending a new. |
setAttributeCells | void setAttributeCells(String qn, String value, String[] cells) | Set attribute `qn` to a value whose `cells` are its glyphs, so the serializer escapes & < > " correctly. `value` is the rejoined text. |
attributeAt | SLXmlAttribute attributeAt(int index) | The attribute object at `index`, or null when out of range. |
removeAttribute | boolean removeAttribute(String qn) | Remove attribute `qn`; return true when one was removed. |
textContent | String textContent() | The concatenated character data of this node and all its descendants, i.e. DOM textContent. Element structure contributes no characters. |
firstElementByTag | SLXmlNode firstElementByTag(String tag) | The first direct child element with tag name `tag`, or null. |
collectByTag | void collectByTag(String tag, SLXmlNode result) | DOM getElementsByTagName: append every descendant element whose tag is `tag` (document order) into the caller-provided result node, which is used purely as an ordered collection via appendChild. "*" matches every element. |
descendantElementCount | int descendantElementCount() | Count descendant elements (not counting this node). |
depth | int depth() | Depth of the deepest element subtree rooted here (a leaf element is 1). |
subjectId | String subjectId() | The "id" attribute of this node ("" when absent or not an element). Used as part of the subject identity of an element. |
sameReference | boolean sameReference(SLXmlNode other) | No description in source. |
sameSubject | boolean sameSubject(SLXmlNode other) | No description in source. |
equals | boolean equals(SLXmlNode other) | No description in source. |
sameStructure | boolean sameStructure(SLXmlNode other) | Convenience alias reading as "the same structure". |
attributesEqual | boolean attributesEqual(SLXmlNode other) | No description in source. |
tieStrength | int tieStrength(SLXmlNode other) | No description in source. |
tieName | String tieName(int strength) | A human word for a tie strength. |
strEq | boolean strEq(String a, String b) | No description in source. |
SLXmlNodeType #sleela 2.5 (lib/xml/SLXmlNodeType.sleela)
SLXmlNodeType class
Defines SLXmlNodeType -- the DOM node-kind registry for the xml family. Mirrors the W3C DOM nodeType constants so a node always reports an honest, catalogued kind.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
ELEMENT | static final int ELEMENT = 1 | ---- the DOM nodeType constants this DOM models ---- |
TEXT | static final int TEXT = 3 | No description in source. |
CDATA | static final int CDATA = 4 | No description in source. |
PI | static final int PI = 7 | No description in source. |
COMMENT | static final int COMMENT = 8 | No description in source. |
DOCUMENT | static final int DOCUMENT = 9 | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
nameOf | String nameOf(int kind) | Human-readable kind name for a nodeType code. |
isKnown | boolean isKnown(int kind) | True for a code this DOM recognizes. |
isContainer | boolean isContainer(int kind) | An element is the only kind that may itself carry attributes and children. |
isCharacterData | boolean isCharacterData(int kind) | Text and CDATA are character-data leaves. |
isLeaf | boolean isLeaf(int kind) | A leaf node never owns element children in this DOM. |
SLXmlParser #sleela 2.5 (lib/xml/SLXmlParser.sleela)
SLXmlParser class
Defines SLXmlParser -- a char-cell text-to-DOM reader for the common XML subset (elements, attributes with double-quoted values, text, comments, and self-closing tags), plus an honest structural well-formedness check. It builds an SLXmlDocument from a char-cell view of the source.
Fields — the named values this unit stores.
| Field | Declaration | What it holds |
|---|---|---|
MAX_DEPTH | static final int MAX_DEPTH = 256 | No description in source. |
openStack | SLXmlNode[] openStack | No description in source. |
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
cellAt | String cellAt(String[] cells, int i) | No description in source. |
isSpaceCell | boolean isSpaceCell(String ch) | No description in source. |
joinRange | String joinRange(String[] cells, int from, int to) | Rejoin cells in [from, to) into a String. |
indexFrom | int indexFrom(String[] cells, int from, String needle) | First index >= from whose cell equals needle, or -1. |
unescapeCells | String unescapeCells(String[] cells, int from, int to) | Unescape the five predefined XML entities in a rejoined text run. Operates cell-wise so "&" / "<" / ">" / """ / "'" become & < > " '. |
entity | String entity(String name) | The replacement for a predefined entity name, or "&name;" left intact. |
isWellFormedCells | boolean isWellFormedCells(String[] cells) | No description in source. |
seekClose | int seekClose(String[] cells, int from) | Index just past the next ">" at/after the "<" at `from` (used to skip a declaration or comment coarsely); returns n when unterminated. |
tagNameFrom | String tagNameFrom(String[] cells, int from, int to) | The tag name within cells [from, to): the run up to the first whitespace. |
parseCells | SLXmlDocument parseCells(String[] cells) | No description in source. |
firstNonSpace | int firstNonSpace(String[] cells, int from, int to) | First non-whitespace cell index in [from, to), or -1 if all whitespace. |
lastNonSpace | int lastNonSpace(String[] cells, int from, int to) | Last non-whitespace cell index in [from, to), or -1 if all whitespace. |
readAttributes | void readAttributes(SLXmlNode el, String[] cells, int from, int to) | No description in source. |
SLXmlSerializer #sleela 2.5 (lib/xml/SLXmlSerializer.sleela)
SLXmlSerializer class
Defines SLXmlSerializer -- renders a DOM tree (SLXmlNode) back to well-formed XML text, with correct character escaping and optional pretty indentation.
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
textCell | String textCell(String ch) | Map one glyph cell to its XML character-data replacement (& < > escaped). |
attrCell | String attrCell(String ch) | Map one glyph cell for an attribute value (adds the double-quote entity). |
escapeTextCells | String escapeTextCells(String[] cells) | Escape element character data given its char-cell view (real). |
escapeAttributeCells | String escapeAttributeCells(String[] cells) | Escape an attribute value given its char-cell view (real). |
indent | String indent(int n) | n levels of two-space indentation. |
attrValue | String attrValue(SLXmlAttribute a) | The escaped form of an attribute's value: its char-cell view when supplied (correctly escaped), else the raw value verbatim (known-safe content). |
textValue | String textValue(SLXmlNode node) | The escaped form of a text/CDATA node's data: its char-cell view when supplied (correctly escaped), else the raw data verbatim. |
openTag | String openTag(SLXmlNode e) | The opening tag (with attributes) for an element node. |
renderNode | String renderNode(SLXmlNode node, int level, boolean pretty) | Serialize `node` and its subtree at indent level `level`, pretty or compact. |
toXml | String toXml(SLXmlNode root) | Compact one-line serialization of a subtree. |
toPrettyXml | String toPrettyXml(SLXmlNode root) | Pretty, indented, multi-line serialization of a subtree. |
xml-dom #sleela 2.5 (lib/xml/xml-dom.sleela)
XmlDom class
Methods — the actions this unit can perform.
| Method | Signature | What it does |
|---|---|---|
buildCatalog | SLXmlDocument buildCatalog() | No description in source. |
nameCells | String[] nameCells() | The glyph cells of "Jack & Jill <xml>" (one per index). The opaque built-in String cannot be sliced in-language, so escapable content is spelled out as cells, exactly as lib/text/SLString prescribes. |
roundTripCells | String[] roundTripCells() | The glyph cells of a tiny document "<doc><p id=\"x1\">hi</p></doc>" used to demonstrate the text-to-DOM round trip over the char-cell parser. |
main | void main() | No description in source. |
demoEquality | void demoEquality() | Demonstrate and verify the three-rung equality ladder on small, standalone trees, plus the reflexive / symmetric / idempotent charge guarantees. |
makeItem | SLXmlNode makeItem(String id, String text) | Build a standalone <item id=.. ><name>text</name></item> subtree for the equality demonstration. Children are bound to typed locals before use. |
nameText | String nameText(SLXmlNode item) | The text of an item's <name> child ("" when absent). |
qualityText | String qualityText(SLXmlNode item) | The text of an item's <quality> child ("" when absent). |