This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch odf13-devel
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 1306cb13ba0f35a72561123a10191c27f58bbb58
Author: Jim Jagielski <[email protected]>
AuthorDate: Fri Oct 30 09:55:29 2026 -0400

    test/odf-validate: validate against the ODF 1.3 schema
---
 test/odf-validate/README.md        | 24 +++++++++++++++++++++---
 test/odf-validate/fetch-schemas.sh |  5 ++++-
 test/odf-validate/make-controls.py | 31 +++++++++++++++++++++++++++++++
 test/odf-validate/selftest.py      | 12 ++++++++++++
 test/odf-validate/validate.py      | 21 ++++++++++++---------
 5 files changed, 80 insertions(+), 13 deletions(-)

diff --git a/test/odf-validate/README.md b/test/odf-validate/README.md
index 1ae32e9757..17433d7ffe 100644
--- a/test/odf-validate/README.md
+++ b/test/odf-validate/README.md
@@ -1,7 +1,7 @@
 # ODF validation harness
 
 This harness has OpenOffice save a corpus of documents as ODF, checks every
-saved package against the OASIS ODF 1.2 and ODF 1.4 RELAX NG schemas with
+saved package against the OASIS ODF 1.2, ODF 1.3 and ODF 1.4 RELAX NG schemas 
with
 jing, and reports the errors grouped by kind. Comparing those reports against
 a baseline shows whether an export change fixed errors or introduced new ones.
 
@@ -43,8 +43,9 @@ The steps:
   - It resumes where it left off, kills a hung office and continues, and
     stops at the first crash.
 - `validate.py` checks content, styles, meta, settings and manifest streams
-  against 1.2 as written, against 1.4 with `office:version` rewritten, and
-  against 1.2 as an extended document (`12x`): `foreign.py` first removes
+  against 1.2 as written, against 1.3 (`13`) and 1.4 (`14`) with
+  `office:version` rewritten, and against 1.2 and 1.3 as extended documents
+  (`12x`, `13x`): `foreign.py` first removes
   foreign elements and attributes as Part 1 §2.2.2 B.1 and §3.17 describe (the
   manifest is left as written). Use `report.py <val.json> <kinds.json> 12x` to
   measure what is wrong apart from foreign content.
@@ -162,6 +163,23 @@ solver into the app copy:
 `roundtrip.py <port> <file> <checks.json>` loads a document and compares UNO
 expressions with expected values; `--capture <out.json>` records them instead.
 
+## Formula evaluation baseline (calcval)
+
+    ./start.sh calcval 2792
+    ./runpy.sh calcval.py 2792 calcval-cases.tsv runs/phase4/baseline.json
+    python3 -I calcval.py --compare runs/phase4/baseline.json 
runs/phase4/new.json
+
+`calcval.py` opens a new Calc document, writes the data area described in the
+header of `calcval-cases.tsv`, and for each case enters the formula in a fresh
+scratch cell (`cell`, `cell@N`) or range (`array:CxR`), recalculates, records
+the result type, `getError()`, `getString()`, `getValue()` and the formula as
+read back, then clears the scratch area. `expected` is the value the ODF 1.3
+Part 4 text requires (`-` records the current behaviour only); the status of
+each case is `match`, `mismatch`, `record` or `exception`. The run prints
+every mismatch, which are the current deviations from ODF 1.3. `--compare`
+lists each case whose recorded result changed (exit 1 if any). RECEIVED and
+BESSELK/BESSELY are Analysis add-ins and are entered by programmatic name.
+
 ## Notes
 
 - AOO has no `-convert-to`; conversion goes over UNO (`convert.py`).
diff --git a/test/odf-validate/fetch-schemas.sh 
b/test/odf-validate/fetch-schemas.sh
index c0d0302eb8..5ef5d27ed5 100755
--- a/test/odf-validate/fetch-schemas.sh
+++ b/test/odf-validate/fetch-schemas.sh
@@ -20,7 +20,7 @@
 #
 #**************************************************************
 
