Home /Modules/xml/SLXmlAspect.sleela

SLXmlAspect.sleela

lib/xml/SLXmlAspect.sleela · 134 line(s) · sleela

<< lib/xml/SLXmlAspect.sleela
   SLeeLa Standard Library Definition.
   Definition: 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. >>
#sleela 2.5
material;
< Family: xml. The "quality of the aspect" register. An XML processor is judged >
< by a small, well-known set of aspects, each defined by a real W3C/ISO item. >
< This executive-grade class names each aspect, states the governing item, and >
< reports an honest quality rating (0..10) for how fully THIS library addresses >
< it. Values are faithful to the real standards and to this library's actual >
< capability -- an unimplemented aspect reports a low, honest score, never an >
< inflated one. >
<  >
< Aspect ids: >
<   0 WELL_FORMED     syntactic well-formedness (XML 1.0 section 2) >
<   1 DOM             the DOM tree model and Node/Element interface >
<   2 NAMESPACES      prefix/local resolution (Namespaces in XML 1.0) >
<   3 SERIALIZATION   DOM-to-text with correct escaping (XML 1.0 section 2.4) >
<   4 VALIDITY        DTD/schema validity (XML 1.0 section 2 / XSD) >
class SLXmlAspect {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs. This is an
     executive-grade class: it carries the full record -- identity plus legality
     (metaNationalSchedule), fiduciary (copyright/trademark/corporation), and
     probation-of-intent (metaOrigin). Values are faithful to the subject's real
     origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 7925;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-28";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < The XML standards are stewarded by the World Wide Web Consortium (W3C), an >
  < international consortium; its host institutions include MIT in the United >
  < States, ERCIM in Europe, Keio University in Japan, and Beihang in China. >
  < The scope is therefore International. >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-28";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: the governing, citable instrument for the family. >
  String metaNationalSchedule = "W3C REC-xml-20081126 (XML 1.0, Fifth Edition)";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  < ---- the catalogued aspects ---- >
  static final int WELL_FORMED   = 0;
  static final int DOM           = 1;
  static final int NAMESPACES    = 2;
  static final int SERIALIZATION = 3;
  static final int VALIDITY      = 4;

  int count() { return 5; }

  < The human name of an aspect id. >
  String nameOf(int aspect) {
    if (aspect == 0) { return "well-formedness"; }
    if (aspect == 1) { return "DOM tree model"; }
    if (aspect == 2) { return "namespace-awareness"; }
    if (aspect == 3) { return "serialization"; }
    if (aspect == 4) { return "validity"; }
    return "unknown-aspect";
  }

  < The governing standards item for an aspect (a real, citable instrument). >
  String itemOf(int aspect) {
    if (aspect == 0) { return "W3C REC-xml section 2 (well-formed documents)"; }
    if (aspect == 1) { return "W3C DOM Level 1 (Node/Element interface)"; }
    if (aspect == 2) { return "W3C REC-xml-names (Namespaces in XML 1.0)"; }
    if (aspect == 3) { return "W3C REC-xml section 2.4 (character-data escaping)"; }
    if (aspect == 4) { return "W3C REC-xml section 2 / XSD (validity)"; }
    return "none";
  }

  < 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. >
  int qualityOf(int aspect) {
    if (aspect == 0) { return 8; }
    if (aspect == 1) { return 9; }
    if (aspect == 2) { return 7; }
    if (aspect == 3) { return 9; }
    if (aspect == 4) { return 1; }
    return 0;
  }

  < A one-word quality band for a score. >
  String bandOf(int score) {
    if (score >= 9) { return "excellent"; }
    if (score >= 7) { return "strong"; }
    if (score >= 4) { return "partial"; }
    if (score >= 1) { return "minimal"; }
    return "absent";
  }

  < True when this library implements the aspect to at least a usable degree. >
  boolean isAddressed(int aspect) { return qualityOf(aspect) >= 4; }

  < The mean quality across all catalogued aspects, scaled x10 to stay integer >
  < (e.g. 68 means an average quality of 6.8 / 10). >
  int overallQualityX10() {
    int sum = 0;
    for (int i = 0; i < count(); i = i + 1) { sum = sum + qualityOf(i); }
    return (sum * 10) / count();
  }
}