mathml schema problem
I'm trying to create xml elements from strings marked up as mathml, and I'm using the mathml3 schema as follows. I'm working in the same directory as the xsd files; I generate the schema object and the parser, but the parser complains about the entities in the marked-up string. What am I doing wrong? thanks, --Tim % ls mathml3-common.xsd* mathml3-presentation.xsd* mathml3.xsd* mathml3-content.xsd* mathml3-strict-content.xsd* % python Python 2.7.1 (r271:86832, Apr 5 2011, 13:19:14) [GCC 4.2.1 20070719 [FreeBSD]] on freebsd8 Type "help", "copyright", "credits" or "license" for more information.
from lxml import etree xsd = 'mathml3.xsd' schema = etree.XMLSchema(etree.parse(xsd)) parser = etree.XMLParser(schema=schema) m = '''<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mstyle displaystyle="true"> <mo>=</mo> <mi>t</mi> <mo>−</mo> <mi>j</mi> </mstyle> </math>''' etree.fromstring(m,parser) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "lxml.etree.pyx", line 2756, in lxml.etree.fromstring (src/lxml/lxml.etree.c:54657) File "parser.pxi", line 1578, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:82774) File "parser.pxi", line 1457, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:81572) File "parser.pxi", line 965, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:78242) File "parser.pxi", line 569, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:74498) File "parser.pxi", line 650, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:75389) File "parser.pxi", line 590, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:74722) lxml.etree.XMLSyntaxError: Entity 'minus' not defined, line 1, column 67
participants (2)
-
Chuck Bearden
-
Tim Arnold