Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
XML library for validating MathML
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-09-17 (18:58)
From: Dario Teixeira <darioteixeira@y...>
Subject: XML library for validating MathML

Given a string containing a mathematical expression in the MathML
markup, I need to verify that the expression is indeed valid MathML.
I am therefore looking for an XML library that can verify an expression
against a given DTD.

Now, I have tried Xml-light, and the code I used is listed below.
Unfortunately, it fails when trying to parse MathML's DTD (it's the
standard DTD from the W3C).  I have tried simpler DTDs, and it does work
with them; am I therefore correct in assuming that Xml-light can only
handle a particular version/subset of DTD features?

let () =
                let x = Xml.parse_file "file.xml" in
                let dtd = Dtd.parse_file "mathml.dtd" in
                let checked = Dtd.check dtd in
                let proven = Dtd.prove checked "math" x in
                print_endline (Xml.to_string proven)
                Dtd.Parse_error exc -> print_endline (Dtd.parse_error exc)

There are of course other XML libraries for Ocaml and let's not forget Cduce.
Can someone recommend one solution that is guaranteed to work with the
MathML DTD?  Note that I don't need to do much with the XML tree; pretty
much all I need is a boilerplate function that returns a boolean on whether
a string is valid or not.

Thanks in advance for your input!
Best regards,
Dario Teixeira