1 /***************************************************************************
2 pseudoDtd.cpp
3 copyright : (C) 2001-2002 by Daniel Naber
4 email : daniel.naber@t-online.de
5 ***************************************************************************/
6
7/***************************************************************************
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or ( at your option ) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 ***************************************************************************/
22
23#ifndef PSEUDO_DTD_H
24#define PSEUDO_DTD_H
25
26#include <qdom.h>
27#include <qprogressdialog.h>
28#include <QMap>
29
30/**
31 * This class contains the attributes for one element.
32 * To get ALL attributes, concatenate the two lists.
33 */
34class ElementAttributes
35{
36 public:
37 QStringList optionalAttributes;
38 QStringList requiredAttributes;
39};
40
41class PseudoDTD
42{
43
44 public:
45 PseudoDTD();
46 ~PseudoDTD();
47
48 void analyzeDTD( QString &metaDtdUrl, QString &metaDtd );
49
50 QStringList allowedElements( QString parentElement );
51 QStringList allowedAttributes( QString parentElement );
52 QStringList attributeValues( QString element, QString attribute );
53 QStringList entities( QString start );
54 QStringList requiredAttributes( const QString &parentElement ) const;
55
56 protected:
57
58 bool parseElements( QDomDocument *doc, QProgressDialog *progress );
59 bool parseAttributes( QDomDocument *doc, QProgressDialog *progress );
60 bool parseAttributeValues( QDomDocument *doc, QProgressDialog *progress );
61 bool parseEntities( QDomDocument *doc, QProgressDialog *progress );
62
63 bool m_sgmlSupport;
64
65 // Entities, e.g. <"nbsp", "160">
66 QMap<QString,QString> m_entityList;
67 // Elements, e.g. <"a", ( "b", "i", "em", "strong" )>
68 QMap<QString,QStringList> m_elementsList;
69 // Attributes e.g. <"a", ( "href", "lang", "title" )>
70 QMap<QString,ElementAttributes> m_attributesList;
71 // Attribute values e.g. <"td", <"align", ( "left", "right", "justify" )>>
72 QMap< QString,QMap<QString,QStringList> > m_attributevaluesList;
73
74};
75
76#endif // PSEUDO_DTD_H
77
78// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
79