2 /****************************************************************************
3 XHTMLToSSMLParser class
5 Parses a piece of XHTML markup and converts into SSML.
8 (C) 2004 by Paul Giannaros <ceruleanblaze@gmail.com>
10 Original author: Paul Giannaros <ceruleanblaze@gmail.com>
11 ******************************************************************************/
13 /***************************************************************************
15 * This program is free software; you can redistribute it and/or modify *
16 * it under the terms of the GNU General Public License as published by *
17 * the Free Software Foundation; version 2 of the License. *
19 ***************************************************************************/
24 #include <QtXml/QXmlAttributes>
25 #include <QtCore/QMap>
27 typedef QMap
<QString
, QString
> QStringMap
;
30 class XHTMLToSSMLParser
: public QXmlDefaultHandler
{
33 /// No need to reimplement constructor..
34 /// The document parsing starts
36 /// start of an element encountered (<element foo="bar">)
37 bool startElement(const QString
&namespaceURI
, const QString
&localName
, const QString
&qName
, const QXmlAttributes
&atts
);
38 /// end of an element encountered (</element>)
39 bool endElement(const QString
&namespaceURI
, const QString
&localName
, const QString
&qName
);
40 /// text encountered (blah bah blah)
41 bool characters(const QString
&);
43 /// Get the output text that was generated during the parsing.
44 /// @returns The converted text.
45 QString
convertedText();
47 /// Parse a line from the configuration file which maps xhtml : ssml equivalent.
48 /// It makes entries in the m_xhtml2ssml map accordingly.
49 /// @param line A line from a file to parse
50 /// @returns true if the syntax of the line was okay and the parsing succeeded - false otherwise.
51 bool readFileConfigEntry(const QString
&line
);
54 /// Dict of xhtml tags -> ssml tags
55 QStringMap m_xhtml2ssml
;
56 /// The output of the conversion