commit 054bdc5d1854b9b1b08735e004a5440bff46531a
Author: Thibaut Cuvelier <cuvelier.thib...@gmail.com>
Date:   Fri May 10 01:52:07 2019 +0200

    MathML stream allows for name spaces.
---
 src/mathed/InsetMath.cpp           |   10 +++---
 src/mathed/InsetMathBig.cpp        |    7 +++--
 src/mathed/InsetMathBoldSymbol.cpp |    6 +++-
 src/mathed/InsetMathBrace.cpp      |    4 +-
 src/mathed/InsetMathCancel.cpp     |    8 +++---
 src/mathed/InsetMathCases.cpp      |    5 +++-
 src/mathed/InsetMathChar.cpp       |    9 ++++--
 src/mathed/InsetMathComment.cpp    |    4 +-
 src/mathed/InsetMathDecoration.cpp |   12 +++++---
 src/mathed/InsetMathDelim.cpp      |   21 ++++++++------
 src/mathed/InsetMathDots.cpp       |    4 +-
 src/mathed/InsetMathDots.h         |    2 +-
 src/mathed/InsetMathEnsureMath.cpp |    6 ++--
 src/mathed/InsetMathExFunc.cpp     |   11 ++++++--
 src/mathed/InsetMathExInt.cpp      |   37 ++++++++++++++++-----------
 src/mathed/InsetMathFont.cpp       |    6 ++--
 src/mathed/InsetMathFrac.cpp       |   50 +++++++++++++++++++----------------
 src/mathed/InsetMathGrid.cpp       |   16 ++++++------
 src/mathed/InsetMathHull.cpp       |   18 ++++++------
 src/mathed/InsetMathMacro.cpp      |    9 +++---
 src/mathed/InsetMathMatrix.cpp     |   22 ++++++++--------
 src/mathed/InsetMathNumber.cpp     |    6 +++-
 src/mathed/InsetMathOverset.cpp    |   10 ++++---
 src/mathed/InsetMathRoot.cpp       |    4 +-
 src/mathed/InsetMathScript.cpp     |   18 ++++++------
 src/mathed/InsetMathSideset.cpp    |   30 +++++++++++-----------
 src/mathed/InsetMathSpace.cpp      |    2 +-
 src/mathed/InsetMathSqrt.cpp       |    4 +-
 src/mathed/InsetMathStackrel.cpp   |    8 ++++-
 src/mathed/InsetMathSubstack.cpp   |    8 +++---
 src/mathed/InsetMathSymbol.cpp     |   12 ++++----
 src/mathed/InsetMathUnderset.cpp   |    4 ++-
 src/mathed/InsetMathXArrow.cpp     |    4 +-
 src/mathed/MathExtern.cpp          |   12 ++++----
 src/mathed/MathStream.cpp          |   31 +++++++++++++++-------
 src/mathed/MathStream.h            |   33 +++++++++++++++++++++---
 36 files changed, 265 insertions(+), 188 deletions(-)

diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 8706001..8228153 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -153,13 +153,13 @@ void InsetMath::mathematica(MathematicaStream & os) const
 }
 
 
-void InsetMath::mathmlize(MathStream & os) const
+void InsetMath::mathmlize(MathStream & ms) const
 {
-       os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
-       os << MTag("mi");
-       NormalStream ns(os.os());
+       ms << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
+       ms << MTag("mi");
+       NormalStream ns(ms.os());
        normalize(ns);
-       os << ETag("mi");
+       ms << ETag("mi");
 }
 
 
diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index 889f8d4..5e89d4e 100644
--- a/src/mathed/InsetMathBig.cpp
+++ b/src/mathed/InsetMathBig.cpp
@@ -135,11 +135,12 @@ void InsetMathBig::normalize(NormalStream & os) const
 }
 
 
-void InsetMathBig::mathmlize(MathStream & os) const
+void InsetMathBig::mathmlize(MathStream & ms) const
 {
-       os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>"
+       ms << "<" << from_ascii(ms.namespacedTag("mo"))
+          << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
           << convertDelimToXMLEscape(delim_)
-          << "</mo>";
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathBoldSymbol.cpp 
b/src/mathed/InsetMathBoldSymbol.cpp
index 62f8098..5dbe1fd 100644
--- a/src/mathed/InsetMathBoldSymbol.cpp
+++ b/src/mathed/InsetMathBoldSymbol.cpp
@@ -107,9 +107,11 @@ void InsetMathBoldSymbol::write(WriteStream & os) const
 }
 
 
-void InsetMathBoldSymbol::mathmlize(MathStream & os) const
+void InsetMathBoldSymbol::mathmlize(MathStream & ms) const
 {
-       os << "<mstyle mathvariant='bold'>" << cell(0) << "</mstyle>";
+       ms << "<" << from_ascii(ms.namespacedTag("mstyle")) << " 
mathvariant='bold'>"
+          << cell(0)
+          << "</" << from_ascii(ms.namespacedTag("mstyle")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathBrace.cpp b/src/mathed/InsetMathBrace.cpp
index 3a452c0..a31a759 100644
--- a/src/mathed/InsetMathBrace.cpp
+++ b/src/mathed/InsetMathBrace.cpp
@@ -96,9 +96,9 @@ void InsetMathBrace::octave(OctaveStream & os) const
 }
 
 
-void InsetMathBrace::mathmlize(MathStream & os) const
+void InsetMathBrace::mathmlize(MathStream & ms) const
 {
-       os << MTag("mrow") << cell(0) << ETag("mrow");
+       ms << MTag("mrow") << cell(0) << ETag("mrow");
 }
 
 
diff --git a/src/mathed/InsetMathCancel.cpp b/src/mathed/InsetMathCancel.cpp
index 25728a3..ee82d0c 100644
--- a/src/mathed/InsetMathCancel.cpp
+++ b/src/mathed/InsetMathCancel.cpp
@@ -138,21 +138,21 @@ void InsetMathCancel::htmlize(HtmlStream & os) const
 }
 
 
