File indexing completed on 2024-05-05 05:52:23
0001 /*************************************************************************** 0002 pseudoDtd.cpp 0003 copyright : (C) 2001-2002 by Daniel Naber 0004 email : daniel.naber@t-online.de 0005 ***************************************************************************/ 0006 0007 /*************************************************************************** 0008 This program is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU General Public License 0010 as published by the Free Software Foundation; either version 2 0011 of the License, or ( at your option ) any later version. 0012 0013 This program is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 GNU General Public License for more details. 0017 0018 You should have received a copy of the GNU General Public License 0019 along with this program; if not, write to the Free Software 0020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0021 ***************************************************************************/ 0022 0023 #pragma once 0024 0025 #include <QProgressDialog> 0026 #include <map> 0027 #include <qdom.h> 0028 0029 /** 0030 * This class contains the attributes for one element. 0031 * To get ALL attributes, concatenate the two lists. 0032 */ 0033 class ElementAttributes 0034 { 0035 public: 0036 QStringList optionalAttributes; 0037 QStringList requiredAttributes; 0038 }; 0039 0040 class PseudoDTD 0041 { 0042 public: 0043 PseudoDTD(); 0044 ~PseudoDTD(); 0045 0046 void analyzeDTD(QString &metaDtdUrl, QString &metaDtd); 0047 0048 QStringList allowedElements(const QString &parentElement); 0049 QStringList allowedAttributes(const QString &parentElement); 0050 QStringList attributeValues(const QString &element, const QString &attribute); 0051 QStringList entities(const QString &start); 0052 QStringList requiredAttributes(const QString &parentElement) const; 0053 0054 protected: 0055 bool parseElements(QDomDocument *doc, QProgressDialog *progress); 0056 bool parseAttributes(QDomDocument *doc, QProgressDialog *progress); 0057 bool parseAttributeValues(QDomDocument *doc, QProgressDialog *progress); 0058 bool parseEntities(QDomDocument *doc, QProgressDialog *progress); 0059 0060 bool m_sgmlSupport; 0061 0062 // Entities, e.g. <"nbsp", "160"> 0063 std::map<QString, QString> m_entityList; 0064 // Elements, e.g. <"a", ( "b", "i", "em", "strong" )> 0065 std::map<QString, QStringList> m_elementsList; 0066 // Attributes e.g. <"a", ( "href", "lang", "title" )> 0067 std::map<QString, ElementAttributes> m_attributesList; 0068 // Attribute values e.g. <"td", <"align", ( "left", "right", "justify" )>> 0069 std::map<QString, std::map<QString, QStringList>> m_attributevaluesList; 0070 }; 0071 0072 // kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off;