openmath 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +5 -3
- data/data/portable-bindings.json +1 -1
- data/lib/openmath/cd/collection.rb +10 -7
- data/lib/openmath/cd/group_collection.rb +6 -8
- data/lib/openmath/content_mathml.rb +11 -16
- data/lib/openmath/foreign.rb +19 -14
- data/lib/openmath/validation.rb +7 -7
- data/lib/openmath/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6cc7ce829d542b70b1f671385a98641abc3cd0bc2a5fc4f2dda2a2170bca5188
|
|
4
|
+
data.tar.gz: 9f2003d8da3f35832953b9d374232c335cfe3efac00e620eac2dfd77b5d6a791
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd47d53f6c69f53cae532bca803180b92ec9748de3f53e8ee523814ec8264eff78bf2d80d0a0f2e94ae832635253a97f0222b8a3ffa86615d689d3b2db47d4c5
|
|
7
|
+
data.tar.gz: 562d77cbb5960b38c5ef2db7113e39fa4c21fc5050862bbb3c991835282b9488222cb8b198e8f56d0f5ace0145639843cd369a3921e0bcdf2f8f642ae5208196
|
data/README.adoc
CHANGED
|
@@ -16,7 +16,7 @@ OpenMath/OMSVN). Namespaced documents parse in both the unprefixed and the
|
|
|
16
16
|
|
|
17
17
|
* **Validation ships**: `Openmath.valid?` / `validate!` check any document
|
|
18
18
|
against its version's vendored RelaxNG schema (OpenMath 2 and the OM3
|
|
19
|
-
draft) through
|
|
19
|
+
draft) through leptris; violations refuse with typed errors.
|
|
20
20
|
* **OpenMath 3**: the versioned hierarchy (`Openmath::V3`) parses and
|
|
21
21
|
round-trips the same object grammar under `Openmath.parse(xml, version: 3)`.
|
|
22
22
|
* **Content dictionaries**: the CD document model, the collection loader,
|
|
@@ -69,8 +69,10 @@ OpenMath/OMSVN). Namespaced documents parse in both the unprefixed and the
|
|
|
69
69
|
|
|
70
70
|
Known limitations (tracked in the issues):
|
|
71
71
|
|
|
72
|
-
*
|
|
73
|
-
|
|
72
|
+
* Validation rides the leptris RelaxNG engine; two engine gaps remain
|
|
73
|
+
tracked upstream (attribute-choice exclusivity leptris#2079, base64Binary
|
|
74
|
+
typing leptris#2080) and the OM3 draft path waits on the combine fix
|
|
75
|
+
(leptris#1709 family).
|
|
74
76
|
|
|
75
77
|
== Usage
|
|
76
78
|
|
data/data/portable-bindings.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":[{"arity":[1,1],"cd":"arith1","name":"abs","operation":"abs"},{"arity":[2,2],"cd":"arith1","name":"divided_by","operation":"divided_by"},{"arity":[1,null],"cd":"arith1","name":"max","operation":"max"},{"arity":[1,null],"cd":"arith1","name":"min","operation":"min"},{"arity":[2,2],"cd":"arith1","name":"minus","operation":"minus"},{"arity":[1,null],"cd":"arith1","name":"plus","operation":"plus"},{"arity":[2,2],"cd":"arith1","name":"power","operation":"power"},{"arity":[2,2],"cd":"arith1","name":"product","operation":"product"},{"arity":[2,2],"cd":"arith1","name":"root","operation":"root"},{"arity":[2,2],"cd":"arith1","name":"sum","operation":"sum"},{"arity":[1,null],"cd":"arith1","name":"times","operation":"times"},{"arity":[1,1],"cd":"arith1","name":"unary_minus","operation":"unary_minus"},{"arity":[1,1],"cd":"integer1","name":"factorial","operation":"factorial"},{"arity":[2,2],"cd":"integer1","name":"quotient","operation":"quotient"},{"arity":[2,2],"cd":"integer1","name":"remainder","operation":"remainder"},{"arity":[2,2],"cd":"interval1","name":"interval","operation":"interval"},{"arity":[2,2],"cd":"interval1","name":"interval_co","operation":"interval_co"},{"arity":[2,2],"cd":"interval1","name":"interval_oc","operation":"interval_oc"},{"arity":[2,2],"cd":"interval1","name":"interval_oo","operation":"interval_oo"},{"arity":[1,1],"cd":"linalg1","name":"transpose","operation":"transpose"},{"arity":[2,2],"cd":"linalg1","name":"vector_product","operation":"vector_product"},{"arity":[1,null],"cd":"linalg2","name":"matrix","operation":"matrix"},{"arity":[0,null],"cd":"linalg2","name":"matrixrow","operation":"matrixrow"},{"arity":[1,1],"cd":"linalg3","name":"determinant","operation":"determinant"},{"arity":[0,null],"cd":"list1","name":"list","operation":"list"},{"arity":[2,2],"cd":"list1","name":"map","operation":"map"},{"arity":[1,null],"cd":"logic1","name":"and","operation":"and"},{"arity":[2,2],"cd":"logic1","name":"implies","operation":"implies"},{"arity":[1,1],"cd":"logic1","name":"not","operation":"not"},{"arity":[1,null],"cd":"logic1","name":"or","operation":"or"},{"arity":[2,null],"cd":"logic1","name":"xor","operation":"xor"},{"arity":[2,2],"cd":"nums1","name":"based_integer","operation":"based_integer"},{"arity":[1,1],"cd":"nums1","name":"integer","operation":"identity"},{"arity":[2,2],"cd":"nums1","name":"rational","operation":"rational"},{"arity":[3,5],"cd":"pmquant","name":"ucov","operation":"ucov"},{"arity":[3,5],"cd":"pmquant","name":"ucov","operation":"ucov"},{"arity":[3,4],"cd":"pmquant","name":"uexp","operation":"uexp"},{"arity":[3,4],"cd":"pmquant","name":"uexp","operation":"uexp"},{"arity":[2,2],"cd":"pmquant","name":"ustd","operation":"ustd"},{"arity":[2,2],"cd":"pmquant","name":"ustd","operation":"ustd"},{"arity":[1,1],"cd":"pmquant","name":"value","operation":"value"},{"arity":[1,1],"cd":"pmquant","name":"value","operation":"value"},{"arity":[2,2],"cd":"relation1","name":"approx","operation":"approx"},{"arity":[2,null],"cd":"relation1","name":"eq","operation":"eq"},{"arity":[2,null],"cd":"relation1","name":"geq","operation":"geq"},{"arity":[2,null],"cd":"relation1","name":"gt","operation":"gt"},{"arity":[2,null],"cd":"relation1","name":"leq","operation":"leq"},{"arity":[2,null],"cd":"relation1","name":"lt","operation":"lt"},{"arity":[2,2],"cd":"relation1","name":"neq","operation":"neq"},{"arity":[1,1],"cd":"rounding1","name":"ceiling","operation":"ceiling"},{"arity":[1,1],"cd":"rounding1","name":"floor","operation":"floor"},{"arity":[1,1],"cd":"rounding1","name":"round","operation":"round"},{"arity":[2,2],"cd":"set1","name":"in","operation":"in"},{"arity":[0,null],"cd":"set1","name":"set","operation":"set"},{"arity":[1,1],"cd":"set1","name":"size","operation":"size"},{"arity":[2,2],"cd":"set1","name":"suchthat","operation":"suchthat"}],"generator":"openmath-ruby 0.1.1","schema":"openmath-portable-bindings/1","table_checksum":"3f9c4df3303c5fe403f3a27e9e770f1842e99c5222a72e619c63b6f883b2e221","vectors":[{"expected":{"value":42},"id":"nums1-integer-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"integer\"/><OMI>42</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/3"},"id":"nums1-rational-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>3</OMI><OMI>9</OMI></OMA></OMOBJ>"},{"expected":{"value":431},"id":"nums1-based-integer-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"based_integer\"/><OMI>16</OMI><OMSTR>1af</OMSTR></OMA></OMOBJ>"},{"id":"nums1-based-integer-2","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"based_integer\"/><OMI>1</OMI><OMSTR>1</OMSTR></OMA></OMOBJ>"},{"expected":{"value":2},"id":"arith1-plus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":6},"id":"arith1-times-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"times\"/><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":-2},"id":"arith1-minus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"minus\"/><OMI>7</OMI><OMI>9</OMI></OMA></OMOBJ>"},{"expected":{"value":-5},"id":"arith1-unary-minus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"unary_minus\"/><OMI>5</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/4"},"id":"arith1-divided-by-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI><OMI>4</OMI></OMA></OMOBJ>"},{"id":"arith1-divided-by-2","refusal":{"error":"ZeroDivisionError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI><OMI>0</OMI></OMA></OMOBJ>"},{"expected":{"value":1024},"id":"arith1-power-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"power\"/><OMI>2</OMI><OMI>10</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/4"},"id":"arith1-power-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"power\"/><OMI>2</OMI><OMI>-2</OMI></OMA></OMOBJ>"},{"expected":{"value":2},"id":"arith1-root-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"root\"/><OMI>4</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":"1.4142135623730951"},"id":"arith1-root-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"root\"/><OMI>2</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"arith1-abs-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"abs\"/><OMI>-3</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"arith1-max-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"max\"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":1},"id":"arith1-min-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"min\"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":"5/1"},"id":"arith1-sum-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"sum\"/><OMA><OMS cd=\"interval1\" name=\"interval\"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMV name=\"x\"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>"},{"expected":{"value":384},"id":"arith1-product-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"product\"/><OMA><OMS cd=\"interval1\" name=\"interval\"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"times\"/><OMV name=\"x\"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>"},{"expected":{"value":true},"id":"relation1-eq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"eq\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-neq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"neq\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":true},"id":"relation1-lt-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"lt\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-geq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"geq\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-approx-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"approx\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"logic1-and-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"logic1\" name=\"and\"/><OMV name=\"a\"/><OMV name=\"b\"/></OMA></OMOBJ>","variables":{"a":true,"b":false}},{"expected":{"value":true},"id":"logic1-implies-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"logic1\" name=\"implies\"/><OMV name=\"a\"/><OMV name=\"b\"/></OMA></OMOBJ>","variables":{"a":false,"b":false}},{"expected":{"value":120},"id":"integer1-factorial-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"factorial\"/><OMI>5</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"integer1-quotient-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"quotient\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":1},"id":"integer1-remainder-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"remainder\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"rounding1-floor-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"rounding1\" name=\"floor\"/><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":4},"id":"rounding1-ceiling-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"rounding1\" name=\"ceiling\"/><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":"[1, 2, 3]"},"id":"list1-list-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":"[1, 2]"},"id":"set1-set-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"set\"/><OMI>1</OMI><OMI>2</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":true},"id":"set1-in-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>2</OMI><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":3},"id":"set1-size-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"size\"/><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":true},"id":"interval1-in-oc-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>3</OMI><OMA><OMS cd=\"interval1\" name=\"interval_oc\"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":false},"id":"interval1-in-oc-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>1</OMI><OMA><OMS cd=\"interval1\" name=\"interval_oc\"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":-2},"id":"linalg3-determinant-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg3\" name=\"determinant\"/><OMA><OMS cd=\"linalg2\" name=\"matrix\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>2</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>3</OMI><OMI>4</OMI></OMA></OMA></OMA></OMOBJ>"},{"expected":{"value":"[0, 0, 1]"},"id":"linalg1-vector-product-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg1\" name=\"vector_product\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>0</OMI><OMI>1</OMI><OMI>0</OMI></OMA></OMA></OMOBJ>"},{"id":"linalg1-vector-product-2","refusal":{"error":"DimensionMismatchError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg1\" name=\"vector_product\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>0</OMI><OMI>0</OMI><OMI>0</OMI><OMI>1</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":3},"id":"fns1-lambda-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMV name=\"x\"/><OMI>1</OMI></OMA></OMBIND><OMI>2</OMI></OMA></OMOBJ>"},{"id":"lambda-arity-1","refusal":{"error":"ArityError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMV name=\"x\"/><OMV name=\"y\"/></OMA></OMBIND><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":12},"id":"omr-resolution-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMI id=\"t\">6</OMI><OMR href=\"#t\"/></OMA></OMOBJ>"},{"id":"omr-cycle-1","refusal":{"error":"RecursionError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA id=\"me\"><OMR href=\"#me\"/></OMA></OMOBJ>"},{"id":"refusal-unbound-1","refusal":{"error":"UnboundSymbolError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"mycd\" name=\"f\"/><OMI>1</OMI></OMA></OMOBJ>"},{"id":"refusal-arity-1","refusal":{"error":"ArityError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI></OMA></OMOBJ>"},{"id":"refusal-domain-1","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMSTR>x</OMSTR></OMA></OMOBJ>"},{"expected":{"class":"Openmath::Evaluation::Uncertain","fields":{"category":"standard","value":"10.3"}},"id":"pmquant-ustd-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"ustd\"/><OMF dec=\"10.3\"/><OMF dec=\"0.2\"/></OMA></OMOBJ>"},{"expected":{"value":"10.3"},"id":"pmquant-value-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"value\"/><OMA><OMS cd=\"pmquant\" name=\"ustd\"/><OMF dec=\"10.3\"/><OMF dec=\"0.2\"/></OMA></OMA></OMOBJ>"},{"id":"pmquant-factor-1","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"uexp\"/><OMF dec=\"1\"/><OMF dec=\"1\"/><OMF dec=\"0\"/></OMA></OMOBJ>"}]}
|
|
1
|
+
{"bindings":[{"arity":[1,1],"cd":"arith1","name":"abs","operation":"abs"},{"arity":[2,2],"cd":"arith1","name":"divided_by","operation":"divided_by"},{"arity":[1,null],"cd":"arith1","name":"max","operation":"max"},{"arity":[1,null],"cd":"arith1","name":"min","operation":"min"},{"arity":[2,2],"cd":"arith1","name":"minus","operation":"minus"},{"arity":[1,null],"cd":"arith1","name":"plus","operation":"plus"},{"arity":[2,2],"cd":"arith1","name":"power","operation":"power"},{"arity":[2,2],"cd":"arith1","name":"product","operation":"product"},{"arity":[2,2],"cd":"arith1","name":"root","operation":"root"},{"arity":[2,2],"cd":"arith1","name":"sum","operation":"sum"},{"arity":[1,null],"cd":"arith1","name":"times","operation":"times"},{"arity":[1,1],"cd":"arith1","name":"unary_minus","operation":"unary_minus"},{"arity":[1,1],"cd":"integer1","name":"factorial","operation":"factorial"},{"arity":[2,2],"cd":"integer1","name":"quotient","operation":"quotient"},{"arity":[2,2],"cd":"integer1","name":"remainder","operation":"remainder"},{"arity":[2,2],"cd":"interval1","name":"interval","operation":"interval"},{"arity":[2,2],"cd":"interval1","name":"interval_co","operation":"interval_co"},{"arity":[2,2],"cd":"interval1","name":"interval_oc","operation":"interval_oc"},{"arity":[2,2],"cd":"interval1","name":"interval_oo","operation":"interval_oo"},{"arity":[1,1],"cd":"linalg1","name":"transpose","operation":"transpose"},{"arity":[2,2],"cd":"linalg1","name":"vector_product","operation":"vector_product"},{"arity":[1,null],"cd":"linalg2","name":"matrix","operation":"matrix"},{"arity":[0,null],"cd":"linalg2","name":"matrixrow","operation":"matrixrow"},{"arity":[1,1],"cd":"linalg3","name":"determinant","operation":"determinant"},{"arity":[0,null],"cd":"list1","name":"list","operation":"list"},{"arity":[2,2],"cd":"list1","name":"map","operation":"map"},{"arity":[1,null],"cd":"logic1","name":"and","operation":"and"},{"arity":[2,2],"cd":"logic1","name":"implies","operation":"implies"},{"arity":[1,1],"cd":"logic1","name":"not","operation":"not"},{"arity":[1,null],"cd":"logic1","name":"or","operation":"or"},{"arity":[2,null],"cd":"logic1","name":"xor","operation":"xor"},{"arity":[2,2],"cd":"nums1","name":"based_integer","operation":"based_integer"},{"arity":[1,1],"cd":"nums1","name":"integer","operation":"identity"},{"arity":[2,2],"cd":"nums1","name":"rational","operation":"rational"},{"arity":[3,5],"cd":"pmquant","name":"ucov","operation":"ucov"},{"arity":[3,5],"cd":"pmquant","name":"ucov","operation":"ucov"},{"arity":[3,4],"cd":"pmquant","name":"uexp","operation":"uexp"},{"arity":[3,4],"cd":"pmquant","name":"uexp","operation":"uexp"},{"arity":[2,2],"cd":"pmquant","name":"ustd","operation":"ustd"},{"arity":[2,2],"cd":"pmquant","name":"ustd","operation":"ustd"},{"arity":[1,1],"cd":"pmquant","name":"value","operation":"value"},{"arity":[1,1],"cd":"pmquant","name":"value","operation":"value"},{"arity":[2,2],"cd":"relation1","name":"approx","operation":"approx"},{"arity":[2,null],"cd":"relation1","name":"eq","operation":"eq"},{"arity":[2,null],"cd":"relation1","name":"geq","operation":"geq"},{"arity":[2,null],"cd":"relation1","name":"gt","operation":"gt"},{"arity":[2,null],"cd":"relation1","name":"leq","operation":"leq"},{"arity":[2,null],"cd":"relation1","name":"lt","operation":"lt"},{"arity":[2,2],"cd":"relation1","name":"neq","operation":"neq"},{"arity":[1,1],"cd":"rounding1","name":"ceiling","operation":"ceiling"},{"arity":[1,1],"cd":"rounding1","name":"floor","operation":"floor"},{"arity":[1,1],"cd":"rounding1","name":"round","operation":"round"},{"arity":[2,2],"cd":"set1","name":"in","operation":"in"},{"arity":[0,null],"cd":"set1","name":"set","operation":"set"},{"arity":[1,1],"cd":"set1","name":"size","operation":"size"},{"arity":[2,2],"cd":"set1","name":"suchthat","operation":"suchthat"}],"generator":"openmath-ruby 0.2.1","schema":"openmath-portable-bindings/1","table_checksum":"3f9c4df3303c5fe403f3a27e9e770f1842e99c5222a72e619c63b6f883b2e221","vectors":[{"expected":{"value":42},"id":"nums1-integer-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"integer\"/><OMI>42</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/3"},"id":"nums1-rational-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>3</OMI><OMI>9</OMI></OMA></OMOBJ>"},{"expected":{"value":431},"id":"nums1-based-integer-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"based_integer\"/><OMI>16</OMI><OMSTR>1af</OMSTR></OMA></OMOBJ>"},{"id":"nums1-based-integer-2","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"based_integer\"/><OMI>1</OMI><OMSTR>1</OMSTR></OMA></OMOBJ>"},{"expected":{"value":2},"id":"arith1-plus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":6},"id":"arith1-times-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"times\"/><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":-2},"id":"arith1-minus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"minus\"/><OMI>7</OMI><OMI>9</OMI></OMA></OMOBJ>"},{"expected":{"value":-5},"id":"arith1-unary-minus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"unary_minus\"/><OMI>5</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/4"},"id":"arith1-divided-by-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI><OMI>4</OMI></OMA></OMOBJ>"},{"id":"arith1-divided-by-2","refusal":{"error":"ZeroDivisionError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI><OMI>0</OMI></OMA></OMOBJ>"},{"expected":{"value":1024},"id":"arith1-power-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"power\"/><OMI>2</OMI><OMI>10</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/4"},"id":"arith1-power-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"power\"/><OMI>2</OMI><OMI>-2</OMI></OMA></OMOBJ>"},{"expected":{"value":2},"id":"arith1-root-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"root\"/><OMI>4</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":"1.4142135623730951"},"id":"arith1-root-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"root\"/><OMI>2</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"arith1-abs-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"abs\"/><OMI>-3</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"arith1-max-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"max\"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":1},"id":"arith1-min-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"min\"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":"5/1"},"id":"arith1-sum-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"sum\"/><OMA><OMS cd=\"interval1\" name=\"interval\"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMV name=\"x\"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>"},{"expected":{"value":384},"id":"arith1-product-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"product\"/><OMA><OMS cd=\"interval1\" name=\"interval\"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"times\"/><OMV name=\"x\"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>"},{"expected":{"value":true},"id":"relation1-eq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"eq\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-neq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"neq\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":true},"id":"relation1-lt-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"lt\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-geq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"geq\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-approx-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"approx\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"logic1-and-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"logic1\" name=\"and\"/><OMV name=\"a\"/><OMV name=\"b\"/></OMA></OMOBJ>","variables":{"a":true,"b":false}},{"expected":{"value":true},"id":"logic1-implies-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"logic1\" name=\"implies\"/><OMV name=\"a\"/><OMV name=\"b\"/></OMA></OMOBJ>","variables":{"a":false,"b":false}},{"expected":{"value":120},"id":"integer1-factorial-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"factorial\"/><OMI>5</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"integer1-quotient-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"quotient\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":1},"id":"integer1-remainder-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"remainder\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"rounding1-floor-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"rounding1\" name=\"floor\"/><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":4},"id":"rounding1-ceiling-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"rounding1\" name=\"ceiling\"/><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":"[1, 2, 3]"},"id":"list1-list-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":"[1, 2]"},"id":"set1-set-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"set\"/><OMI>1</OMI><OMI>2</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":true},"id":"set1-in-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>2</OMI><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":3},"id":"set1-size-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"size\"/><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":true},"id":"interval1-in-oc-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>3</OMI><OMA><OMS cd=\"interval1\" name=\"interval_oc\"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":false},"id":"interval1-in-oc-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>1</OMI><OMA><OMS cd=\"interval1\" name=\"interval_oc\"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":-2},"id":"linalg3-determinant-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg3\" name=\"determinant\"/><OMA><OMS cd=\"linalg2\" name=\"matrix\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>2</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>3</OMI><OMI>4</OMI></OMA></OMA></OMA></OMOBJ>"},{"expected":{"value":"[0, 0, 1]"},"id":"linalg1-vector-product-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg1\" name=\"vector_product\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>0</OMI><OMI>1</OMI><OMI>0</OMI></OMA></OMA></OMOBJ>"},{"id":"linalg1-vector-product-2","refusal":{"error":"DimensionMismatchError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg1\" name=\"vector_product\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>0</OMI><OMI>0</OMI><OMI>0</OMI><OMI>1</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":3},"id":"fns1-lambda-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMV name=\"x\"/><OMI>1</OMI></OMA></OMBIND><OMI>2</OMI></OMA></OMOBJ>"},{"id":"lambda-arity-1","refusal":{"error":"ArityError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMV name=\"x\"/><OMV name=\"y\"/></OMA></OMBIND><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":12},"id":"omr-resolution-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMI id=\"t\">6</OMI><OMR href=\"#t\"/></OMA></OMOBJ>"},{"id":"omr-cycle-1","refusal":{"error":"RecursionError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA id=\"me\"><OMR href=\"#me\"/></OMA></OMOBJ>"},{"id":"refusal-unbound-1","refusal":{"error":"UnboundSymbolError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"mycd\" name=\"f\"/><OMI>1</OMI></OMA></OMOBJ>"},{"id":"refusal-arity-1","refusal":{"error":"ArityError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI></OMA></OMOBJ>"},{"id":"refusal-domain-1","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMSTR>x</OMSTR></OMA></OMOBJ>"},{"expected":{"class":"Openmath::Evaluation::Uncertain","fields":{"category":"standard","value":"10.3"}},"id":"pmquant-ustd-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"ustd\"/><OMF dec=\"10.3\"/><OMF dec=\"0.2\"/></OMA></OMOBJ>"},{"expected":{"value":"10.3"},"id":"pmquant-value-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"value\"/><OMA><OMS cd=\"pmquant\" name=\"ustd\"/><OMF dec=\"10.3\"/><OMF dec=\"0.2\"/></OMA></OMA></OMOBJ>"},{"id":"pmquant-factor-1","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"uexp\"/><OMF dec=\"1\"/><OMF dec=\"1\"/><OMF dec=\"0\"/></OMA></OMOBJ>"}]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "leptris"
|
|
4
4
|
|
|
5
5
|
module Openmath
|
|
6
6
|
module CD
|
|
@@ -68,15 +68,18 @@ module Openmath
|
|
|
68
68
|
# Validates a CD document against the vendored omcd2.rng. Returns the
|
|
69
69
|
# list of Openmath::Validation::Error objects; empty when valid.
|
|
70
70
|
def self.validate(xml)
|
|
71
|
-
@schema ||=
|
|
72
|
-
File.
|
|
71
|
+
@schema ||= Leptris::XML::RelaxNG.parse_file(
|
|
72
|
+
File.expand_path("../../../schemas/omcd2.rng", __dir__),
|
|
73
73
|
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
begin
|
|
75
|
+
document = Leptris::XML.parse(xml, strict: true)
|
|
76
|
+
rescue Leptris::XML::ParseError
|
|
77
|
+
raise Openmath::Validation::ValidationError,
|
|
78
|
+
[Openmath::Validation::Error.new("malformed XML", "/")]
|
|
79
|
+
end
|
|
77
80
|
|
|
78
81
|
@schema.validate(document).map do |e|
|
|
79
|
-
Openmath::Validation::Error.new(e
|
|
82
|
+
Openmath::Validation::Error.new(e, nil)
|
|
80
83
|
end
|
|
81
84
|
end
|
|
82
85
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "leptris"
|
|
4
4
|
|
|
5
5
|
module Openmath
|
|
6
6
|
module CD
|
|
@@ -89,20 +89,18 @@ module Openmath
|
|
|
89
89
|
# Returns the list of Openmath::Validation::Error objects; empty
|
|
90
90
|
# when valid.
|
|
91
91
|
def validate(xml)
|
|
92
|
-
@schema ||=
|
|
93
|
-
File.
|
|
92
|
+
@schema ||= Leptris::XML::RelaxNG.parse_file(
|
|
93
|
+
File.expand_path("../../../schemas/omcdgroup2.rng", __dir__),
|
|
94
94
|
)
|
|
95
95
|
begin
|
|
96
|
-
document =
|
|
97
|
-
rescue
|
|
96
|
+
document = Leptris::XML.parse(xml, strict: true)
|
|
97
|
+
rescue Leptris::XML::ParseError
|
|
98
98
|
raise Openmath::Validation::ValidationError,
|
|
99
99
|
[Openmath::Validation::Error.new("malformed XML", "/")]
|
|
100
100
|
end
|
|
101
|
-
raise Openmath::Validation::ValidationError,
|
|
102
|
-
[Openmath::Validation::Error.new("malformed XML", "/")] if document.errors.any?
|
|
103
101
|
|
|
104
102
|
@schema.validate(document).map do |e|
|
|
105
|
-
Openmath::Validation::Error.new(e
|
|
103
|
+
Openmath::Validation::Error.new(e, nil)
|
|
106
104
|
end
|
|
107
105
|
end
|
|
108
106
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "moxml"
|
|
4
4
|
|
|
5
5
|
module Openmath
|
|
6
6
|
# The Content MathML v4 encoding (the plurimath#35 re-parenting:
|
|
@@ -28,7 +28,7 @@ module Openmath
|
|
|
28
28
|
# Parses Content MathML into the versioned object model: the parsed
|
|
29
29
|
# object slots into an OMOBJ root, as the XML and binary readers do.
|
|
30
30
|
def parse(input, version: 2)
|
|
31
|
-
doc =
|
|
31
|
+
doc = Moxml.parse(input)
|
|
32
32
|
root = doc.root
|
|
33
33
|
raise Error, "no root element" unless root
|
|
34
34
|
|
|
@@ -54,16 +54,11 @@ module Openmath
|
|
|
54
54
|
|
|
55
55
|
def content_element(name, children = nil, attributes = nil)
|
|
56
56
|
attributes_arg = attributes && !attributes.empty? ? attributes : nil
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
node = Nokogiri::XML::Node.new(name, children.first.document)
|
|
63
|
-
attributes_arg&.each { |key, value| node[key] = value }
|
|
64
|
-
children.each { |child| node.add_child(child) }
|
|
65
|
-
node
|
|
66
|
-
end
|
|
57
|
+
doc = children&.first&.document || Moxml.new.create_document
|
|
58
|
+
node = doc.create_element(name)
|
|
59
|
+
attributes_arg&.each { |key, value| node[key] = value }
|
|
60
|
+
children&.each { |child| node.add_child(child) }
|
|
61
|
+
node
|
|
67
62
|
end
|
|
68
63
|
|
|
69
64
|
# The reader: one Content MathML element at a time.
|
|
@@ -333,12 +328,12 @@ module Openmath
|
|
|
333
328
|
end
|
|
334
329
|
|
|
335
330
|
def document
|
|
336
|
-
wrapper =
|
|
337
|
-
math =
|
|
331
|
+
wrapper = Moxml.new.create_document
|
|
332
|
+
math = wrapper.create_element("math")
|
|
338
333
|
math["xmlns"] = NAMESPACE
|
|
339
334
|
math.add_child(element(@root))
|
|
340
335
|
wrapper.root = math
|
|
341
|
-
|
|
336
|
+
wrapper.to_xml(indent: 2, declaration: false, expand_empty: false)
|
|
342
337
|
end
|
|
343
338
|
|
|
344
339
|
def element(node)
|
|
@@ -436,7 +431,7 @@ module Openmath
|
|
|
436
431
|
end
|
|
437
432
|
|
|
438
433
|
def sep(document)
|
|
439
|
-
|
|
434
|
+
document.create_element("sep")
|
|
440
435
|
end
|
|
441
436
|
end
|
|
442
437
|
end
|
data/lib/openmath/foreign.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "moxml"
|
|
4
4
|
|
|
5
5
|
module Openmath
|
|
6
6
|
# Foreign-markup capture for OMFOREIGN (the schema's notOM content).
|
|
7
7
|
#
|
|
8
8
|
# lutaml-model's mapping DSL has no representation for arbitrary-markup
|
|
9
9
|
# children, so capture rides a source-side pass: after the typed parse,
|
|
10
|
-
# the document is re-walked with
|
|
10
|
+
# the document is re-walked with Moxml in parallel with the model
|
|
11
11
|
# tree, and every OMFOREIGN's foreign children (elements outside the
|
|
12
12
|
# OpenMath namespace) are serialized verbatim into the instance's
|
|
13
13
|
# +notom_value+, with +notom_positions+ recording how many OpenMath
|
|
@@ -15,7 +15,6 @@ module Openmath
|
|
|
15
15
|
# back at those positions through Base::Omobj's to_xml override.
|
|
16
16
|
module Foreign
|
|
17
17
|
OPENMATH_NS = "http://www.openmath.org/OpenMath"
|
|
18
|
-
SAVE_OPTIONS = Nokogiri::XML::Node::SaveOptions::AS_XML
|
|
19
18
|
|
|
20
19
|
module_function
|
|
21
20
|
|
|
@@ -32,7 +31,7 @@ module Openmath
|
|
|
32
31
|
# Omforeign's notom_value/notom_positions from the serialized foreign
|
|
33
32
|
# children in document order. Nested OMFOREIGN objects descend.
|
|
34
33
|
def capture(object, source)
|
|
35
|
-
root =
|
|
34
|
+
root = Moxml.parse(source).root
|
|
36
35
|
return object unless root
|
|
37
36
|
|
|
38
37
|
capture_node(object, root)
|
|
@@ -43,19 +42,19 @@ module Openmath
|
|
|
43
42
|
# locating each OMFOREIGN node by the same positional pairing capture
|
|
44
43
|
# used, and re-serializes.
|
|
45
44
|
def inject_tree(object, xml_string)
|
|
46
|
-
doc =
|
|
45
|
+
doc = Moxml.parse(xml_string)
|
|
47
46
|
place(object, doc.root)
|
|
48
47
|
root_serialize(doc)
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
# Appends the fragments of a standalone Omforeign serialization.
|
|
52
51
|
def inject(xml, fragments)
|
|
53
|
-
doc =
|
|
52
|
+
doc = Moxml.parse(xml)
|
|
54
53
|
target = doc.root
|
|
55
54
|
return xml.to_s unless target
|
|
56
55
|
|
|
57
56
|
fragments.each do |fragment|
|
|
58
|
-
node =
|
|
57
|
+
node = Moxml.parse(fragment).root
|
|
59
58
|
target.add_child(node) if node
|
|
60
59
|
end
|
|
61
60
|
root_serialize(doc)
|
|
@@ -67,7 +66,7 @@ module Openmath
|
|
|
67
66
|
positions = []
|
|
68
67
|
cursor = child_cursor(model)
|
|
69
68
|
|
|
70
|
-
node.
|
|
69
|
+
element_children(node).each do |child|
|
|
71
70
|
model_child = cursor.call(child.name)
|
|
72
71
|
om_children += 1 if model_child || openmath_child?(child)
|
|
73
72
|
if model_child
|
|
@@ -80,14 +79,14 @@ module Openmath
|
|
|
80
79
|
|
|
81
80
|
return unless omforeign?(model)
|
|
82
81
|
|
|
83
|
-
model.notom_value = foreign.map { |n| n.to_xml(
|
|
82
|
+
model.notom_value = foreign.map { |n| n.to_xml(indent: 0, expand_empty: false) }
|
|
84
83
|
model.notom_positions = positions
|
|
85
84
|
end
|
|
86
85
|
|
|
87
86
|
def place(model, node)
|
|
88
87
|
cursor = child_cursor(model)
|
|
89
88
|
|
|
90
|
-
node.
|
|
89
|
+
element_children(node).each do |child|
|
|
91
90
|
model_child = cursor.call(child.name)
|
|
92
91
|
next unless model_child
|
|
93
92
|
|
|
@@ -101,9 +100,9 @@ module Openmath
|
|
|
101
100
|
def insert_fragments(node, model)
|
|
102
101
|
fragments = Array(model.notom_value)
|
|
103
102
|
positions = Array(model.notom_positions)
|
|
104
|
-
siblings = node.
|
|
103
|
+
siblings = element_children(node).select { |c| openmath_child?(c) }
|
|
105
104
|
fragments.each_with_index do |fragment, i|
|
|
106
|
-
fragment_node =
|
|
105
|
+
fragment_node = Moxml.parse(fragment).root
|
|
107
106
|
next unless fragment_node
|
|
108
107
|
|
|
109
108
|
anchor = siblings[positions[i]] if positions[i]
|
|
@@ -116,7 +115,13 @@ module Openmath
|
|
|
116
115
|
end
|
|
117
116
|
|
|
118
117
|
def openmath_child?(node)
|
|
119
|
-
(node.
|
|
118
|
+
(node.namespace_uri || OPENMATH_NS) == OPENMATH_NS
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Element children only, in document order (the walk skips text,
|
|
122
|
+
# comments and processing instructions).
|
|
123
|
+
def element_children(node)
|
|
124
|
+
node.children.select { |child| child.is_a?(Moxml::Element) }
|
|
120
125
|
end
|
|
121
126
|
|
|
122
127
|
# Document-order model child of +name+ matched positionally against
|
|
@@ -140,7 +145,7 @@ module Openmath
|
|
|
140
145
|
end
|
|
141
146
|
|
|
142
147
|
def root_serialize(doc)
|
|
143
|
-
doc.root.to_xml(
|
|
148
|
+
doc.root.to_xml(indent: 0, expand_empty: false)
|
|
144
149
|
end
|
|
145
150
|
end
|
|
146
151
|
end
|
data/lib/openmath/validation.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "leptris"
|
|
4
4
|
|
|
5
5
|
module Openmath
|
|
6
6
|
module Validation
|
|
@@ -31,20 +31,20 @@ module Openmath
|
|
|
31
31
|
raise ArgumentError, "unsupported OpenMath version #{version.inspect}"
|
|
32
32
|
end
|
|
33
33
|
@schemas ||= {}
|
|
34
|
-
@schemas[version] ||=
|
|
35
|
-
File.
|
|
34
|
+
@schemas[version] ||= Leptris::XML::RelaxNG.parse_file(
|
|
35
|
+
File.expand_path("../../schemas/#{file}", __dir__),
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# Validates the document against the version's schema. Returns the list
|
|
40
40
|
# of Error objects; empty when the document is valid.
|
|
41
41
|
def validate(xml, version: 2)
|
|
42
|
-
document =
|
|
43
|
-
raise ValidationError, [Error.new("malformed XML", "/")] if document.errors.any?
|
|
44
|
-
|
|
42
|
+
document = Leptris::XML.parse(xml, strict: true)
|
|
45
43
|
schema(version).validate(document).map do |e|
|
|
46
|
-
Error.new(e
|
|
44
|
+
Error.new(e, nil)
|
|
47
45
|
end
|
|
46
|
+
rescue Leptris::XML::ParseError
|
|
47
|
+
raise ValidationError, [Error.new("malformed XML", "/")]
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# Validates and raises ValidationError carrying every violation.
|
data/lib/openmath/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openmath
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
@@ -39,19 +39,33 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 0.6.1
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: leptris
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '1.
|
|
47
|
+
version: '1.9'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '1.
|
|
54
|
+
version: '1.9'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: nokogiri
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
55
69
|
description: |
|
|
56
70
|
OpenMath 2 and OpenMath 3 XML encoding parsed into a typed model
|
|
57
71
|
declared with LutaML Model, with content-dictionary-aware semantics.
|