-# usage: fetch-schemas.sh -- download the OASIS ODF 1.2 and 1.4 RELAX NG 
schemas into schema/
+# usage: fetch-schemas.sh -- download the OASIS ODF 1.2, 1.3 and 1.4 RELAX NG 
schemas into schema/
 # They are not committed: they carry OASIS copyright terms.
 source ${0:A:h}/env.sh
 mkdir -p $D/schema
@@ -29,6 +29,9 @@ SUMS=(
   https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-schema.rng 
ca5d2510858c6f922b20cd27dc76d34959c1a976b9dfc6b5caeadbebfc83dbbb
   
https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-manifest-schema.rng
 75f972902bc785c15e51fb4e112e2f1b24e2327829eb54786cf8687ee39c7631
   
https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-dsig-schema.rng 
52fbf196dc11fcaac41ff4b320f005daf419794c2f343a26ecab05778d7e7f6f
+  
https://docs.oasis-open.org/office/OpenDocument/v1.3/os/schemas/OpenDocument-v1.3-schema.rng
 40bad03efdbb02825230d357da0aa6ac679934c5bf56c6281752c0c24d58e4e6
+  
https://docs.oasis-open.org/office/OpenDocument/v1.3/os/schemas/OpenDocument-v1.3-manifest-schema.rng
 8aee71f03484be112af972d622cc9031280c007b0a454ae8815e8e333c9bdd17
+  
https://docs.oasis-open.org/office/OpenDocument/v1.3/os/schemas/OpenDocument-v1.3-dsig-schema.rng
 1760eab7fba2394b6b9d2c77b4ed2187ed01ff8029f8538ba7bff3b834866573
   
https://docs.oasis-open.org/office/OpenDocument/v1.4/os/schemas/OpenDocument-v1.4-schema.rng
 4034ec6be29205d5fc1ee5f42468ac6ef824287b3aba6d9289032af4fafbda7f
   
https://docs.oasis-open.org/office/OpenDocument/v1.4/os/schemas/OpenDocument-v1.4-manifest-schema.rng
 f96e1fe95f4e3609717a307c28e2fe0654c890fe70ea03eb8a53caa20b684782
 )
diff --git a/test/odf-validate/make-controls.py 
b/test/odf-validate/make-controls.py
index 47f2e3de73..3ef816b550 100644
--- a/test/odf-validate/make-controls.py
+++ b/test/odf-validate/make-controls.py
@@ -41,10 +41,28 @@ def mk(name, ver, body, extra=None):
             z.writestr(n, t, compress_type=zipfile.ZIP_DEFLATED)
 
 
+OFFNS = ('xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" '
+         'xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" '
+         'xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; '
+         'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"')
+
+
+def mkdoc(name, ext, mime, streams):
+    """A package whose streams are given whole: {"content.xml": (root element, 
body)}, written with office:version 1.2."""
+    mani = MANI.replace("application/vnd.oasis.opendocument.text", mime)
+    with zipfile.ZipFile(os.path.join(C, name + "." + ext), "w") as z:
+        z.writestr(zipfile.ZipInfo("mimetype"), mime, 
compress_type=zipfile.ZIP_STORED)
+        for n, (root, body) in streams.items():
+            z.writestr(n, '<?xml version="1.0" encoding="UTF-8"?>\n<%s %s 
office:version="1.2">%s</%s>\n' % (root, OFFNS, body, root), 
compress_type=zipfile.ZIP_DEFLATED)
+        z.writestr("META-INF/manifest.xml", mani, 
compress_type=zipfile.ZIP_DEFLATED)
+
+
 os.makedirs(C, exist_ok=True)
 mk("good", "1.2", "<text:p>hi</text:p>")
 mk("bad", "1.2", "<text:bogus/>")
 mk("wrongver", "1.1", "<text:p>hi</text:p>")