-void InsetMathCancel::mathmlize(MathStream & os) const
+void InsetMathCancel::mathmlize(MathStream & ms) const
 {
        switch (kind_) {
        case cancel:
-               os << MTag("menclose", "notation='updiagonalstrike'")
+               ms << MTag("menclose", "notation='updiagonalstrike'")
                   << cell(0)
                   << ETag("menclose");
                break;
        case bcancel:
-               os << MTag("menclose", "notation='downdiagonalstrike'")
+               ms << MTag("menclose", "notation='downdiagonalstrike'")
                   << cell(0)
                   << ETag("menclose");
                break;
        case xcancel:
-               os << MTag("menclose", "notation='updiagonalstrike'")
+               ms << MTag("menclose", "notation='updiagonalstrike'")
                   << MTag("menclose", "notation='downdiagonalstrike'")
                   << cell(0)
                   << ETag("menclose")
diff --git a/src/mathed/InsetMathCases.cpp b/src/mathed/InsetMathCases.cpp
index 0a5fa33..5ddb9d0 100644
--- a/src/mathed/InsetMathCases.cpp
+++ b/src/mathed/InsetMathCases.cpp
@@ -145,7 +145,10 @@ void InsetMathCases::maple(MapleStream & os) const
 
 void InsetMathCases::mathmlize(MathStream & ms) const
 {
-       ms << "<mo form='prefix' fence='true' stretchy='true' 
symmetric='true'>{</mo>";
+       ms << "<" << from_ascii(ms.namespacedTag("mo"))
+          << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
+          << "{"
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
        InsetMathGrid::mathmlize(ms);
 }
 
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 1137c95..7069bdc 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -239,15 +239,18 @@ void InsetMathChar::mathmlize(MathStream & ms) const
        }
 
        if (!entity.empty()) {
-               ms << "<mo>" << from_ascii(entity) << "</mo>";
+               ms << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+                  << from_ascii(entity)
+                  << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
                return;
        }
 
        char const * type =
                (isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
                        ? "mi" : "mo";
-       // we don't use MTag and ETag because we do not want the spacing
-       ms << "<" << type << ">" << char_type(char_) << "</" << type << ">";
+       // we don't use MTag and ETag because we do not want the spacing before 
the end tag.
+       docstring tag = from_ascii(ms.namespacedTag(type));
+       ms << "<" << tag << ">" << char_type(char_) << "</" << tag << ">";
 }
 
 
diff --git a/src/mathed/InsetMathComment.cpp b/src/mathed/InsetMathComment.cpp
index ea502d1..1a248eb 100644
--- a/src/mathed/InsetMathComment.cpp
+++ b/src/mathed/InsetMathComment.cpp
@@ -83,9 +83,9 @@ void InsetMathComment::maple(MapleStream & os) const
 }
 
 
-void InsetMathComment::mathmlize(MathStream & os) const
+void InsetMathComment::mathmlize(MathStream & ms) const
 {
-       os << MTag("comment") << cell(0) << ETag("comment");
+       ms << MTag("comment") << cell(0) << ETag("comment");
 }
 
 
diff --git a/src/mathed/InsetMathDecoration.cpp 
b/src/mathed/InsetMathDecoration.cpp
index afb8228..685e65d 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -218,16 +218,18 @@ namespace {
        }
 } // namespace
 
-void InsetMathDecoration::mathmlize(MathStream & os) const
+void InsetMathDecoration::mathmlize(MathStream & ms) const
 {
        TranslationMap const & t = translationMap();
        TranslationMap::const_iterator cur = t.find(to_utf8(key_->name));
        LASSERT(cur != t.end(), return);
        char const * const outag = cur->second.over ? "mover" : "munder";
-       os << MTag(outag)
-                << MTag("mrow") << cell(0) << ETag("mrow")
-                << from_ascii("<mo stretchy=\"true\">" + cur->second.tag + 
"</mo>")
-                << ETag(outag);
+       ms << MTag(outag)
+          << MTag("mrow") << cell(0) << ETag("mrow")
+          << "<" << from_ascii(ms.namespacedTag("mo")) << " stretchy=\"true\">"
+          << from_ascii(cur->second.tag)
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << ETag(outag);
 }
 
 
diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index 1989d48..95b533b 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -179,19 +179,22 @@ void InsetMathDelim::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathDelim::mathmlize(MathStream & os) const
+void InsetMathDelim::mathmlize(MathStream & ms) const
 {
-       os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>"
-          << "<mrow>"
+       ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' 
fence='true' stretchy='true' symmetric='true'>"
+          << "<" << from_ascii(ms.namespacedTag("mrow")) << ">"
           << convertDelimToXMLEscape(left_)
-          << "</mrow>"
-          << "</mo>\n"
+          << "</" << from_ascii(ms.namespacedTag("mrow")) << ">"
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << "\n"
           << cell(0)
-          << "\n<mo form='postfix' fence='true' stretchy='true' 
symmetric='true'>"
-          << "<mrow>"
+          << "\n"
+          << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' 
fence='true' stretchy='true' symmetric='true'>"
+          << "<" << from_ascii(ms.namespacedTag("mrow")) << ">"
           << convertDelimToXMLEscape(right_)
-          << "</mrow>"
-          << "</mo>\n";
+          << "</" << from_ascii(ms.namespacedTag("mrow")) << ">"
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << "\n";
 }
 
 
diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp
index 3679771..6ec3661 100644
--- a/src/mathed/InsetMathDots.cpp
+++ b/src/mathed/InsetMathDots.cpp
@@ -85,7 +85,7 @@ void InsetMathDots::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetMathDots::mathmlize(MathStream & os) const
+void InsetMathDots::mathmlize(MathStream & ms) const
 {
        // which symbols we support is decided by what is listed in
        // lib/symbols as generating a dots inset
@@ -103,7 +103,7 @@ void InsetMathDots::mathmlize(MathStream & os) const
                ent = "&vellip;";
        else
                LASSERT(false, ent = "&hellip;");
-       os << MTag("mi") << from_ascii(ent) << ETag("mi");
+       ms << MTag("mi") << from_ascii(ent) << ETag("mi");
 }
 
 
diff --git a/src/mathed/InsetMathDots.h b/src/mathed/InsetMathDots.h
index 8a84a22..9155f7e 100644
--- a/src/mathed/InsetMathDots.h
+++ b/src/mathed/InsetMathDots.h
@@ -35,7 +35,7 @@ public:
        ///
        InsetCode lyxCode() const { return MATH_DOTS_CODE; }
        ///
-       void mathmlize(MathStream & os) const;
+       void mathmlize(MathStream & ms) const;
        ///
        void htmlize(HtmlStream & os) const;
 protected:
diff --git a/src/mathed/InsetMathEnsureMath.cpp 
b/src/mathed/InsetMathEnsureMath.cpp
index 8bd685c..55c7be7 100644
--- a/src/mathed/InsetMathEnsureMath.cpp
+++ b/src/mathed/InsetMathEnsureMath.cpp
@@ -69,10 +69,10 @@ void InsetMathEnsureMath::write(WriteStream & os) const
 }
 
 
-void InsetMathEnsureMath::mathmlize(MathStream & os) const
+void InsetMathEnsureMath::mathmlize(MathStream & ms) const
 {
-       SetMode mathmode(os, false);
-       os << MTag("mstyle", "class='math'")
+       SetMode mathmode(ms, false);
+       ms << MTag("mstyle", "class='math'")
           << cell(0)
           << ETag("mstyle");
 }
diff --git a/src/mathed/InsetMathExFunc.cpp b/src/mathed/InsetMathExFunc.cpp
index e4e1f10..9782e25 100644
--- a/src/mathed/InsetMathExFunc.cpp
+++ b/src/mathed/InsetMathExFunc.cpp
@@ -122,10 +122,15 @@ void InsetMathExFunc::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathExFunc::mathmlize(MathStream & os) const
+void InsetMathExFunc::mathmlize(MathStream & ms) const
 {
-       os << "<mi>" << name_ << "</mi><mo>&af;</mo>";
-       os << cell(0);
+       ms << "<" << from_ascii(ms.namespacedTag("mi")) << ">"
+          << name_
+       << "</" << from_ascii(ms.namespacedTag("mi")) << ">"
+          << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << "&af;"
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << cell(0);
 }
 
 
diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp
index 35bee0e..537870f 100644
--- a/src/mathed/InsetMathExInt.cpp
+++ b/src/mathed/InsetMathExInt.cpp
@@ -124,7 +124,7 @@ void InsetMathExInt::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathExInt::mathmlize(MathStream & os) const
+void InsetMathExInt::mathmlize(MathStream & ms) const
 {
        // At the moment, we are not extracting sums and the like for MathML.
        // If we should decide to do so later, then we'll need to re-merge
@@ -134,27 +134,34 @@ void InsetMathExInt::mathmlize(MathStream & os) const
        bool const lower = !cell(2).empty();
        bool const upper = !cell(3).empty();
        if (lower && upper)
-               os << MTag("msubsup");
+               ms << MTag("msubsup");
        else if (lower)
-               os << MTag("msub");
+               ms << MTag("msub");
        else if (upper)
-               os << MTag("msup");
-       os << MTag("mrow");
-       sym.mathmlize(os);
-       os << ETag("mrow");
+               ms << MTag("msup");
+       ms << MTag("mrow");
+       sym.mathmlize(ms);
+       ms << ETag("mrow");
        if (lower)
-               os << MTag("mrow") << cell(2) << ETag("mrow");
+               ms << MTag("mrow") << cell(2) << ETag("mrow");
        if (upper)
-               os << MTag("mrow") << cell(3) << ETag("mrow");
+               ms << MTag("mrow") << cell(3) << ETag("mrow");
        if (lower && upper)
-               os << ETag("msubsup");
+               ms << ETag("msubsup");
        else if (lower)
-               os << ETag("msub");
+               ms << ETag("msub");
        else if (upper)
-               os << ETag("msup");
-       os << cell(0) << "<mo> &InvisibleTimes; </mo>"
-          << MTag("mrow") << "<mo> &DifferentialD; </mo>"
-          << cell(1) << ETag("mrow");
+               ms << ETag("msup");
+       ms << cell(0)
+          << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
+          << " &InvisibleTimes; "
+       << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << MTag("mrow")
+          << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
+          << " &DifferentialD; "
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << cell(1)
+          << ETag("mrow");
 }
 
 
diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp
index 6611590..f199ee5 100644
--- a/src/mathed/InsetMathFont.cpp
+++ b/src/mathed/InsetMathFont.cpp
@@ -193,7 +193,7 @@ void InsetMathFont::htmlize(HtmlStream & os) const
 
 
 // The fonts we want to support are listed in lib/symbols
