Qt 4.8
qdom.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <qplatformdefs.h>
43 #include <qdom.h>
44 #include "private/qxmlutils_p.h"
45 
46 #ifndef QT_NO_DOM
47 
48 #include <qatomic.h>
49 #include <qbuffer.h>
50 #include <qhash.h>
51 #include <qiodevice.h>
52 #include <qlist.h>
53 #include <qregexp.h>
54 #include <qtextcodec.h>
55 #include <qtextstream.h>
56 #include <qxml.h>
57 #include <qvariant.h>
58 #include <qmap.h>
59 #include <qshareddata.h>
60 #include <qdebug.h>
61 #include <stdio.h>
62 
64 
65 /*
66  ### old todo comments -- I don't know if they still apply...
67 
68  If the document dies, remove all pointers to it from children
69  which can not be deleted at this time.
70 
71  If a node dies and has direct children which can not be deleted,
72  then remove the pointer to the parent.
73 
74  createElement and friends create double reference counts.
75 */
76 
77 /* ##### new TODOs:
78 
79  Remove emtpy emthods in the *Private classes
80 
81  Make a lot of the (mostly empty) methods in the public classes inline.
82  Specially constructors assignment operators and comparison operators are candidates.
83 
84  The virtual isXxx functions in *Private can probably be replaced by inline methods checking the nodeType().
85 */
86 
87 /*
88  Reference counting:
89 
90  Some simple rules:
91  1) If an intern object returns a pointer to another intern object
92  then the reference count of the returned object is not increased.
93  2) If an extern object is created and gets a pointer to some intern
94  object, then the extern object increases the intern objects reference count.
95  3) If an extern object is deleted, then it decreases the reference count
96  on its associated intern object and deletes it if nobody else hold references
97  on the intern object.
98 */
99 
100 
101 /*
102  Helper to split a qualified name in the prefix and local name.
103 */
104 static void qt_split_namespace(QString& prefix, QString& name, const QString& qName, bool hasURI)
105 {
106  int i = qName.indexOf(QLatin1Char(':'));
107  if (i == -1) {
108  if (hasURI)
109  prefix = QLatin1String("");
110  else
111  prefix.clear();
112  name = qName;
113  } else {
114  prefix = qName.left(i);
115  name = qName.mid(i + 1);
116  }
117 }
118 
119 /**************************************************************
120  *
121  * Private class declerations
122  *
123  **************************************************************/
124 
126 {
127 public:
129 
133 };
134 
136 {
137 public:
139  QDomNodePrivate(QDomNodePrivate* n, bool deep);
140  virtual ~QDomNodePrivate();
141 
142  QString nodeName() const { return name; }
143  QString nodeValue() const { return value; }
144  virtual void setNodeValue(const QString& v) { value = v; }
145 
146  QDomDocumentPrivate* ownerDocument();
147  void setOwnerDocument(QDomDocumentPrivate* doc);
148 
149  virtual QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild);
150  virtual QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild);
151  virtual QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild);
152  virtual QDomNodePrivate* removeChild(QDomNodePrivate* oldChild);
153  virtual QDomNodePrivate* appendChild(QDomNodePrivate* newChild);
154 
155  QDomNodePrivate* namedItem(const QString& name);
156 
157  virtual QDomNodePrivate* cloneNode(bool deep = true);
158  virtual void normalize();
159  virtual void clear();
160 
161  inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : 0; }
162  inline void setParent(QDomNodePrivate *p) { ownerNode = p; hasParent = true; }
163 
164  void setNoParent() {
165  ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : 0;
166  hasParent = false;
167  }
168 
169  // Dynamic cast
170  virtual bool isAttr() const { return false; }
171  virtual bool isCDATASection() const { return false; }
172  virtual bool isDocumentFragment() const { return false; }
173  virtual bool isDocument() const { return false; }
174  virtual bool isDocumentType() const { return false; }
175  virtual bool isElement() const { return false; }
176  virtual bool isEntityReference() const { return false; }
177  virtual bool isText() const { return false; }
178  virtual bool isEntity() const { return false; }
179  virtual bool isNotation() const { return false; }
180  virtual bool isProcessingInstruction() const { return false; }
181  virtual bool isCharacterData() const { return false; }
182  virtual bool isComment() const { return false; }
183 
184  virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; }
185 
186  virtual void save(QTextStream&, int, int) const;
187 
188  void setLocation(int lineNumber, int columnNumber);
189 
190  // Variables
194  QDomNodePrivate* ownerNode; // either the node's parent or the node's owner document
197 
198  QString name; // this is the local name if prefix != null
200  QString prefix; // set this only for ElementNode and AttributeNode
201  QString namespaceURI; // set this only for ElementNode and AttributeNode
203  bool hasParent : 1;
204 
207 };
208 
210 {
211 public:
216 
217  bool operator== (const QDomNodeListPrivate&) const;
218  bool operator!= (const QDomNodeListPrivate&) const;
219 
220  void createList();
221  QDomNodePrivate* item(int index);
222  uint length() const;
223 
225  /*
226  This list contains the children of this node.
227  */
232  long timestamp;
233 };
234 
236 {
237 public:
240 
241  QDomNodePrivate* namedItem(const QString& name) const;
242  QDomNodePrivate* namedItemNS(const QString& nsURI, const QString& localName) const;
243  QDomNodePrivate* setNamedItem(QDomNodePrivate* arg);
244  QDomNodePrivate* setNamedItemNS(QDomNodePrivate* arg);
245  QDomNodePrivate* removeNamedItem(const QString& name);
246  QDomNodePrivate* item(int index) const;
247  uint length() const;
248  bool contains(const QString& name) const;
249  bool containsNS(const QString& nsURI, const QString & localName) const;
250 
254  void clearMap();
255  bool isReadOnly() { return readonly; }
256  void setReadOnly(bool r) { readonly = r; }
257  bool isAppendToParent() { return appendToParent; }
267  void setAppendToParent(bool b) { appendToParent = b; }
268 
274 
275  // Variables
279  bool readonly;
281 };
282 
284 {
285 public:
289  void init();
290 
291  // Reimplemented from QDomNodePrivate
292  QDomNodePrivate* cloneNode(bool deep = true);
293  QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild);
294  QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild);
295  QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild);
296  QDomNodePrivate* removeChild(QDomNodePrivate* oldChild);
297  QDomNodePrivate* appendChild(QDomNodePrivate* newChild);
298 
299  virtual bool isDocumentType() const { return true; }
301 
302  void save(QTextStream& s, int, int) const;
303 
304  // Variables
310 };
311 
313 {
314 public:
317 
318  // Reimplemented from QDomNodePrivate
319  virtual QDomNodePrivate* cloneNode(bool deep = true);
320  virtual bool isDocumentFragment() const { return true; }
322 };
323 
325 {
326 public:
329 
330  uint dataLength() const;
331  QString substringData(unsigned long offset, unsigned long count) const;
332  void appendData(const QString& arg);
333  void insertData(unsigned long offset, const QString& arg);
334  void deleteData(unsigned long offset, unsigned long count);
335  void replaceData(unsigned long offset, unsigned long count, const QString& arg);
336 
337  // Reimplemented from QDomNodePrivate
338  virtual bool isCharacterData() const { return true; }
340  QDomNodePrivate* cloneNode(bool deep = true);
341 };
342 
344 {
345 public:
347  QDomTextPrivate(QDomTextPrivate* n, bool deep);
348 
349  QDomTextPrivate* splitText(int offset);
350 
351  // Reimplemented from QDomNodePrivate
352  QDomNodePrivate* cloneNode(bool deep = true);
353  virtual bool isText() const { return true; }
355  virtual void save(QTextStream& s, int, int) const;
356 };
357 
359 {
360 public:
362  QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& nsURI, const QString& qName);
363  QDomAttrPrivate(QDomAttrPrivate* n, bool deep);
364 
365  bool specified() const;
366 
367  // Reimplemented from QDomNodePrivate
368  void setNodeValue(const QString& v);
369  QDomNodePrivate* cloneNode(bool deep = true);
370  virtual bool isAttr() const { return true; }
372  virtual void save(QTextStream& s, int, int) const;
373 
374  // Variables
376 };
377 
379 {
380 public:
382  QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& nsURI, const QString& qName);
383  QDomElementPrivate(QDomElementPrivate* n, bool deep);
385 
386  QString attribute(const QString& name, const QString& defValue) const;
387  QString attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const;
388  void setAttribute(const QString& name, const QString& value);
389  void setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue);
390  void removeAttribute(const QString& name);
391  QDomAttrPrivate* attributeNode(const QString& name);
392  QDomAttrPrivate* attributeNodeNS(const QString& nsURI, const QString& localName);
393  QDomAttrPrivate* setAttributeNode(QDomAttrPrivate* newAttr);
394  QDomAttrPrivate* setAttributeNodeNS(QDomAttrPrivate* newAttr);
395  QDomAttrPrivate* removeAttributeNode(QDomAttrPrivate* oldAttr);
396  bool hasAttribute(const QString& name);
397  bool hasAttributeNS(const QString& nsURI, const QString& localName);
398 
399  QString text();
400 
401  // Reimplemented from QDomNodePrivate
402  QDomNamedNodeMapPrivate* attributes() { return m_attr; }
403  bool hasAttributes() { return (m_attr->length() > 0); }
404  virtual bool isElement() const { return true; }
406  QDomNodePrivate* cloneNode(bool deep = true);
407  virtual void save(QTextStream& s, int, int) const;
408 
409  // Variables
411 };
412 
413 
415 {
416 public:
418  QDomCommentPrivate(QDomCommentPrivate* n, bool deep);
419 
420  // Reimplemented from QDomNodePrivate
421  QDomNodePrivate* cloneNode(bool deep = true);
422  virtual bool isComment() const { return true; }
424  virtual void save(QTextStream& s, int, int) const;
425 };
426 
428 {
429 public:
432 
433  // Reimplemented from QDomNodePrivate
434  QDomNodePrivate* cloneNode(bool deep = true);
435  virtual bool isCDATASection() const { return true; }
437  virtual void save(QTextStream& s, int, int) const;
438 };
439 
441 {
442 public:
444  const QString& pub, const QString& sys);
446 
447  // Reimplemented from QDomNodePrivate
448  QDomNodePrivate* cloneNode(bool deep = true);
449  virtual bool isNotation() const { return true; }
451  virtual void save(QTextStream& s, int, int) const;
452 
453  // Variables
456 };
457 
459 {
460 public:
462  const QString& pub, const QString& sys, const QString& notation);
463  QDomEntityPrivate(QDomEntityPrivate* n, bool deep);
464 
465  // Reimplemented from QDomNodePrivate
466  QDomNodePrivate* cloneNode(bool deep = true);
467  virtual bool isEntity() const { return true; }
469  virtual void save(QTextStream& s, int, int) const;
470 
471  // Variables
475 };
476 
478 {
479 public:
482 
483  // Reimplemented from QDomNodePrivate
484  QDomNodePrivate* cloneNode(bool deep = true);
485  bool isEntityReference() const { return true; }
487  virtual void save(QTextStream& s, int, int) const;
488 };
489 
491 {
492 public:
494  const QString& data);
496 
497  // Reimplemented from QDomNodePrivate
498  QDomNodePrivate* cloneNode(bool deep = true);
499  virtual bool isProcessingInstruction() const { return true; }
501  virtual void save(QTextStream& s, int, int) const;
502 };
503 
505 {
506 public:
512 
513  bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn);
514  bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn);
515 
516  // Attributes
517  QDomDocumentTypePrivate* doctype() { return type.data(); }
519  QDomElementPrivate* documentElement();
520 
521  // Factories
522  QDomElementPrivate* createElement(const QString& tagName);
523  QDomElementPrivate* createElementNS(const QString& nsURI, const QString& qName);
524  QDomDocumentFragmentPrivate* createDocumentFragment();
526  QDomCommentPrivate* createComment(const QString& data);
527  QDomCDATASectionPrivate* createCDATASection(const QString& data);
528  QDomProcessingInstructionPrivate* createProcessingInstruction(const QString& target, const QString& data);
529  QDomAttrPrivate* createAttribute(const QString& name);
530  QDomAttrPrivate* createAttributeNS(const QString& nsURI, const QString& qName);
531  QDomEntityReferencePrivate* createEntityReference(const QString& name);
532 
533  QDomNodePrivate* importNode(const QDomNodePrivate* importedNode, bool deep);
534 
535  // Reimplemented from QDomNodePrivate
536  QDomNodePrivate* cloneNode(bool deep = true);
537  bool isDocument() const { return true; }
539  void clear();
540 
541  // Variables
544 
545  void saveDocument(QTextStream& stream, const int indent, QDomNode::EncodingPolicy encUsed) const;
546 
547  /* \internal
548  Counter for the QDomNodeListPrivate timestamps.
549 
550  This is a cache optimization, that might in some cases be effective. The
551  dilemma is that QDomNode::childNodes() returns a list, but the
552  implementation stores the children in a linked list. Hence, in order to
553  get the children out through childNodes(), a list must be populated each
554  time, which is O(N).
555 
556  DOM has the requirement of node references being live, see DOM Core
557  Level 3, 1.1.1 The DOM Structure Model, which means that changes to the
558  underlying documents must be reflected in node lists.
559 
560  This mechanism, nodeListTime, is a caching optimization that reduces the
561  amount of times the node list is rebuilt, by only doing so when the
562  document actually changes. However, a change to anywhere in any document
563  invalidate all lists, since no dependency tracking is done.
564 
565  It functions by that all modifying functions(insertBefore() and so on)
566  increment the count; each QDomNodeListPrivate copies nodeListTime on
567  construction, and compares its own value to nodeListTime in order to
568  determine whether it needs to rebuild.
569 
570  This is reentrant. The nodeListTime may overflow, but that's ok since we
571  check for equalness, not whether nodeListTime is smaller than the list's
572  stored timestamp.
573  */
575 };
576 
577 /**************************************************************
578  *
579  * QDomHandler
580  *
581  **************************************************************/
582 
584 {
585 public:
586  QDomHandler(QDomDocumentPrivate* d, bool namespaceProcessing);
587  ~QDomHandler();
588 
589  // content handler
590  bool endDocument();
591  bool startElement(const QString& nsURI, const QString& localName, const QString& qName, const QXmlAttributes& atts);
592  bool endElement(const QString& nsURI, const QString& localName, const QString& qName);
593  bool characters(const QString& ch);
594  bool processingInstruction(const QString& target, const QString& data);
595  bool skippedEntity(const QString& name);
596 
597  // error handler
598  bool fatalError(const QXmlParseException& exception);
599 
600  // lexical handler
601  bool startCDATA();
602  bool endCDATA();
603  bool startEntity(const QString &);
604  bool endEntity(const QString &);
605  bool startDTD(const QString& name, const QString& publicId, const QString& systemId);
606  bool comment(const QString& ch);
607 
608  // decl handler
609  bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) ;
610 
611  // DTD handler
612  bool notationDecl(const QString & name, const QString & publicId, const QString & systemId);
613  bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) ;
614 
615  void setDocumentLocator(QXmlLocator *locator);
616 
620 
621 private:
625  bool cdata;
628 
629 #ifdef Q_OS_SYMBIAN
630  // Workaround crash in elf2e32 under Wine.
631  virtual void dummy() {}
632 #endif
633 };
634 
635 /**************************************************************
636  *
637  * Functions for verifying legal data
638  *
639  **************************************************************/
642 
643 // [5] Name ::= (Letter | '_' | ':') (NameChar)*
644 
645 static QString fixedXmlName(const QString &_name, bool *ok, bool namespaces = false)
646 {
647  QString name, prefix;
648  if (namespaces)
649  qt_split_namespace(prefix, name, _name, true);
650  else
651  name = _name;
652 
653  if (name.isEmpty()) {
654  *ok = false;
655  return QString();
656  }
657 
659  *ok = true;
660  return _name;
661  }
662 
663  QString result;
664  bool firstChar = true;
665  for (int i = 0; i < name.size(); ++i) {
666  QChar c = name.at(i);
667  if (firstChar) {
668  if (QXmlUtils::isLetter(c) || c.unicode() == '_' || c.unicode() == ':') {
669  result.append(c);
670  firstChar = false;
672  *ok = false;
673  return QString();
674  }
675  } else {
676  if (QXmlUtils::isNameChar(c))
677  result.append(c);
679  *ok = false;
680  return QString();
681  }
682  }
683  }
684 
685  if (result.isEmpty()) {
686  *ok = false;
687  return QString();
688  }
689 
690  *ok = true;
691  if (namespaces && !prefix.isEmpty())
692  return prefix + QLatin1Char(':') + result;
693  return result;
694 }
695 
696 // [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
697 // '<', '&' and "]]>" will be escaped when writing
698 
699 static QString fixedCharData(const QString &data, bool *ok)
700 {
702  *ok = true;
703  return data;
704  }
705 
706  QString result;
707  for (int i = 0; i < data.size(); ++i) {
708  QChar c = data.at(i);
709  if (QXmlUtils::isChar(c)) {
710  result.append(c);
712  *ok = false;
713  return QString();
714  }
715  }
716 
717  *ok = true;
718  return result;
719 }
720 
721 // [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
722 // can't escape "--", since entities are not recognised within comments
723 
724 static QString fixedComment(const QString &data, bool *ok)
725 {
727  *ok = true;
728  return data;
729  }
730 
731  QString fixedData = fixedCharData(data, ok);
732  if (!*ok)
733  return QString();
734 
735  for (;;) {
736  int idx = fixedData.indexOf(QLatin1String("--"));
737  if (idx == -1)
738  break;
740  *ok = false;
741  return QString();
742  }
743  fixedData.remove(idx, 2);
744  }
745 
746  *ok = true;
747  return fixedData;
748 }
749 
750 // [20] CData ::= (Char* - (Char* ']]>' Char*))
751 // can't escape "]]>", since entities are not recognised within comments
752 
753 static QString fixedCDataSection(const QString &data, bool *ok)
754 {
756  *ok = true;
757  return data;
758  }
759 
760  QString fixedData = fixedCharData(data, ok);
761  if (!*ok)
762  return QString();
763 
764  for (;;) {
765  int idx = fixedData.indexOf(QLatin1String("]]>"));
766  if (idx == -1)
767  break;
769  *ok = false;
770  return QString();
771  }
772  fixedData.remove(idx, 3);
773  }
774 
775  *ok = true;
776  return fixedData;
777 }
778 
779 // [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
780 
781 static QString fixedPIData(const QString &data, bool *ok)
782 {
784  *ok = true;
785  return data;
786  }
787 
788  QString fixedData = fixedCharData(data, ok);
789  if (!*ok)
790  return QString();
791 
792  for (;;) {
793  int idx = fixedData.indexOf(QLatin1String("?>"));
794  if (idx == -1)
795  break;
797  *ok = false;
798  return QString();
799  }
800  fixedData.remove(idx, 2);
801  }
802 
803  *ok = true;
804  return fixedData;
805 }
806 
807 // [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
808 // The correct quote will be chosen when writing
809 
810 static QString fixedPubidLiteral(const QString &data, bool *ok)
811 {
813  *ok = true;
814  return data;
815  }
816 
817  QString result;
818 
819  if(QXmlUtils::isPublicID(data))
820  result = data;
822  *ok = false;
823  return QString();
824  }
825 
826  if (result.indexOf(QLatin1Char('\'')) != -1
827  && result.indexOf(QLatin1Char('"')) != -1) {
829  *ok = false;
830  return QString();
831  } else {
832  result.remove(QLatin1Char('\''));
833  }
834  }
835 
836  *ok = true;
837  return result;
838 }
839 
840 // [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
841 // The correct quote will be chosen when writing
842 
843 static QString fixedSystemLiteral(const QString &data, bool *ok)
844 {
846  *ok = true;
847  return data;
848  }
849 
850  QString result = data;
851 
852  if (result.indexOf(QLatin1Char('\'')) != -1
853  && result.indexOf(QLatin1Char('"')) != -1) {
855  *ok = false;
856  return QString();
857  } else {
858  result.remove(QLatin1Char('\''));
859  }
860  }
861 
862  *ok = true;
863  return result;
864 }
865 
866 /**************************************************************
867  *
868  * QDomImplementationPrivate
869  *
870  **************************************************************/
871 
873 {
874  return new QDomImplementationPrivate;
875 }
876 
877 /**************************************************************
878  *
879  * QDomImplementation
880  *
881  **************************************************************/
882 
923 {
924  impl = 0;
925 }
926 
931 {
932  impl = x.impl;
933  if (impl)
934  impl->ref.ref();
935 }
936 
938 {
939  // We want to be co-owners, so increase the reference count
940  impl = p;
941  if (impl)
942  impl->ref.ref();
943 }
944 
949 {
950  if (x.impl)
951  x.impl->ref.ref();
952  if (impl && !impl->ref.deref())
953  delete impl;
954  impl = x.impl;
955  return *this;
956 }
957 
963 {
964  return (impl == x.impl);
965 }
966 
972 {
973  return (impl != x.impl);
974 }
975 
980 {
981  if (impl && !impl->ref.deref())
982  delete impl;
983 }
984 
995 bool QDomImplementation::hasFeature(const QString& feature, const QString& version) const
996 {
997  if (feature == QLatin1String("XML")) {
998  if (version.isEmpty() || version == QLatin1String("1.0")) {
999  return true;
1000  }
1001  }
1002  // ### add DOM level 2 features
1003  return false;
1004 }
1005 
1038 QDomDocumentType QDomImplementation::createDocumentType(const QString& qName, const QString& publicId, const QString& systemId)
1039 {
1040  bool ok;
1041  QString fixedName = fixedXmlName(qName, &ok, true);
1042  if (!ok)
1043  return QDomDocumentType();
1044 
1045  QString fixedPublicId = fixedPubidLiteral(publicId, &ok);
1046  if (!ok)
1047  return QDomDocumentType();
1048 
1049  QString fixedSystemId = fixedSystemLiteral(systemId, &ok);
1050  if (!ok)
1051  return QDomDocumentType();
1052 
1054  dt->name = fixedName;
1055  if (systemId.isNull()) {
1056  dt->publicId.clear();
1057  dt->systemId.clear();
1058  } else {
1059  dt->publicId = fixedPublicId;
1060  dt->systemId = fixedSystemId;
1061  }
1062  dt->ref.deref();
1063  return QDomDocumentType(dt);
1064 }
1065 
1072 {
1073  QDomDocument doc(doctype);
1074  QDomElement root = doc.createElementNS(nsURI, qName);
1075  if (root.isNull())
1076  return QDomDocument();
1077  doc.appendChild(root);
1078  return doc;
1079 }
1080 
1086 {
1087  return (impl == 0);
1088 }
1089 
1138 {
1140 }
1141 
1161 {
1163 }
1164 
1165 /**************************************************************
1166  *
1167  * QDomNodeListPrivate
1168  *
1169  **************************************************************/
1170 
1172 {
1173  ref = 1;
1174  node_impl = n_impl;
1175  if (node_impl)
1176  node_impl->ref.ref();
1177  timestamp = 0;
1178 }
1179 
1181 {
1182  ref = 1;
1183  node_impl = n_impl;
1184  if (node_impl)
1185  node_impl->ref.ref();
1186  tagname = name;
1187  timestamp = 0;
1188 }
1189 
1191 {
1192  ref = 1;
1193  node_impl = n_impl;
1194  if (node_impl)
1195  node_impl->ref.ref();
1196  tagname = localName;
1197  nsURI = _nsURI;
1198  timestamp = 0;
1199 }
1200 
1202 {
1203  if (node_impl && !node_impl->ref.deref())
1204  delete node_impl;
1205 }
1206 
1208 {
1209  return (node_impl == other.node_impl) && (tagname == other.tagname);
1210 }
1211 
1213 {
1214  return (node_impl != other.node_impl) || (tagname != other.tagname);
1215 }
1216 
1218 {
1219  if (!node_impl)
1220  return;
1221 
1222  const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
1223  if (doc && timestamp != doc->nodeListTime)
1224  timestamp = doc->nodeListTime;
1225 
1226  QDomNodePrivate* p = node_impl->first;
1227 
1228  list.clear();
1229  if (tagname.isNull()) {
1230  while (p) {
1231  list.append(p);
1232  p = p->next;
1233  }
1234  } else if (nsURI.isNull()) {
1235  while (p && p != node_impl) {
1236  if (p->isElement() && p->nodeName() == tagname) {
1237  list.append(p);
1238  }
1239  if (p->first)
1240  p = p->first;
1241  else if (p->next)
1242  p = p->next;
1243  else {
1244  p = p->parent();
1245  while (p && p != node_impl && !p->next)
1246  p = p->parent();
1247  if (p && p != node_impl)
1248  p = p->next;
1249  }
1250  }
1251  } else {
1252  while (p && p != node_impl) {
1253  if (p->isElement() && p->name==tagname && p->namespaceURI==nsURI) {
1254  list.append(p);
1255  }
1256  if (p->first)
1257  p = p->first;
1258  else if (p->next)
1259  p = p->next;
1260  else {
1261  p = p->parent();
1262  while (p && p != node_impl && !p->next)
1263  p = p->parent();
1264  if (p && p != node_impl)
1265  p = p->next;
1266  }
1267  }
1268  }
1269 }
1270 
1272 {
1273  if (!node_impl)
1274  return 0;
1275 
1276  const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
1277  if (!doc || timestamp != doc->nodeListTime)
1278  createList();
1279 
1280  if (index >= list.size())
1281  return 0;
1282 
1283  return list.at(index);
1284 }
1285 
1287 {
1288  if (!node_impl)
1289  return 0;
1290 
1291  const QDomDocumentPrivate *const doc = node_impl->ownerDocument();
1292  if (!doc || timestamp != doc->nodeListTime) {
1293  QDomNodeListPrivate *that = const_cast<QDomNodeListPrivate *>(this);
1294  that->createList();
1295  }
1296 
1297  return list.count();
1298 }
1299 
1300 /**************************************************************
1301  *
1302  * QDomNodeList
1303  *
1304  **************************************************************/
1305 
1338 {
1339  impl = 0;
1340 }
1341 
1343 {
1344  impl = p;
1345 }
1346 
1351 {
1352  impl = n.impl;
1353  if (impl)
1354  impl->ref.ref();
1355 }
1356 
1361 {
1362  if (n.impl)
1363  n.impl->ref.ref();
1364  if (impl && !impl->ref.deref())
1365  delete impl;
1366  impl = n.impl;
1367  return *this;
1368 }
1369 
1375 {
1376  if (impl == n.impl)
1377  return true;
1378  if (!impl || !n.impl)
1379  return false;
1380  return (*impl == *n.impl);
1381 }
1382 
1388 {
1389  return !operator==(n);
1390 }
1391 
1396 {
1397  if (impl && !impl->ref.deref())
1398  delete impl;
1399 }
1400 
1411 {
1412  if (!impl)
1413  return QDomNode();
1414 
1415  return QDomNode(impl->item(index));
1416 }
1417 
1422 {
1423  if (!impl)
1424  return 0;
1425  return impl->length();
1426 }
1427 
1470 /**************************************************************
1471  *
1472  * QDomNodePrivate
1473  *
1474  **************************************************************/
1475 
1477 {
1478  ownerNode = doc;
1479  hasParent = false;
1480 }
1481 
1483 {
1484  ref = 1;
1485  if (par)
1486  setParent(par);
1487  else
1488  setOwnerDocument(doc);
1489  prev = 0;
1490  next = 0;
1491  first = 0;
1492  last = 0;
1493  createdWithDom1Interface = true;
1494  lineNumber = -1;
1495  columnNumber = -1;
1496 }
1497 
1499 {
1500  ref = 1;
1501  setOwnerDocument(n->ownerDocument());
1502  prev = 0;
1503  next = 0;
1504  first = 0;
1505  last = 0;
1506 
1507  name = n->name;
1508  value = n->value;
1509  prefix = n->prefix;
1510  namespaceURI = n->namespaceURI;
1511  createdWithDom1Interface = n->createdWithDom1Interface;
1512  lineNumber = -1;
1513  columnNumber = -1;
1514 
1515  if (!deep)
1516  return;
1517 
1518  for (QDomNodePrivate* x = n->first; x; x = x->next)
1519  appendChild(x->cloneNode(true));
1520 }
1521 
1523 {
1524  QDomNodePrivate* p = first;
1525  QDomNodePrivate* n;
1526 
1527  while (p) {
1528  n = p->next;
1529  if (!p->ref.deref())
1530  delete p;
1531  else
1532  p->setNoParent();
1533  p = n;
1534  }
1535  first = 0;
1536  last = 0;
1537 }
1538 
1540 {
1541  QDomNodePrivate* p = first;
1542  QDomNodePrivate* n;
1543 
1544  while (p) {
1545  n = p->next;
1546  if (!p->ref.deref())
1547  delete p;
1548  p = n;
1549  }
1550  first = 0;
1551  last = 0;
1552 }
1553 
1555 {
1556  QDomNodePrivate* p = first;
1557  while (p) {
1558  if (p->nodeName() == n)
1559  return p;
1560  p = p->next;
1561  }
1562  return 0;
1563 }
1564 
1565 
1567 {
1568  // Error check
1569  if (!newChild)
1570  return 0;
1571 
1572  // Error check
1573  if (newChild == refChild)
1574  return 0;
1575 
1576  // Error check
1577  if (refChild && refChild->parent() != this)
1578  return 0;
1579 
1580  // "mark lists as dirty"
1581  QDomDocumentPrivate *const doc = ownerDocument();
1582  if(doc)
1583  doc->nodeListTime++;
1584 
1585  // Special handling for inserting a fragment. We just insert
1586  // all elements of the fragment instead of the fragment itself.
1587  if (newChild->isDocumentFragment()) {
1588  // Fragment is empty ?
1589  if (newChild->first == 0)
1590  return newChild;
1591 
1592  // New parent
1593  QDomNodePrivate* n = newChild->first;
1594  while (n) {
1595  n->setParent(this);
1596  n = n->next;
1597  }
1598 
1599  // Insert at the beginning ?
1600  if (!refChild || refChild->prev == 0) {
1601  if (first)
1602  first->prev = newChild->last;
1603  newChild->last->next = first;
1604  if (!last)
1605  last = newChild->last;
1606  first = newChild->first;
1607  } else {
1608  // Insert in the middle
1609  newChild->last->next = refChild;
1610  newChild->first->prev = refChild->prev;
1611  refChild->prev->next = newChild->first;
1612  refChild->prev = newChild->last;
1613  }
1614 
1615  // No need to increase the reference since QDomDocumentFragment
1616  // does not decrease the reference.
1617 
1618  // Remove the nodes from the fragment
1619  newChild->first = 0;
1620  newChild->last = 0;
1621  return newChild;
1622  }
1623 
1624  // No more errors can occur now, so we take
1625  // ownership of the node.
1626  newChild->ref.ref();
1627 
1628  if (newChild->parent())
1629  newChild->parent()->removeChild(newChild);
1630 
1631  newChild->setParent(this);
1632 
1633  if (!refChild) {
1634  if (first)
1635  first->prev = newChild;
1636  newChild->next = first;
1637  if (!last)
1638  last = newChild;
1639  first = newChild;
1640  return newChild;
1641  }
1642 
1643  if (refChild->prev == 0) {
1644  if (first)
1645  first->prev = newChild;
1646  newChild->next = first;
1647  if (!last)
1648  last = newChild;
1649  first = newChild;
1650  return newChild;
1651  }
1652 
1653  newChild->next = refChild;
1654  newChild->prev = refChild->prev;
1655  refChild->prev->next = newChild;
1656  refChild->prev = newChild;
1657 
1658  return newChild;
1659 }
1660 
1662 {
1663  // Error check
1664  if (!newChild)
1665  return 0;
1666 
1667  // Error check
1668  if (newChild == refChild)
1669  return 0;
1670 
1671  // Error check
1672  if (refChild && refChild->parent() != this)
1673  return 0;
1674 
1675  // "mark lists as dirty"
1676  QDomDocumentPrivate *const doc = ownerDocument();
1677  if(doc)
1678  doc->nodeListTime++;
1679 
1680  // Special handling for inserting a fragment. We just insert
1681  // all elements of the fragment instead of the fragment itself.
1682  if (newChild->isDocumentFragment()) {
1683  // Fragment is empty ?
1684  if (newChild->first == 0)
1685  return newChild;
1686 
1687  // New parent
1688  QDomNodePrivate* n = newChild->first;
1689  while (n) {
1690  n->setParent(this);
1691  n = n->next;
1692  }
1693 
1694  // Insert at the end
1695  if (!refChild || refChild->next == 0) {
1696  if (last)
1697  last->next = newChild->first;
1698  newChild->first->prev = last;
1699  if (!first)
1700  first = newChild->first;
1701  last = newChild->last;
1702  } else { // Insert in the middle
1703  newChild->first->prev = refChild;
1704  newChild->last->next = refChild->next;
1705  refChild->next->prev = newChild->last;
1706  refChild->next = newChild->first;
1707  }
1708 
1709  // No need to increase the reference since QDomDocumentFragment
1710  // does not decrease the reference.
1711 
1712  // Remove the nodes from the fragment
1713  newChild->first = 0;
1714  newChild->last = 0;
1715  return newChild;
1716  }
1717 
1718  // Release new node from its current parent
1719  if (newChild->parent())
1720  newChild->parent()->removeChild(newChild);
1721 
1722  // No more errors can occur now, so we take
1723  // ownership of the node
1724  newChild->ref.ref();
1725 
1726  newChild->setParent(this);
1727 
1728  // Insert at the end
1729  if (!refChild) {
1730  if (last)
1731  last->next = newChild;
1732  newChild->prev = last;
1733  if (!first)
1734  first = newChild;
1735  last = newChild;
1736  return newChild;
1737  }
1738 
1739  if (refChild->next == 0) {
1740  if (last)
1741  last->next = newChild;
1742  newChild->prev = last;
1743  if (!first)
1744  first = newChild;
1745  last = newChild;
1746  return newChild;
1747  }
1748 
1749  newChild->prev = refChild;
1750  newChild->next = refChild->next;
1751  refChild->next->prev = newChild;
1752  refChild->next = newChild;
1753 
1754  return newChild;
1755 }
1756 
1758 {
1759  if (!newChild || !oldChild)
1760  return 0;
1761  if (oldChild->parent() != this)
1762  return 0;
1763  if (newChild == oldChild)
1764  return 0;
1765 
1766  // mark lists as dirty
1767  QDomDocumentPrivate *const doc = ownerDocument();
1768  if(doc)
1769  doc->nodeListTime++;
1770 
1771  // Special handling for inserting a fragment. We just insert
1772  // all elements of the fragment instead of the fragment itself.
1773  if (newChild->isDocumentFragment()) {
1774  // Fragment is empty ?
1775  if (newChild->first == 0)
1776  return newChild;
1777 
1778  // New parent
1779  QDomNodePrivate* n = newChild->first;
1780  while (n) {
1781  n->setParent(this);
1782  n = n->next;
1783  }
1784 
1785 
1786  if (oldChild->next)
1787  oldChild->next->prev = newChild->last;
1788  if (oldChild->prev)
1789  oldChild->prev->next = newChild->first;
1790 
1791  newChild->last->next = oldChild->next;
1792  newChild->first->prev = oldChild->prev;
1793 
1794  if (first == oldChild)
1795  first = newChild->first;
1796  if (last == oldChild)
1797  last = newChild->last;
1798 
1799  oldChild->setNoParent();
1800  oldChild->next = 0;
1801  oldChild->prev = 0;
1802 
1803  // No need to increase the reference since QDomDocumentFragment
1804  // does not decrease the reference.
1805 
1806  // Remove the nodes from the fragment
1807  newChild->first = 0;
1808  newChild->last = 0;
1809 
1810  // We are no longer interested in the old node
1811  if (oldChild)
1812  oldChild->ref.deref();
1813 
1814  return oldChild;
1815  }
1816 
1817  // No more errors can occur now, so we take
1818  // ownership of the node
1819  newChild->ref.ref();
1820 
1821  // Release new node from its current parent
1822  if (newChild->parent())
1823  newChild->parent()->removeChild(newChild);
1824 
1825  newChild->setParent(this);
1826 
1827  if (oldChild->next)
1828  oldChild->next->prev = newChild;
1829  if (oldChild->prev)
1830  oldChild->prev->next = newChild;
1831 
1832  newChild->next = oldChild->next;
1833  newChild->prev = oldChild->prev;
1834 
1835  if (first == oldChild)
1836  first = newChild;
1837  if (last == oldChild)
1838  last = newChild;
1839 
1840  oldChild->setNoParent();
1841  oldChild->next = 0;
1842  oldChild->prev = 0;
1843 
1844  // We are no longer interested in the old node
1845  if (oldChild)
1846  oldChild->ref.deref();
1847 
1848  return oldChild;
1849 }
1850 
1852 {
1853  // Error check
1854  if (oldChild->parent() != this)
1855  return 0;
1856 
1857  // "mark lists as dirty"
1858  QDomDocumentPrivate *const doc = ownerDocument();
1859  if(doc)
1860  doc->nodeListTime++;
1861 
1862  // Perhaps oldChild was just created with "createElement" or that. In this case
1863  // its parent is QDomDocument but it is not part of the documents child list.
1864  if (oldChild->next == 0 && oldChild->prev == 0 && first != oldChild)
1865  return 0;
1866 
1867  if (oldChild->next)
1868  oldChild->next->prev = oldChild->prev;
1869  if (oldChild->prev)
1870  oldChild->prev->next = oldChild->next;
1871 
1872  if (last == oldChild)
1873  last = oldChild->prev;
1874  if (first == oldChild)
1875  first = oldChild->next;
1876 
1877  oldChild->setNoParent();
1878  oldChild->next = 0;
1879  oldChild->prev = 0;
1880 
1881  // We are no longer interested in the old node
1882  oldChild->ref.deref();
1883 
1884  return oldChild;
1885 }
1886 
1888 {
1889  // No reference manipulation needed. Done in insertAfter.
1890  return insertAfter(newChild, 0);
1891 }
1892 
1894 {
1895  QDomNodePrivate* p = this;
1896  while (p && !p->isDocument()) {
1897  if (!p->hasParent)
1898  return (QDomDocumentPrivate*)p->ownerNode;
1899  p = p->parent();
1900  }
1901 
1902  return static_cast<QDomDocumentPrivate *>(p);
1903 }
1904 
1906 {
1907  QDomNodePrivate* p = new QDomNodePrivate(this, deep);
1908  // We are not interested in this node
1909  p->ref.deref();
1910  return p;
1911 }
1912 
1914 {
1915  QDomNodePrivate* p = n->first;
1916  QDomTextPrivate* t = 0;
1917 
1918  while (p) {
1919  if (p->isText()) {
1920  if (t) {
1921  QDomNodePrivate* tmp = p->next;
1922  t->appendData(p->nodeValue());
1923  n->removeChild(p);
1924  p = tmp;
1925  } else {
1926  t = (QDomTextPrivate*)p;
1927  p = p->next;
1928  }
1929  } else {
1930  p = p->next;
1931  t = 0;
1932  }
1933  }
1934 }
1936 {
1937  // ### This one has moved from QDomElementPrivate to this position. It is
1938  // not tested.
1939  qNormalizeNode(this);
1940 }
1941 
1945 void QDomNodePrivate::save(QTextStream& s, int depth, int indent) const
1946 {
1947  const QDomNodePrivate* n = first;
1948  while (n) {
1949  n->save(s, depth, indent);
1950  n = n->next;
1951  }
1952 }
1953 
1954 void QDomNodePrivate::setLocation(int lineNumber, int columnNumber)
1955 {
1956  this->lineNumber = lineNumber;
1957  this->columnNumber = columnNumber;
1958 }
1959 
1960 /**************************************************************
1961  *
1962  * QDomNode
1963  *
1964  **************************************************************/
1965 
1966 #define IMPL ((QDomNodePrivate*)impl)
1967 
2058 {
2059  impl = 0;
2060 }
2061 
2070 {
2071  impl = n.impl;
2072  if (impl)
2073  impl->ref.ref();
2074 }
2075 
2083 {
2084  impl = n;
2085  if (impl)
2086  impl->ref.ref();
2087 }
2088 
2097 {
2098  if (n.impl)
2099  n.impl->ref.ref();
2100  if (impl && !impl->ref.deref())
2101  delete impl;
2102  impl = n.impl;
2103  return *this;
2104 }
2105 
2126 bool QDomNode::operator== (const QDomNode& n) const
2127 {
2128  return (impl == n.impl);
2129 }
2130 
2135 bool QDomNode::operator!= (const QDomNode& n) const
2136 {
2137  return (impl != n.impl);
2138 }
2139 
2144 {
2145  if (impl && !impl->ref.deref())
2146  delete impl;
2147 }
2148 
2179 {
2180  if (!impl)
2181  return QString();
2182 
2183  if (!IMPL->prefix.isEmpty())
2184  return IMPL->prefix + QLatin1Char(':') + IMPL->name;
2185  return IMPL->name;
2186 }
2187 
2207 {
2208  if (!impl)
2209  return QString();
2210  return IMPL->value;
2211 }
2212 
2219 {
2220  if (!impl)
2221  return;
2222  IMPL->setNodeValue(v);
2223 }
2224 
2257 {
2258  if (!impl)
2259  return QDomNode::BaseNode;
2260  return IMPL->nodeType();
2261 }
2262 
2268 {
2269  if (!impl)
2270  return QDomNode();
2271  return QDomNode(IMPL->parent());
2272 }
2273 
2291 {
2292  if (!impl)
2293  return QDomNodeList();
2294  return QDomNodeList(new QDomNodeListPrivate(impl));
2295 }
2296 
2305 {
2306  if (!impl)
2307  return QDomNode();
2308  return QDomNode(IMPL->first);
2309 }
2310 
2319 {
2320  if (!impl)
2321  return QDomNode();
2322  return QDomNode(IMPL->last);
2323 }
2324 
2337 {
2338  if (!impl)
2339  return QDomNode();
2340  return QDomNode(IMPL->prev);
2341 }
2342 
2355 {
2356  if (!impl)
2357  return QDomNode();
2358  return QDomNode(IMPL->next);
2359 }
2360 
2361 
2362 // ###### don't think this is part of the DOM and
2371 {
2372  if (!impl || !impl->isElement())
2373  return QDomNamedNodeMap();
2374 
2375  return QDomNamedNodeMap(static_cast<QDomElementPrivate *>(impl)->attributes());
2376 }
2377 
2382 {
2383  if (!impl)
2384  return QDomDocument();
2385  return QDomDocument(IMPL->ownerDocument());
2386 }
2387 
2397 {
2398  if (!impl)
2399  return QDomNode();
2400  return QDomNode(IMPL->cloneNode(deep));
2401 }
2402 
2410 {
2411  if (!impl)
2412  return;
2413  IMPL->normalize();
2414 }
2415 
2423 bool QDomNode::isSupported(const QString& feature, const QString& version) const
2424 {
2426  return i.hasFeature(feature, version);
2427 }
2428 
2442 {
2443  if (!impl)
2444  return QString();
2445  return IMPL->namespaceURI;
2446 }
2447 
2470 {
2471  if (!impl)
2472  return QString();
2473  return IMPL->prefix;
2474 }
2475 
2490 {
2491  if (!impl || IMPL->prefix.isNull())
2492  return;
2493  if (isAttr() || isElement())
2494  IMPL->prefix = pre;
2495 }
2496 
2510 {
2511  if (!impl || IMPL->createdWithDom1Interface)
2512  return QString();
2513  return IMPL->name;
2514 }
2515 
2522 {
2523  if (!impl || !impl->isElement())
2524  return false;
2525  return static_cast<QDomElementPrivate *>(impl)->hasAttributes();
2526 }
2527 
2550 QDomNode QDomNode::insertBefore(const QDomNode& newChild, const QDomNode& refChild)
2551 {
2552  if (!impl)
2553  return QDomNode();
2554  return QDomNode(IMPL->insertBefore(newChild.impl, refChild.impl));
2555 }
2556 
2579 QDomNode QDomNode::insertAfter(const QDomNode& newChild, const QDomNode& refChild)
2580 {
2581  if (!impl)
2582  return QDomNode();
2583  return QDomNode(IMPL->insertAfter(newChild.impl, refChild.impl));
2584 }
2585 
2602 QDomNode QDomNode::replaceChild(const QDomNode& newChild, const QDomNode& oldChild)
2603 {
2604  if (!impl || !newChild.impl || !oldChild.impl)
2605  return QDomNode();
2606  return QDomNode(IMPL->replaceChild(newChild.impl, oldChild.impl));
2607 }
2608 
2619 {
2620  if (!impl)
2621  return QDomNode();
2622 
2623  if (oldChild.isNull())
2624  return QDomNode();
2625 
2626  return QDomNode(IMPL->removeChild(oldChild.impl));
2627 }
2628 
2656 {
2657  if (!impl) {
2658  qWarning("Calling appendChild() on a null node does nothing.");
2659  return QDomNode();
2660  }
2661  return QDomNode(IMPL->appendChild(newChild.impl));
2662 }
2663 
2669 {
2670  if (!impl)
2671  return false;
2672  return IMPL->first != 0;
2673 }
2674 
2679 bool QDomNode::isNull() const
2680 {
2681  return (impl == 0);
2682 }
2683 
2691 {
2692  if (impl && !impl->ref.deref())
2693  delete impl;
2694  impl = 0;
2695 }
2696 
2707 {
2708  if (!impl)
2709  return QDomNode();
2710  return QDomNode(impl->namedItem(name));
2711 }
2712 
2728 void QDomNode::save(QTextStream& str, int indent) const
2729 {
2730  save(str, indent, QDomNode::EncodingFromDocument);
2731 }
2732 
2745 void QDomNode::save(QTextStream& str, int indent, EncodingPolicy encodingPolicy) const
2746 {
2747  if (!impl)
2748  return;
2749 
2750  if(isDocument())
2751  static_cast<const QDomDocumentPrivate *>(impl)->saveDocument(str, indent, encodingPolicy);
2752  else
2753  IMPL->save(str, 1, indent);
2754 }
2755 
2766 {
2767  node.save(str, 1);
2768 
2769  return str;
2770 }
2771 
2781 bool QDomNode::isAttr() const
2782 {
2783  if(impl)
2784  return impl->isAttr();
2785  return false;
2786 }
2787 
2799 {
2800  if(impl)
2801  return impl->isCDATASection();
2802  return false;
2803 }
2804 
2816 {
2817  if(impl)
2818  return impl->isDocumentFragment();
2819  return false;
2820 }
2821 
2831 {
2832  if(impl)
2833  return impl->isDocument();
2834  return false;
2835 }
2836 
2848 {
2849  if(impl)
2850  return impl->isDocumentType();
2851  return false;
2852 }
2853 
2863 {
2864  if(impl)
2865  return impl->isElement();
2866  return false;
2867 }
2868 
2880 {
2881  if(impl)
2882  return impl->isEntityReference();
2883  return false;
2884 }
2885 
2894 bool QDomNode::isText() const
2895 {
2896  if(impl)
2897  return impl->isText();
2898  return false;
2899 }
2900 
2910 {
2911  if(impl)
2912  return impl->isEntity();
2913  return false;
2914 }
2915 
2925 {
2926  if(impl)
2927  return impl->isNotation();
2928  return false;
2929 }
2930 
2942 {
2943  if(impl)
2944  return impl->isProcessingInstruction();
2945  return false;
2946 }
2947 
2959 {
2960  if (impl)
2961  return impl->isCharacterData();
2962  return false;
2963 }
2964 
2974 {
2975  if (impl)
2976  return impl->isComment();
2977  return false;
2978 }
2979 
2980 #undef IMPL
2981 
2991 {
2992  for (QDomNode child = firstChild(); !child.isNull(); child = child.nextSibling()) {
2993  if (child.isElement()) {
2994  QDomElement elt = child.toElement();
2995  if (tagName.isEmpty() || elt.tagName() == tagName)
2996  return elt;
2997  }
2998  }
2999  return QDomElement();
3000 }
3001 
3011 {
3012  for (QDomNode child = lastChild(); !child.isNull(); child = child.previousSibling()) {
3013  if (child.isElement()) {
3014  QDomElement elt = child.toElement();
3015  if (tagName.isEmpty() || elt.tagName() == tagName)
3016  return elt;
3017  }
3018  }
3019  return QDomElement();
3020 }
3021 
3031 {
3032  for (QDomNode sib = nextSibling(); !sib.isNull(); sib = sib.nextSibling()) {
3033  if (sib.isElement()) {
3034  QDomElement elt = sib.toElement();
3035  if (tagName.isEmpty() || elt.tagName() == tagName)
3036  return elt;
3037  }
3038  }
3039  return QDomElement();
3040 }
3041 
3051 {
3052  for (QDomNode sib = previousSibling(); !sib.isNull(); sib = sib.previousSibling()) {
3053  if (sib.isElement()) {
3054  QDomElement elt = sib.toElement();
3055  if (tagName.isEmpty() || elt.tagName() == tagName)
3056  return elt;
3057  }
3058  }
3059  return QDomElement();
3060 }
3061 
3075 {
3076  return impl ? impl->lineNumber : -1;
3077 }
3078 
3092 {
3093  return impl ? impl->columnNumber : -1;
3094 }
3095 
3096 
3097 /**************************************************************
3098  *
3099  * QDomNamedNodeMapPrivate
3100  *
3101  **************************************************************/
3102 
3104 {
3105  ref = 1;
3106  readonly = false;
3107  parent = n;
3108  appendToParent = false;
3109 }
3110 
3112 {
3113  clearMap();
3114 }
3115 
3117 {
3119  m->readonly = readonly;
3120  m->appendToParent = appendToParent;
3121 
3123  for (; it != map.constEnd(); ++it) {
3124  QDomNodePrivate *new_node = (*it)->cloneNode();
3125  new_node->setParent(p);
3126  m->setNamedItem(new_node);
3127  }
3128 
3129  // we are no longer interested in ownership
3130  m->ref.deref();
3131  return m.take();
3132 }
3133 
3135 {
3136  // Dereference all of our children if we took references
3137  if (!appendToParent) {
3139  for (; it != map.constEnd(); ++it)
3140  if (!(*it)->ref.deref())
3141  delete *it;
3142  }
3143  map.clear();
3144 }
3145 
3147 {
3148  QDomNodePrivate* p = map[name];
3149  return p;
3150 }
3151 
3153 {
3155  QDomNodePrivate *n;
3156  for (; it != map.constEnd(); ++it) {
3157  n = *it;
3158  if (!n->prefix.isNull()) {
3159  // node has a namespace
3160  if (n->namespaceURI == nsURI && n->name == localName)
3161  return n;
3162  }
3163  }
3164  return 0;
3165 }
3166 
3168 {
3169  if (readonly || !arg)
3170  return 0;
3171 
3172  if (appendToParent)
3173  return parent->appendChild(arg);
3174 
3175  QDomNodePrivate *n = map.value(arg->nodeName());
3176  // We take a reference
3177  arg->ref.ref();
3178  map.insertMulti(arg->nodeName(), arg);
3179  return n;
3180 }
3181 
3183 {
3184  if (readonly || !arg)
3185  return 0;
3186 
3187  if (appendToParent)
3188  return parent->appendChild(arg);
3189 
3190  if (!arg->prefix.isNull()) {
3191  // node has a namespace
3192  QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
3193  // We take a reference
3194  arg->ref.ref();
3195  map.insertMulti(arg->nodeName(), arg);
3196  return n;
3197  } else {
3198  // ### check the following code if it is ok
3199  return setNamedItem(arg);
3200  }
3201 }
3202 
3204 {
3205  if (readonly)
3206  return 0;
3207 
3208  QDomNodePrivate* p = namedItem(name);
3209  if (p == 0)
3210  return 0;
3211  if (appendToParent)
3212  return parent->removeChild(p);
3213 
3214  map.remove(p->nodeName());
3215  // We took a reference, so we have to free one here
3216  p->ref.deref();
3217  return p;
3218 }
3219 
3221 {
3222  if ((uint)index >= length())
3223  return 0;
3224  return *(map.constBegin() + index);
3225 }
3226 
3227 // ### Qt 5: convert all length/size() functions in QDom to use int instead of uint.
3229 {
3230  return map.count();
3231 }
3232 
3234 {
3235  return map.value(name) != 0;
3236 }
3237 
3238 bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & localName) const
3239 {
3240  return namedItemNS(nsURI, localName) != 0;
3241 }
3242 
3243 /**************************************************************
3244  *
3245  * QDomNamedNodeMap
3246  *
3247  **************************************************************/
3248 
3249 #define IMPL ((QDomNamedNodeMapPrivate*)impl)
3250 
3296 {
3297  impl = 0;
3298 }
3299 
3304 {
3305  impl = n.impl;
3306  if (impl)
3307  impl->ref.ref();
3308 }
3309 
3311 {
3312  impl = n;
3313  if (impl)
3314  impl->ref.ref();
3315 }
3316 
3321 {
3322  if (n.impl)
3323  n.impl->ref.ref();
3324  if (impl && !impl->ref.deref())
3325  delete impl;
3326  impl = n.impl;
3327  return *this;
3328 }
3329 
3335 {
3336  return (impl == n.impl);
3337 }
3338 
3344 {
3345  return (impl != n.impl);
3346 }
3347 
3352 {
3353  if (impl && !impl->ref.deref())
3354  delete impl;
3355 }
3356 
3367 {
3368  if (!impl)
3369  return QDomNode();
3370  return QDomNode(IMPL->namedItem(name));
3371 }
3372 
3384 {
3385  if (!impl)
3386  return QDomNode();
3387  return QDomNode(IMPL->setNamedItem((QDomNodePrivate*)newNode.impl));
3388 }
3389 
3400 {
3401  if (!impl)
3402  return QDomNode();
3403  return QDomNode(IMPL->removeNamedItem(name));
3404 }
3405 
3415 {
3416  if (!impl)
3417  return QDomNode();
3418  return QDomNode(IMPL->item(index));
3419 }
3420 
3430 QDomNode QDomNamedNodeMap::namedItemNS(const QString& nsURI, const QString& localName) const
3431 {
3432  if (!impl)
3433  return QDomNode();
3434  return QDomNode(IMPL->namedItemNS(nsURI, localName));
3435 }
3436 
3446 {
3447  if (!impl)
3448  return QDomNode();
3449  return QDomNode(IMPL->setNamedItemNS((QDomNodePrivate*)newNode.impl));
3450 }
3451 
3464 {
3465  if (!impl)
3466  return QDomNode();
3467  QDomNodePrivate *n = IMPL->namedItemNS(nsURI, localName);
3468  if (!n)
3469  return QDomNode();
3470  return QDomNode(IMPL->removeNamedItem(n->name));
3471 }
3472 
3479 {
3480  if (!impl)
3481  return 0;
3482  return IMPL->length();
3483 }
3484 
3522 {
3523  if (!impl)
3524  return false;
3525  return IMPL->contains(name);
3526 }
3527 
3528 #undef IMPL
3529 
3530 /**************************************************************
3531  *
3532  * QDomDocumentTypePrivate
3533  *
3534  **************************************************************/
3535 
3537  : QDomNodePrivate(doc, parent)
3538 {
3539  init();
3540 }
3541 
3543  : QDomNodePrivate(n, deep)
3544 {
3545  init();
3546  // Refill the maps with our new children
3547  QDomNodePrivate* p = first;
3548  while (p) {
3549  if (p->isEntity())
3550  // Don't use normal insert function since we would create infinite recursion
3551  entities->map.insertMulti(p->nodeName(), p);
3552  if (p->isNotation())
3553  // Don't use normal insert function since we would create infinite recursion
3554  notations->map.insertMulti(p->nodeName(), p);
3555  p = p->next;
3556  }
3557 }
3558 
3560 {
3561  if (!entities->ref.deref())
3562  delete entities;
3563  if (!notations->ref.deref())
3564  delete notations;
3565 }
3566 
3568 {
3569  entities = new QDomNamedNodeMapPrivate(this);
3570  QT_TRY {
3571  notations = new QDomNamedNodeMapPrivate(this);
3572  publicId.clear();
3573  systemId.clear();
3575 
3576  entities->setAppendToParent(true);
3578  } QT_CATCH(...) {
3579  delete entities;
3580  QT_RETHROW;
3581  }
3582 }
3583 
3585 {
3586  QDomNodePrivate* p = new QDomDocumentTypePrivate(this, deep);
3587  // We are not interested in this node
3588  p->ref.deref();
3589  return p;
3590 }
3591 
3593 {
3594  // Call the origianl implementation
3595  QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);
3596  // Update the maps
3597  if (p && p->isEntity())
3598  entities->map.insertMulti(p->nodeName(), p);
3599  else if (p && p->isNotation())
3600  notations->map.insertMulti(p->nodeName(), p);
3601 
3602  return p;
3603 }
3604 
3606 {
3607  // Call the origianl implementation
3608  QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);
3609  // Update the maps
3610  if (p && p->isEntity())
3611  entities->map.insertMulti(p->nodeName(), p);
3612  else if (p && p->isNotation())
3613  notations->map.insertMulti(p->nodeName(), p);
3614 
3615  return p;
3616 }
3617 
3619 {
3620  // Call the origianl implementation
3621  QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);
3622  // Update the maps
3623  if (p) {
3624  if (oldChild && oldChild->isEntity())
3625  entities->map.remove(oldChild->nodeName());
3626  else if (oldChild && oldChild->isNotation())
3627  notations->map.remove(oldChild->nodeName());
3628 
3629  if (p->isEntity())
3630  entities->map.insertMulti(p->nodeName(), p);
3631  else if (p->isNotation())
3632  notations->map.insertMulti(p->nodeName(), p);
3633  }
3634 
3635  return p;
3636 }
3637 
3639 {
3640  // Call the origianl implementation
3642  // Update the maps
3643  if (p && p->isEntity())
3644  entities->map.remove(p->nodeName());
3645  else if (p && p->isNotation())
3646  notations->map.remove(p ->nodeName());
3647 
3648  return p;
3649 }
3650 
3652 {
3653  return insertAfter(newChild, 0);
3654 }
3655 
3657 {
3658  QChar quote = data.indexOf(QLatin1Char('\'')) == -1
3659  ? QLatin1Char('\'')
3660  : QLatin1Char('"');
3661  return quote + data + quote;
3662 }
3663 
3664 void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const
3665 {
3666  if (name.isEmpty())
3667  return;
3668 
3669  s << "<!DOCTYPE " << name;
3670 
3671  if (!publicId.isNull()) {
3672  s << " PUBLIC " << quotedValue(publicId);
3673  if (!systemId.isNull()) {
3674  s << ' ' << quotedValue(systemId);
3675  }
3676  } else if (!systemId.isNull()) {
3677  s << " SYSTEM " << quotedValue(systemId);
3678  }
3679 
3680  if (entities->length()>0 || notations->length()>0) {
3681  s << " [" << endl;
3682 
3684  for (; it2 != notations->map.constEnd(); ++it2)
3685  (*it2)->save(s, 0, indent);
3686 
3688  for (; it != entities->map.constEnd(); ++it)
3689  (*it)->save(s, 0, indent);
3690 
3691  s << ']';
3692  }
3693 
3694  s << '>' << endl;
3695 }
3696 
3697 /**************************************************************
3698  *
3699  * QDomDocumentType
3700  *
3701  **************************************************************/
3702 
3703 #define IMPL ((QDomDocumentTypePrivate*)impl)
3704 
3730 QDomDocumentType::QDomDocumentType() : QDomNode()
3731 {
3732 }
3733 
3741 QDomDocumentType::QDomDocumentType(const QDomDocumentType& n)
3742  : QDomNode(n)
3743 {
3744 }
3745 
3746 QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate* n)
3747  : QDomNode(n)
3748 {
3749 }
3750 
3758 QDomDocumentType& QDomDocumentType::operator= (const QDomDocumentType& n)
3759 {
3760  return (QDomDocumentType&) QDomNode::operator=(n);
3761 }
3762 
3769 QString QDomDocumentType::name() const
3770 {
3771  if (!impl)
3772  return QString();
3773  return IMPL->nodeName();
3774 }
3775 
3779 QDomNamedNodeMap QDomDocumentType::entities() const
3780 {
3781  if (!impl)
3782  return QDomNamedNodeMap();
3783  return QDomNamedNodeMap(IMPL->entities);
3784 }
3785 
3789 QDomNamedNodeMap QDomDocumentType::notations() const
3790 {
3791  if (!impl)
3792  return QDomNamedNodeMap();
3793  return QDomNamedNodeMap(IMPL->notations);
3794 }
3795 
3802 QString QDomDocumentType::publicId() const
3803 {
3804  if (!impl)
3805  return QString();
3806  return IMPL->publicId;
3807 }
3808 
3815 QString QDomDocumentType::systemId() const
3816 {
3817  if (!impl)
3818  return QString();
3819  return IMPL->systemId;
3820 }
3821 
3828 QString QDomDocumentType::internalSubset() const
3829 {
3830  if (!impl)
3831  return QString();
3832  return IMPL->internalSubset;
3833 }
3834 
3835 /*
3836  Are these needed at all? The only difference when removing these
3837  two methods in all subclasses is that we'd get a different type
3838  for null nodes.
3839 */
3840 
3852 #undef IMPL
3853 
3854 /**************************************************************
3855  *
3856  * QDomDocumentFragmentPrivate
3857  *
3858  **************************************************************/
3859 
3861  : QDomNodePrivate(doc, parent)
3862 {
3863  name = QLatin1String("#document-fragment");
3864 }
3865 
3867  : QDomNodePrivate(n, deep)
3868 {
3869 }
3870 
3872 {
3873  QDomNodePrivate* p = new QDomDocumentFragmentPrivate(this, deep);
3874  // We are not interested in this node
3875  p->ref.deref();
3876  return p;
3877 }
3878 
3879 /**************************************************************
3880  *
3881  * QDomDocumentFragment
3882  *
3883  **************************************************************/
3884 
3917 {
3918 }
3919 
3921  : QDomNode(n)
3922 {
3923 }
3924 
3933  : QDomNode(x)
3934 {
3935 }
3936 
3945 {
3947 }
3948 
3960 /**************************************************************
3961  *
3962  * QDomCharacterDataPrivate
3963  *
3964  **************************************************************/
3965 
3967  const QString& data)
3968  : QDomNodePrivate(d, p)
3969 {
3970  value = data;
3971  name = QLatin1String("#character-data");
3972 }
3973 
3975  : QDomNodePrivate(n, deep)
3976 {
3977 }
3978 
3980 {
3981  QDomNodePrivate* p = new QDomCharacterDataPrivate(this, deep);
3982  // We are not interested in this node
3983  p->ref.deref();
3984  return p;
3985 }
3986 
3988 {
3989  return value.length();
3990 }
3991 
3992 QString QDomCharacterDataPrivate::substringData(unsigned long offset, unsigned long n) const
3993 {
3994  return value.mid(offset, n);
3995 }
3996 
3997 void QDomCharacterDataPrivate::insertData(unsigned long offset, const QString& arg)
3998 {
3999  value.insert(offset, arg);
4000 }
4001 
4002 void QDomCharacterDataPrivate::deleteData(unsigned long offset, unsigned long n)
4003 {
4004  value.remove(offset, n);
4005 }
4006 
4007 void QDomCharacterDataPrivate::replaceData(unsigned long offset, unsigned long n, const QString& arg)
4008 {
4009  value.replace(offset, n, arg);
4010 }
4011 
4013 {
4014  value += arg;
4015 }
4016 
4017 /**************************************************************
4018  *
4019  * QDomCharacterData
4020  *
4021  **************************************************************/
4022 
4023 #define IMPL ((QDomCharacterDataPrivate*)impl)
4024 
4057 {
4058 }
4059 
4068  : QDomNode(x)
4069 {
4070 }
4071 
4073  : QDomNode(n)
4074 {
4075 }
4076 
4085 {
4087 }
4088 
4096 {
4097  if (!impl)
4098  return QString();
4099  return impl->nodeValue();
4100 }
4101 
4106 {
4107  if (impl)
4108  impl->setNodeValue(v);
4109 }
4110 
4115 {
4116  if (impl)
4117  return IMPL->dataLength();
4118  return 0;
4119 }
4120 
4124 QString QDomCharacterData::substringData(unsigned long offset, unsigned long count)
4125 {
4126  if (!impl)
4127  return QString();
4128  return IMPL->substringData(offset, count);
4129 }
4130 
4135 {
4136  if (impl)
4137  IMPL->appendData(arg);
4138 }
4139 
4143 void QDomCharacterData::insertData(unsigned long offset, const QString& arg)
4144 {
4145  if (impl)
4146  IMPL->insertData(offset, arg);
4147 }
4148 
4152 void QDomCharacterData::deleteData(unsigned long offset, unsigned long count)
4153 {
4154  if (impl)
4155  IMPL->deleteData(offset, count);
4156 }
4157 
4162 void QDomCharacterData::replaceData(unsigned long offset, unsigned long count, const QString& arg)
4163 {
4164  if (impl)
4165  IMPL->replaceData(offset, count, arg);
4166 }
4167 
4174 {
4175  if (!impl)
4176  return CharacterDataNode;
4177  return QDomNode::nodeType();
4178 }
4179 
4180 #undef IMPL
4181 
4182 /**************************************************************
4183  *
4184  * QDomAttrPrivate
4185  *
4186  **************************************************************/
4187 
4189  : QDomNodePrivate(d, parent)
4190 {
4191  name = name_;
4192  m_specified = false;
4193 }
4194 
4196  : QDomNodePrivate(d, p)
4197 {
4198  qt_split_namespace(prefix, name, qName, !nsURI.isNull());
4199  namespaceURI = nsURI;
4200  createdWithDom1Interface = false;
4201  m_specified = false;
4202 }
4203 
4205  : QDomNodePrivate(n, deep)
4206 {
4207  m_specified = n->specified();
4208 }
4209 
4211 {
4212  value = v;
4213  QDomTextPrivate *t = new QDomTextPrivate(0, this, v);
4214  // keep the refcount balanced: appendChild() does a ref anyway.
4215  t->ref.deref();
4216  if (first) {
4217  delete removeChild(first);
4218  }
4219  appendChild(t);
4220 }
4221 
4223 {
4224  QDomNodePrivate* p = new QDomAttrPrivate(this, deep);
4225  // We are not interested in this node
4226  p->ref.deref();
4227  return p;
4228 }
4229 
4231 {
4232  return m_specified;
4233 }
4234 
4235 /* \internal
4236  Encode & escape \a str. Yes, it makes no sense to return a QString,
4237  but is so for legacy reasons.
4238 
4239  Remember that content produced should be able to roundtrip with 2.11 End-of-Line Handling
4240  and 3.3.3 Attribute-Value Normalization.
4241 
4242  If \a performAVN is true, characters will be escaped to survive Attribute Value Normalization.
4243  If \a encodeEOLs is true, characters will be escaped to survive End-of-Line Handling.
4244 */
4245 static QString encodeText(const QString &str,
4246  QTextStream &s,
4247  const bool encodeQuotes = true,
4248  const bool performAVN = false,
4249  const bool encodeEOLs = false)
4250 {
4251 #ifdef QT_NO_TEXTCODEC
4252  Q_UNUSED(s);
4253 #else
4254  const QTextCodec *const codec = s.codec();
4255  Q_ASSERT(codec);
4256 #endif
4257  QString retval(str);
4258  int len = retval.length();
4259  int i = 0;
4260 
4261  while (i < len) {
4262  const QChar ati(retval.at(i));
4263 
4264  if (ati == QLatin1Char('<')) {
4265  retval.replace(i, 1, QLatin1String("&lt;"));
4266  len += 3;
4267  i += 4;
4268  } else if (encodeQuotes && (ati == QLatin1Char('"'))) {
4269  retval.replace(i, 1, QLatin1String("&quot;"));
4270  len += 5;
4271  i += 6;
4272  } else if (ati == QLatin1Char('&')) {
4273  retval.replace(i, 1, QLatin1String("&amp;"));
4274  len += 4;
4275  i += 5;
4276  } else if (ati == QLatin1Char('>') && i >= 2 && retval[i - 1] == QLatin1Char(']') && retval[i - 2] == QLatin1Char(']')) {
4277  retval.replace(i, 1, QLatin1String("&gt;"));
4278  len += 3;
4279  i += 4;
4280  } else if (performAVN &&
4281  (ati == QChar(0xA) ||
4282  ati == QChar(0xD) ||
4283  ati == QChar(0x9))) {
4284  const QString replacement(QLatin1String("&#x") + QString::number(ati.unicode(), 16) + QLatin1Char(';'));
4285  retval.replace(i, 1, replacement);
4286  i += replacement.length();
4287  len += replacement.length() - 1;
4288  } else if (encodeEOLs && ati == QChar(0xD)) {
4289  retval.replace(i, 1, QLatin1String("&#xd;")); // Replace a single 0xD with a ref for 0xD
4290  len += 4;
4291  i += 5;
4292  } else {
4293 #ifndef QT_NO_TEXTCODEC
4294  if(codec->canEncode(ati))
4295  ++i;
4296  else
4297 #endif
4298  {
4299  // We have to use a character reference to get it through.
4300  const ushort codepoint(ati.unicode());
4301  const QString replacement(QLatin1String("&#x") + QString::number(codepoint, 16) + QLatin1Char(';'));
4302  retval.replace(i, 1, replacement);
4303  i += replacement.length();
4304  len += replacement.length() - 1;
4305  }
4306  }
4307  }
4308 
4309  return retval;
4310 }
4311 
4312 void QDomAttrPrivate::save(QTextStream& s, int, int) const
4313 {
4314  if (namespaceURI.isNull()) {
4315  s << name << "=\"" << encodeText(value, s, true, true) << '\"';
4316  } else {
4317  s << prefix << ':' << name << "=\"" << encodeText(value, s, true, true) << '\"';
4318  /* This is a fix for 138243, as good as it gets.
4319  *
4320  * QDomElementPrivate::save() output a namespace declaration if
4321  * the element is in a namespace, no matter what. This function do as well, meaning
4322  * that we get two identical namespace declaration if we don't have the if-
4323  * statement below.
4324  *
4325  * This doesn't work when the parent element has the same prefix as us but
4326  * a different namespace. However, this can only occur by the user modifying the element,
4327  * and we don't do fixups by that anyway, and hence it's the user responsibility to not
4328  * arrive in those situations. */
4329  if(!ownerNode ||
4330  ownerNode->prefix != prefix) {
4331  s << " xmlns:" << prefix << "=\"" << encodeText(namespaceURI, s, true, true) << '\"';
4332  }
4333  }
4334 }
4335 
4336 /**************************************************************
4337  *
4338  * QDomAttr
4339  *
4340  **************************************************************/
4341 
4342 #define IMPL ((QDomAttrPrivate*)impl)
4343 
4385 {
4386 }
4387 
4396  : QDomNode(x)
4397 {
4398 }
4399 
4401  : QDomNode(n)
4402 {
4403 }
4404 
4413 {
4414  return (QDomAttr&) QDomNode::operator=(x);
4415 }
4416 
4421 {
4422  if (!impl)
4423  return QString();
4424  return impl->nodeName();
4425 }
4426 
4434 {
4435  if (!impl)
4436  return false;
4437  return IMPL->specified();
4438 }
4439 
4446 {
4447  Q_ASSERT(impl->parent());
4448  if (!impl->parent()->isElement())
4449  return QDomElement();
4450  return QDomElement((QDomElementPrivate*)(impl->parent()));
4451 }
4452 
4460 {
4461  if (!impl)
4462  return QString();
4463  return impl->nodeValue();
4464 }
4465 
4472 {
4473  if (!impl)
4474  return;
4475  impl->setNodeValue(v);
4476  IMPL->m_specified = true;
4477 }
4478 
4488 #undef IMPL
4489 
4490 /**************************************************************
4491  *
4492  * QDomElementPrivate
4493  *
4494  **************************************************************/
4495 
4497  const QString& tagname)
4498  : QDomNodePrivate(d, p)
4499 {
4500  name = tagname;
4501  m_attr = new QDomNamedNodeMapPrivate(this);
4502 }
4503 
4505  const QString& nsURI, const QString& qName)
4506  : QDomNodePrivate(d, p)
4507 {
4508  qt_split_namespace(prefix, name, qName, !nsURI.isNull());
4509  namespaceURI = nsURI;
4510  createdWithDom1Interface = false;
4511  m_attr = new QDomNamedNodeMapPrivate(this);
4512 }
4513 
4515  QDomNodePrivate(n, deep)
4516 {
4517  m_attr = n->m_attr->clone(this);
4518  // Reference is down to 0, so we set it to 1 here.
4519  m_attr->ref.ref();
4520 }
4521 
4523 {
4524  if (!m_attr->ref.deref())
4525  delete m_attr;
4526 }
4527 
4529 {
4530  QDomNodePrivate* p = new QDomElementPrivate(this, deep);
4531  // We are not interested in this node
4532  p->ref.deref();
4533  return p;
4534 }
4535 
4536 QString QDomElementPrivate::attribute(const QString& name_, const QString& defValue) const
4537 {
4538  QDomNodePrivate* n = m_attr->namedItem(name_);
4539  if (!n)
4540  return defValue;
4541 
4542  return n->nodeValue();
4543 }
4544 
4545 QString QDomElementPrivate::attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const
4546 {
4547  QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4548  if (!n)
4549  return defValue;
4550 
4551  return n->nodeValue();
4552 }
4553 
4554 void QDomElementPrivate::setAttribute(const QString& aname, const QString& newValue)
4555 {
4556  QDomNodePrivate* n = m_attr->namedItem(aname);
4557  if (!n) {
4558  n = new QDomAttrPrivate(ownerDocument(), this, aname);
4559  n->setNodeValue(newValue);
4560 
4561  // Referencing is done by the map, so we set the reference counter back
4562  // to 0 here. This is ok since we created the QDomAttrPrivate.
4563  n->ref.deref();
4564  m_attr->setNamedItem(n);
4565  } else {
4566  n->setNodeValue(newValue);
4567  }
4568 }
4569 
4570 void QDomElementPrivate::setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue)
4571 {
4572  QString prefix, localName;
4573  qt_split_namespace(prefix, localName, qName, true);
4574  QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4575  if (!n) {
4576  n = new QDomAttrPrivate(ownerDocument(), this, nsURI, qName);
4577  n->setNodeValue(newValue);
4578 
4579  // Referencing is done by the map, so we set the reference counter back
4580  // to 0 here. This is ok since we created the QDomAttrPrivate.
4581  n->ref.deref();
4582  m_attr->setNamedItem(n);
4583  } else {
4584  n->setNodeValue(newValue);
4585  n->prefix = prefix;
4586  }
4587 }
4588 
4590 {
4591  QDomNodePrivate* p = m_attr->removeNamedItem(aname);
4592  if (p && p->ref == 0)
4593  delete p;
4594 }
4595 
4597 {
4598  return (QDomAttrPrivate*)m_attr->namedItem(aname);
4599 }
4600 
4602 {
4603  return (QDomAttrPrivate*)m_attr->namedItemNS(nsURI, localName);
4604 }
4605 
4607 {
4608  QDomNodePrivate* n = m_attr->namedItem(newAttr->nodeName());
4609 
4610  // Referencing is done by the maps
4611  m_attr->setNamedItem(newAttr);
4612 
4613  newAttr->setParent(this);
4614 
4615  return (QDomAttrPrivate*)n;
4616 }
4617 
4619 {
4620  QDomNodePrivate* n = 0;
4621  if (!newAttr->prefix.isNull())
4622  n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
4623 
4624  // Referencing is done by the maps
4625  m_attr->setNamedItem(newAttr);
4626 
4627  return (QDomAttrPrivate*)n;
4628 }
4629 
4631 {
4632  return (QDomAttrPrivate*)m_attr->removeNamedItem(oldAttr->nodeName());
4633 }
4634 
4636 {
4637  return m_attr->contains(aname);
4638 }
4639 
4640 bool QDomElementPrivate::hasAttributeNS(const QString& nsURI, const QString& localName)
4641 {
4642  return m_attr->containsNS(nsURI, localName);
4643 }
4644 
4646 {
4647  QString t(QLatin1String(""));
4648 
4649  QDomNodePrivate* p = first;
4650  while (p) {
4651  if (p->isText() || p->isCDATASection())
4652  t += p->nodeValue();
4653  else if (p->isElement())
4654  t += ((QDomElementPrivate*)p)->text();
4655  p = p->next;
4656  }
4657 
4658  return t;
4659 }
4660 
4661 void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const
4662 {
4663  if (!(prev && prev->isText()))
4664  s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
4665 
4666  QString qName(name);
4667  QString nsDecl(QLatin1String(""));
4668  if (!namespaceURI.isNull()) {
4679  if (prefix.isEmpty()) {
4680  nsDecl = QLatin1String(" xmlns");
4681  } else {
4682  qName = prefix + QLatin1Char(':') + name;
4683  nsDecl = QLatin1String(" xmlns:") + prefix;
4684  }
4685  nsDecl += QLatin1String("=\"") + encodeText(namespaceURI, s) + QLatin1Char('\"');
4686  }
4687  s << '<' << qName << nsDecl;
4688 
4689  QSet<QString> outputtedPrefixes;
4690 
4691  /* Write out attributes. */
4692  if (!m_attr->map.isEmpty()) {
4694  for (; it != m_attr->map.constEnd(); ++it) {
4695  s << ' ';
4696  if (it.value()->namespaceURI.isNull()) {
4697  s << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
4698  } else {
4699  s << it.value()->prefix << ':' << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
4700  /* This is a fix for 138243, as good as it gets.
4701  *
4702  * QDomElementPrivate::save() output a namespace declaration if
4703  * the element is in a namespace, no matter what. This function do as well, meaning
4704  * that we get two identical namespace declaration if we don't have the if-
4705  * statement below.
4706  *
4707  * This doesn't work when the parent element has the same prefix as us but
4708  * a different namespace. However, this can only occur by the user modifying the element,
4709  * and we don't do fixups by that anyway, and hence it's the user responsibility to not
4710  * arrive in those situations. */
4711  if((!it.value()->ownerNode ||
4712  it.value()->ownerNode->prefix != it.value()->prefix) &&
4713  !outputtedPrefixes.contains(it.value()->prefix)) {
4714  s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, s, true, true) << '\"';
4715  outputtedPrefixes.insert(it.value()->prefix);
4716  }
4717  }
4718  }
4719  }
4720 
4721  if (last) {
4722  // has child nodes
4723  if (first->isText())
4724  s << '>';
4725  else {
4726  s << '>';
4727 
4728  /* -1 disables new lines. */
4729  if (indent != -1)
4730  s << endl;
4731  }
4732  QDomNodePrivate::save(s, depth + 1, indent); if (!last->isText())
4733  s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
4734 
4735  s << "</" << qName << '>';
4736  } else {
4737  s << "/>";
4738  }
4739  if (!(next && next->isText())) {
4740  /* -1 disables new lines. */
4741  if (indent != -1)
4742  s << endl;
4743  }
4744 }
4745 
4746 /**************************************************************
4747  *
4748  * QDomElement
4749  *
4750  **************************************************************/
4751 
4752 #define IMPL ((QDomElementPrivate*)impl)
4753 
4808 QDomElement::QDomElement()
4809  : QDomNode()
4810 {
4811 }
4812 
4820 QDomElement::QDomElement(const QDomElement& x)
4821  : QDomNode(x)
4822 {
4823 }
4824 
4825 QDomElement::QDomElement(QDomElementPrivate* n)
4826  : QDomNode(n)
4827 {
4828 }
4829 
4837 QDomElement& QDomElement::operator= (const QDomElement& x)
4838 {
4839  return (QDomElement&) QDomNode::operator=(x);
4840 }
4841 
4856 void QDomElement::setTagName(const QString& name)
4857 {
4858  if (impl)
4859  impl->name = name;
4860 }
4861 
4871 QString QDomElement::tagName() const
4872 {
4873  if (!impl)
4874  return QString();
4875  return impl->nodeName();
4876 }
4877 
4878 
4884 QDomNamedNodeMap QDomElement::attributes() const
4885 {
4886  if (!impl)
4887  return QDomNamedNodeMap();
4888  return QDomNamedNodeMap(IMPL->attributes());
4889 }
4890 
4897 QString QDomElement::attribute(const QString& name, const QString& defValue) const
4898 {
4899  if (!impl)
4900  return defValue;
4901  return IMPL->attribute(name, defValue);
4902 }
4903 
4911 void QDomElement::setAttribute(const QString& name, const QString& value)
4912 {
4913  if (!impl)
4914  return;
4915  IMPL->setAttribute(name, value);
4916 }
4917 
4946 void QDomElement::setAttribute(const QString& name, qlonglong value)
4947 {
4948  if (!impl)
4949  return;
4950  QString x;
4951  x.setNum(value);
4952  IMPL->setAttribute(name, x);
4953 }
4954 
4963 void QDomElement::setAttribute(const QString& name, qulonglong value)
4964 {
4965  if (!impl)
4966  return;
4967  QString x;
4968  x.setNum(value);
4969  IMPL->setAttribute(name, x);
4970 }
4971 
4980 void QDomElement::setAttribute(const QString& name, float value)
4981 {
4982  if (!impl)
4983  return;
4984  QString x;
4985  x.setNum(value);
4986  IMPL->setAttribute(name, x);
4987 }
4988 
4997 void QDomElement::setAttribute(const QString& name, double value)
4998 {
4999  if (!impl)
5000  return;
5001  QString x;
5002  char buf[256];
5003  int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
5004  if (count > 0)
5005  x = QString::fromLatin1(buf, count);
5006  else
5007  x.setNum(value); // Fallback
5008  IMPL->setAttribute(name, x);
5009 }
5010 
5016 void QDomElement::removeAttribute(const QString& name)
5017 {
5018  if (!impl)
5019  return;
5020  IMPL->removeAttribute(name);
5021 }
5022 
5030 QDomAttr QDomElement::attributeNode(const QString& name)
5031 {
5032  if (!impl)
5033  return QDomAttr();
5034  return QDomAttr(IMPL->attributeNode(name));
5035 }
5036 
5047 QDomAttr QDomElement::setAttributeNode(const QDomAttr& newAttr)
5048 {
5049  if (!impl)
5050  return QDomAttr();
5051  return QDomAttr(IMPL->setAttributeNode(((QDomAttrPrivate*)newAttr.impl)));
5052 }
5053 
5059 QDomAttr QDomElement::removeAttributeNode(const QDomAttr& oldAttr)
5060 {
5061  if (!impl)
5062  return QDomAttr(); // ### should this return oldAttr?
5063  return QDomAttr(IMPL->removeAttributeNode(((QDomAttrPrivate*)oldAttr.impl)));
5064 }
5065 
5075 QDomNodeList QDomElement::elementsByTagName(const QString& tagname) const
5076 {
5077  return QDomNodeList(new QDomNodeListPrivate(impl, tagname));
5078 }
5079 
5092 bool QDomElement::hasAttribute(const QString& name) const
5093 {
5094  if (!impl)
5095  return false;
5096  return IMPL->hasAttribute(name);
5097 }
5098 
5106 QString QDomElement::attributeNS(const QString nsURI, const QString& localName, const QString& defValue) const
5107 {
5108  if (!impl)
5109  return defValue;
5110  return IMPL->attributeNS(nsURI, localName, defValue);
5111 }
5112 
5125 void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, const QString& value)
5126 {
5127  if (!impl)
5128  return;
5129  IMPL->setAttributeNS(nsURI, qName, value);
5130 }
5131 
5147 void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, qlonglong value)
5148 {
5149  if (!impl)
5150  return;
5151  QString x;
5152  x.setNum(value);
5153  IMPL->setAttributeNS(nsURI, qName, x);
5154 }
5155 
5159 void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, qulonglong value)
5160 {
5161  if (!impl)
5162  return;
5163  QString x;
5164  x.setNum(value);
5165  IMPL->setAttributeNS(nsURI, qName, x);
5166 }
5167 
5171 void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, double value)
5172 {
5173  if (!impl)
5174  return;
5175  QString x;
5176  x.setNum(value);
5177  IMPL->setAttributeNS(nsURI, qName, x);
5178 }
5179 
5186 void QDomElement::removeAttributeNS(const QString& nsURI, const QString& localName)
5187 {
5188  if (!impl)
5189  return;
5190  QDomNodePrivate *n = IMPL->attributeNodeNS(nsURI, localName);
5191  if (!n)
5192  return;
5193  IMPL->removeAttribute(n->nodeName());
5194 }
5195 
5203 QDomAttr QDomElement::attributeNodeNS(const QString& nsURI, const QString& localName)
5204 {
5205  if (!impl)
5206  return QDomAttr();
5207  return QDomAttr(IMPL->attributeNodeNS(nsURI, localName));
5208 }
5209 
5220 QDomAttr QDomElement::setAttributeNodeNS(const QDomAttr& newAttr)
5221 {
5222  if (!impl)
5223  return QDomAttr();
5224  return QDomAttr(IMPL->setAttributeNodeNS(((QDomAttrPrivate*)newAttr.impl)));
5225 }
5226 
5236 QDomNodeList QDomElement::elementsByTagNameNS(const QString& nsURI, const QString& localName) const
5237 {
5238  return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));
5239 }
5240 
5246 bool QDomElement::hasAttributeNS(const QString& nsURI, const QString& localName) const
5247 {
5248  if (!impl)
5249  return false;
5250  return IMPL->hasAttributeNS(nsURI, localName);
5251 }
5252 
5267 QString QDomElement::text() const
5268 {
5269  if (!impl)
5270  return QString();
5271  return IMPL->text();
5272 }
5273 
5274 #undef IMPL
5275 
5276 /**************************************************************
5277  *
5278  * QDomTextPrivate
5279  *
5280  **************************************************************/
5281 
5282 QDomTextPrivate::QDomTextPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& val)
5283  : QDomCharacterDataPrivate(d, parent, val)
5284 {
5285  name = QLatin1String("#text");
5286 }
5287 
5288 QDomTextPrivate::QDomTextPrivate(QDomTextPrivate* n, bool deep)
5289  : QDomCharacterDataPrivate(n, deep)
5290 {
5291 }
5292 
5293 QDomNodePrivate* QDomTextPrivate::cloneNode(bool deep)
5294 {
5295  QDomNodePrivate* p = new QDomTextPrivate(this, deep);
5296  // We are not interested in this node
5297  p->ref.deref();
5298  return p;
5299 }
5300 
5301 QDomTextPrivate* QDomTextPrivate::splitText(int offset)
5302 {
5303  if (!parent()) {
5304  qWarning("QDomText::splitText The node has no parent. So I can not split");
5305  return 0;
5306  }
5307 
5308  QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), 0, value.mid(offset));
5309  value.truncate(offset);
5310 
5311  parent()->insertAfter(t, this);
5312 
5313  return t;
5314 }
5315 
5316 void QDomTextPrivate::save(QTextStream& s, int, int) const
5317 {
5318  QDomTextPrivate *that = const_cast<QDomTextPrivate*>(this);
5319  s << encodeText(value, s, !(that->parent() && that->parent()->isElement()), false, true);
5320 }
5321 
5322 /**************************************************************
5323  *
5324  * QDomText
5325  *
5326  **************************************************************/
5327 
5328 #define IMPL ((QDomTextPrivate*)impl)
5329 
5356 QDomText::QDomText()
5357  : QDomCharacterData()
5358 {
5359 }
5360 
5368 QDomText::QDomText(const QDomText& x)
5369  : QDomCharacterData(x)
5370 {
5371 }
5372 
5373 QDomText::QDomText(QDomTextPrivate* n)
5374  : QDomCharacterData(n)
5375 {
5376 }
5377 
5385 QDomText& QDomText::operator= (const QDomText& x)
5386 {
5387  return (QDomText&) QDomNode::operator=(x);
5388 }
5389 
5409 QDomText QDomText::splitText(int offset)
5410 {
5411  if (!impl)
5412  return QDomText();
5413  return QDomText(IMPL->splitText(offset));
5414 }
5415 
5416 #undef IMPL
5417 
5418 /**************************************************************
5419  *
5420  * QDomCommentPrivate
5421  *
5422  **************************************************************/
5423 
5424 QDomCommentPrivate::QDomCommentPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& val)
5425  : QDomCharacterDataPrivate(d, parent, val)
5426 {
5427  name = QLatin1String("#comment");
5428 }
5429 
5430 QDomCommentPrivate::QDomCommentPrivate(QDomCommentPrivate* n, bool deep)
5431  : QDomCharacterDataPrivate(n, deep)
5432 {
5433 }
5434 
5435 
5436 QDomNodePrivate* QDomCommentPrivate::cloneNode(bool deep)
5437 {
5438  QDomNodePrivate* p = new QDomCommentPrivate(this, deep);
5439  // We are not interested in this node
5440  p->ref.deref();
5441  return p;
5442 }
5443 
5444 void QDomCommentPrivate::save(QTextStream& s, int depth, int indent) const
5445 {
5446  /* We don't output whitespace if we would pollute a text node. */
5447  if (!(prev && prev->isText()))
5448  s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
5449 
5450  s << "<!--" << value;
5451  if (value.endsWith(QLatin1Char('-')))
5452  s << ' '; // Ensures that XML comment doesn't end with --->
5453  s << "-->";
5454 
5455  if (!(next && next->isText()))
5456  s << endl;
5457 }
5458 
5459 /**************************************************************
5460  *
5461  * QDomComment
5462  *
5463  **************************************************************/
5464 
5491  : QDomCharacterData()
5492 {
5493 }
5494 
5503  : QDomCharacterData(x)
5504 {
5505 }
5506 
5508  : QDomCharacterData(n)
5509 {
5510 }
5511 
5520 {
5521  return (QDomComment&) QDomNode::operator=(x);
5522 }
5523 
5533 /**************************************************************
5534  *
5535  * QDomCDATASectionPrivate
5536  *
5537  **************************************************************/
5538 
5540  const QString& val)
5541  : QDomTextPrivate(d, parent, val)
5542 {
5543  name = QLatin1String("#cdata-section");
5544 }
5545 
5547  : QDomTextPrivate(n, deep)
5548 {
5549 }
5550 
5552 {
5553  QDomNodePrivate* p = new QDomCDATASectionPrivate(this, deep);
5554  // We are not interested in this node
5555  p->ref.deref();
5556  return p;
5557 }
5558 
5560 {
5561  // ### How do we escape "]]>" ?
5562  // "]]>" is not allowed; so there should be none in value anyway
5563  s << "<![CDATA[" << value << "]]>";
5564 }
5565 
5566 /**************************************************************
5567  *
5568  * QDomCDATASection
5569  *
5570  **************************************************************/
5571 
5604  : QDomText()
5605 {
5606 }
5607 
5616  : QDomText(x)
5617 {
5618 }
5619 
5621  : QDomText(n)
5622 {
5623 }
5624 
5633 {
5635 }
5636 
5646 /**************************************************************
5647  *
5648  * QDomNotationPrivate
5649  *
5650  **************************************************************/
5651 
5653  const QString& aname,
5654  const QString& pub, const QString& sys)
5655  : QDomNodePrivate(d, parent)
5656 {
5657  name = aname;
5658  m_pub = pub;
5659  m_sys = sys;
5660 }
5661 
5663  : QDomNodePrivate(n, deep)
5664 {
5665  m_sys = n->m_sys;
5666  m_pub = n->m_pub;
5667 }
5668 
5670 {
5671  QDomNodePrivate* p = new QDomNotationPrivate(this, deep);
5672  // We are not interested in this node
5673  p->ref.deref();
5674  return p;
5675 }
5676 
5677 void QDomNotationPrivate::save(QTextStream& s, int, int) const
5678 {
5679  s << "<!NOTATION " << name << ' ';
5680  if (!m_pub.isNull()) {
5681  s << "PUBLIC " << quotedValue(m_pub);
5682  if (!m_sys.isNull())
5683  s << ' ' << quotedValue(m_sys);
5684  } else {
5685  s << "SYSTEM " << quotedValue(m_sys);
5686  }
5687  s << '>' << endl;
5688 }
5689 
5690 /**************************************************************
5691  *
5692  * QDomNotation
5693  *
5694  **************************************************************/
5695 
5696 #define IMPL ((QDomNotationPrivate*)impl)
5697 
5733 QDomNotation::QDomNotation()
5734  : QDomNode()
5735 {
5736 }
5737 
5745 QDomNotation::QDomNotation(const QDomNotation& x)
5746  : QDomNode(x)
5747 {
5748 }
5749 
5750 QDomNotation::QDomNotation(QDomNotationPrivate* n)
5751  : QDomNode(n)
5752 {
5753 }
5754 
5762 QDomNotation& QDomNotation::operator= (const QDomNotation& x)
5763 {
5764  return (QDomNotation&) QDomNode::operator=(x);
5765 }
5766 
5779 QString QDomNotation::publicId() const
5780 {
5781  if (!impl)
5782  return QString();
5783  return IMPL->m_pub;
5784 }
5785 
5789 QString QDomNotation::systemId() const
5790 {
5791  if (!impl)
5792  return QString();
5793  return IMPL->m_sys;
5794 }
5795 
5796 #undef IMPL
5797 
5798 /**************************************************************
5799  *
5800  * QDomEntityPrivate
5801  *
5802  **************************************************************/
5803 
5804 QDomEntityPrivate::QDomEntityPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5805  const QString& aname,
5806  const QString& pub, const QString& sys, const QString& notation)
5807  : QDomNodePrivate(d, parent)
5808 {
5809  name = aname;
5810  m_pub = pub;
5811  m_sys = sys;
5812  m_notationName = notation;
5813 }
5814 
5815 QDomEntityPrivate::QDomEntityPrivate(QDomEntityPrivate* n, bool deep)
5816  : QDomNodePrivate(n, deep)
5817 {
5818  m_sys = n->m_sys;
5819  m_pub = n->m_pub;
5820  m_notationName = n->m_notationName;
5821 }
5822 
5823 QDomNodePrivate* QDomEntityPrivate::cloneNode(bool deep)
5824 {
5825  QDomNodePrivate* p = new QDomEntityPrivate(this, deep);
5826  // We are not interested in this node
5827  p->ref.deref();
5828  return p;
5829 }
5830 
5831 /*
5832  Encode an entity value upon saving.
5833 */
5834 static QByteArray encodeEntity(const QByteArray& str)
5835 {
5836  QByteArray tmp(str);
5837  uint len = tmp.size();
5838  uint i = 0;
5839  const char* d = tmp.data();
5840  while (i < len) {
5841  if (d[i] == '%'){
5842  tmp.replace(i, 1, "&#60;");
5843  d = tmp;
5844  len += 4;
5845  i += 5;
5846  }
5847  else if (d[i] == '"') {
5848  tmp.replace(i, 1, "&#34;");
5849  d = tmp;
5850  len += 4;
5851  i += 5;
5852  } else if (d[i] == '&' && i + 1 < len && d[i+1] == '#') {
5853  // Don't encode &lt; or &quot; or &custom;.
5854  // Only encode character references
5855  tmp.replace(i, 1, "&#38;");
5856  d = tmp;
5857  len += 4;
5858  i += 5;
5859  } else {
5860  ++i;
5861  }
5862  }
5863 
5864  return tmp;
5865 }
5866 
5867 void QDomEntityPrivate::save(QTextStream& s, int, int) const
5868 {
5869  QString _name = name;
5870  if (_name.startsWith(QLatin1Char('%')))
5871  _name = QLatin1String("% ") + _name.mid(1);
5872 
5873  if (m_sys.isNull() && m_pub.isNull()) {
5874  s << "<!ENTITY " << _name << " \"" << encodeEntity(value.toUtf8()) << "\">" << endl;
5875  } else {
5876  s << "<!ENTITY " << _name << ' ';
5877  if (m_pub.isNull()) {
5878  s << "SYSTEM " << quotedValue(m_sys);
5879  } else {
5880  s << "PUBLIC " << quotedValue(m_pub) << ' ' << quotedValue(m_sys);
5881  }
5882  if (! m_notationName.isNull()) {
5883  s << " NDATA " << m_notationName;
5884  }
5885  s << '>' << endl;
5886  }
5887 }
5888 
5889 /**************************************************************
5890  *
5891  * QDomEntity
5892  *
5893  **************************************************************/
5894 
5895 #define IMPL ((QDomEntityPrivate*)impl)
5896 
5935 QDomEntity::QDomEntity()
5936  : QDomNode()
5937 {
5938 }
5939 
5940 
5948 QDomEntity::QDomEntity(const QDomEntity& x)
5949  : QDomNode(x)
5950 {
5951 }
5952 
5953 QDomEntity::QDomEntity(QDomEntityPrivate* n)
5954  : QDomNode(n)
5955 {
5956 }
5957 
5965 QDomEntity& QDomEntity::operator= (const QDomEntity& x)
5966 {
5967  return (QDomEntity&) QDomNode::operator=(x);
5968 }
5969 
5983 QString QDomEntity::publicId() const
5984 {
5985  if (!impl)
5986  return QString();
5987  return IMPL->m_pub;
5988 }
5989 
5994 QString QDomEntity::systemId() const
5995 {
5996  if (!impl)
5997  return QString();
5998  return IMPL->m_sys;
5999 }
6000 
6006 QString QDomEntity::notationName() const
6007 {
6008  if (!impl)
6009  return QString();
6010  return IMPL->m_notationName;
6011 }
6012 
6013 #undef IMPL
6014 
6015 /**************************************************************
6016  *
6017  * QDomEntityReferencePrivate
6018  *
6019  **************************************************************/
6020 
6021 QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& aname)
6022  : QDomNodePrivate(d, parent)
6023 {
6024  name = aname;
6025 }
6026 
6027 QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomNodePrivate* n, bool deep)
6028  : QDomNodePrivate(n, deep)
6029 {
6030 }
6031 
6032 QDomNodePrivate* QDomEntityReferencePrivate::cloneNode(bool deep)
6033 {
6034  QDomNodePrivate* p = new QDomEntityReferencePrivate(this, deep);
6035  // We are not interested in this node
6036  p->ref.deref();
6037  return p;
6038 }
6039 
6040 void QDomEntityReferencePrivate::save(QTextStream& s, int, int) const
6041 {
6042  s << '&' << name << ';';
6043 }
6044 
6045 /**************************************************************
6046  *
6047  * QDomEntityReference
6048  *
6049  **************************************************************/
6050 
6094 QDomEntityReference::QDomEntityReference()
6095  : QDomNode()
6096 {
6097 }
6098 
6106 QDomEntityReference::QDomEntityReference(const QDomEntityReference& x)
6107  : QDomNode(x)
6108 {
6109 }
6110 
6111 QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n)
6112  : QDomNode(n)
6113 {
6114 }
6115 
6123 QDomEntityReference& QDomEntityReference::operator= (const QDomEntityReference& x)
6124 {
6125  return (QDomEntityReference&) QDomNode::operator=(x);
6126 }
6127 
6137 /**************************************************************
6138  *
6139  * QDomProcessingInstructionPrivate
6140  *
6141  **************************************************************/
6142 
6143 QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomDocumentPrivate* d,
6144  QDomNodePrivate* parent, const QString& target, const QString& data)
6145  : QDomNodePrivate(d, parent)
6146 {
6147  name = target;
6148  value = data;
6149 }
6150 
6151 QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n, bool deep)
6152  : QDomNodePrivate(n, deep)
6153 {
6154 }
6155 
6156 
6157 QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(bool deep)
6158 {
6159  QDomNodePrivate* p = new QDomProcessingInstructionPrivate(this, deep);
6160  // We are not interested in this node
6161  p->ref.deref();
6162  return p;
6163 }
6164 
6165 void QDomProcessingInstructionPrivate::save(QTextStream& s, int, int) const
6166 {
6167  s << "<?" << name << ' ' << value << "?>" << endl;
6168 }
6169 
6170 /**************************************************************
6171  *
6172  * QDomProcessingInstruction
6173  *
6174  **************************************************************/
6175 
6217 QDomProcessingInstruction::QDomProcessingInstruction()
6218  : QDomNode()
6219 {
6220 }
6221 
6229 QDomProcessingInstruction::QDomProcessingInstruction(const QDomProcessingInstruction& x)
6230  : QDomNode(x)
6231 {
6232 }
6233 
6234 QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPrivate* n)
6235  : QDomNode(n)
6236 {
6237 }
6238 
6246 QDomProcessingInstruction& QDomProcessingInstruction::operator= (const QDomProcessingInstruction& x)
6247 {
6248  return (QDomProcessingInstruction&) QDomNode::operator=(x);
6249 }
6250 
6265 QString QDomProcessingInstruction::target() const
6266 {
6267  if (!impl)
6268  return QString();
6269  return impl->nodeName();
6270 }
6271 
6277 QString QDomProcessingInstruction::data() const
6278 {
6279  if (!impl)
6280  return QString();
6281  return impl->nodeValue();
6282 }
6283 
6289 void QDomProcessingInstruction::setData(const QString& d)
6290 {
6291  if (!impl)
6292  return;
6293  impl->setNodeValue(d);
6294 }
6295 
6296 /**************************************************************
6297  *
6298  * QDomDocumentPrivate
6299  *
6300  **************************************************************/
6301 
6302 QDomDocumentPrivate::QDomDocumentPrivate()
6303  : QDomNodePrivate(0),
6304  impl(new QDomImplementationPrivate),
6305  nodeListTime(1)
6306 {
6307  type = new QDomDocumentTypePrivate(this, this);
6308  type->ref.deref();
6309 
6310  name = QLatin1String("#document");
6311 }
6312 
6313 QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname)
6314  : QDomNodePrivate(0),
6315  impl(new QDomImplementationPrivate),
6316  nodeListTime(1)
6317 {
6318  type = new QDomDocumentTypePrivate(this, this);
6319  type->ref.deref();
6320  type->name = aname;
6321 
6322  name = QLatin1String("#document");
6323 }
6324 
6325 QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)
6326  : QDomNodePrivate(0),
6327  impl(new QDomImplementationPrivate),
6328  nodeListTime(1)
6329 {
6330  if (dt != 0) {
6331  type = dt;
6332  } else {
6333  type = new QDomDocumentTypePrivate(this, this);
6334  type->ref.deref();
6335  }
6336 
6337  name = QLatin1String("#document");
6338 }
6339 
6340 QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep)
6341  : QDomNodePrivate(n, deep),
6342  impl(n->impl->clone()),
6343  nodeListTime(1)
6344 {
6345  type = static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());
6346  type->setParent(this);
6347 }
6348 
6349 QDomDocumentPrivate::~QDomDocumentPrivate()
6350 {
6351 }
6352 
6353 void QDomDocumentPrivate::clear()
6354 {
6355  impl.reset();
6356  type.reset();
6357  QDomNodePrivate::clear();
6358 }
6359 
6360 static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing)
6361 {
6362  reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing);
6363  reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), !namespaceProcessing);
6364  reader.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), false); // Shouldn't change in Qt 4
6365 }
6366 
6367 bool QDomDocumentPrivate::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
6368 {
6369  QXmlSimpleReader reader;
6370  initializeReader(reader, namespaceProcessing);
6371  return setContent(source, &reader, errorMsg, errorLine, errorColumn);
6372 }
6373 
6374 bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn)
6375 {
6376  clear();
6378  type = new QDomDocumentTypePrivate(this, this);
6379  type->ref.deref();
6380 
6381  bool namespaceProcessing = reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))
6382  && !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"));
6383 
6384  QDomHandler hnd(this, namespaceProcessing);
6385  reader->setContentHandler(&hnd);
6386  reader->setErrorHandler(&hnd);
6387  reader->setLexicalHandler(&hnd);
6388  reader->setDeclHandler(&hnd);
6389  reader->setDTDHandler(&hnd);
6390 
6391  if (!reader->parse(source)) {
6392  if (errorMsg)
6393  *errorMsg = hnd.errorMsg;
6394  if (errorLine)
6395  *errorLine = hnd.errorLine;
6396  if (errorColumn)
6397  *errorColumn = hnd.errorColumn;
6398  return false;
6399  }
6400 
6401  return true;
6402 }
6403 
6405 {
6406  QDomNodePrivate *p = new QDomDocumentPrivate(this, deep);
6407  // We are not interested in this node
6408  p->ref.deref();
6409  return p;
6410 }
6411 
6413 {
6414  QDomNodePrivate *p = first;
6415  while (p && !p->isElement())
6416  p = p->next;
6417 
6418  return static_cast<QDomElementPrivate *>(p);
6419 }
6420 
6422 {
6423  bool ok;
6424  QString fixedName = fixedXmlName(tagName, &ok);
6425  if (!ok)
6426  return 0;
6427 
6428  QDomElementPrivate *e = new QDomElementPrivate(this, 0, fixedName);
6429  e->ref.deref();
6430  return e;
6431 }
6432 
6433 QDomElementPrivate* QDomDocumentPrivate::createElementNS(const QString &nsURI, const QString &qName)
6434 {
6435  bool ok;
6436  QString fixedName = fixedXmlName(qName, &ok, true);
6437  if (!ok)
6438  return 0;
6439 
6440  QDomElementPrivate *e = new QDomElementPrivate(this, 0, nsURI, fixedName);
6441  e->ref.deref();
6442  return e;
6443 }
6444 
6446 {
6448  f->ref.deref();
6449  return f;
6450 }
6451 
6453 {
6454  bool ok;
6455  QString fixedData = fixedCharData(data, &ok);
6456  if (!ok)
6457  return 0;
6458 
6459  QDomTextPrivate *t = new QDomTextPrivate(this, 0, fixedData);
6460  t->ref.deref();
6461  return t;
6462 }
6463 
6465 {
6466  bool ok;
6467  QString fixedData = fixedComment(data, &ok);
6468  if (!ok)
6469  return 0;
6470 
6471  QDomCommentPrivate *c = new QDomCommentPrivate(this, 0, fixedData);
6472  c->ref.deref();
6473  return c;
6474 }
6475 
6477 {
6478  bool ok;
6479  QString fixedData = fixedCDataSection(data, &ok);
6480  if (!ok)
6481  return 0;
6482 
6483  QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, 0, fixedData);
6484  c->ref.deref();
6485  return c;
6486 }
6487 
6489  const QString &data)
6490 {
6491  bool ok;
6492  QString fixedData = fixedPIData(data, &ok);
6493  if (!ok)
6494  return 0;
6495  // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
6496  QString fixedTarget = fixedXmlName(target, &ok);
6497  if (!ok)
6498  return 0;
6499 
6500  QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, 0, fixedTarget, fixedData);
6501  p->ref.deref();
6502  return p;
6503 }
6505 {
6506  bool ok;
6507  QString fixedName = fixedXmlName(aname, &ok);
6508  if (!ok)
6509  return 0;
6510 
6511  QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, fixedName);
6512  a->ref.deref();
6513  return a;
6514 }
6515 
6516 QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(const QString &nsURI, const QString &qName)
6517 {
6518  bool ok;
6519  QString fixedName = fixedXmlName(qName, &ok, true);
6520  if (!ok)
6521  return 0;
6522 
6523  QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, nsURI, fixedName);
6524  a->ref.deref();
6525  return a;
6526 }
6527 
6529 {
6530  bool ok;
6531  QString fixedName = fixedXmlName(aname, &ok);
6532  if (!ok)
6533  return 0;
6534 
6535  QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, 0, fixedName);
6536  e->ref.deref();
6537  return e;
6538 }
6539 
6541 {
6542  QDomNodePrivate *node = 0;
6543  switch (importedNode->nodeType()) {
6545  node = new QDomAttrPrivate((QDomAttrPrivate*)importedNode, true);
6546  break;
6548  node = new QDomDocumentFragmentPrivate((QDomDocumentFragmentPrivate*)importedNode, deep);
6549  break;
6550  case QDomNode::ElementNode:
6551  node = new QDomElementPrivate((QDomElementPrivate*)importedNode, deep);
6552  break;
6553  case QDomNode::EntityNode:
6554  node = new QDomEntityPrivate((QDomEntityPrivate*)importedNode, deep);
6555  break;
6557  node = new QDomEntityReferencePrivate((QDomEntityReferencePrivate*)importedNode, false);
6558  break;
6560  node = new QDomNotationPrivate((QDomNotationPrivate*)importedNode, deep);
6561  break;
6563  node = new QDomProcessingInstructionPrivate((QDomProcessingInstructionPrivate*)importedNode, deep);
6564  break;
6565  case QDomNode::TextNode:
6566  node = new QDomTextPrivate((QDomTextPrivate*)importedNode, deep);
6567  break;
6569  node = new QDomCDATASectionPrivate((QDomCDATASectionPrivate*)importedNode, deep);
6570  break;
6571  case QDomNode::CommentNode:
6572  node = new QDomCommentPrivate((QDomCommentPrivate*)importedNode, deep);
6573  break;
6574  default:
6575  break;
6576  }
6577  if (node) {
6578  node->setOwnerDocument(this);
6579  // The QDomNode constructor increases the refcount, so deref first to
6580  // keep refcount balanced.
6581  node->ref.deref();
6582  }
6583  return node;
6584 }
6585 
6587 {
6588  const QDomNodePrivate* n = first;
6589 
6590  if(encUsed == QDomNode::EncodingFromDocument) {
6591 #ifndef QT_NO_TEXTCODEC
6592  const QDomNodePrivate* n = first;
6593 
6594  QTextCodec *codec = 0;
6595 
6596  if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {
6597  // we have an XML declaration
6598  QString data = n->nodeValue();
6599  QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
6600  encoding.indexIn(data);
6601  QString enc = encoding.cap(3);
6602  if (enc.isEmpty())
6603  enc = encoding.cap(5);
6604  if (!enc.isEmpty())
6605  codec = QTextCodec::codecForName(enc.toLatin1().data());
6606  }
6607  if (!codec)
6608  codec = QTextCodec::codecForName("UTF-8");
6609  if (codec)
6610  s.setCodec(codec);
6611 #endif
6612  bool doc = false;
6613 
6614  while (n) {
6615  if (!doc && !(n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml"))) {
6616  // save doctype after XML declaration
6617  type->save(s, 0, indent);
6618  doc = true;
6619  }
6620  n->save(s, 0, indent);
6621  n = n->next;
6622  }
6623  }
6624  else {
6625 
6626  // Write out the XML declaration.
6627 #ifdef QT_NO_TEXTCODEC
6628  const QLatin1String codecName("iso-8859-1");
6629 #else
6630  const QTextCodec *const codec = s.codec();
6631  Q_ASSERT_X(codec, "QDomNode::save()", "A codec must be specified in the text stream.");
6632  const QByteArray codecName = codec->name();
6633 #endif
6634 
6635  s << "<?xml version=\"1.0\" encoding=\""
6636  << codecName
6637  << "\"?>\n";
6638 
6639  // Skip the first processing instruction by name "xml", if any such exists.
6640  const QDomNodePrivate* startNode = n;
6641 
6642  // First, we try to find the PI and sets the startNode to the one appearing after it.
6643  while (n) {
6644  if(n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {
6645  startNode = n->next;
6646  break;
6647  }
6648  else
6649  n = n->next;
6650  }
6651 
6652  // Now we serialize all the nodes after the faked XML declaration(the PI).
6653  while(startNode) {
6654  startNode->save(s, 0, indent);
6655  startNode = startNode->next;
6656  }
6657  }
6658 }
6659 
6660 /**************************************************************
6661  *
6662  * QDomDocument
6663  *
6664  **************************************************************/
6665 
6666 #define IMPL ((QDomDocumentPrivate*)impl)
6667 
6752 {
6753  impl = 0;
6754 }
6755 
6760 QDomDocument::QDomDocument(const QString& name)
6761 {
6762  // We take over ownership
6763  impl = new QDomDocumentPrivate(name);
6764 }
6765 
6772 {
6774 }
6775 
6784  : QDomNode(x)
6785 {
6786 }
6787 
6789  : QDomNode(x)
6790 {
6791 }
6792 
6801 {
6802  return (QDomDocument&) QDomNode::operator=(x);
6803 }
6804 
6809 {
6810 }
6811 
6823 bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
6824 {
6825  if (!impl)
6826  impl = new QDomDocumentPrivate();
6827  QXmlInputSource source;
6828  source.setData(text);
6829  return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
6830 }
6831 
6887 bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
6888 {
6889  if (!impl)
6890  impl = new QDomDocumentPrivate();
6891  QBuffer buf;
6892  buf.setData(data);
6893  QXmlInputSource source(&buf);
6894  return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
6895 }
6896 
6906 bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
6907 {
6908  if (!impl)
6909  impl = new QDomDocumentPrivate();
6910  QXmlInputSource source(dev);
6911  return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
6912 }
6913 
6925 bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn )
6926 {
6927  if (!impl)
6928  impl = new QDomDocumentPrivate();
6929  QXmlSimpleReader reader;
6930  initializeReader(reader, namespaceProcessing);
6931  return IMPL->setContent(source, &reader, errorMsg, errorLine, errorColumn);
6932 }
6933 
6947 bool QDomDocument::setContent(const QString& text, QString *errorMsg, int *errorLine, int *errorColumn)
6948 {
6949  return setContent(text, false, errorMsg, errorLine, errorColumn);
6950 }
6951 
6964 bool QDomDocument::setContent(const QByteArray& buffer, QString *errorMsg, int *errorLine, int *errorColumn )
6965 {
6966  return setContent(buffer, false, errorMsg, errorLine, errorColumn);
6967 }
6968 
6980 bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine, int *errorColumn )
6981 {
6982  return setContent(dev, false, errorMsg, errorLine, errorColumn);
6983 }
6984 
7001 bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn )
7002 {
7003  if (!impl)
7004  impl = new QDomDocumentPrivate();
7005  return IMPL->setContent(source, reader, errorMsg, errorLine, errorColumn);
7006 }
7007 
7016 QString QDomDocument::toString(int indent) const
7017 {
7018  QString str;
7020  save(s, indent);
7021  return str;
7022 }
7023 
7034 {
7035  // ### if there is an encoding specified in the xml declaration, this
7036  // encoding declaration should be changed to utf8
7037  return toString(indent).toUtf8();
7038 }
7039 
7040 
7045 {
7046  if (!impl)
7047  return QDomDocumentType();
7048  return QDomDocumentType(IMPL->doctype());
7049 }
7050 
7055 {
7056  if (!impl)
7057  return QDomImplementation();
7058  return QDomImplementation(IMPL->implementation());
7059 }
7060 
7065 {
7066  if (!impl)
7067  return QDomElement();
7068  return QDomElement(IMPL->documentElement());
7069 }
7070 
7082 {
7083  if (!impl)
7084  impl = new QDomDocumentPrivate();
7085  return QDomElement(IMPL->createElement(tagName));
7086 }
7087 
7094 {
7095  if (!impl)
7096  impl = new QDomDocumentPrivate();
7097  return QDomDocumentFragment(IMPL->createDocumentFragment());
7098 }
7099 
7111 {
7112  if (!impl)
7113  impl = new QDomDocumentPrivate();
7114  return QDomText(IMPL->createTextNode(value));
7115 }
7116 
7127 {
7128  if (!impl)
7129  impl = new QDomDocumentPrivate();
7130  return QDomComment(IMPL->createComment(value));
7131 }
7132 
7144 {
7145  if (!impl)
7146  impl = new QDomDocumentPrivate();
7147  return QDomCDATASection(IMPL->createCDATASection(value));
7148 }
7149 
7163  const QString& data)
7164 {
7165  if (!impl)
7166  impl = new QDomDocumentPrivate();
7167  return QDomProcessingInstruction(IMPL->createProcessingInstruction(target, data));
7168 }
7169 
7170 
7181 {
7182  if (!impl)
7183  impl = new QDomDocumentPrivate();
7184  return QDomAttr(IMPL->createAttribute(name));
7185 }
7186 
7197 {
7198  if (!impl)
7199  impl = new QDomDocumentPrivate();
7200  return QDomEntityReference(IMPL->createEntityReference(name));
7201 }
7202 
7211 QDomNodeList QDomDocument::elementsByTagName(const QString& tagname) const
7212 {
7213  return QDomNodeList(new QDomNodeListPrivate(impl, tagname));
7214 }
7215 
7282 QDomNode QDomDocument::importNode(const QDomNode& importedNode, bool deep)
7283 {
7284  if (!impl)
7285  impl = new QDomDocumentPrivate();
7286  return QDomNode(IMPL->importNode(importedNode.impl, deep));
7287 }
7288 
7301 QDomElement QDomDocument::createElementNS(const QString& nsURI, const QString& qName)
7302 {
7303  if (!impl)
7304  impl = new QDomDocumentPrivate();
7305  return QDomElement(IMPL->createElementNS(nsURI, qName));
7306 }
7307 
7320 QDomAttr QDomDocument::createAttributeNS(const QString& nsURI, const QString& qName)
7321 {
7322  if (!impl)
7323  impl = new QDomDocumentPrivate();
7324  return QDomAttr(IMPL->createAttributeNS(nsURI, qName));
7325 }
7326 
7335 QDomNodeList QDomDocument::elementsByTagNameNS(const QString& nsURI, const QString& localName)
7336 {
7337  return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));
7338 }
7339 
7349 QDomElement QDomDocument::elementById(const QString& /*elementId*/)
7350 {
7351  qWarning("elementById() is not implemented and will always return a null node.");
7352  return QDomElement();
7353 }
7354 
7364 #undef IMPL
7365 
7366 /**************************************************************
7367  *
7368  * Node casting functions
7369  *
7370  **************************************************************/
7371 
7380 {
7381  if (impl && impl->isAttr())
7382  return QDomAttr(((QDomAttrPrivate*)impl));
7383  return QDomAttr();
7384 }
7385 
7394 {
7395  if (impl && impl->isCDATASection())
7397  return QDomCDATASection();
7398 }
7399 
7408 {
7409  if (impl && impl->isDocumentFragment())
7411  return QDomDocumentFragment();
7412 }
7413 
7422 {
7423  if (impl && impl->isDocument())
7425  return QDomDocument();
7426 }
7427 
7436 {
7437  if (impl && impl->isDocumentType())
7439  return QDomDocumentType();
7440 }
7441 
7450 {
7451  if (impl && impl->isElement())
7452  return QDomElement(((QDomElementPrivate*)impl));
7453  return QDomElement();
7454 }
7455 
7464 {
7465  if (impl && impl->isEntityReference())
7467  return QDomEntityReference();
7468 }
7469 
7477 {
7478  if (impl && impl->isText())
7479  return QDomText(((QDomTextPrivate*)impl));
7480  return QDomText();
7481 }
7482 
7491 {
7492  if (impl && impl->isEntity())
7493  return QDomEntity(((QDomEntityPrivate*)impl));
7494  return QDomEntity();
7495 }
7496 
7505 {
7506  if (impl && impl->isNotation())
7508  return QDomNotation();
7509 }
7510 
7519 {
7520  if (impl && impl->isProcessingInstruction())
7522  return QDomProcessingInstruction();
7523 }
7524 
7533 {
7534  if (impl && impl->isCharacterData())
7536  return QDomCharacterData();
7537 }
7538 
7547 {
7548  if (impl && impl->isComment())
7549  return QDomComment(((QDomCommentPrivate*)impl));
7550  return QDomComment();
7551 }
7552 
7553 /**************************************************************
7554  *
7555  * QDomHandler
7556  *
7557  **************************************************************/
7558 
7559 QDomHandler::QDomHandler(QDomDocumentPrivate* adoc, bool namespaceProcessing)
7560  : errorLine(0), errorColumn(0), doc(adoc), node(adoc), cdata(false),
7561  nsProcessing(namespaceProcessing), locator(0)
7562 {
7563 }
7564 
7566 {
7567 }
7568 
7570 {
7571  // ### is this really necessary? (rms)
7572  if (node != doc)
7573  return false;
7574  return true;
7575 }
7576 
7577 bool QDomHandler::startDTD(const QString& name, const QString& publicId, const QString& systemId)
7578 {
7579  doc->doctype()->name = name;
7580  doc->doctype()->publicId = publicId;
7581  doc->doctype()->systemId = systemId;
7582  return true;
7583 }
7584 
7585 bool QDomHandler::startElement(const QString& nsURI, const QString&, const QString& qName, const QXmlAttributes& atts)
7586 {
7587  // tag name
7588  QDomNodePrivate* n;
7589  if (nsProcessing) {
7590  n = doc->createElementNS(nsURI, qName);
7591  } else {
7592  n = doc->createElement(qName);
7593  }
7594 
7595  if (!n)
7596  return false;
7597 
7599 
7600  node->appendChild(n);
7601  node = n;
7602 
7603  // attributes
7604  for (int i=0; i<atts.length(); i++)
7605  {
7606  if (nsProcessing) {
7607  ((QDomElementPrivate*)node)->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i));
7608  } else {
7609  ((QDomElementPrivate*)node)->setAttribute(atts.qName(i), atts.value(i));
7610  }
7611  }
7612 
7613  return true;
7614 }
7615 
7616 bool QDomHandler::endElement(const QString&, const QString&, const QString&)
7617 {
7618  if (!node || node == doc)
7619  return false;
7620  node = node->parent();
7621 
7622  return true;
7623 }
7624 
7625 bool QDomHandler::characters(const QString& ch)
7626 {
7627  // No text as child of some document
7628  if (node == doc)
7629  return false;
7630 
7632  if (cdata) {
7633  n.reset(doc->createCDATASection(ch));
7634  } else if (!entityName.isEmpty()) {
7636  QString(), QString(), QString()));
7637  e->value = ch;
7638  e->ref.deref();
7639  doc->doctype()->appendChild(e.data());
7640  e.take();
7642  } else {
7643  n.reset(doc->createTextNode(ch));
7644  }
7646  node->appendChild(n.data());
7647  n.take();
7648 
7649  return true;
7650 }
7651 
7652 bool QDomHandler::processingInstruction(const QString& target, const QString& data)
7653 {
7654  QDomNodePrivate *n;
7655  n = doc->createProcessingInstruction(target, data);
7656  if (n) {
7658  node->appendChild(n);
7659  return true;
7660  }
7661  else
7662  return false;
7663 }
7664 
7666 bool QDomHandler::skippedEntity(const QString& name)
7667 {
7668  // we can only handle inserting entity references into content
7669  if (!qt_xml_skipped_entity_in_content)
7670  return true;
7671 
7674  node->appendChild(n);
7675  return true;
7676 }
7677 
7679 {
7680  errorMsg = exception.message();
7681  errorLine = exception.lineNumber();
7682  errorColumn = exception.columnNumber();
7683  return QXmlDefaultHandler::fatalError(exception);
7684 }
7685 
7687 {
7688  cdata = true;
7689  return true;
7690 }
7691 
7693 {
7694  cdata = false;
7695  return true;
7696 }
7697 
7698 bool QDomHandler::startEntity(const QString &name)
7699 {
7700  entityName = name;
7701  return true;
7702 }
7703 
7704 bool QDomHandler::endEntity(const QString &)
7705 {
7706  entityName.clear();
7707  return true;
7708 }
7709 
7710 bool QDomHandler::comment(const QString& ch)
7711 {
7712  QDomNodePrivate *n;
7713  n = doc->createComment(ch);
7715  node->appendChild(n);
7716  return true;
7717 }
7718 
7719 bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)
7720 {
7721  QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name,
7722  publicId, systemId, notationName);
7723  // keep the refcount balanced: appendChild() does a ref anyway.
7724  e->ref.deref();
7725  doc->doctype()->appendChild(e);
7726  return true;
7727 }
7728 
7729 bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)
7730 {
7731  return unparsedEntityDecl(name, publicId, systemId, QString());
7732 }
7733 
7734 bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId)
7735 {
7736  QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId);
7737  // keep the refcount balanced: appendChild() does a ref anyway.
7738  n->ref.deref();
7739  doc->doctype()->appendChild(n);
7740  return true;
7741 }
7742 
7744 {
7745  this->locator = locator;
7746 }
7747 
7749 
7750 #endif // QT_NO_DOM
bool fatalError(const QXmlParseException &exception)
A reader must use this function to report a non-recoverable error.
Definition: qdom.cpp:7678
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QDomNodePrivate * node_impl
Definition: qdom.cpp:228
QAtomicInt ref
Definition: qdom.cpp:224
double d
Definition: qnumeric_p.h:62
QDomElement firstChildElement(const QString &tagName=QString()) const
Returns the first child element with tag name tagName if tagName is non-empty; otherwise returns the ...
Definition: qdom.cpp:2990
bool endElement(const QString &nsURI, const QString &localName, const QString &qName)
The reader calls this function when it has parsed an end element tag with the qualified name qName...
Definition: qdom.cpp:7616
QDomImplementation()
Constructs a QDomImplementation object.
Definition: qdom.cpp:922
QString text()
Definition: qdom.cpp:4645
bool endEntity(const QString &)
The reader calls this function to report the end of an entity called name.
Definition: qdom.cpp:7704
QString value() const
Returns the value of the attribute or an empty string if the attribute has not been specified...
Definition: qdom.cpp:4459
QDomNodePrivate * item(int index)
Definition: qdom.cpp:1271
QDomNode parentNode() const
Returns the parent node.
Definition: qdom.cpp:2267
QDomProcessingInstruction toProcessingInstruction() const
Converts a QDomNode into a QDomProcessingInstruction.
Definition: qdom.cpp:7518
QDomElement createElement(const QString &tagName)
Creates a new element called tagName that can be inserted into the DOM tree, e.g. ...
Definition: qdom.cpp:7081
bool startElement(const QString &nsURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
The reader calls this function when it has parsed a start element tag.
Definition: qdom.cpp:7585
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:6404
void clear()
Converts the node into a null node; if it was not a null node before, its type and contents are delet...
Definition: qdom.cpp:2690
virtual QDomNodePrivate * replaceChild(QDomNodePrivate *newChild, QDomNodePrivate *oldChild)
Definition: qdom.cpp:1757
QDomNode appendChild(const QDomNode &newChild)
Appends newChild as the node&#39;s last child.
Definition: qdom.cpp:2655
uint length() const
Definition: qdom.cpp:1286
bool isCDATASection() const
Returns true if the node is a CDATA section; otherwise returns false.
Definition: qdom.cpp:2798
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
QDomEntityReferencePrivate * createEntityReference(const QString &name)
Definition: qdom.cpp:6528
QDomEntityReference createEntityReference(const QString &name)
Creates a new entity reference called name that can be inserted into the document, e.g.
Definition: qdom.cpp:7196
bool isSupported(const QString &feature, const QString &version) const
Returns true if the DOM implementation implements the feature feature and this feature is supported b...
Definition: qdom.cpp:2423
The QXmlLocator class provides the XML handler classes with information about the parsing position wi...
Definition: qxml.h:285
QString tagName() const
Returns the tag name of this element.
Definition: qdom.cpp:4871
int type
Definition: qmetatype.cpp:239
QDomNamedNodeMap attributes() const
Returns a named node map of all attributes.
Definition: qdom.cpp:2370
virtual bool isCharacterData() const
Definition: qdom.cpp:181
uint dataLength() const
Definition: qdom.cpp:3987
unsigned char c[8]
Definition: qnumeric_p.h:62
virtual void setContentHandler(QXmlContentHandler *handler)=0
Sets the content handler to handler.
bool startDTD(const QString &name, const QString &publicId, const QString &systemId)
The reader calls this function to report the start of a DTD declaration, if any.
Definition: qdom.cpp:7577
bool characters(const QString &ch)
The reader calls this function when it has parsed a chunk of character data (either normal character ...
Definition: qdom.cpp:7625
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
Definition: qregexp.cpp:4310
QDomElement nextSiblingElement(const QString &taName=QString()) const
Returns the next sibling element with tag name tagName if tagName is non-empty; otherwise returns any...
Definition: qdom.cpp:3030
QDomNodePrivate * parent() const
Definition: qdom.cpp:161
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool endCDATA()
The reader calls this function to report the end of a CDATA section.
Definition: qdom.cpp:7692
QDomNodePrivate * removeChild(QDomNodePrivate *oldChild)
Definition: qdom.cpp:3638
QString value(int index) const
Returns an attribute&#39;s value for the attribute at position index.
Definition: qxml.cpp:1192
QDomNodePrivate * importNode(const QDomNodePrivate *importedNode, bool deep)
Definition: qdom.cpp:6540
QDomAttrPrivate(QDomDocumentPrivate *, QDomNodePrivate *, const QString &name)
Definition: qdom.cpp:4188
virtual QDomNodePrivate * insertAfter(QDomNodePrivate *newChild, QDomNodePrivate *refChild)
Definition: qdom.cpp:1661
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
void setLocation(int lineNumber, int columnNumber)
Definition: qdom.cpp:1954
QDomDocumentFragment()
Constructs an empty document fragment.
Definition: qdom.cpp:3916
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
bool skippedEntity(const QString &name)
Some readers may skip entities if they have not seen the declarations (e.
Definition: qdom.cpp:7666
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
static QString fixedCharData(const QString &data, bool *ok)
Definition: qdom.cpp:699
bool specified() const
Returns true if the attribute has been set by the user with setValue().
Definition: qdom.cpp:4433
bool isDocument() const
Returns true if the node is a document; otherwise returns false.
Definition: qdom.cpp:2830
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
static void setInvalidDataPolicy(InvalidDataPolicy policy)
Sets the invalid data policy, which specifies what should be done when a factory function in QDomDocu...
Definition: qdom.cpp:1160
bool operator==(const QDomNodeListPrivate &) const
Definition: qdom.cpp:1207
QDomCommentPrivate * createComment(const QString &data)
Definition: qdom.cpp:6464
T * data() const
Returns the value of the pointer referenced by this object.
The QDomText class represents text data in the parsed XML document.
Definition: qdom.h:534
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
bool isDocumentFragment() const
Returns true if the node is a document fragment; otherwise returns false.
Definition: qdom.cpp:2815
The QAtomicInt class provides platform-independent atomic operations on integers. ...
Definition: qatomic.h:55
bool hasFeature(const QString &feature, const QString &version) const
The function returns true if QDom implements the requested version of a feature; otherwise returns fa...
Definition: qdom.cpp:995
#define it(className, varName)
uint length() const
Returns the number of nodes in the map.
Definition: qdom.cpp:3478
NodeType
This enum defines the type of the node:
Definition: qdom.h:131
QDomNode removeNamedItem(const QString &name)
Removes the node called name from the map.
Definition: qdom.cpp:3399
uint length() const
Returns the number of nodes in the list.
Definition: qdom.cpp:1421
QDomNodePrivate * prev
Definition: qdom.cpp:192
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
Definition: qbuffer.cpp:315
The QDomProcessingInstruction class represents an XML processing instruction.
Definition: qdom.h:648
QDomNodeList elementsByTagName(const QString &tagname) const
Returns a QDomNodeList, that contains all the elements in the document with the name tagname...
Definition: qdom.cpp:7211
QHash< QString, QDomNodePrivate * > map
Definition: qdom.cpp:277
bool isNull()
Returns false if the object was created by QDomDocument::implementation(); otherwise returns true...
Definition: qdom.cpp:1085
void setAttributeNS(const QString &nsURI, const QString &qName, const QString &newValue)
Definition: qdom.cpp:4570
QString substringData(unsigned long offset, unsigned long count) const
Definition: qdom.cpp:3992
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:423
QDomAttr()
Constructs an empty attribute.
Definition: qdom.cpp:4384
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:486
QDomCharacterData()
Constructs an empty character data object.
Definition: qdom.cpp:4056
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QDomElement lastChildElement(const QString &tagName=QString()) const
Returns the last child element with tag name tagName if tagName is non-empty; otherwise returns the l...
Definition: qdom.cpp:3010
void saveDocument(QTextStream &stream, const int indent, QDomNode::EncodingPolicy encUsed) const
Definition: qdom.cpp:6586
bool createdWithDom1Interface
Definition: qdom.cpp:202
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
NodeType nodeType() const
Returns the type of the node.
Definition: qdom.cpp:2256
virtual void save(QTextStream &, int, int) const
Definition: qdom.cpp:1945
void normalize()
Calling normalize() on an element converts all its children into a standard form. ...
Definition: qdom.cpp:2409
int columnNumber
Definition: qdom.cpp:206
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
void setCodec(QTextCodec *codec)
Sets the codec for this stream to codec.
bool hasChildNodes() const
Returns true if the node has one or more children; otherwise returns false.
Definition: qdom.cpp:2668
QDomAttrPrivate * removeAttributeNode(QDomAttrPrivate *oldAttr)
Definition: qdom.cpp:4630
QDomNodePrivate * appendChild(QDomNodePrivate *newChild)
Definition: qdom.cpp:3651
bool startCDATA()
The reader calls this function to report the start of a CDATA section.
Definition: qdom.cpp:7686
virtual void save(QTextStream &s, int, int) const
Definition: qdom.cpp:5677
T * take()
Returns the value of the pointer referenced by this object.
QDomComment & operator=(const QDomComment &)
Assigns x to this DOM comment.
Definition: qdom.cpp:5519
QDomNode firstChild() const
Returns the first child of the node.
Definition: qdom.cpp:2304
QString toString(int=1) const
Converts the parsed document back to its textual representation.
Definition: qdom.cpp:7016
virtual bool isText() const
Definition: qdom.cpp:177
QString nodeName() const
Returns the name of the node.
Definition: qdom.cpp:2178
void removeAttribute(const QString &name)
Definition: qdom.cpp:4589
QDomCDATASection toCDATASection() const
Converts a QDomNode into a QDomCDATASection.
Definition: qdom.cpp:7393
QString attributeNS(const QString &nsURI, const QString &localName, const QString &defValue) const
Definition: qdom.cpp:4545
QDomDocument toDocument() const
Converts a QDomNode into a QDomDocument.
Definition: qdom.cpp:7421
QString name
Definition: qdom.cpp:198
bool contains(const QString &name) const
Returns true if the map contains a node called name; otherwise returns false.
Definition: qdom.cpp:3521
static void clear(QVariant::Private *d)
Definition: qvariant.cpp:197
QDomNotation toNotation() const
Converts a QDomNode into a QDomNotation.
Definition: qdom.cpp:7504
bool operator!=(const QDomNodeList &) const
Returns true the node list n and this node list are not equal; otherwise returns false.
Definition: qdom.cpp:1387
QString localName() const
If the node uses namespaces, this function returns the local name of the node; otherwise it returns a...
Definition: qdom.cpp:2509
virtual void save(QTextStream &s, int, int) const
Definition: qdom.cpp:4312
QDomDocumentPrivate * ownerDocument()
Definition: qdom.cpp:1893
bool isElement() const
Returns true if the node is an element; otherwise returns false.
Definition: qdom.cpp:2862
QDomNodeList & operator=(const QDomNodeList &)
Assigns n to this node list.
Definition: qdom.cpp:1360
QDomDocumentTypePrivate * doctype()
Definition: qdom.cpp:517
static bool isChar(const QChar c)
Determines whether c is a valid instance of production [2]Char in the XML 1.0 specification.
Definition: qxmlutils.cpp:271
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString internalSubset
Definition: qdom.cpp:309
bool specified() const
Definition: qdom.cpp:4230
QDomNode()
Constructs a null node.
Definition: qdom.cpp:2057
long ASN1_INTEGER_get ASN1_INTEGER * a
QDomNode & operator=(const QDomNode &)
Assigns a copy of n to this DOM node.
Definition: qdom.cpp:2096
virtual bool isNotation() const
Definition: qdom.cpp:179
QDomNodePrivate * insertBefore(QDomNodePrivate *newChild, QDomNodePrivate *refChild)
Definition: qdom.cpp:3592
bool operator!=(QBool b1, bool b2)
Definition: qglobal.h:2026
QDomProcessingInstructionPrivate * createProcessingInstruction(const QString &target, const QString &data)
Definition: qdom.cpp:6488
bool ref()
Atomically increments the value of this QAtomicInt.
QDomNode item(int index) const
Retrieves the node at position index.
Definition: qdom.cpp:3414
bool isEntityReference() const
Definition: qdom.cpp:485
QDomNodePrivate * removeNamedItem(const QString &name)
Definition: qdom.cpp:3203
void setData(const QString &)
Sets this object&#39;s string to v.
Definition: qdom.cpp:4105
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
friend class QDomNodeList
Definition: qdom.h:249
QDomNodePrivate * insertAfter(QDomNodePrivate *newChild, QDomNodePrivate *refChild)
Definition: qdom.cpp:3605
bool isDocument() const
Definition: qdom.cpp:537
The QString class provides a Unicode character string.
Definition: qstring.h:83
static InvalidDataPolicy invalidDataPolicy()
Returns the invalid data policy, which specifies what should be done when a factory function in QDomD...
Definition: qdom.cpp:1137
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:405
QDomTextPrivate * createTextNode(const QString &data)
Definition: qdom.cpp:6452
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
void setNoParent()
Definition: qdom.cpp:164
~QDomImplementation()
Destroys the object and frees its resources.
Definition: qdom.cpp:979
QDomText toText() const
Converts a QDomNode into a QDomText.
Definition: qdom.cpp:7476
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:4222
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QString entityName
Definition: qdom.cpp:624
void insertData(unsigned long offset, const QString &arg)
Inserts the string arg into the stored string at position offset.
Definition: qdom.cpp:4143
virtual bool isAttr() const
Definition: qdom.cpp:170
QDomNodePrivate * ownerNode
Definition: qdom.cpp:194
The QDomDocumentType class is the representation of the DTD in the document tree. ...
Definition: qdom.h:282
QDomNamedNodeMapPrivate * clone(QDomNodePrivate *parent)
Definition: qdom.cpp:3116
QDomComment()
Constructs an empty comment.
Definition: qdom.cpp:5490
virtual QDomNodePrivate * appendChild(QDomNodePrivate *newChild)
Definition: qdom.cpp:1887
The QDomNotation class represents an XML notation.
Definition: qdom.h:589
bool hasAttribute(const QString &name)
Definition: qdom.cpp:4635
QDomNodePrivate * setNamedItemNS(QDomNodePrivate *arg)
Definition: qdom.cpp:3182
uint length() const
Returns the length of the stored string.
Definition: qdom.cpp:4114
QDomDocumentType doctype() const
Returns the document type of this document.
Definition: qdom.cpp:7044
virtual bool isEntity() const
Definition: qdom.cpp:467
QString attribute(const QString &name, const QString &defValue) const
Definition: qdom.cpp:4536
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool notationDecl(const QString &name, const QString &publicId, const QString &systemId)
The reader calls this function when it has parsed a notation declaration.
Definition: qdom.cpp:7734
void setPrefix(const QString &pre)
If the node has a namespace prefix, this function changes the namespace prefix of the node to pre...
Definition: qdom.cpp:2489
QDomAttr createAttributeNS(const QString &nsURI, const QString &qName)
Creates a new attribute with namespace support that can be inserted into an element.
Definition: qdom.cpp:7320
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:500
virtual bool isElement() const
Definition: qdom.cpp:175
virtual bool isComment() const
Definition: qdom.cpp:422
QDomImplementation implementation() const
Returns a QDomImplementation object.
Definition: qdom.cpp:7054
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:538
QTextCodec * codec() const
Returns the codec that is current assigned to the stream.
virtual int lineNumber() const =0
Returns the line number (starting at 1) or -1 if there is no line number available.
static QString fixedCDataSection(const QString &data, bool *ok)
Definition: qdom.cpp:753
void setReadOnly(bool r)
Definition: qdom.cpp:256
QString substringData(unsigned long offset, unsigned long count)
Returns the substring of length count from position offset.
Definition: qdom.cpp:4124
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
bool m_specified
Definition: qdom.cpp:375
bool operator!=(const QDomImplementation &) const
Returns true if x and this DOM implementation object were created from different QDomDocuments; other...
Definition: qdom.cpp:971
bool setContent(const QByteArray &text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0)
Definition: qdom.cpp:6887
QDomNamedNodeMapPrivate * entities
Definition: qdom.cpp:305
bool canEncode(QChar) const
Returns true if the Unicode character ch can be fully encoded with this codec; otherwise returns fals...
virtual QDomNode::NodeType nodeType() const
Definition: qdom.cpp:184
QAtomicInt ref
Definition: qdom.cpp:191
bool operator==(const QDomImplementation &) const
Returns true if x and this DOM implementation object were created from the same QDomDocument; otherwi...
Definition: qdom.cpp:962
static void qt_split_namespace(QString &prefix, QString &name, const QString &qName, bool hasURI)
Definition: qdom.cpp:104
QDomNodePrivate * replaceChild(QDomNodePrivate *newChild, QDomNodePrivate *oldChild)
Definition: qdom.cpp:3618
QDomNodePrivate(QDomDocumentPrivate *, QDomNodePrivate *parent=0)
Definition: qdom.cpp:1482
static QString fixedPIData(const QString &data, bool *ok)
Definition: qdom.cpp:781
The QXmlSimpleReader class provides an implementation of a simple XML parser.
Definition: qxml.h:241
QString tagname
Definition: qdom.cpp:229
#define QT_RETHROW
Definition: qglobal.h:1539
virtual bool isDocumentFragment() const
Definition: qdom.cpp:320
bool processingInstruction(const QString &target, const QString &data)
The reader calls this function when it has parsed a processing instruction.
Definition: qdom.cpp:7652
void appendData(const QString &arg)
Appends the string arg to the stored string.
Definition: qdom.cpp:4134
QString nodeValue() const
Definition: qdom.cpp:143
The QDomDocument class represents an XML document.
Definition: qdom.h:308
QDomDocumentFragment & operator=(const QDomDocumentFragment &)
Assigns x to this DOM document fragment.
Definition: qdom.cpp:3944
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QDomElement toElement() const
Converts a QDomNode into a QDomElement.
Definition: qdom.cpp:7449
void setValue(const QString &)
Sets the attribute&#39;s value to v.
Definition: qdom.cpp:4471
int columnNumber() const
For nodes created by QDomDocument::setContent(), this function returns the column number in the XML d...
Definition: qdom.cpp:3091
bool nsProcessing
Definition: qdom.cpp:626
static FILE * stream
QDomHandler(QDomDocumentPrivate *d, bool namespaceProcessing)
Definition: qdom.cpp:7559
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:371
QDomNode insertAfter(const QDomNode &newChild, const QDomNode &refChild)
Inserts the node newChild after the child node refChild.
Definition: qdom.cpp:2579
QDomAttrPrivate * attributeNode(const QString &name)
Definition: qdom.cpp:4596
virtual bool isDocumentType() const
Definition: qdom.cpp:299
QDomNodePrivate * namedItem(const QString &name)
Definition: qdom.cpp:1554
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:300
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:468
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
Definition: qregexp.cpp:4136
QDomDocumentPrivate * doc
Definition: qdom.cpp:622
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
void replaceData(unsigned long offset, unsigned long count, const QString &arg)
Definition: qdom.cpp:4007
bool contains(const T &value) const
Definition: qset.h:91
QString value
Definition: qdom.cpp:199
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
virtual int columnNumber() const =0
Returns the column number (starting at 1) or -1 if there is no column number available.
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:339
QDomImplementationPrivate * implementation()
Definition: qdom.cpp:518
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fixedSystemLiteral(const QString &data, bool *ok)
Definition: qdom.cpp:843
QString m_sys
Definition: qdom.cpp:472
static bool init
void replaceData(unsigned long offset, unsigned long count, const QString &arg)
Replaces the substring of length count starting at position offset with the string arg...
Definition: qdom.cpp:4162
static bool isNameChar(const QChar c)
Determines whether c is a valid instance of production [4]NameChar in the XML 1.0 specification...
Definition: qxmlutils.cpp:291
QString m_notationName
Definition: qdom.cpp:474
QDomNodePrivate * parent
Definition: qdom.cpp:278
const char * name
QDomDocumentFragmentPrivate * createDocumentFragment()
Definition: qdom.cpp:6445
virtual QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:3871
bool deref()
Atomically decrements the value of this QAtomicInt.
QExplicitlySharedDataPointer< QDomDocumentTypePrivate > type
Definition: qdom.cpp:543
QDomNodePrivate * item(int index) const
Definition: qdom.cpp:3220
virtual void setData(const QString &dat)
Sets the data of the input source to dat.
Definition: qxml.cpp:1509
QDomDocumentFragment toDocumentFragment() const
Converts a QDomNode into a QDomDocumentFragment.
Definition: qdom.cpp:7407
virtual void save(QTextStream &s, int, int) const
Definition: qdom.cpp:4661
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
QDomNode namedItemNS(const QString &nsURI, const QString &localName) const
Returns the node associated with the local name localName and the namespace URI nsURI.
Definition: qdom.cpp:3430
QDomCDATASection & operator=(const QDomCDATASection &)
Assigns x to this CDATA section.
Definition: qdom.cpp:5632
friend class QDomDocumentType
Definition: qdom.h:248
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
Q_CORE_EXPORT void qWarning(const char *,...)
virtual bool isAttr() const
Definition: qdom.cpp:370
int errorLine
Definition: qdom.cpp:618
const_iterator insert(const T &value)
Definition: qset.h:179
The QDomDocumentFragment class is a tree of QDomNodes which is not usually a complete QDomDocument...
Definition: qdom.h:399
virtual bool isEntity() const
Definition: qdom.cpp:178
void deleteData(unsigned long offset, unsigned long count)
Definition: qdom.cpp:4002
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
virtual QDomNodePrivate * insertBefore(QDomNodePrivate *newChild, QDomNodePrivate *refChild)
Definition: qdom.cpp:1566
QDomAttrPrivate * createAttribute(const QString &name)
Definition: qdom.cpp:6504
bool hasParent
Definition: qdom.cpp:203
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
virtual bool isCDATASection() const
Definition: qdom.cpp:171
QDomDocument()
Constructs an empty document.
Definition: qdom.cpp:6751
bool cdata
Definition: qdom.cpp:625
virtual void setDTDHandler(QXmlDTDHandler *handler)=0
Sets the DTD handler to handler.
QString nodeValue() const
Returns the value of the node.
Definition: qdom.cpp:2206
int columnNumber() const
Returns the column number where the error occurred.
Definition: qxml.cpp:609
virtual void setDeclHandler(QXmlDeclHandler *handler)=0
Sets the declaration handler to handler.
QDomNodePrivate * next
Definition: qdom.cpp:193
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QDomAttr createAttribute(const QString &name)
Creates a new attribute called name that can be inserted into an element, e.g.
Definition: qdom.cpp:7180
QDomNodePrivate * impl
Definition: qdom.h:243
The QXmlDefaultHandler class provides a default implementation of all the XML handler classes...
Definition: qxml.h:372
#define IMPL
Definition: qdom.cpp:6666
static QSvgNode * createTextNode(QSvgNode *parent, const QXmlStreamAttributes &attributes, QSvgHandler *handler)
QDomNodePrivate * setNamedItem(QDomNodePrivate *arg)
Definition: qdom.cpp:3167
bool hasAttributes() const
Returns true if the node has attributes; otherwise returns false.
Definition: qdom.cpp:2521
virtual void setNodeValue(const QString &v)
Definition: qdom.cpp:144
QDomElement ownerElement() const
Returns the element node this attribute is attached to or a null node if this attribute is not attach...
Definition: qdom.cpp:4445
QDomElementPrivate * documentElement()
Definition: qdom.cpp:6412
EncodingPolicy
This enum specifies how QDomNode::save() determines what encoding to use when serializing.
Definition: qdom.h:148
virtual bool isText() const
Definition: qdom.cpp:353
QDomNode removeChild(const QDomNode &oldChild)
Removes oldChild from the list of children.
Definition: qdom.cpp:2618
~QDomNode()
Destroys the object and frees its resources.
Definition: qdom.cpp:2143
#define QT_CATCH(A)
Definition: qglobal.h:1537
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
The QDomCDATASection class represents an XML CDATA section.
Definition: qdom.h:572
The QDomComment class represents an XML comment.
Definition: qdom.h:555
QDomAttrPrivate * setAttributeNode(QDomAttrPrivate *newAttr)
Definition: qdom.cpp:4606
QDomCDATASection createCDATASection(const QString &data)
Creates a new CDATA section for the string value that can be inserted into the document, e.g.
Definition: qdom.cpp:7143
The QXmlReader class provides an interface for XML readers (i.e.
Definition: qxml.h:215
QDomImplementationPrivate * clone()
Definition: qdom.cpp:872
virtual void setErrorHandler(QXmlErrorHandler *handler)=0
Sets the error handler to handler.
QDomCDATASectionPrivate * createCDATASection(const QString &data)
Definition: qdom.cpp:6476
QDomImplementation & operator=(const QDomImplementation &)
Assigns x to this DOM implementation.
Definition: qdom.cpp:948
static QString quotedValue(const QString &data)
Definition: qdom.cpp:3656
void setNodeValue(const QString &)
Sets the node&#39;s value to v.
Definition: qdom.cpp:2218
bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)
The reader calls this function when it finds an unparsed entity declaration.
Definition: qdom.cpp:7719
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QDomComment toComment() const
Converts a QDomNode into a QDomComment.
Definition: qdom.cpp:7546
QString name() const
Returns the attribute&#39;s name.
Definition: qdom.cpp:4420
uint length() const
Definition: qdom.cpp:3228
virtual void save(QTextStream &s, int, int) const
Definition: qdom.cpp:5559
The QDomEntity class represents an XML entity.
Definition: qdom.h:610
virtual QByteArray name() const =0
QTextCodec subclasses must reimplement this function.
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString message() const
Returns the error message.
Definition: qxml.cpp:602
bool isAttr() const
Returns true if the node is an attribute; otherwise returns false.
Definition: qdom.cpp:2781
static QByteArray encodeEntity(const QByteArray &str)
Definition: qdom.cpp:5834
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:5669
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:354
QDomElementPrivate(QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &name)
Definition: qdom.cpp:4496
QDomNotationPrivate(QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &name, const QString &pub, const QString &sys)
Definition: qdom.cpp:5652
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
virtual QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:1905
bool hasAttributeNS(const QString &nsURI, const QString &localName)
Definition: qdom.cpp:4640
static QString fixedComment(const QString &data, bool *ok)
Definition: qdom.cpp:724
QDomNodePrivate * last
Definition: qdom.cpp:196
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QDomNode namedItem(const QString &name) const
Returns the node called name.
Definition: qdom.cpp:3366
virtual ~QDomNodePrivate()
Definition: qdom.cpp:1522
QDomNamedNodeMapPrivate * attributes()
Definition: qdom.cpp:402
bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)
The reader calls this function to report a parsed external entity declaration.
Definition: qdom.cpp:7729
QDomNodeList()
Creates an empty node list.
Definition: qdom.cpp:1337
QDomAttrPrivate * attributeNodeNS(const QString &nsURI, const QString &localName)
Definition: qdom.cpp:4601
QDomCDATASectionPrivate(QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &val)
Definition: qdom.cpp:5539
QDomCharacterData & operator=(const QDomCharacterData &)
Assigns x to this character data.
Definition: qdom.cpp:4084
QString & append(QChar c)
Definition: qstring.cpp:1777
QXmlLocator * locator
Definition: qdom.cpp:627
QDomElement elementById(const QString &elementId)
Returns the element whose ID is equal to elementId.
Definition: qdom.cpp:7349
QDomDocumentTypePrivate(QDomDocumentPrivate *, QDomNodePrivate *parent=0)
Definition: qdom.cpp:3536
~QDomDocument()
Destroys the object and frees its resources.
Definition: qdom.cpp:6808
QDomDocumentFragment createDocumentFragment()
Creates a new document fragment, that can be used to hold parts of the document, e.g.
Definition: qdom.cpp:7093
QDomCDATASection()
Constructs an empty CDATA section.
Definition: qdom.cpp:5603
int length() const
Returns the number of attributes in the list.
Definition: qxml.cpp:1092
The QDomEntityReference class represents an XML entity reference.
Definition: qdom.h:631
QDomNodeListPrivate(QDomNodePrivate *)
Definition: qdom.cpp:1171
QString uri(int index) const
Looks up an attribute&#39;s namespace URI for the attribute at position index.
Definition: qxml.cpp:1137
QDomNode cloneNode(bool deep=true) const
Creates a deep (not shallow) copy of the QDomNode.
Definition: qdom.cpp:2396
QDomNodeListPrivate * impl
Definition: qdom.h:274
QString namespaceURI
Definition: qdom.cpp:201
~QDomHandler()
Definition: qdom.cpp:7565
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:73
void setAttribute(const QString &name, const QString &value)
Definition: qdom.cpp:4554
QDomNode namedItem(const QString &name) const
Returns the first direct child node for which nodeName() equals name.
Definition: qdom.cpp:2706
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
QDomAttr toAttr() const
Converts a QDomNode into a QDomAttr.
Definition: qdom.cpp:7379
void setParent(QDomNodePrivate *p)
Definition: qdom.cpp:162
unsigned short ushort
Definition: qglobal.h:995
The QDomAttr class represents one attribute of a QDomElement.
Definition: qdom.h:449
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QDomNode setNamedItemNS(const QDomNode &newNode)
Inserts the node newNode in the map.
Definition: qdom.cpp:3445
virtual bool isEntityReference() const
Definition: qdom.cpp:176
virtual void setLexicalHandler(QXmlLexicalHandler *handler)=0
Sets the lexical handler to handler.
The QDomNode class is the base class for all the nodes in a DOM tree.
Definition: qdom.h:128
QDomDocumentType toDocumentType() const
Converts a QDomNode into a QDomDocumentType.
Definition: qdom.cpp:7435
bool isEntity() const
Returns true if the node is an entity; otherwise returns false.
Definition: qdom.cpp:2909
QDomText createTextNode(const QString &data)
Creates a text node for the string value that can be inserted into the document tree, e.g.
Definition: qdom.cpp:7110
bool contains(const QString &name) const
Definition: qdom.cpp:3233
static bool isLetter(const QChar c)
Determines whether c is a valid instance of production [84]Letter in the XML 1.0 specification.
Definition: qxmlutils.cpp:256
static QDomImplementation::InvalidDataPolicy invalidDataPolicy
Definition: qdom.cpp:132
bool isProcessingInstruction() const
Returns true if the node is a processing instruction; otherwise returns false.
Definition: qdom.cpp:2941
QDomProcessingInstruction createProcessingInstruction(const QString &target, const QString &data)
Creates a new processing instruction that can be inserted into the document, e.g. ...
Definition: qdom.cpp:7162
int lineNumber
Definition: qdom.cpp:205
QDomNamedNodeMap & operator=(const QDomNamedNodeMap &)
Assigns n to this named node map.
Definition: qdom.cpp:3320
QDomDocumentType createDocumentType(const QString &qName, const QString &publicId, const QString &systemId)
Creates a document type node for the name qName.
Definition: qdom.cpp:1038
QDomNode replaceChild(const QDomNode &newChild, const QDomNode &oldChild)
Replaces oldChild with newChild.
Definition: qdom.cpp:2602
QDomEntity toEntity() const
Converts a QDomNode into a QDomEntity.
Definition: qdom.cpp:7490
QDomAttrPrivate * setAttributeNodeNS(QDomAttrPrivate *newAttr)
Definition: qdom.cpp:4618
~QDomNodeList()
Destroys the object and frees its resources.
Definition: qdom.cpp:1395
QDomElementPrivate * createElementNS(const QString &nsURI, const QString &qName)
Definition: qdom.cpp:6433
void setNodeValue(const QString &v)
Definition: qdom.cpp:4210
QString m_pub
Definition: qdom.cpp:473
bool isNull() const
Returns true if this node is null (i.e.
Definition: qdom.cpp:2679
QByteArray toByteArray(int=1) const
Converts the parsed document back to its textual representation and returns a QByteArray containing t...
Definition: qdom.cpp:7033
virtual bool isElement() const
Definition: qdom.cpp:404
bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
Definition: qdom.cpp:6367
static QString fixedXmlName(const QString &_name, bool *ok, bool namespaces=false)
Definition: qdom.cpp:645
QDomAttr & operator=(const QDomAttr &)
Assigns x to this DOM attribute.
Definition: qdom.cpp:4412
static QString fixedPubidLiteral(const QString &data, bool *ok)
Definition: qdom.cpp:810
QDomNode insertBefore(const QDomNode &newChild, const QDomNode &refChild)
Inserts the node newChild before the child node refChild.
Definition: qdom.cpp:2550
QString errorMsg
Definition: qdom.cpp:617
bool isNotation() const
Returns true if the node is a notation; otherwise returns false.
Definition: qdom.cpp:2924
Definition: qnamespace.h:54
QString qName(int index) const
Looks up an attribute&#39;s XML 1.0 qualified name for the attribute at position index.
Definition: qxml.cpp:1125
int errorColumn
Definition: qdom.cpp:619
virtual bool isDocumentType() const
Definition: qdom.cpp:174
virtual bool parse(const QXmlInputSource &input)=0
Parses the given input.
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:3584
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
virtual bool isDocument() const
Definition: qdom.cpp:173
bool fatalError(const QXmlParseException &exception)
This reimplementation does nothing.
Definition: qxml.cpp:2811
QDomCharacterDataPrivate(QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &data)
Definition: qdom.cpp:3966
The QDomNodeList class is a list of QDomNode objects.
Definition: qdom.h:253
virtual bool isProcessingInstruction() const
Definition: qdom.cpp:499
bool operator!=(const QDomNodeListPrivate &) const
Definition: qdom.cpp:1212
QDomNode setNamedItem(const QDomNode &newNode)
Inserts the node newNode into the named node map.
Definition: qdom.cpp:3383
QDomNode removeNamedItemNS(const QString &nsURI, const QString &localName)
Removes the node with the local name localName and the namespace URI nsURI from the map...
Definition: qdom.cpp:3463
QDomNodePrivate * first
Definition: qdom.cpp:195
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:3979
quint16 index
virtual bool isNotation() const
Definition: qdom.cpp:449
bool operator!=(const QDomNamedNodeMap &) const
Returns true if n and this named node map are not equal; otherwise returns false. ...
Definition: qdom.cpp:3343
QDomNode item(int index) const
Returns the node at position index.
Definition: qdom.cpp:1410
The QDomCharacterData class represents a generic string in the DOM.
Definition: qdom.h:416
InvalidDataPolicy
This enum specifies what should be done when a factory function in QDomDocument is called with invali...
Definition: qdom.h:114
void setOwnerDocument(QDomDocumentPrivate *doc)
Definition: qdom.cpp:1476
bool operator==(const QDomNamedNodeMap &) const
Returns true if n and this named node map are equal; otherwise returns false.
Definition: qdom.cpp:3334
QDomElement previousSiblingElement(const QString &tagName=QString()) const
Returns the previous sibilng element with tag name tagName if tagName is non-empty; otherwise returns...
Definition: qdom.cpp:3050
bool isDocumentType() const
Returns true if the node is a document type; otherwise returns false.
Definition: qdom.cpp:2847
bool startEntity(const QString &)
The reader calls this function to report the start of an entity called name.
Definition: qdom.cpp:7698
QDomImplementationPrivate * impl
Definition: qdom.h:122
The QXmlAttributes class provides XML attributes.
Definition: qxml.h:119
QDomNodePrivate * node
Definition: qdom.cpp:623
QDomNodeList elementsByTagNameNS(const QString &nsURI, const QString &localName)
Returns a QDomNodeList that contains all the elements in the document with the local name localName a...
Definition: qdom.cpp:7335
bool endDocument()
The reader calls this function after it has finished parsing.
Definition: qdom.cpp:7569
QString namespaceURI() const
Returns the namespace URI of this node or an empty string if the node has no namespace URI...
Definition: qdom.cpp:2441
bool qt_xml_skipped_entity_in_content
Definition: qxml.cpp:104
QTextStream & operator<<(QTextStream &str, const QDomNode &node)
Writes the XML representation of the node node and all its children to the stream str...
Definition: qdom.cpp:2765
virtual bool feature(const QString &name, bool *ok=0) const =0
If the reader has the feature called name, the feature&#39;s value is returned.
bool isComment() const
Returns true if the node is a comment; otherwise returns false.
Definition: qdom.cpp:2973
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:436
QDomDocument & operator=(const QDomDocument &)
Assigns x to this DOM document.
Definition: qdom.cpp:6800
virtual void normalize()
Definition: qdom.cpp:1935
void setAppendToParent(bool b)
Definition: qdom.cpp:267
QDomDocumentFragmentPrivate(QDomDocumentPrivate *, QDomNodePrivate *parent=0)
Definition: qdom.cpp:3860
QString prefix() const
Returns the namespace prefix of the node or an empty string if the node has no namespace prefix...
Definition: qdom.cpp:2469
QDomDocument ownerDocument() const
Returns the document to which this node belongs.
Definition: qdom.cpp:2381
QDomEntityReference toEntityReference() const
Converts a QDomNode into a QDomEntityReference.
Definition: qdom.cpp:7463
bool operator!=(const QDomNode &) const
Returns true if n and this DOM node are not equal; otherwise returns false.
Definition: qdom.cpp:2135
bool isEntityReference() const
Returns true if the node is an entity reference; otherwise returns false.
Definition: qdom.cpp:2879
bool isCharacterData() const
Returns true if the node is a character data node; otherwise returns false.
Definition: qdom.cpp:2958
QDomNodePrivate * namedItemNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3152
virtual bool isCharacterData() const
Definition: qdom.cpp:338
static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing)
Definition: qdom.cpp:6360
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772
virtual bool isDocumentFragment() const
Definition: qdom.cpp:172
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
QDomComment createComment(const QString &data)
Creates a new comment for the string value that can be inserted into the document, e.g.
Definition: qdom.cpp:7126
friend class QDomElement
Definition: qdom.h:472
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
static QString encodeText(const QString &str, QTextStream &s, const bool encodeQuotes=true, const bool performAVN=false, const bool encodeEOLs=false)
Definition: qdom.cpp:4245
The QXmlInputSource class provides the input data for the QXmlReader subclasses.
Definition: qxml.h:158
virtual QDomNodePrivate * removeChild(QDomNodePrivate *oldChild)
Definition: qdom.cpp:1851
virtual bool isProcessingInstruction() const
Definition: qdom.cpp:180
~QDomNamedNodeMap()
Destroys the object and frees its resources.
Definition: qdom.cpp:3351
The QDomNamedNodeMap class contains a collection of nodes that can be accessed by name...
Definition: qdom.h:362
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:5551
bool hasAttributes()
Definition: qdom.cpp:403
QString nodeName() const
Definition: qdom.cpp:142
QDomNode previousSibling() const
Returns the previous sibling in the document tree.
Definition: qdom.cpp:2336
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
bool comment(const QString &ch)
The reader calls this function to report an XML comment anywhere in the document. ...
Definition: qdom.cpp:7710
QExplicitlySharedDataPointer< QDomImplementationPrivate > impl
Definition: qdom.cpp:542
QDomAttrPrivate * createAttributeNS(const QString &nsURI, const QString &qName)
Definition: qdom.cpp:6516
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671
QDomDocument createDocument(const QString &nsURI, const QString &qName, const QDomDocumentType &doctype)
Creates a DOM document with the document type doctype.
Definition: qdom.cpp:1071
static void normalize(double &x, double &y)
QDomNode lastChild() const
Returns the last child of the node.
Definition: qdom.cpp:2318
static bool isPublicID(const QString &candidate)
Determines whether c is a valid instance of production [12] PubidLiteral in the XML 1...
Definition: qxmlutils.cpp:316
The QDomImplementation class provides information about the features of the DOM implementation.
Definition: qdom.h:99
void appendData(const QString &arg)
Definition: qdom.cpp:4012
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QDomNode importNode(const QDomNode &importedNode, bool deep)
Imports the node importedNode from another document to this document.
Definition: qdom.cpp:7282
The QDomElement class represents one element in the DOM tree.
Definition: qdom.h:476
QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:4528
void save(QTextStream &, int) const
Writes the XML representation of the node and all its children to the stream str. ...
Definition: qdom.cpp:2728
bool operator==(QBool b1, bool b2)
Definition: qglobal.h:2023
QDomNamedNodeMapPrivate * notations
Definition: qdom.cpp:306
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:450
#define impl(owner, mather, type)
#define QT_TRY
Definition: qglobal.h:1536
virtual void clear()
Definition: qdom.cpp:1539
QDomNodePrivate * namedItem(const QString &name) const
Definition: qdom.cpp:3146
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void save(QTextStream &s, int, int) const
Definition: qdom.cpp:3664
virtual bool isComment() const
Definition: qdom.cpp:182
bool isText() const
Returns true if the node is a text node; otherwise returns false.
Definition: qdom.cpp:2894
void setDocumentLocator(QXmlLocator *locator)
The reader calls this function before it starts parsing the document.
Definition: qdom.cpp:7743
QDomElement documentElement() const
Returns the root element of the document.
Definition: qdom.cpp:7064
QDomNode::NodeType nodeType() const
Definition: qdom.cpp:321
QDomNamedNodeMap()
Constructs an empty named node map.
Definition: qdom.cpp:3295
QDomElementPrivate * createElement(const QString &tagName)
Definition: qdom.cpp:6421
static void qNormalizeNode(QDomNodePrivate *n)
Definition: qdom.cpp:1913
bool containsNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3238
QDomNode nextSibling() const
Returns the next sibling in the document tree.
Definition: qdom.cpp:2354
QDomNamedNodeMapPrivate(QDomNodePrivate *)
Definition: qdom.cpp:3103
bool operator==(const QDomNodeList &) const
Returns true if the node list n and this node list are equal; otherwise returns false.
Definition: qdom.cpp:1374
#define text
Definition: qobjectdefs.h:80
QDomNode::NodeType nodeType() const
Returns the type of node this object refers to (i.e.
Definition: qdom.cpp:4173
void deleteData(unsigned long offset, unsigned long count)
Deletes a substring of length count from position offset.
Definition: qdom.cpp:4152
The QXmlParseException class is used to report errors with the QXmlErrorHandler interface.
Definition: qxml.h:192
virtual bool isCDATASection() const
Definition: qdom.cpp:435
QDomNodeList childNodes() const
Returns a list of all direct child nodes.
Definition: qdom.cpp:2290
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391
void insertData(unsigned long offset, const QString &arg)
Definition: qdom.cpp:3997
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QString data() const
Returns the string stored in this object.
Definition: qdom.cpp:4095
QList< QDomNodePrivate * > list
Definition: qdom.cpp:231
int lineNumber() const
Returns the line number where the error occurred.
Definition: qxml.cpp:616
QDomElement createElementNS(const QString &nsURI, const QString &qName)
Creates a new element with namespace support that can be inserted into the DOM tree.
Definition: qdom.cpp:7301
QDomCharacterData toCharacterData() const
Converts a QDomNode into a QDomCharacterData.
Definition: qdom.cpp:7532
QString prefix
Definition: qdom.cpp:200
int lineNumber() const
For nodes created by QDomDocument::setContent(), this function returns the line number in the XML doc...
Definition: qdom.cpp:3074
Q_CORE_EXPORT QTextStream & endl(QTextStream &s)
bool operator==(const QDomNode &) const
Returns true if n and this DOM node are equal; otherwise returns false.
Definition: qdom.cpp:2126