+# text:drop-down is new in ODF 1.3 (OFFICE-3881): invalid in 1.2, valid in 1.3 
and 1.4
+mk("new13", "1.2", '<text:p><text:drop-down text:name="d"><text:label 
text:value="a"/></text:drop-down></text:p>')
 # ODF 1.2 Part 1 2.2.1 B.4: an embedded object whose content.xml is MathML
 mk("mathobj", "1.2", "<text:p>hi</text:p>", {"Object 1/content.xml": MATH})
 # ODF 1.2 Part 1 2.2.1 D.1/D.2: checked by idcheck.py, not by the schema
@@ -57,3 +75,16 @@ mk("badns", "1.2", "<text:p><zz:span/></text:p>")
 mk("badsig", "1.2", "<text:p>hi</text:p>", {"META-INF/documentsignatures.xml": 
'<a><b xml:id="x"/><b xml:id="x"/></a>'})
 # Part 1 2.2.2 B.1: valid as an extended document only (foreign attribute, 
foreign element in a paragraph, foreign element elsewhere)
 mk("extforeign", "1.2", '<text:p xmlns:foo="urn:foo" 
foo:x="1">a<foo:y>b</foo:y>c</text:p><foo:w 
xmlns:foo="urn:foo">z<text:p>q</text:p></foo:w>')
+TEXT = "application/vnd.oasis.opendocument.text"
+# meta:creator-initials in office:annotation is new in ODF 1.3; baseinit is 
the same note without it
+ANN = 
'<office:body><office:text><text:p><office:annotation><dc:creator>A</dc:creator>%s<text:p>n</text:p></office:annotation>x</text:p></office:text></office:body>'
+for n, ini in (("baseinit", ""), ("newinit", 
"<meta:creator-initials>AB</meta:creator-initials>")):
+    mkdoc(n, "odt", TEXT, {"content.xml": ("office:document-content", ANN % 
ini)})
+# chart:coordinate-region (inner plot position) is new in 1.3; baseregion is 
the same chart without it
+CHART = "application/vnd.oasis.opendocument.chart"
+for n, region in (("baseregion", ""), ("newregion", '<chart:coordinate-region 
svg:x="1cm" svg:y="1cm" svg:width="5cm" svg:height="4cm"/>')):
+    mkdoc(n, "odc", CHART, {"content.xml": ("office:document-content", 
'<office:body><office:chart><chart:chart 
chart:class="chart:bar"><chart:plot-area>%s</chart:plot-area></chart:chart></office:chart></office:body>'
 % region)})
+# 1.3 makes style:scale-to, style:scale-to-pages and the pair 
scale-to-X/scale-to-Y mutually exclusive (OFFICE-3857); 1.2 has no scale-to-X/Y
+for n, attrs in (("scaleone", 'style:scale-to="80%"'), ("scalexy", 
'style:scale-to-X="2" style:scale-to-Y="3"'), ("scaleboth", 
'style:scale-to-X="2" style:scale-to-Y="3" style:scale-to="80%"')):
+    mkdoc(n, "odt", TEXT, {"content.xml": ("office:document-content", 
"<office:body><office:text><text:p>hi</text:p></office:text></office:body>"),
+                          "styles.xml": ("office:document-styles", 
'<office:automatic-styles><style:page-layout 
style:name="pm1"><style:page-layout-properties 
%s/></style:page-layout></office:automatic-styles>' % attrs)})
diff --git a/test/odf-validate/selftest.py b/test/odf-validate/selftest.py
index 77443f0f37..007ef02374 100644
--- a/test/odf-validate/selftest.py
+++ b/test/odf-validate/selftest.py
@@ -32,6 +32,18 @@ checks = {
     "good.odt clean in 1.2 and 1.4": not errs("12", "good.odt") and not 
errs("14", "good.odt"),
     "bad.odt flags text:bogus in 1.2 and 1.4": all(any('"text:bogus"' in m for 
m in errs(v, "bad.odt")) for v in ("12", "14")),
     "wrongver.odt flags office:version in 1.2 and 1.4": 
all(any('office:version' in m for m in errs(v, "wrongver.odt")) for v in ("12", 
"14")),
+    "13: good.odt clean in 1.3 and 1.3 extended": not errs("13", "good.odt") 
and not errs("13x", "good.odt"),
+    "13: bad.odt flags text:bogus in 1.3 and 1.3 extended": 
all(any('"text:bogus"' in m for m in errs(v, "bad.odt")) for v in ("13", 
"13x")),
+    "13: wrongver.odt flags office:version in 1.3 and 1.3 extended": 
all(any("office:version" in m for m in errs(v, "wrongver.odt")) for v in ("13", 
"13x")),
+    "13: new13.odt (text:drop-down) invalid in 1.2, valid in 1.3 and 1.3 
extended": bool(errs("12", "new13.odt")) and not errs("13", "new13.odt") and 
not errs("13x", "new13.odt"),
+    "13: extforeign.odt invalid as written, valid once foreign content is 
removed": bool(errs("13", "extforeign.odt")) and not errs("13x", 
"extforeign.odt"),
+    "13: meta:creator-initials invalid in 1.2, valid in 1.3 and 1.3 extended; 
the note without it is clean in all": any('"meta:creator-initials"' in m for m 
in errs("12", "newinit.odt"))
+        and not errs("13", "newinit.odt") and not errs("13x", "newinit.odt") 
and not any(errs(v, "baseinit.odt") for v in ("12", "13", "13x")),
+    "13: chart:coordinate-region invalid in 1.2, valid in 1.3 and 1.3 
extended; the chart without it is clean in all": 
any('"chart:coordinate-region"' in m for m in errs("12", "newregion.odc"))
+        and not errs("13", "newregion.odc") and not errs("13x", 
"newregion.odc") and not any(errs(v, "baseregion.odc") for v in ("12", "13", 
"13x")),
+    "13: style:scale-to-X/Y together with style:scale-to invalid in 1.3 and 
1.3 extended": all(any('"style:scale-to"' in m for m in errs(v, 
"scaleboth.odt")) for v in ("13", "13x")),
+    "13: style:scale-to-X/Y alone and style:scale-to alone valid in 1.3 and 
1.3 extended; X/Y invalid in 1.2": not any(errs(v, p) for v in ("13", "13x") 
for p in ("scalexy.odt", "scaleone.odt"))
+        and any('"style:scale-to-X"' in m for m in errs("12", "scalexy.odt")) 
and not errs("12", "scaleone.odt"),
     "mathobj.odt MathML object skipped": d["mathml_skipped"] == 
["mathobj.odt/Object 1/content.xml"] and not errs("12", "mathobj.odt"),
     "no unparsed jing output": not any(e[0] == "?" for v in d["errors"] for e 
in d["errors"][v]),
 }