-void InsetMathFont::mathmlize(MathStream & os) const
+void InsetMathFont::mathmlize(MathStream & ms) const
 {
        // FIXME These are not quite right, because they do not nest
        // correctly. A proper fix would presumably involve tracking
@@ -224,11 +224,11 @@ void InsetMathFont::mathmlize(MathStream & os) const
        // no support at present for textipa, textsc, noun
 
        if (!variant.empty())
-               os << MTag("mstyle", "mathvariant='" + variant + "'")
+               ms << MTag("mstyle", "mathvariant='" + variant + "'")
                   << cell(0)
                   << ETag("mstyle");
        else
-               os << cell(0);
+               ms << cell(0);
 }
 
 
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 7a281a3..90d507c 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -491,14 +491,14 @@ void InsetMathFrac::octave(OctaveStream & os) const
 }
 
 
-void InsetMathFrac::mathmlize(MathStream & os) const
+void InsetMathFrac::mathmlize(MathStream & ms) const
 {
        switch (kind_) {
        case ATOP:
-               os << MTag("mfrac", "linethickeness='0'")
+               ms << MTag("mfrac", "linethickness='0'")
                   << MTag("mrow") << cell(0) << ETag("mrow")
-                        << MTag("mrow") << cell(1) << ETag("mrow")
-                        << ETag("mfrac");
+                  << MTag("mrow") << cell(1) << ETag("mrow")
+                  << ETag("mfrac");
                break;
 
        // we do not presently distinguish these
@@ -509,38 +509,38 @@ void InsetMathFrac::mathmlize(MathStream & os) const
        case CFRAC:
        case CFRACLEFT:
        case CFRACRIGHT:
-               os << MTag("mfrac")
+               ms << MTag("mfrac")
                   << MTag("mrow") << cell(0) << ETag("mrow")
-                        << MTag("mrow") << cell(1) << ETag("mrow")
-                        << ETag("mfrac");
+                  << MTag("mrow") << cell(1) << ETag("mrow")
+                  << ETag("mfrac");
                break;
 
        case NICEFRAC:
-               os << MTag("mfrac", "bevelled='true'")
+               ms << MTag("mfrac", "bevelled='true'")
                   << MTag("mrow") << cell(0) << ETag("mrow")
-                        << MTag("mrow") << cell(1) << ETag("mrow")
-                        << ETag("mfrac");
+                  << MTag("mrow") << cell(1) << ETag("mrow")
+                  << ETag("mfrac");
                break;
 
        case UNITFRAC:
                if (nargs() == 3)
-                       os << cell(2);
-               os << MTag("mfrac", "bevelled='true'")
+                       ms << cell(2);
+               ms << MTag("mfrac", "bevelled='true'")
                   << MTag("mrow") << cell(0) << ETag("mrow")
-                        << MTag("mrow") << cell(1) << ETag("mrow")
-                        << ETag("mfrac");
+                  << MTag("mrow") << cell(1) << ETag("mrow")
+                  << ETag("mfrac");
                break;
 
        case UNIT:
                // FIXME This is not right, because we still output mi, etc,
                // when we output the cell. So we need to prevent that somehow.
                if (nargs() == 2)
-                       os << cell(0)
-                          << MTag("mstyle mathvariant='normal'")
-                          << cell(1)
+                       ms << cell(0)
+                          << MTag("mstyle mathvariant='normal'") 
+                          << cell(1) 
                           << ETag("mstyle");
                else
-                       os << MTag("mstyle mathvariant='normal'")
+                       ms << MTag("mstyle mathvariant='normal'")
                           << cell(0)
                           << ETag("mstyle");
        }
@@ -730,7 +730,7 @@ void InsetMathBinom::normalize(NormalStream & os) const
 }
 
 
-void InsetMathBinom::mathmlize(MathStream & os) const
+void InsetMathBinom::mathmlize(MathStream & ms) const
 {
        char ldelim = ' ';
        char rdelim = ' ';
@@ -751,11 +751,15 @@ void InsetMathBinom::mathmlize(MathStream & os) const
                rdelim = ']';
                break;
        }
-       os << "<mo fence='true' stretchy='true' form='prefix'>" << ldelim << 
"</mo>"
-          << "<mfrac linethickness='0'>"
+       ms << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' 
stretchy='true' form='prefix'>"
+          << ldelim
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+          << "<" << from_ascii(ms.namespacedTag("mfrac")) << " 
linethickness='0'>"
           << cell(0) << cell(1)
-          << "</mfrac>"
-          << "<mo fence='true' stretchy='true' form='postfix'>" << rdelim << 
"</mo>";
+       << "</" << from_ascii(ms.namespacedTag("mfrac")) << ">"
+          << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' 
stretchy='true' form='postfix'>"
+          << rdelim
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index b6d90ee..d6f275a 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1184,15 +1184,15 @@ void InsetMathGrid::normalize(NormalStream & os) const
 }
 
 
-void InsetMathGrid::mathmlize(MathStream & os) const
+void InsetMathGrid::mathmlize(MathStream & ms) const
 {
        bool const havetable = nrows() > 1 || ncols() > 1;
        if (havetable)
-               os << MTag("mtable");
+               ms << MTag("mtable");
        char const * const celltag = havetable ? "mtd" : "mrow";
        for (row_type row = 0; row < nrows(); ++row) {
                if (havetable)
-                       os << MTag("mtr");
+                       ms << MTag("mtr");
                for (col_type col = 0; col < ncols(); ++col) {
                        idx_type const i = index(row, col);
                        if (cellinfo_[i].multi != CELL_PART_OF_MULTICOLUMN) {
@@ -1200,16 +1200,16 @@ void InsetMathGrid::mathmlize(MathStream & os) const
                                ostringstream attr;
                                if (havetable && cellcols > 1)
                                        attr << "colspan='" << cellcols << '\'';
-                               os << MTag(celltag, attr.str());
-                               os << cell(index(row, col));
-                               os << ETag(celltag);
+                               ms << MTag(celltag, attr.str());
+                               ms << cell(index(row, col));
+                               ms << ETag(celltag);
                        }
                }
                if (havetable)
-                       os << ETag("mtr");
+                       ms << ETag("mtr");
        }
        if (havetable)
-               os << ETag("mtable");
+               ms << ETag("mtable");
 }
 
 
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index a117af6..465ba64 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -2517,13 +2517,13 @@ void InsetMathHull::htmlize(HtmlStream & os) const
 // this duplicates code from InsetMathGrid, but
 // we need access here to number information,
 // and we simply do not have that in InsetMathGrid.
