Coercing SVG to W3C Profile
Jaques Distler: Using that local copy of the W3C Validator means we need to adhere to the rather lame restrictions of the XHTML+MathML+SVG DTD
Perhaps this might help.
Notes:
- This code eats unknown namespace declarations. In most cases, this should be caught downstream. If this is a concern, a
die if...statement or two might be in order. - Non-namespace-well-formed input (as well as any input that causes the parser to
die) will be returned unmodified. Again, presumably such input will fail validation anyway. Unfortunately, this also precludes the fixing up of comments that contain references to XHTML entity definitions other than the ones predefined by XML itself. Could perhaps be addressed by optionally prefixing the input with a<!DOCTYPE>for parsing purposes. - In rare cases, this code may unnecessarily declare a harmless
xlinknamespace into the output. - Empty elements will be converted to separate open and close tags. Come to think of it, that might be handy.
- You may want to handle other events, like Comment.
In my case, however,
http://www.w3.org/1998/Math/MathMLis a known namespace.
Add this to xmlSerialize:
$element .= " xmlns=\"${\MATHMLNS}\""
if $element eq 'math' && $expat->namespace($element) eq MATHMLNS;
Posted by Sam Ruby
at
Wow!
That was quick.
The
MT::Sanitizeroutine will eat unknown namespace declarations, too, so that’s not a big deal.In my case, however,
http://www.w3.org/1998/Math/MathMLis a known namespace.That’s what MathML::Entities is for. One just needs to ensure that that filter is applied before this one.
Anyway, it’ll take me a while to roll this into MovableType. But thank you!
Posted by Jacques Distler at