diff --git a/test/odf-validate/validate.py b/test/odf-validate/validate.py
index d4bb275156..89f6067add 100644
--- a/test/odf-validate/validate.py
+++ b/test/odf-validate/validate.py
@@ -20,16 +20,19 @@
 #**************************************************************
 
 # usage: validate.py <outdir> <val.json>
-# Validates every package in <outdir> against ODF 1.2 as written, against ODF 
1.4 with the version rewritten ("14"),
-# and against ODF 1.2 after removing foreign elements and attributes ("12x", 
Part 1 2.2.2 B.1; manifest left as written).
+# Validates every package in <outdir> against ODF 1.2 as written, against ODF 
1.3 and 1.4 with the version rewritten
+# ("13", "14"), and against ODF 1.2 and 1.3 after removing foreign elements 
and attributes ("12x", "13x"; Part 1 2.2.2 B.1;
+# manifest left as written apart from the version).
 import sys, os, re, zipfile, subprocess, json, shutil, importlib.util
 
 D = os.path.dirname(os.path.abspath(__file__))
 JING = ["java", "-jar", os.environ.get("ODFV_JING", 
"/Applications/XMLauthor/lib/jing.jar"), "-i"]
 SCH = {"12": (D + "/schema/OpenDocument-v1.2-os-schema.rng", D + 
"/schema/OpenDocument-v1.2-os-manifest-schema.rng"),
+       "13": (D + "/schema/OpenDocument-v1.3-schema.rng", D + 
"/schema/OpenDocument-v1.3-manifest-schema.rng"),
        "14": (D + "/schema/OpenDocument-v1.4-schema.rng", D + 
"/schema/OpenDocument-v1.4-manifest-schema.rng")}
 SCH["12x"] = SCH["12"]
-VERSIONS = ("12", "14", "12x")
+SCH["13x"] = SCH["13"]
+VERSIONS = ("12", "14", "12x", "13", "13x")
 _spec = importlib.util.spec_from_file_location("foreign", D + "/foreign.py")
 foreign = importlib.util.module_from_spec(_spec)
 _spec.loader.exec_module(foreign)
@@ -50,7 +53,7 @@ def main():
         sys.exit("validate.py: <val.json> must live under " + os.path.join(D, 
"runs"))
     shutil.rmtree(work, ignore_errors=True)
     files = {v: ([], []) for v in VERSIONS}
-    mixed = foreign.mixed_elements(SCH["12"][0])
+    mixed = {"12x": foreign.mixed_elements(SCH["12"][0]), "13x": 
foreign.mixed_elements(SCH["13"][0])}
     skipped, bad_zip = [], []
     pkgs = sorted(p for p in os.listdir(outdir) if not p.startswith("."))
     for pkg in pkgs:
@@ -67,11 +70,11 @@ def main():
                 skipped.append(pkg + "/" + name); continue
             for v in VERSIONS:
                 t = text
-                if v == "14":
+                if v in ("12x", "13x") and not is_mani:
+                    t = foreign.strip_foreign(t, mixed[v])
+                if v in ("13", "13x", "14"):
                     attr = "manifest:version" if is_mani else "office:version"
-                    t = re.sub(attr + '="1.2"', attr + '="1.4"', t, count=1)
-                elif v == "12x" and not is_mani:
-                    t = foreign.strip_foreign(t, mixed)
+                    t = re.sub(attr + '="1.2"', attr + '="1.%s"' % v[1], t, 
count=1)
                 p = os.path.join(work, v, pkg, name)
                 os.makedirs(os.path.dirname(p), exist_ok=True)
                 open(p, "w", encoding="utf-8").write(t)
@@ -97,7 +100,7 @@ def main():
     json.dump({"packages": pkgs, "bad_zip": bad_zip, "mathml_skipped": skipped,
                "nfiles": len(files["12"][0]) + len(files["12"][1]), "errors": 
errors}, open(valjson, "w"))
     for v in VERSIONS:
-        print(f"ODF {v[0]}.{v[1]}{' extended, foreign content removed' if v == 
'12x' else ''}: {len(errors[v])} errors in {len({e[0].split('/')[0] for e in 
errors[v]})} of {len(pkgs)} packages")
+        print(f"ODF {v[0]}.{v[1]}{' extended, foreign content removed' if 
v.endswith('x') else ''}: {len(errors[v])} errors in {len({e[0].split('/')[0] 
for e in errors[v]})} of {len(pkgs)} packages")
     print(f"files validated: {len(files['12'][0]) + len(files['12'][1])}, 
MathML skipped: {len(skipped)}, bad zips: {bad_zip}")
     unparsed = [e for v in errors for e in errors[v] if e[0] == "?"]
     if unparsed:

Reply via email to