-void InsetMathHull::mathmlize(MathStream & os) const
+void InsetMathHull::mathmlize(MathStream & ms) const
 {
        bool const havenumbers = haveNumbers();
        bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
 
        if (havetable)
-               os << MTag("mtable");
+               ms << MTag("mtable");
        char const * const celltag = havetable ? "mtd" : "mrow";
        // FIXME There does not seem to be wide support at the moment
        // for mlabeledtr, so we have to use just mtr for now.
@@ -2531,25 +2531,25 @@ void InsetMathHull::mathmlize(MathStream & os) const
        char const * const rowtag = "mtr";
        for (row_type row = 0; row < nrows(); ++row) {
                if (havetable)
-                       os << MTag(rowtag);
+                       ms << MTag(rowtag);
                for (col_type col = 0; col < ncols(); ++col) {
-                       os << MTag(celltag)
+                       ms << MTag(celltag)
                           << cell(index(row, col))
                           << ETag(celltag);
                }
                // fleqn?
                if (havenumbers) {
-                       os << MTag("mtd");
+                       ms << MTag("mtd");
                        docstring const & num = numbers_[row];
                        if (!num.empty())
-                               os << '(' << num << ')';
-                 os << ETag("mtd");
+                               ms << '(' << num << ')';
+                 ms << ETag("mtd");
                }
                if (havetable)
-                       os << ETag(rowtag);
+                       ms << ETag(rowtag);
        }
        if (havetable)
-               os << ETag("mtable");
+               ms << ETag("mtable");
 }
 
 
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index bdf8625..3cabf6a 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -1176,7 +1176,7 @@ void InsetMathMacro::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathMacro::mathmlize(MathStream & os) const
+void InsetMathMacro::mathmlize(MathStream & ms) const
 {
        // macro_ is 0 if this is an unknown macro
        LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL);
@@ -1184,8 +1184,9 @@ void InsetMathMacro::mathmlize(MathStream & os) const
                docstring const xmlname = d->macro_->xmlname();
                if (!xmlname.empty()) {
                        char const * type = d->macro_->MathMLtype();
-                       os << '<' << type << "> " << xmlname << " </"
-                          << type << '>';
+                       ms << "<" << from_ascii(ms.namespacedTag(type)) << ">"
+                          << xmlname
+                          << "</" << from_ascii(ms.namespacedTag(type)) << ">";
                        return;
                }
        }
@@ -1193,7 +1194,7 @@ void InsetMathMacro::mathmlize(MathStream & os) const
                // this means that we do not recognize the macro
                throw MathExportException();
        }
-       os << d->expanded_;
+       ms << d->expanded_;
 }
 
 
diff --git a/src/mathed/InsetMathMatrix.cpp b/src/mathed/InsetMathMatrix.cpp
index b13d006..a499903 100644
--- a/src/mathed/InsetMathMatrix.cpp
+++ b/src/mathed/InsetMathMatrix.cpp
@@ -92,14 +92,14 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathMatrix::mathmlize(MathStream & os) const
+void InsetMathMatrix::mathmlize(MathStream & ms) const
 {
-       os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' 
lspace='thinmathspace'>"
-          << convertDelimToXMLEscape(left_)
-          << "</mo>"
+       ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' 
fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << convertDelimToXMLEscape(left_) 
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
           << MTag("mtable");
        for (row_type row = 0; row < nrows(); ++row) {
-               os << MTag("mtr");
+               ms << MTag("mtr");
                for (col_type col = 0; col < ncols(); ++col) {
                        idx_type const i = index(row, col);
                        if (cellinfo(i).multi != CELL_PART_OF_MULTICOLUMN) {
@@ -107,15 +107,15 @@ void InsetMathMatrix::mathmlize(MathStream & os) const
                                ostringstream attr;
                                if (cellcols > 1)
                                        attr << "columnspan='" << cellcols << 
'\'';
-                               os << MTag("mtd", attr.str()) << cell(i) << 
ETag("mtd");
+                               ms << MTag("mtd", attr.str()) << cell(i) << 
ETag("mtd");
                        }
                }
-               os << ETag("mtr");
+               ms << ETag("mtr");
        }
-       os << ETag("mtable");
-       os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' 
lspace='thinmathspace'>"
-          << convertDelimToXMLEscape(right_)
-          << "</mo>";
+       ms << ETag("mtable")
+          << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' 
fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+          << convertDelimToXMLEscape(right_) 
+          << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathNumber.cpp b/src/mathed/InsetMathNumber.cpp
index 5237ceb..5a35415 100644
--- a/src/mathed/InsetMathNumber.cpp
+++ b/src/mathed/InsetMathNumber.cpp
@@ -69,9 +69,11 @@ void InsetMathNumber::octave(OctaveStream & os) const
 }
 
 
