This commit is contained in:
wangjinlei
2024-07-17 09:23:45 +08:00
parent edf9deeb1a
commit 881ac3e056
1001 changed files with 41032 additions and 5452 deletions

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element;
use PHPUnit\Framework\TestCase;
class AbstractGroupElementTest extends TestCase
{
public function testConstruct(): void
{
$row = new Element\Row();
$this->assertIsArray($row->getElements());
$this->assertCount(0, $row->getElements());
}
public function testAdd(): void
{
$identifierA = new Element\Identifier('a');
$row = new Element\Row();
$this->assertCount(0, $row->getElements());
$this->assertInstanceOf(Element\AbstractGroupElement::class, $row->add($identifierA));
$this->assertCount(1, $row->getElements());
$this->assertEquals([$identifierA], $row->getElements());
}
public function testRemove(): void
{
$identifierA = new Element\Identifier('a');
$row = new Element\Row();
$row->add($identifierA);
$this->assertCount(1, $row->getElements());
$this->assertInstanceOf(Element\AbstractGroupElement::class, $row->remove($identifierA));
$this->assertCount(0, $row->getElements());
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element;
use PhpOffice\Math\Element\Fraction;
use PHPUnit\Framework\TestCase;
class FractionTest extends TestCase
{
public function testConstruct(): void
{
$identifierA = new Element\Identifier('a');
$identifierB = new Element\Identifier('b');
$fraction = new Fraction($identifierA, $identifierB);
$this->assertEquals($identifierA, $fraction->getNumerator());
$this->assertEquals($identifierB, $fraction->getDenominator());
}
public function testBase(): void
{
$identifierA = new Element\Identifier('a');
$identifierB = new Element\Identifier('b');
$identifierC = new Element\Identifier('c');
$fraction = new Fraction($identifierA, $identifierB);
$this->assertEquals($identifierA, $fraction->getNumerator());
$this->assertInstanceOf(Fraction::class, $fraction->setNumerator($identifierC));
$this->assertEquals($identifierC, $fraction->getNumerator());
}
public function testFraction(): void
{
$identifierA = new Element\Identifier('a');
$identifierB = new Element\Identifier('b');
$identifierC = new Element\Identifier('c');
$fraction = new Fraction($identifierA, $identifierB);
$this->assertEquals($identifierB, $fraction->getDenominator());
$this->assertInstanceOf(Fraction::class, $fraction->setDenominator($identifierC));
$this->assertEquals($identifierC, $fraction->getDenominator());
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element\Identifier;
use PHPUnit\Framework\TestCase;
class IdentifierTest extends TestCase
{
public function testConstruct(): void
{
$operator = new Identifier('x');
$this->assertEquals('x', $operator->getValue());
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element\Numeric;
use PHPUnit\Framework\TestCase;
class NumericTest extends TestCase
{
public function testConstruct(): void
{
$numeric = new Numeric(2);
$this->assertEquals(2, $numeric->getValue());
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element\Operator;
use PHPUnit\Framework\TestCase;
class OperatorTest extends TestCase
{
public function testConstruct(): void
{
$operator = new Operator('+');
$this->assertEquals('+', $operator->getValue());
}
}

View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element\Semantics;
use PHPUnit\Framework\TestCase;
class SemanticsTest extends TestCase
{
public function testConstruct(): void
{
$semantics = new Semantics();
$this->assertIsArray($semantics->getAnnotations());
$this->assertCount(0, $semantics->getAnnotations());
}
public function testAnnotation(): void
{
$semantics = new Semantics();
$this->assertIsArray($semantics->getAnnotations());
$this->assertCount(0, $semantics->getAnnotations());
$this->assertInstanceOf(Semantics::class, $semantics->addAnnotation('encoding', 'content'));
$this->assertEquals(['encoding' => 'content'], $semantics->getAnnotations());
$this->assertCount(1, $semantics->getAnnotations());
$this->assertEquals('content', $semantics->getAnnotation('encoding'));
$this->assertNull($semantics->getAnnotation('notexisting'));
}
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Element;
use PhpOffice\Math\Element;
use PhpOffice\Math\Element\Superscript;
use PHPUnit\Framework\TestCase;
class SuperscriptTest extends TestCase
{
public function testConstruct(): void
{
$superscript = new Superscript(new Element\Identifier('a'), new Element\Identifier('a'));
$this->assertInstanceOf(Element\Identifier::class, $superscript->getBase());
$this->assertInstanceOf(Element\Identifier::class, $superscript->getSuperscript());
}
public function testBase(): void
{
$identifierA = new Element\Identifier('a');
$identifierB = new Element\Identifier('b');
$identifierC = new Element\Identifier('c');
$superscript = new Superscript($identifierA, $identifierB);
$this->assertEquals($identifierA, $superscript->getBase());
$this->assertInstanceOf(Superscript::class, $superscript->setBase($identifierC));
$this->assertEquals($identifierC, $superscript->getBase());
}
public function testSuperscript(): void
{
$identifierA = new Element\Identifier('a');
$identifierB = new Element\Identifier('b');
$identifierC = new Element\Identifier('c');
$superscript = new Superscript($identifierA, $identifierB);
$this->assertEquals($identifierB, $superscript->getSuperscript());
$this->assertInstanceOf(Superscript::class, $superscript->setSuperscript($identifierC));
$this->assertEquals($identifierC, $superscript->getSuperscript());
}
}

View File

@@ -0,0 +1,243 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Reader;
use PhpOffice\Math\Element;
use PhpOffice\Math\Exception\InvalidInputException;
use PhpOffice\Math\Exception\NotImplementedException;
use PhpOffice\Math\Math;
use PhpOffice\Math\Reader\MathML;
use PHPUnit\Framework\TestCase;
class MathMLTest extends TestCase
{
public function testReadBasic(): void
{
$content = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>a</mi> <mo>&InvisibleTimes;</mo> <msup><mi>x</mi><mn>2</mn></msup>
<mo>+</mo><mi>b</mi><mo>&InvisibleTimes;</mo><mi>x</mi>
<mo>+</mo><mi>c</mi>
</mrow>
</math>';
$reader = new MathML();
$math = $reader->read($content);
$this->assertInstanceOf(Math::class, $math);
$elements = $math->getElements();
$this->assertCount(1, $elements);
$this->assertInstanceOf(Element\Row::class, $elements[0]);
/** @var Element\Row $element */
$element = $elements[0];
$subElements = $element->getElements();
$this->assertCount(9, $subElements);
/** @var Element\Identifier $subElement */
$subElement = $subElements[0];
$this->assertInstanceOf(Element\Identifier::class, $subElement);
$this->assertEquals('a', $subElement->getValue());
/** @var Element\Identifier $subElement */
$subElement = $subElements[1];
$this->assertInstanceOf(Element\Operator::class, $subElement);
$this->assertEquals('InvisibleTimes', $subElement->getValue());
/** @var Element\Superscript $subElement */
$subElement = $subElements[2];
$this->assertInstanceOf(Element\Superscript::class, $subElements[2]);
/** @var Element\Identifier $base */
$base = $subElement->getBase();
$this->assertInstanceOf(Element\Identifier::class, $base);
$this->assertEquals('x', $base->getValue());
/** @var Element\Numeric $superscript */
$superscript = $subElement->getSuperscript();
$this->assertInstanceOf(Element\Numeric::class, $superscript);
$this->assertEquals(2, $superscript->getValue());
/** @var Element\Operator $subElement */
$subElement = $subElements[3];
$this->assertInstanceOf(Element\Operator::class, $subElement);
$this->assertEquals('+', $subElement->getValue());
/** @var Element\Identifier $subElement */
$subElement = $subElements[4];
$this->assertInstanceOf(Element\Identifier::class, $subElement);
$this->assertEquals('b', $subElement->getValue());
/** @var Element\Operator $subElement */
$subElement = $subElements[5];
$this->assertInstanceOf(Element\Operator::class, $subElement);
$this->assertEquals('InvisibleTimes', $subElement->getValue());
/** @var Element\Identifier $subElement */
$subElement = $subElements[6];
$this->assertInstanceOf(Element\Identifier::class, $subElement);
$this->assertEquals('x', $subElement->getValue());
/** @var Element\Operator $subElement */
$subElement = $subElements[7];
$this->assertInstanceOf(Element\Operator::class, $subElement);
$this->assertEquals('+', $subElement->getValue());
/** @var Element\Identifier $subElement */
$subElement = $subElements[8];
$this->assertInstanceOf(Element\Identifier::class, $subElement);
$this->assertEquals('c', $subElement->getValue());
}
public function testReadFraction(): void
{
$content = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mfrac bevelled="true">
<mfrac>
<mi> a </mi>
<mi> b </mi>
</mfrac>
<mfrac>
<mi> c </mi>
<mi> d </mi>
</mfrac>
</mfrac>
</math>';
$reader = new MathML();
$math = $reader->read($content);
$this->assertInstanceOf(Math::class, $math);
$elements = $math->getElements();
$this->assertCount(1, $elements);
$this->assertInstanceOf(Element\Fraction::class, $elements[0]);
/** @var Element\Fraction $element */
$element = $elements[0];
$this->assertInstanceOf(Element\Fraction::class, $element->getNumerator());
/** @var Element\Fraction $subElement */
$subElement = $element->getNumerator();
/** @var Element\Identifier $numerator */
$numerator = $subElement->getNumerator();
$this->assertInstanceOf(Element\Identifier::class, $numerator);
$this->assertEquals('a', $numerator->getValue());
/** @var Element\Identifier $denominator */
$denominator = $subElement->getDenominator();
$this->assertInstanceOf(Element\Identifier::class, $denominator);
$this->assertEquals('b', $denominator->getValue());
$this->assertInstanceOf(Element\Fraction::class, $element->getDenominator());
/** @var Element\Fraction $subElement */
$subElement = $element->getDenominator();
/** @var Element\Identifier $numerator */
$numerator = $subElement->getNumerator();
$this->assertInstanceOf(Element\Identifier::class, $numerator);
$this->assertEquals('c', $numerator->getValue());
/** @var Element\Identifier $denominator */
$denominator = $subElement->getDenominator();
$this->assertInstanceOf(Element\Identifier::class, $denominator);
$this->assertEquals('d', $denominator->getValue());
}
public function testReadFractionInvalid(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\MathML::getElement : The tag `mfrac` has not two subelements');
$content = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mfrac>
<mi> a </mi>
</mfrac>
</math>';
$reader = new MathML();
$math = $reader->read($content);
}
public function testReadSuperscriptInvalid(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\MathML::getElement : The tag `msup` has not two subelements');
$content = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi> a </mi>
</msup>
</math>';
$reader = new MathML();
$math = $reader->read($content);
}
public function testReadSemantics(): void
{
$content = '<?xml version="1.0" encoding="UTF-8"?>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<mfrac>
<mi>π</mi>
<mn>2</mn>
</mfrac>
<mo stretchy="false">+</mo>
<mrow>
<mi>a</mi>
<mo stretchy="false"></mo>
<mn>2</mn>
</mrow>
</mrow>
<annotation encoding="StarMath 5.0">{π} over {2} + { a } * 2 </annotation>
</semantics>
</math>';
$reader = new MathML();
$math = $reader->read($content);
$this->assertInstanceOf(Math::class, $math);
$elements = $math->getElements();
$this->assertCount(1, $elements);
$this->assertInstanceOf(Element\Semantics::class, $elements[0]);
/** @var Element\Semantics $element */
$element = $elements[0];
// Check MathML
$subElements = $element->getElements();
$this->assertCount(1, $subElements);
$this->assertInstanceOf(Element\Row::class, $subElements[0]);
// Check Annotation
$this->assertCount(1, $element->getAnnotations());
$this->assertEquals('{π} over {2} + { a } * 2', $element->getAnnotation('StarMath 5.0'));
}
public function testReadNotImplemented(): void
{
$this->expectException(NotImplementedException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\MathML::getElement : The tag `mnotexisting` is not implemented');
$content = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mnotexisting>
<mi> a </mi>
</mnotexisting>
</math>';
$reader = new MathML();
$math = $reader->read($content);
}
}

View File

@@ -0,0 +1,197 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Reader;
use PhpOffice\Math\Element;
use PhpOffice\Math\Exception\InvalidInputException;
use PhpOffice\Math\Exception\NotImplementedException;
use PhpOffice\Math\Math;
use PhpOffice\Math\Reader\OfficeMathML;
use PHPUnit\Framework\TestCase;
class OfficeMathMLTest extends TestCase
{
public function testRead(): void
{
$content = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:oMath>
<m:f>
<m:num><m:r><m:t>2</m:t></m:r></m:num>
<m:den><m:r><m:t>π</m:t></m:r></m:den>
</m:f>
</m:oMath>
</m:oMathPara>';
$reader = new OfficeMathML();
$math = $reader->read($content);
$this->assertInstanceOf(Math::class, $math);
$elements = $math->getElements();
$this->assertCount(1, $elements);
$this->assertInstanceOf(Element\Row::class, $elements[0]);
/** @var Element\Row $element */
$element = $elements[0];
$subElements = $element->getElements();
$this->assertCount(1, $subElements);
$this->assertInstanceOf(Element\Fraction::class, $subElements[0]);
/** @var Element\Fraction $subElement */
$subElement = $subElements[0];
/** @var Element\Identifier $numerator */
$numerator = $subElement->getNumerator();
$this->assertInstanceOf(Element\Numeric::class, $numerator);
$this->assertEquals(2, $numerator->getValue());
/** @var Element\Numeric $denominator */
$denominator = $subElement->getDenominator();
$this->assertInstanceOf(Element\Identifier::class, $denominator);
$this->assertEquals('π', $denominator->getValue());
}
public function testReadWithWTag(): void
{
$content = '<m:oMath xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:f>
<m:num>
<m:r>
<w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr>
<m:t xml:space="preserve">π</m:t>
</m:r>
</m:num>
<m:den>
<m:r>
<w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr>
<m:t xml:space="preserve">2</m:t>
</m:r>
</m:den>
</m:f>
<m:r>
<w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr>
<m:t xml:space="preserve">+</m:t>
</m:r>
<m:r>
<w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr>
<m:t xml:space="preserve">a</m:t>
</m:r>
<m:r>
<w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr>
<m:t xml:space="preserve"></m:t>
</m:r>
<m:r>
<w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/></w:rPr>
<m:t xml:space="preserve">2</m:t>
</m:r>
</m:oMath>';
$reader = new OfficeMathML();
$math = $reader->read($content);
$this->assertInstanceOf(Math::class, $math);
$elements = $math->getElements();
$this->assertCount(5, $elements);
/** @var Element\Fraction $element */
$element = $elements[0];
$this->assertInstanceOf(Element\Fraction::class, $element);
/** @var Element\Identifier $numerator */
$numerator = $element->getNumerator();
$this->assertInstanceOf(Element\Identifier::class, $numerator);
$this->assertEquals('π', $numerator->getValue());
/** @var Element\Numeric $denominator */
$denominator = $element->getDenominator();
$this->assertInstanceOf(Element\Numeric::class, $denominator);
$this->assertEquals(2, $denominator->getValue());
/** @var Element\Operator $element */
$element = $elements[1];
$this->assertInstanceOf(Element\Operator::class, $element);
$this->assertEquals('+', $element->getValue());
/** @var Element\Identifier $element */
$element = $elements[2];
$this->assertInstanceOf(Element\Identifier::class, $element);
$this->assertEquals('a', $element->getValue());
/** @var Element\Operator $element */
$element = $elements[3];
$this->assertInstanceOf(Element\Operator::class, $element);
$this->assertEquals('', $element->getValue());
/** @var Element\Numeric $element */
$element = $elements[4];
$this->assertInstanceOf(Element\Numeric::class, $element);
$this->assertEquals(2, $element->getValue());
}
public function testReadFractionNoNumerator(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\OfficeMathML::getElement : The tag `m:f` has no numerator defined');
$content = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:oMath>
<m:f>
<m:den><m:r><m:t>2</m:t></m:r></m:den>
</m:f>
</m:oMath>
</m:oMathPara>';
$reader = new OfficeMathML();
$math = $reader->read($content);
}
public function testReadFractionNoDenominator(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\OfficeMathML::getElement : The tag `m:f` has no denominator defined');
$content = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:oMath>
<m:f>
<m:num><m:r><m:t>π</m:t></m:r></m:num>
</m:f>
</m:oMath>
</m:oMathPara>';
$reader = new OfficeMathML();
$math = $reader->read($content);
}
public function testReadBasicNoText(): void
{
$this->expectException(InvalidInputException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\OfficeMathML::getElement : The tag `m:r` has no tag `m:t` defined');
$content = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:oMath>
<m:r>
a
</m:r>
</m:oMath>
</m:oMathPara>';
$reader = new OfficeMathML();
$math = $reader->read($content);
}
public function testReadNotImplemented(): void
{
$this->expectException(NotImplementedException::class);
$this->expectExceptionMessage('PhpOffice\Math\Reader\OfficeMathML::getElement : The tag `m:mnotexisting` is not implemented');
$content = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:oMath>
<m:mnotexisting>
<m:num><m:r><m:t>π</m:t></m:r></m:num>
</m:mnotexisting>
</m:oMath>
</m:oMathPara>';
$reader = new OfficeMathML();
$math = $reader->read($content);
}
}

View File

@@ -0,0 +1,104 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Writer;
use PhpOffice\Math\Element;
use PhpOffice\Math\Exception\NotImplementedException;
use PhpOffice\Math\Math;
use PhpOffice\Math\Writer\MathML;
class MathMLTest extends WriterTestCase
{
public function testWrite(): void
{
$opTimes = new Element\Operator('&InvisibleTimes;');
$math = new Math();
$row = new Element\Row();
$math->add($row);
$row->add(new Element\Identifier('a'));
$row->add(clone $opTimes);
$superscript = new Element\Superscript(
new Element\Identifier('x'),
new Element\Numeric(2)
);
$row->add($superscript);
$row->add(new Element\Operator('+'));
$row->add(new Element\Identifier('b'));
$row->add(clone $opTimes);
$row->add(new Element\Identifier('x'));
$row->add(new Element\Operator('+'));
$row->add(new Element\Identifier('c'));
$writer = new MathML();
$output = $writer->write($math);
$expected = '<?xml version="1.0" encoding="UTF-8"?>'
. PHP_EOL
. '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">'
. '<math xmlns="http://www.w3.org/1998/Math/MathML">'
. '<mrow><mi>a</mi><mo>&amp;InvisibleTimes;</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mo>&amp;InvisibleTimes;</mo><mi>x</mi><mo>+</mo><mi>c</mi>'
. '</mrow>'
. '</math>'
. PHP_EOL;
$this->assertEquals($expected, $output);
$this->assertIsSchemaMathMLValid($output);
}
public function testWriteFraction(): void
{
$math = new Math();
$fraction = new Element\Fraction(
new Element\Identifier('π'),
new Element\Numeric(2)
);
$math->add($fraction);
$writer = new MathML();
$output = $writer->write($math);
$expected = '<?xml version="1.0" encoding="UTF-8"?>'
. PHP_EOL
. '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">'
. '<math xmlns="http://www.w3.org/1998/Math/MathML">'
. '<mfrac>'
. '<mi>π</mi><mn>2</mn>'
. '</mfrac>'
. '</math>'
. PHP_EOL;
$this->assertEquals($expected, $output);
$this->assertIsSchemaMathMLValid($output);
}
public function testWriteNotImplemented(): void
{
$this->expectException(NotImplementedException::class);
if (method_exists($this, 'expectExceptionMessageRegExp')) {
$this->expectExceptionMessageRegExp('/PhpOffice\\\Math\\\Writer\\\MathML::getElementTagName : The element of the class/');
$this->expectExceptionMessageRegExp('/has no tag name/');
} else {
// @phpstan-ignore-next-line
$this->expectExceptionMessageMatches('/PhpOffice\\\Math\\\Writer\\\MathML::getElementTagName : The element of the class/');
// @phpstan-ignore-next-line
$this->expectExceptionMessageMatches('/has no tag name/');
}
$math = new Math();
$object = new class() extends Element\AbstractElement {};
$math->add($object);
$writer = new MathML();
$output = $writer->write($math);
}
}

View File

@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Writer;
use PhpOffice\Math\Element;
use PhpOffice\Math\Exception\NotImplementedException;
use PhpOffice\Math\Math;
use PhpOffice\Math\Writer\OfficeMathML;
class OfficeMathMLTest extends WriterTestCase
{
public function testWriteFraction(): void
{
$math = new Math();
$fraction = new Element\Fraction(
new Element\Identifier('π'),
new Element\Numeric(2)
);
$math->add($fraction);
$writer = new OfficeMathML();
$output = $writer->write($math);
$expected = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">'
. '<m:oMath>'
. '<m:f>'
. '<m:num><m:r><m:t>π</m:t></m:r></m:num>'
. '<m:den><m:r><m:t>2</m:t></m:r></m:den>'
. '</m:f>'
. '</m:oMath>'
. '</m:oMathPara>';
$this->assertEquals($expected, $output);
}
public function testWriteRow(): void
{
$math = new Math();
$row = new Element\Row();
$math->add($row);
$row->add(new Element\Identifier('x'));
$writer = new OfficeMathML();
$output = $writer->write($math);
$expected = '<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">'
. '<m:oMath>'
. '<m:r><m:t>x</m:t></m:r>'
. '</m:oMath>'
. '</m:oMathPara>';
$this->assertEquals($expected, $output);
}
public function testWriteNotImplemented(): void
{
$this->expectException(NotImplementedException::class);
if (method_exists($this, 'expectExceptionMessageRegExp')) {
$this->expectExceptionMessageRegExp('/PhpOffice\\\Math\\\Writer\\\OfficeMathML::getElementTagName : The element of the class/');
$this->expectExceptionMessageRegExp('/has no tag name/');
} else {
// @phpstan-ignore-next-line
$this->expectExceptionMessageMatches('/PhpOffice\\\Math\\\Writer\\\OfficeMathML::getElementTagName : The element of the class/');
// @phpstan-ignore-next-line
$this->expectExceptionMessageMatches('/has no tag name/');
}
$math = new Math();
$object = new class() extends Element\AbstractElement {};
$math->add($object);
$writer = new OfficeMathML();
$output = $writer->write($math);
}
}

View File

@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
namespace Tests\PhpOffice\Math\Writer;
use DOMDocument;
use LibXMLError;
use PHPUnit\Framework\TestCase;
class WriterTestCase extends TestCase
{
public function assertIsSchemaMathMLValid(string $content): void
{
$dom = new DOMDocument();
$dom->loadXML($content);
$xmlSource = $dom->saveXML();
if (is_string($xmlSource)) {
$dom->loadXML($xmlSource);
$dom->schemaValidate(dirname(__DIR__, 2) . '/resources/schema/mathml3/mathml3.xsd');
$error = libxml_get_last_error();
if ($error instanceof LibXMLError) {
$this->failXmlError($error, $xmlSource);
} else {
$this->assertTrue(true);
}
return;
}
$this->fail(sprintf('The XML is not valid : %s', $content));
}
/**
* @param array<string, string> $params
*/
protected function failXmlError(LibXMLError $error, string $source, array $params = []): void
{
switch ($error->level) {
case LIBXML_ERR_WARNING:
$errorType = 'warning';
break;
case LIBXML_ERR_ERROR:
$errorType = 'error';
break;
case LIBXML_ERR_FATAL:
$errorType = 'fatal';
break;
default:
$errorType = 'Error';
break;
}
$errorLine = (int) $error->line;
$contents = explode("\n", $source);
$lines = [];
if (isset($contents[$errorLine - 2])) {
$lines[] = '>> ' . $contents[$errorLine - 2];
}
if (isset($contents[$errorLine - 1])) {
$lines[] = '>>> ' . $contents[$errorLine - 1];
}
if (isset($contents[$errorLine])) {
$lines[] = '>> ' . $contents[$errorLine];
}
$paramStr = '';
if (!empty($params)) {
$paramStr .= "\n" . ' - Parameters :' . "\n";
foreach ($params as $key => $val) {
$paramStr .= ' - ' . $key . ' : ' . $val . "\n";
}
}
$this->fail(sprintf(
"Validation %s :\n - - Line : %s\n - Message : %s - Lines :\n%s%s",
$errorType,
$error->line,
$error->message,
implode(PHP_EOL, $lines),
$paramStr
));
}
}

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://www.w3.org/1998/Math/MathML" elementFormDefault="qualified" targetNamespace="http://www.w3.org/1998/Math/MathML">
<xs:element name="math">
<xs:complexType>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:MathExpression"/>
<xs:attributeGroup ref="m:math.attributes"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="CommonDeprecatedAtt">
<xs:attribute name="other"/>
</xs:attributeGroup>
<xs:attributeGroup name="CommonAtt">
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="xref"/>
<xs:attribute name="class" type="xs:NMTOKENS"/>
<xs:attribute name="style" type="xs:string"/>
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attributeGroup ref="m:CommonDeprecatedAtt"/>
<xs:anyAttribute namespace="##other" processContents="skip"/>
</xs:attributeGroup>
<xs:attributeGroup name="math.deprecatedattributes">
<xs:attribute name="mode" type="xs:string"/>
<xs:attribute name="macros" type="xs:string"/>
</xs:attributeGroup>
<xs:attributeGroup name="name">
<xs:attribute name="name" use="required" type="xs:NCName"/>
</xs:attributeGroup>
<xs:attributeGroup name="cd">
<xs:attribute name="cd" use="required" type="xs:NCName"/>
</xs:attributeGroup>
<xs:attributeGroup name="src">
<xs:attribute name="src" type="xs:anyURI"/>
</xs:attributeGroup>
<xs:element name="annotation">
<xs:complexType mixed="true">
<xs:attributeGroup ref="m:annotation.attributes"/>
</xs:complexType>
</xs:element>
<xs:complexType name="annotation-xml.model"><!--content model altered for libxml (annotation-xml)--><xs:sequence>
<xs:any processContents="lax"/>
</xs:sequence>
</xs:complexType>
<xs:group name="anyElement">
<xs:choice>
<xs:any namespace="##other" processContents="skip"/>
<xs:any namespace="##local" processContents="skip"/>
</xs:choice>
</xs:group>
<xs:element name="annotation-xml">
<xs:complexType>
<xs:complexContent>
<xs:extension base="m:annotation-xml.model">
<xs:attributeGroup ref="m:annotation.attributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="annotation.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attribute name="cd" type="xs:NCName"/>
<xs:attribute name="name" type="xs:NCName"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attributeGroup ref="m:src"/>
</xs:attributeGroup>
<xs:attributeGroup name="DefEncAtt">
<xs:attribute name="encoding" type="xs:string"/>
<xs:attribute name="definitionURL" type="xs:anyURI"/>
</xs:attributeGroup>
<xs:group name="semantics">
<xs:sequence>
<xs:element name="semantics">
<xs:complexType>
<xs:sequence>
<xs:group ref="m:MathExpression"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:annotation"/>
<xs:element ref="m:annotation-xml"/>
</xs:choice>
</xs:sequence>
<xs:attributeGroup ref="m:semantics.attributes"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="semantics.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="cd" type="xs:NCName"/>
<xs:attribute name="name" type="xs:NCName"/>
</xs:attributeGroup>
<xs:simpleType name="length">
<xs:restriction base="xs:string">
<xs:pattern value="\s*((-?[0-9]*([0-9]\.?|\.[0-9])[0-9]*(e[mx]|in|cm|mm|p[xtc]|%)?)|(negative)?((very){0,2}thi(n|ck)|medium)mathspace)\s*"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@@ -0,0 +1,681 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://www.w3.org/1998/Math/MathML" elementFormDefault="qualified" targetNamespace="http://www.w3.org/1998/Math/MathML">
<xs:include schemaLocation="mathml3-strict-content.xsd"/>
<xs:complexType name="cn.content" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:mglyph"/>
<xs:element ref="m:sep"/>
<xs:element ref="m:PresentationExpression"/>
</xs:choice>
</xs:complexType>
<xs:attributeGroup name="cn.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="type"/>
<xs:attribute name="base"/>
</xs:attributeGroup>
<xs:attributeGroup name="ci.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="type"/>
</xs:attributeGroup>
<xs:attributeGroup name="ci.type">
<xs:attribute name="type" use="required"/>
</xs:attributeGroup>
<xs:complexType name="ci.content" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:mglyph"/>
<xs:element ref="m:PresentationExpression"/>
</xs:choice>
</xs:complexType>
<xs:attributeGroup name="csymbol.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="type"/>
<xs:attribute name="cd" type="xs:NCName"/>
</xs:attributeGroup>
<xs:complexType name="csymbol.content" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:mglyph"/>
<xs:element ref="m:PresentationExpression"/>
</xs:choice>
</xs:complexType>
<xs:element name="bvar">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:choice>
<xs:element ref="m:ci"/>
<xs:group ref="m:semantics-ci"/>
</xs:choice>
<xs:element ref="m:degree"/>
</xs:choice>
<xs:attributeGroup ref="m:CommonAtt"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="cbytes.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:attributeGroup>
<xs:attributeGroup name="cs.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:attributeGroup>
<!--Ambiguous content model altered (apply.content)-->
<xs:complexType name="apply.content">
<xs:sequence>
<xs:group ref="m:ContExp"/>
<xs:group ref="m:BvarQ"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:Qualifier"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:ContExp"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="bind.content">
<xs:complexContent>
<xs:extension base="m:apply.content"/>
</xs:complexContent>
</xs:complexType>
<xs:attributeGroup name="base">
<xs:attribute name="base" use="required"/>
</xs:attributeGroup>
<xs:element name="sep">
<xs:complexType/>
</xs:element>
<xs:element name="PresentationExpression" abstract="true"/>
<xs:group name="DomainQ">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:domainofapplication"/>
<xs:element ref="m:condition"/>
<!--Ambiguous content model altered (interval)--><xs:sequence>
<xs:element ref="m:lowlimit"/>
<xs:element minOccurs="0" ref="m:uplimit"/>
</xs:sequence>
</xs:choice>
</xs:sequence>
</xs:group>
<xs:element name="domainofapplication">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="condition">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="uplimit">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="lowlimit">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:group name="Qualifier">
<xs:choice>
<xs:group ref="m:DomainQ"/>
<xs:element ref="m:degree"/>
<xs:element ref="m:momentabout"/>
<xs:element ref="m:logbase"/>
</xs:choice>
</xs:group>
<xs:element name="degree">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="momentabout">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="logbase">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="type">
<xs:attribute name="type" use="required"/>
</xs:attributeGroup>
<xs:attributeGroup name="order">
<xs:attribute name="order" use="required">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="numeric"/>
<xs:enumeration value="lexicographic"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:attributeGroup name="closure">
<xs:attribute name="closure" use="required"/>
</xs:attributeGroup>
<xs:element name="piecewise">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:piece"/>
<xs:element ref="m:otherwise"/>
</xs:choice>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="piece">
<xs:complexType>
<xs:sequence>
<xs:group ref="m:ContExp"/>
<xs:group ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="otherwise">
<xs:complexType>
<xs:group ref="m:ContExp"/>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="DeprecatedContExp" abstract="true"/>
<xs:element name="reln" substitutionGroup="m:DeprecatedContExp">
<xs:complexType>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="fn" substitutionGroup="m:DeprecatedContExp">
<xs:complexType>
<xs:group ref="m:ContExp"/>
</xs:complexType>
</xs:element>
<xs:element name="declare" substitutionGroup="m:DeprecatedContExp">
<xs:complexType>
<xs:group maxOccurs="unbounded" ref="m:ContExp"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="scope" type="xs:string"/>
<xs:attribute name="nargs" type="xs:nonNegativeInteger"/>
<xs:attribute name="occurrence">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="prefix"/>
<xs:enumeration value="infix"/>
<xs:enumeration value="function-model"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="interval.class" abstract="true">
<xs:complexType>
<xs:sequence>
<xs:group ref="m:ContExp"/>
<xs:group ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="closure"/>
</xs:complexType>
</xs:element>
<xs:element name="interval" substitutionGroup="m:interval.class"/>
<xs:element name="unary-functional.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="inverse" substitutionGroup="m:unary-functional.class"/>
<xs:element name="ident" substitutionGroup="m:unary-functional.class"/>
<xs:element name="domain" substitutionGroup="m:unary-functional.class"/>
<xs:element name="codomain" substitutionGroup="m:unary-functional.class"/>
<xs:element name="image" substitutionGroup="m:unary-functional.class"/>
<xs:element name="ln" substitutionGroup="m:unary-functional.class"/>
<xs:element name="log" substitutionGroup="m:unary-functional.class"/>
<xs:element name="moment" substitutionGroup="m:unary-functional.class"/>
<xs:element name="lambda.class" abstract="true">
<xs:complexType>
<xs:sequence>
<xs:group ref="m:BvarQ"/>
<xs:group ref="m:DomainQ"/>
<xs:group ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="lambda" substitutionGroup="m:lambda.class"/>
<xs:element name="nary-functional.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="compose" substitutionGroup="m:nary-functional.class"/>
<xs:group name="binary-arith.class">
<xs:choice>
<xs:element ref="m:quotient"/>
<xs:element ref="m:divide"/>
<xs:element ref="m:minus"/>
<xs:element ref="m:power"/>
<xs:element ref="m:rem"/>
<xs:element ref="m:root"/>
</xs:choice>
</xs:group>
<xs:element name="quotient">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="divide">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="minus">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="power">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="rem">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="root">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:group name="unary-arith.class">
<xs:choice>
<xs:element ref="m:factorial"/>
<!--Ambiguous content model altered (minus)--><!--Ambiguous content model altered (root)--><xs:element ref="m:abs"/>
<xs:element ref="m:conjugate"/>
<xs:element ref="m:arg"/>
<xs:element ref="m:real"/>
<xs:element ref="m:imaginary"/>
<xs:element ref="m:floor"/>
<xs:element ref="m:ceiling"/>
<xs:element ref="m:exp"/>
</xs:choice>
</xs:group>
<xs:element name="factorial">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="abs">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="conjugate">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="arg">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="real">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="imaginary">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="floor">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="ceiling">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="exp">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="nary-minmax.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="max" substitutionGroup="m:nary-minmax.class"/>
<xs:element name="min" substitutionGroup="m:nary-minmax.class"/>
<xs:element name="nary-arith.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="plus" substitutionGroup="m:nary-arith.class"/>
<xs:element name="times" substitutionGroup="m:nary-arith.class"/>
<xs:element name="gcd" substitutionGroup="m:nary-arith.class"/>
<xs:element name="lcm" substitutionGroup="m:nary-arith.class"/>
<xs:element name="nary-logical.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="and" substitutionGroup="m:nary-logical.class"/>
<xs:element name="or" substitutionGroup="m:nary-logical.class"/>
<xs:element name="xor" substitutionGroup="m:nary-logical.class"/>
<xs:element name="unary-logical.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="not" substitutionGroup="m:unary-logical.class"/>
<xs:element name="binary-logical.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="implies" substitutionGroup="m:binary-logical.class"/>
<xs:element name="equivalent" substitutionGroup="m:binary-logical.class"/>
<xs:element name="quantifier.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="forall" substitutionGroup="m:quantifier.class"/>
<xs:element name="exists" substitutionGroup="m:quantifier.class"/>
<xs:element name="nary-reln.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="eq" substitutionGroup="m:nary-reln.class"/>
<xs:element name="gt" substitutionGroup="m:nary-reln.class"/>
<xs:element name="lt" substitutionGroup="m:nary-reln.class"/>
<xs:element name="geq" substitutionGroup="m:nary-reln.class"/>
<xs:element name="leq" substitutionGroup="m:nary-reln.class"/>
<xs:element name="binary-reln.class" abstract="true"/>
<xs:element name="neq" substitutionGroup="m:binary-reln.class">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="approx" substitutionGroup="m:binary-reln.class">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="factorof" substitutionGroup="m:binary-reln.class">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="tendsto" substitutionGroup="m:binary-reln.class">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="type"/>
</xs:complexType>
</xs:element>
<xs:element name="int.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="int" substitutionGroup="m:int.class"/>
<xs:element name="Differential-Operator.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="diff" substitutionGroup="m:Differential-Operator.class"/>
<xs:element name="partialdiff.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="partialdiff" substitutionGroup="m:partialdiff.class"/>
<xs:element name="unary-veccalc.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="divergence" substitutionGroup="m:unary-veccalc.class"/>
<xs:element name="grad" substitutionGroup="m:unary-veccalc.class"/>
<xs:element name="curl" substitutionGroup="m:unary-veccalc.class"/>
<xs:element name="laplacian" substitutionGroup="m:unary-veccalc.class"/>
<xs:element name="nary-setlist-constructor.class" abstract="true"/>
<xs:element name="set" substitutionGroup="m:nary-setlist-constructor.class">
<xs:complexType>
<xs:sequence>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:BvarQ"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:DomainQ"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="type"/>
</xs:complexType>
</xs:element>
<xs:element name="list" substitutionGroup="m:nary-setlist-constructor.class">
<xs:complexType>
<xs:sequence>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:BvarQ"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:DomainQ"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
<xs:attribute name="order">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="numeric"/>
<xs:enumeration value="lexicographic"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="nary-set.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="union" substitutionGroup="m:nary-set.class"/>
<xs:element name="intersect" substitutionGroup="m:nary-set.class"/>
<xs:element name="cartesianproduct" substitutionGroup="m:nary-set.class"/>
<xs:element name="binary-set.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="in" substitutionGroup="m:binary-set.class"/>
<xs:element name="notin" substitutionGroup="m:binary-set.class"/>
<xs:element name="notsubset" substitutionGroup="m:binary-set.class"/>
<xs:element name="notprsubset" substitutionGroup="m:binary-set.class"/>
<xs:element name="setdiff" substitutionGroup="m:binary-set.class"/>
<xs:element name="nary-set-reln.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="subset" substitutionGroup="m:nary-set-reln.class"/>
<xs:element name="prsubset" substitutionGroup="m:nary-set-reln.class"/>
<xs:element name="unary-set.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="card" substitutionGroup="m:unary-set.class"/>
<xs:element name="sum.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="sum" substitutionGroup="m:sum.class"/>
<xs:element name="product.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="product" substitutionGroup="m:product.class"/>
<xs:element name="limit.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="limit" substitutionGroup="m:limit.class"/>
<xs:element name="unary-elementary.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="sin" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="cos" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="tan" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="sec" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="csc" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="cot" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="sinh" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="cosh" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="tanh" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="sech" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="csch" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="coth" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arcsin" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arccos" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arctan" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arccosh" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arccot" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arccoth" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arccsc" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arccsch" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arcsec" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arcsech" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arcsinh" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="arctanh" substitutionGroup="m:unary-elementary.class"/>
<xs:element name="nary-stats.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="mean" substitutionGroup="m:nary-stats.class"/>
<xs:element name="sdev" substitutionGroup="m:nary-stats.class"/>
<xs:element name="variance" substitutionGroup="m:nary-stats.class"/>
<xs:element name="median" substitutionGroup="m:nary-stats.class"/>
<xs:element name="mode" substitutionGroup="m:nary-stats.class"/>
<xs:element name="nary-constructor.class" abstract="true">
<xs:complexType>
<xs:sequence>
<xs:group ref="m:BvarQ"/>
<xs:group ref="m:DomainQ"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="vector" substitutionGroup="m:nary-constructor.class"/>
<xs:element name="matrix" substitutionGroup="m:nary-constructor.class"/>
<xs:element name="matrixrow" substitutionGroup="m:nary-constructor.class"/>
<xs:element name="unary-linalg.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="determinant" substitutionGroup="m:unary-linalg.class"/>
<xs:element name="transpose" substitutionGroup="m:unary-linalg.class"/>
<xs:element name="nary-linalg.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="selector" substitutionGroup="m:nary-linalg.class"/>
<xs:element name="binary-linalg.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="vectorproduct" substitutionGroup="m:binary-linalg.class"/>
<xs:element name="scalarproduct" substitutionGroup="m:binary-linalg.class"/>
<xs:element name="outerproduct" substitutionGroup="m:binary-linalg.class"/>
<xs:element name="constant-set.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="integers" substitutionGroup="m:constant-set.class"/>
<xs:element name="reals" substitutionGroup="m:constant-set.class"/>
<xs:element name="rationals" substitutionGroup="m:constant-set.class"/>
<xs:element name="naturalnumbers" substitutionGroup="m:constant-set.class"/>
<xs:element name="complexes" substitutionGroup="m:constant-set.class"/>
<xs:element name="primes" substitutionGroup="m:constant-set.class"/>
<xs:element name="emptyset" substitutionGroup="m:constant-set.class"/>
<xs:element name="constant-arith.class" abstract="true">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:DefEncAtt"/>
</xs:complexType>
</xs:element>
<xs:element name="exponentiale" substitutionGroup="m:constant-arith.class"/>
<xs:element name="imaginaryi" substitutionGroup="m:constant-arith.class"/>
<xs:element name="notanumber" substitutionGroup="m:constant-arith.class"/>
<xs:element name="true" substitutionGroup="m:constant-arith.class"/>
<xs:element name="false" substitutionGroup="m:constant-arith.class"/>
<xs:element name="pi" substitutionGroup="m:constant-arith.class"/>
<xs:element name="eulergamma" substitutionGroup="m:constant-arith.class"/>
<xs:element name="infinity" substitutionGroup="m:constant-arith.class"/>
</xs:schema>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://www.w3.org/1998/Math/MathML" elementFormDefault="qualified" targetNamespace="http://www.w3.org/1998/Math/MathML">
<xs:group name="ContExp">
<xs:choice>
<!--Ambiguous content model altered (ContExp)-->
<xs:element ref="m:apply"/>
<xs:element ref="m:bind"/>
<xs:element ref="m:ci"/>
<xs:element ref="m:cn"/>
<xs:element ref="m:csymbol"/>
<xs:element ref="m:cbytes"/>
<xs:element ref="m:cerror"/>
<xs:element ref="m:cs"/>
<xs:element ref="m:share"/>
<xs:element ref="m:piecewise"/>
<xs:element ref="m:DeprecatedContExp"/>
<xs:element ref="m:interval.class"/>
<xs:element ref="m:unary-functional.class"/>
<xs:element ref="m:lambda.class"/>
<xs:element ref="m:nary-functional.class"/>
<xs:group ref="m:binary-arith.class"/>
<xs:group ref="m:unary-arith.class"/>
<xs:element ref="m:nary-minmax.class"/>
<xs:element ref="m:nary-arith.class"/>
<xs:element ref="m:nary-logical.class"/>
<xs:element ref="m:unary-logical.class"/>
<xs:element ref="m:binary-logical.class"/>
<xs:element ref="m:quantifier.class"/>
<xs:element ref="m:nary-reln.class"/>
<xs:element ref="m:binary-reln.class"/>
<xs:element ref="m:int.class"/>
<xs:element ref="m:Differential-Operator.class"/>
<xs:element ref="m:partialdiff.class"/>
<xs:element ref="m:unary-veccalc.class"/>
<xs:element ref="m:nary-setlist-constructor.class"/>
<xs:element ref="m:nary-set.class"/>
<xs:element ref="m:binary-set.class"/>
<xs:element ref="m:nary-set-reln.class"/>
<xs:element ref="m:unary-set.class"/>
<xs:element ref="m:sum.class"/>
<xs:element ref="m:product.class"/>
<xs:element ref="m:limit.class"/>
<xs:element ref="m:unary-elementary.class"/>
<xs:element ref="m:nary-stats.class"/>
<xs:element ref="m:nary-constructor.class"/>
<xs:element ref="m:unary-linalg.class"/>
<xs:element ref="m:nary-linalg.class"/>
<xs:element ref="m:binary-linalg.class"/>
<xs:element ref="m:constant-set.class"/>
<xs:element ref="m:constant-arith.class"/>
</xs:choice>
</xs:group>
<xs:element name="cn">
<xs:complexType>
<xs:complexContent>
<xs:extension base="m:cn.content">
<xs:attributeGroup ref="m:cn.attributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:group name="semantics-ci">
<xs:sequence>
<xs:element name="semantics">
<xs:complexType>
<xs:sequence>
<xs:choice>
<xs:element ref="m:ci"/>
<xs:group ref="m:semantics-ci"/>
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:annotation"/>
<xs:element ref="m:annotation-xml"/>
</xs:choice>
</xs:sequence>
<xs:attributeGroup ref="m:semantics.attributes"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:group name="semantics-contexp">
<xs:sequence>
<xs:element name="semantics">
<xs:complexType>
<xs:sequence>
<xs:group ref="m:ContExp"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="m:annotation"/>
<xs:element ref="m:annotation-xml"/>
</xs:choice>
</xs:sequence>
<xs:attributeGroup ref="m:semantics.attributes"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:element name="ci">
<xs:complexType>
<xs:complexContent>
<xs:extension base="m:ci.content">
<xs:attributeGroup ref="m:ci.attributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="csymbol">
<xs:complexType>
<xs:complexContent>
<xs:extension base="m:csymbol.content">
<xs:attributeGroup ref="m:csymbol.attributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="SymbolName">
<xs:restriction base="xs:NCName"/>
</xs:simpleType>
<xs:group name="BvarQ">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="m:bvar"/>
</xs:sequence>
</xs:group>
<xs:element name="apply">
<xs:complexType>
<xs:complexContent>
<xs:extension base="m:apply.content">
<xs:attributeGroup ref="m:CommonAtt"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="bind">
<xs:complexType>
<xs:complexContent>
<xs:extension base="m:bind.content">
<xs:attributeGroup ref="m:CommonAtt"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="share">
<xs:complexType>
<xs:attributeGroup ref="m:CommonAtt"/>
<xs:attributeGroup ref="m:src"/>
</xs:complexType>
</xs:element>
<xs:element name="cerror">
<xs:complexType>
<xs:sequence>
<xs:element ref="m:csymbol"/>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="m:ContExp"/>
</xs:sequence>
<xs:attributeGroup ref="m:cerror.attributes"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="cerror.attributes">
<xs:attributeGroup ref="m:CommonAtt"/>
</xs:attributeGroup>
<xs:element name="cbytes">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="m:base64">
<xs:attributeGroup ref="m:cbytes.attributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="base64">
<xs:restriction base="xs:base64Binary"/>
</xs:simpleType>
<xs:element name="cs">
<xs:complexType mixed="true">
<xs:attributeGroup ref="m:cs.attributes"/>
</xs:complexType>
</xs:element>
<xs:group name="MathExpression">
<xs:choice>
<xs:group ref="m:ContExp"/>
<xs:element ref="m:PresentationExpression"/>
<xs:group ref="m:semantics"/>
</xs:choice>
</xs:group>
</xs:schema>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://www.w3.org/1998/Math/MathML" elementFormDefault="qualified" targetNamespace="http://www.w3.org/1998/Math/MathML">
<xs:include schemaLocation="mathml3-content.xsd"/>
<xs:include schemaLocation="mathml3-presentation.xsd"/>
<xs:include schemaLocation="mathml3-common.xsd"/>
</xs:schema>