Discussion:
Bad syntax?
(too old to reply)
Chuck Bowling
2005-10-16 00:44:37 UTC
Permalink
I'm not sure what I'm doing wrong but I can't get MathML symbols to work in
Firefox. This is the code I'm trying to run in an *.xml file:

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo> &sum; </mo>
</mrow></math>

It gives me this error:

XML Parsing Error: undefined entity
Location: file:///C:/Documents%20and%20Settings/xx/Desktop/t.xml
Line Number 3, Column 6:<mo> &sum; </mo>
-----^


Anybody know what I'm doing wrong?
Vincent Lefevre
2005-10-16 08:26:19 UTC
Permalink
Post by Chuck Bowling
I'm not sure what I'm doing wrong but I can't get MathML symbols to work in
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo> &sum; </mo>
</mrow></math>
XML Parsing Error: undefined entity
Location: file:///C:/Documents%20and%20Settings/xx/Desktop/t.xml
Line Number 3, Column 6:<mo> &sum; </mo>
-----^
I don't know what Firefox does, but you must define the entities to
be able to use them. This can be done by using a MathML DTD.

BTW, you should also use an XML prolog.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Chuck Bowling
2005-10-16 13:29:36 UTC
Permalink
Post by Vincent Lefevre
Post by Chuck Bowling
I'm not sure what I'm doing wrong but I can't get MathML symbols to work in
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo> &sum; </mo>
</mrow></math>
XML Parsing Error: undefined entity
Location: file:///C:/Documents%20and%20Settings/xx/Desktop/t.xml
Line Number 3, Column 6:<mo> &sum; </mo>
-----^
I don't know what Firefox does, but you must define the entities to
be able to use them. This can be done by using a MathML DTD.
BTW, you should also use an XML prolog.
Thanks. I appreciate the help. Guess it's pretty obvious I'm a complete noob
at this. :)
Alex Milowski
2005-10-16 17:18:30 UTC
Permalink
Post by Vincent Lefevre
Post by Chuck Bowling
I'm not sure what I'm doing wrong but I can't get MathML symbols to work in
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo> &sum; </mo>
</mrow></math>
XML Parsing Error: undefined entity
Location: file:///C:/Documents%20and%20Settings/xx/Desktop/t.xml
Line Number 3, Column 6:<mo> &sum; </mo>
-----^
I don't know what Firefox does, but you must define the entities to
be able to use them. This can be done by using a MathML DTD.
BTW, you should also use an XML prolog.
An alternative to referencing the DTD (as DTD's can be problematic) is
to use unicode character references. You can lookup the mapping at:

http://www.w3.org/TR/MathML2/bycodes.html

You can also use the unicode code pages for reference:

http://www.unicode.org/charts/

With a character reference, your MathML becomes:

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo> &#x2211; </mo>
</mrow></math>

The beauty of this solution is that:

* there are no extra declarations
* you can cut-n-paste this MathML chunk anywhere and not
have to worry about defining characters in the prolog
or DTD.

I have had quite a bit of success using MathML in many different
vocabularies (not just XHTML) with unicode. Most "normal" symbols
used are in unicode 2.0. Unicode 3.0 extends this addition additional
symbols.

Also, if you have a unicode aware authoring tool, you can just insert
the character directly. This is what I do in that I use XMLMind's XML
editor (see www.xmlmind.com) and use their unicode character palette to
insert such characters. In the authoring tool, I just see the character
and not the character reference--which makes things rather nice.

Further, some operating systems (e.g. mac OS X) suppose character
palettes at the OS level. This lets you insert unicode characters
without
the tool have support for browsing character code pages. This works
as long as the tool you use for authoring supports pasting of unicode
characters.

In addition, if there isn't a unicode character (which is possible but
not often the case), you can use mglyph. See:

http://www.w3.org/TR/MathML2/chapter3.html#presm.mglyph

-- Alex Milowski

"The excellence of grammar as a guide is proportional to the paucity
of the
inflexions, i.e. to the degree of analysis effected by the language
considered."

Bertrand Russell in a footnote of Principles of Mathematics
Vincent Lefevre
2005-10-16 23:23:07 UTC
Permalink
Post by Alex Milowski
An alternative to referencing the DTD (as DTD's can be problematic)
is to use unicode character references.
Yes, I have performance problems with DTDs (see below), but each
solution has their own advantages and drawbacks:

* The named entities: it is often easy to know what they mean, but
they require a DTD or an explicit definition in the XML file. In
particular, the MathML DTD is quite large, making the processing
very slow with non highly optimized tools; the solution I have
currently chosen for XSLT is to use an XML catalog that provides
fake DTDs containing only the needed entity definitions and I got
a speed up of a factor 100 for my web site (the original DTD is
based on DocBook and MathML).

* The numeric entities: they work and can be edited everywhere,
with any text editor; this is probably the best solution for
compatibility. But it is difficult to remember what they mean
(unless the editor knows about XML and can show the character
itself -- for instance, Emacs + nxml mode can do this).

* Characters: they don't need a DTD either and they are much more
readable than numeric entities, but it is not always possible to
use them in some limited environments: fonts may be missing and/or
when editing the XML file from a text terminal, the character set
may just be based on ISO-8859-*. Also, it may be difficult to see
the difference between some characters (e.g., all the dashes).

Only the first solution fits my needs for special characters in
XML source files. These source files can then be processed with
XSLT, and either characters or numeric entities are generated.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Alex Milowski
2005-10-17 14:38:26 UTC
Permalink
Actually, I use tools that assume everything is UTF-8. Then I can just
put the character into the document and everything is fine. When I view
the document, the characters are viewed as what they are.

You have to "jump ship" and go into Unicode with all your tools. But in
the end, it is worth it.

I thought that most programming tools have overcome this and done
something
similar. But it seems that this may still be a problem in Emacs
(which is
tool bad). Check out:

http://www.tbray.org/ongoing/When/200x/2003/09/27/UniEmacs

You might check out what Norm Walsh has on this:

http://norman.walsh.name/2003/09/29/xmlchars

He's a big XML/Emacs user. :)


-- Alex Milowski

"The excellence of grammar as a guide is proportional to the paucity
of the
inflexions, i.e. to the degree of analysis effected by the language
considered."

Bertrand Russell in a footnote of Principles of Mathematics
Vincent Lefevre
2005-10-17 15:41:10 UTC
Permalink
Post by Alex Milowski
You have to "jump ship" and go into Unicode with all your tools.
This is not always possible. First zsh doesn't support UTF-8 locales
yet (but UTF-8 support is in progress and it will soon). Then some
accounts don't have support for UTF-8 locales yet either (I could
ask the sysadmin to compile UTF-8 locales, though). Moreover, the
Zaurus original ROM doesn't support UTF-8.
Post by Alex Milowski
I thought that most programming tools have overcome this and done
something similar. But it seems that this may still be a problem in
http://www.tbray.org/ongoing/When/200x/2003/09/27/UniEmacs
I don't have problems with Emacs when the system supports Unicode
(UTF-8 locales, Unicode fonts...).

I'm currently using a mixed environment, with both ISO-8859-1 and
UTF-8.
--
Vincent Lefèvre <***@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Continue reading on narkive:
Loading...