-void InsetMathNumber::mathmlize(MathStream & os) const
+void InsetMathNumber::mathmlize(MathStream & ms) const
 {
-       os << "<mn>" << str_ << "</mn>";
+       ms << "<" << from_ascii(ms.namespacedTag("mn")) << ">"
+          << str_
+          << "</" << from_ascii(ms.namespacedTag("mn")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp
index 3d36218..2db26cf 100644
--- a/src/mathed/InsetMathOverset.cpp
+++ b/src/mathed/InsetMathOverset.cpp
@@ -105,16 +105,18 @@ void InsetMathOverset::normalize(NormalStream & os) const
 
 void InsetMathOverset::mathmlize(MathStream & ms) const
 {
-       ms << "<mover accent='false'>" << cell(0) << cell(1) << "</mover>";
+       ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>"
+          << cell(0) << cell(1)
+          << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
 }
 
 
 void InsetMathOverset::htmlize(HtmlStream & os) const
 {
        os << MTag("span", "class='overset'")
-                << MTag("span", "class='top'") << cell(1) << ETag("span")
-                << MTag("span") << cell(0) << ETag("span")
-                << ETag("span");
+          << MTag("span", "class='top'") << cell(1) << ETag("span")
+          << MTag("span") << cell(0) << ETag("span")
+          << ETag("span");
 }
 
 
diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp
index 6661d85..de4253e 100644
--- a/src/mathed/InsetMathRoot.cpp
+++ b/src/mathed/InsetMathRoot.cpp
@@ -216,9 +216,9 @@ void InsetMathRoot::octave(OctaveStream & os) const
 }
 
 
-void InsetMathRoot::mathmlize(MathStream & os) const
+void InsetMathRoot::mathmlize(MathStream & ms) const
 {
-       os << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
+       ms << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
 }
 
 
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 2f66b0f..bc19868 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -612,32 +612,32 @@ void InsetMathScript::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathScript::mathmlize(MathStream & os) const
+void InsetMathScript::mathmlize(MathStream & ms) const
 {
        bool d = hasDown() && !down().empty();
        bool u = hasUp() && !up().empty();
        bool l = hasLimits();
 
        if (u && d)
-               os << MTag(l ? "munderover" : "msubsup");
+               ms << MTag(l ? "munderover" : "msubsup");
        else if (u)
-               os << MTag(l ? "mover" : "msup");
+               ms << MTag(l ? "mover" : "msup");
        else if (d)
-               os << MTag(l ? "munder" : "msub");
+               ms << MTag(l ? "munder" : "msub");
 
        if (!nuc().empty())
-               os << MTag("mrow") << nuc() << ETag("mrow");
+               ms << MTag("mrow") << nuc() << ETag("mrow");
        else
-               os << "<mrow />";
+               ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " />";
 
        if (u && d)
-               os << MTag("mrow") << down() << ETag("mrow")
+               ms << MTag("mrow") << down() << ETag("mrow")
                   << MTag("mrow") << up() << ETag("mrow")
                   << ETag(l ? "munderover" : "msubsup");
        else if (u)
-               os << MTag("mrow") << up() << ETag("mrow") << ETag(l ? "mover" 
: "msup");
+               ms << MTag("mrow") << up() << ETag("mrow") << ETag(l ? "mover" 
: "msup");
        else if (d)
-               os << MTag("mrow") << down() << ETag("mrow") << ETag(l ? 
"munder" : "msub");
+               ms << MTag("mrow") << down() << ETag("mrow") << ETag(l ? 
"munder" : "msub");
 }
 
 
diff --git a/src/mathed/InsetMathSideset.cpp b/src/mathed/InsetMathSideset.cpp
index ccbab52..642e07c 100644
--- a/src/mathed/InsetMathSideset.cpp
+++ b/src/mathed/InsetMathSideset.cpp
@@ -385,41 +385,41 @@ void InsetMathSideset::normalize(NormalStream & os) const
 }
 
 
-void InsetMathSideset::mathmlize(MathStream & os) const
+void InsetMathSideset::mathmlize(MathStream & ms) const
 {
        // FIXME This is only accurate if both scriptl_ and scriptr_ are true
        if (!scriptl_)
-               os << MTag("mrow") << bl() << ETag("mrow");
+               ms << MTag("mrow") << bl() << ETag("mrow");
        if (scriptl_ || scriptr_) {
-               os << MTag("mmultiscripts");
+               ms << MTag("mmultiscripts");
 
                if (nuc().empty())
-                       os << "<mrow />";
+                       ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " 
/>";
                else
-                       os << MTag("mrow") << nuc() << ETag("mrow");
+                       ms << MTag("mrow") << nuc() << ETag("mrow");
 
                if (br().empty() || !scriptr_)
-                       os << "<none />";
+                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " 
/>";
                else
-                       os << MTag("mrow") << br() << ETag("mrow");
+                       ms << MTag("mrow") << br() << ETag("mrow");
                if (tr().empty() || !scriptr_)
-                       os << "<none />";
+                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " 
/>";
                else
-                       os << MTag("mrow") << tr() << ETag("mrow");
+                       ms << MTag("mrow") << tr() << ETag("mrow");
 
                if (bl().empty() || !scriptl_)
-                       os << "<none />";
+                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " 
/>";
                else
-                       os << MTag("mrow") << bl() << ETag("mrow");
+                       ms << MTag("mrow") << bl() << ETag("mrow");
                if (tl().empty() || !scriptl_)
-                       os << "<none />";
+                       ms << "<" << from_ascii(ms.namespacedTag("none")) << " 
/>";
                else
-                       os << MTag("mrow") << tl() << ETag("mrow");
+                       ms << MTag("mrow") << tl() << ETag("mrow");
 
-               os << ETag("mmultiscripts");
+               ms << ETag("mmultiscripts");
        }
        if (!scriptr_)
-               os << MTag("mrow") << br() << ETag("mrow");
+               ms << MTag("mrow") << br() << ETag("mrow");
 }
 
 
diff --git a/src/mathed/InsetMathSpace.cpp b/src/mathed/InsetMathSpace.cpp
index db09609..8e76486 100644
--- a/src/mathed/InsetMathSpace.cpp
+++ b/src/mathed/InsetMathSpace.cpp
@@ -209,7 +209,7 @@ void InsetMathSpace::mathmlize(MathStream & ms) const
                l = ss.str() + "px";
        }
 
-       ms << "<mspace";
+       ms << "<" << from_ascii(ms.namespacedTag("mspace"));
        if (!l.empty())
                ms << " width=\"" << from_ascii(l) << "\"";
        ms << " />";
diff --git a/src/mathed/InsetMathSqrt.cpp b/src/mathed/InsetMathSqrt.cpp
index 7416c33..23d28e8 100644
--- a/src/mathed/InsetMathSqrt.cpp
+++ b/src/mathed/InsetMathSqrt.cpp
@@ -98,9 +98,9 @@ void InsetMathSqrt::octave(OctaveStream & os) const
 }
 
 
-void InsetMathSqrt::mathmlize(MathStream & os) const
+void InsetMathSqrt::mathmlize(MathStream & ms) const
 {
-       os << MTag("msqrt") << cell(0) << ETag("msqrt");
+       ms << MTag("msqrt") << cell(0) << ETag("msqrt");
 }
 
 
diff --git a/src/mathed/InsetMathStackrel.cpp b/src/mathed/InsetMathStackrel.cpp
index 430d8f1..53e3075 100644
--- a/src/mathed/InsetMathStackrel.cpp
+++ b/src/mathed/InsetMathStackrel.cpp
@@ -144,9 +144,13 @@ void InsetMathStackrel::normalize(NormalStream & os) const
 void InsetMathStackrel::mathmlize(MathStream & ms) const
 {
        if (nargs() > 2)
-               ms << "<munderover>" << cell(0) << cell(2) << cell(1) << 
"</munderover>";
+               ms << "<" << from_ascii(ms.namespacedTag("munderover")) << ">"
+                  << cell(0) << cell(2) << cell(1)
+                  << "</" << from_ascii(ms.namespacedTag("munderover")) << ">";
        else
-               ms << "<mover accent='false'>" << cell(0) << cell(1) << 
"</mover>";
+               ms << "<" << from_ascii(ms.namespacedTag("mover")) << " 
accent='false'>"
+                  << cell(0) << cell(1)
+                  << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathSubstack.cpp b/src/mathed/InsetMathSubstack.cpp
index fb29077..f9dfb01 100644
--- a/src/mathed/InsetMathSubstack.cpp
+++ b/src/mathed/InsetMathSubstack.cpp
@@ -125,19 +125,19 @@ void InsetMathSubstack::maple(MapleStream & os) const
 }
 
 
-void InsetMathSubstack::mathmlize(MathStream & os) const
+void InsetMathSubstack::mathmlize(MathStream & ms) const
 {
        int movers = 0;
        row_type const numrows = nrows();
        for (row_type row = 0; row < nrows(); ++row) {
                if (row < numrows - 1) {
                        movers ++;
-                       os << MTag("munder");
+                       ms << MTag("munder");
                }
-               os << MTag("mrow") << cell(index(row, 0)) << ETag("mrow");
+               ms << MTag("mrow") << cell(index(row, 0)) << ETag("mrow");
        }
        for (int i = 1; i <= movers; ++i)
-               os << ETag("munder");
+               ms << ETag("munder");
 }
 
 
diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp
index b3b44bf..4a7a338 100644
--- a/src/mathed/InsetMathSymbol.cpp
+++ b/src/mathed/InsetMathSymbol.cpp
@@ -162,18 +162,18 @@ void InsetMathSymbol::mathematica(MathematicaStream & os) 
const
 }
 
 
-void InsetMathSymbol::mathmlize(MathStream & os) const
+void InsetMathSymbol::mathmlize(MathStream & ms) const
 {
        // FIXME We may need to do more interesting things
        // with MathMLtype.
-       char const * type = sym_->MathMLtype();
-       os << '<' << type << "> ";
+       docstring tag = from_ascii(ms.namespacedTag(sym_->MathMLtype()));
+       ms << '<' << tag << ">";
        if (sym_->xmlname == "x")
                // unknown so far
-               os << name();
+               ms << name();
        else
-               os << sym_->xmlname;
-       os << " </" << type << '>';
+               ms << sym_->xmlname;
+       ms << "</" << tag << '>';
 }
 
 
diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp
index 832631d..2c38e30 100644
--- a/src/mathed/InsetMathUnderset.cpp
+++ b/src/mathed/InsetMathUnderset.cpp
@@ -94,7 +94,9 @@ void InsetMathUnderset::normalize(NormalStream & os) const
 
 void InsetMathUnderset::mathmlize(MathStream & ms) const
 {
-       ms << "<munder accent='false'>" << cell(0) << cell(1) << "</munder>";
+       ms << "<" << from_ascii(ms.namespacedTag("munder")) << " 
accent='false'>"
+          << cell(0) << cell(1)
+          << "</" << from_ascii(ms.namespacedTag("munder")) << ">";
 }
 
 
diff --git a/src/mathed/InsetMathXArrow.cpp b/src/mathed/InsetMathXArrow.cpp
index 55f2665..2ea3b71 100644
--- a/src/mathed/InsetMathXArrow.cpp
+++ b/src/mathed/InsetMathXArrow.cpp
@@ -123,9 +123,9 @@ void InsetMathXArrow::mathmlize(MathStream & ms) const
                lyxerr << "mathmlize conversion for '" << name_ << "' not 
implemented" << endl;
                LASSERT(false, arrow = "&rarr;");
        }
-       ms << "<munderover accent='false' accentunder='false'>"
+       ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " 
accent='false' accentunder='false'>"
           << arrow << cell(1) << cell(0)
-          << "</munderover>";
+          << "</" << from_ascii(ms.namespacedTag("munderover"))<< ">";
 }
 
 
diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 504fab7..46c5448 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1586,19 +1586,19 @@ void mathematica(MathData const & dat, 
MathematicaStream & os)
 }
 
 
-void mathmlize(MathData const & dat, MathStream & os)
+void mathmlize(MathData const & dat, MathStream & ms)
 {
        MathData ar = dat;
        extractStructure(ar, MATHML);
        if (ar.empty())
-               os << "<mrow/>";
+               ms << "<" << from_ascii(ms.namespacedTag("mrow")) << "/>";
        else if (ar.size() == 1)
-               os << ar.front();
+               ms << ar.front();
        else {
-               os << MTag("mrow");
+               ms << MTag("mrow");
                for (MathData::const_iterator it = ar.begin(); it != ar.end(); 
++it)
-                       (*it)->mathmlize(os);
-               os << ETag("mrow");
+                       (*it)->mathmlize(ms);
+               ms << ETag("mrow");
        }
 }
 
diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 9a6c32c..6cf1a99 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -269,8 +269,8 @@ WriteStream & operator<<(WriteStream & ws, unsigned int i)
 //////////////////////////////////////////////////////////////////////
 
 
-MathStream::MathStream(odocstream & os)
-       : os_(os), tab_(0), line_(0), in_text_(false)
+MathStream::MathStream(odocstream & os, std::string xmlns)
+       : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
 {}
 
 
@@ -339,10 +339,10 @@ MathStream & operator<<(MathStream & ms, MTag const & t)
 {
        ++ms.tab();
        ms.cr();
-       ms.os() << '<' << from_ascii(t.tag_);
+       ms.os() << '<' << from_ascii(ms.namespacedTag(t.tag_));
        if (!t.attr_.empty())
                ms.os() << " " << from_ascii(t.attr_);
-       ms << '>';
+       ms << ">";
        return ms;
 }
 
@@ -352,7 +352,18 @@ MathStream & operator<<(MathStream & ms, ETag const & t)
        ms.cr();
        if (ms.tab() > 0)
                --ms.tab();
-       ms.os() << "</" << from_ascii(t.tag_) << '>';
+       ms.os() << "</" << from_ascii(ms.namespacedTag(t.tag_)) << ">";
+       return ms;
+}
+
+
+MathStream & operator<<(MathStream & ms, CTag const & t)
+{
+       ms.cr();
+       ms.os() << "<" << from_ascii(ms.namespacedTag(t.tag_));
+    if (!t.attr_.empty())
+        ms.os() << " " << from_utf8(t.attr_);
+    ms.os() << "/>";
        return ms;
 }
 
@@ -452,17 +463,17 @@ HtmlStream & operator<<(HtmlStream & ms, docstring const 
& s)
 //////////////////////////////////////////////////////////////////////
 
 
-SetMode::SetMode(MathStream & os, bool text)
-       : os_(os)
+SetMode::SetMode(MathStream & ms, bool text)
+       : ms_(ms)
 {
-       was_text_ = os_.inText();
-       os_.setTextMode(text);
+       was_text_ = ms_.inText();
+       ms_.setTextMode(text);
 }
 
 
 SetMode::~SetMode()
 {
-       os_.setTextMode(was_text_);
+       ms_.setTextMode(was_text_);
 }
 
 
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index df9d610..f6f6e75 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -293,6 +293,8 @@ private:
 //  MathML
 //
 
+
+/// Start tag.
 class MTag {
 public:
        ///
@@ -304,6 +306,8 @@ public:
        std::string attr_;
 };
 
+
+/// End tag.
 class ETag {
 public:
        ///
@@ -313,6 +317,19 @@ public:
 };
 
 
+/// Compound tag (no content, directly closed).
+class CTag {
+public:
+       ///
+       CTag(char const * const tag, std::string attr = "")
+            : tag_(tag), attr_(attr) {}
+       ///
+       char const * const tag_;
+    ///
+    std::string attr_;
+};
+
+
 /// Throw MathExportException to signal that the attempt to export
 /// some math in the current format did not succeed. E.g., we can't
 /// export xymatrix as MathML, so that will throw, and we'll fall back
@@ -322,8 +339,8 @@ class MathExportException : public std::exception {};
 
 class MathStream {
 public:
-       ///
-       explicit MathStream(odocstream & os);
+       /// Builds a stream proxy for os; the MathML namespace is given by 
xmlns (supposed to be already defined elsewhere in the document).
+       explicit MathStream(odocstream & os, std::string xmlns="");
        ///
        void cr();
        ///
@@ -342,6 +359,10 @@ public:
        docstring deferred() const;
        ///
        bool inText() const { return in_text_; }
+       ///
+       std::string xmlns() const { return xmlns_; }
+       /// Returns the tag name prefixed by the name space if needed.
+       std::string namespacedTag(std::string tag) const { return 
((xmlns().empty()) ? "" : xmlns() + ":") + tag; }
 private:
        ///
        void setTextMode(bool t) { in_text_ = t; }
@@ -356,6 +377,8 @@ private:
        ///
        odocstringstream deferred_;
        ///
+       std::string xmlns_;
+       ///
        friend class SetMode;
 };
 
@@ -375,18 +398,20 @@ MathStream & operator<<(MathStream &, char_type);
 MathStream & operator<<(MathStream &, MTag const &);
 ///
 MathStream & operator<<(MathStream &, ETag const &);
+///
+MathStream & operator<<(MathStream &, CTag const &);
 
 
 /// A simpler version of ModeSpecifier, for MathML
 class SetMode {
 public:
        ///
-       explicit SetMode(MathStream & os, bool text);
+       explicit SetMode(MathStream & ms, bool text);
        ///
        ~SetMode();
 private:
        ///
-       MathStream & os_;
+       MathStream & ms_;
        ///
        bool was_text_;
 };
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to