Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DomLibXml2.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*----------------------------------------------------------------------------*/
8/*----------------------------------------------------------------------------*/
9
10// *********** ATTENTION ***********
11
12// ATTENTION: CE FICHIER N'EST PLUS UTILISÉ MAIS CONSERVÉ POUR REGARDER
13// L'IMPLÉMENTATION PRÉCÉDENTE
14
15/*----------------------------------------------------------------------------*/
16/*----------------------------------------------------------------------------*/
17#include "arcane/utils/StringBuilder.h"
18#include "arcane/utils/StringImpl.h"
19#include "arcane/utils/String.h"
20#include "arcane/utils/NotImplementedException.h"
21#include "arcane/utils/ITraceMng.h"
22
23#include "arcane/Dom.h"
24#include "arcane/DomUtils.h"
25#include "arcane/IXmlDocumentHolder.h"
26#include "arcane/XmlNode.h"
27
28#include <cassert>
29#include <cstring>
30#include <cwchar>
31#include <string>
32#include <vector>
33#define _AMD64_
34
35
36#include <list>
37#include <map>
38#include <string>
39#ifdef HAVE_INTTYPES_H
40#include <inttypes.h>
41#endif
42#include <assert.h>
43#include <typeinfo>
44#if !defined(_MSC_VER)
45#include <sys/time.h>
46#endif
47#include "arcane/utils/Exception.h"
48#include "arcane/utils/String.h"
49#include <libxml/tree.h>
50#include <time.h>
51
52#ifdef ARCANE_OS_WIN32
53#define USE_WCHAR
54#endif
55
56#ifdef USE_WCHAR
57namespace // anonymous
58{
59typedef wchar_t XMLCh; // Problem wchar_t is compiler dependant...In Xerces XMLCh typedef was generated. And
60 // no wstring were used. Here massively used...
61typedef unsigned char XMLByte;
62} // namespace
63#else /* USE_WCHAR */
64namespace // anonymous
65{
66typedef char16_t XMLCh;
67typedef unsigned char XMLByte;
68} // namespace
69#endif /* USE_WCHAR */
70
71ARCANE_BEGIN_NAMESPACE
72ARCANE_BEGIN_NAMESPACE_DOM
73// ---------------------------------------------------------------------------
74// Constants for the Unicode characters of interest to us in an XML parser
75// We don't put these inside the class because then they could not be const
76// inline values, which would have significant performance ramifications.
77//
78// We cannot use a namespace because of the requirement to support old
79// compilers.
80// ---------------------------------------------------------------------------
81const XMLCh chNull = 0x00;
82const XMLCh chHTab = 0x09;
83const XMLCh chLF = 0x0A;
84const XMLCh chVTab = 0x0B;
85const XMLCh chFF = 0x0C;
86const XMLCh chCR = 0x0D;
87const XMLCh chAmpersand = 0x26;
88const XMLCh chAsterisk = 0x2A;
89const XMLCh chAt = 0x40;
90const XMLCh chBackSlash = 0x5C;
91const XMLCh chBang = 0x21;
92const XMLCh chCaret = 0x5E;
93const XMLCh chCloseAngle = 0x3E;
94const XMLCh chCloseCurly = 0x7D;
95const XMLCh chCloseParen = 0x29;
96const XMLCh chCloseSquare = 0x5D;
97const XMLCh chColon = 0x3A;
98const XMLCh chComma = 0x2C;
99const XMLCh chDash = 0x2D;
100const XMLCh chDollarSign = 0x24;
101const XMLCh chDoubleQuote = 0x22;
102const XMLCh chEqual = 0x3D;
103const XMLCh chForwardSlash = 0x2F;
104const XMLCh chGrave = 0x60;
105const XMLCh chNEL = 0x85;
106const XMLCh chOpenAngle = 0x3C;
107const XMLCh chOpenCurly = 0x7B;
108const XMLCh chOpenParen = 0x28;
109const XMLCh chOpenSquare = 0x5B;
110const XMLCh chPercent = 0x25;
111const XMLCh chPeriod = 0x2E;
112const XMLCh chPipe = 0x7C;
113const XMLCh chPlus = 0x2B;
114const XMLCh chPound = 0x23;
115const XMLCh chQuestion = 0x3F;
116const XMLCh chSingleQuote = 0x27;
117const XMLCh chSpace = 0x20;
118const XMLCh chSemiColon = 0x3B;
119const XMLCh chTilde = 0x7E;
120const XMLCh chUnderscore = 0x5F;
121
122const XMLCh chSwappedUnicodeMarker = XMLCh(0xFFFE);
123const XMLCh chUnicodeMarker = XMLCh(0xFEFF);
124
125const XMLCh chDigit_0 = 0x30;
126const XMLCh chDigit_1 = 0x31;
127const XMLCh chDigit_2 = 0x32;
128const XMLCh chDigit_3 = 0x33;
129const XMLCh chDigit_4 = 0x34;
130const XMLCh chDigit_5 = 0x35;
131const XMLCh chDigit_6 = 0x36;
132const XMLCh chDigit_7 = 0x37;
133const XMLCh chDigit_8 = 0x38;
134const XMLCh chDigit_9 = 0x39;
135
136const XMLCh chLatin_A = 0x41;
137const XMLCh chLatin_B = 0x42;
138const XMLCh chLatin_C = 0x43;
139const XMLCh chLatin_D = 0x44;
140const XMLCh chLatin_E = 0x45;
141const XMLCh chLatin_F = 0x46;
142const XMLCh chLatin_G = 0x47;
143const XMLCh chLatin_H = 0x48;
144const XMLCh chLatin_I = 0x49;
145const XMLCh chLatin_J = 0x4A;
146const XMLCh chLatin_K = 0x4B;
147const XMLCh chLatin_L = 0x4C;
148const XMLCh chLatin_M = 0x4D;
149const XMLCh chLatin_N = 0x4E;
150const XMLCh chLatin_O = 0x4F;
151const XMLCh chLatin_P = 0x50;
152const XMLCh chLatin_Q = 0x51;
153const XMLCh chLatin_R = 0x52;
154const XMLCh chLatin_S = 0x53;
155const XMLCh chLatin_T = 0x54;
156const XMLCh chLatin_U = 0x55;
157const XMLCh chLatin_V = 0x56;
158const XMLCh chLatin_W = 0x57;
159const XMLCh chLatin_X = 0x58;
160const XMLCh chLatin_Y = 0x59;
161const XMLCh chLatin_Z = 0x5A;
162
163const XMLCh chLatin_a = 0x61;
164const XMLCh chLatin_b = 0x62;
165const XMLCh chLatin_c = 0x63;
166const XMLCh chLatin_d = 0x64;
167const XMLCh chLatin_e = 0x65;
168const XMLCh chLatin_f = 0x66;
169const XMLCh chLatin_g = 0x67;
170const XMLCh chLatin_h = 0x68;
171const XMLCh chLatin_i = 0x69;
172const XMLCh chLatin_j = 0x6A;
173const XMLCh chLatin_k = 0x6B;
174const XMLCh chLatin_l = 0x6C;
175const XMLCh chLatin_m = 0x6D;
176const XMLCh chLatin_n = 0x6E;
177const XMLCh chLatin_o = 0x6F;
178const XMLCh chLatin_p = 0x70;
179const XMLCh chLatin_q = 0x71;
180const XMLCh chLatin_r = 0x72;
181const XMLCh chLatin_s = 0x73;
182const XMLCh chLatin_t = 0x74;
183const XMLCh chLatin_u = 0x75;
184const XMLCh chLatin_v = 0x76;
185const XMLCh chLatin_w = 0x77;
186const XMLCh chLatin_x = 0x78;
187const XMLCh chLatin_y = 0x79;
188const XMLCh chLatin_z = 0x7A;
189
190const XMLCh chYenSign = 0xA5;
191const XMLCh chWonSign = 0x20A9;
192
193const XMLCh chLineSeparator = 0x2028;
194const XMLCh chParagraphSeparator = 0x2029;
195
197{
198 public:
200 : m_document_node(node)
201 {}
203 : m_document_node(0)
204 {}
206 virtual XmlNode documentNode() { return XmlNode(0, m_document_node); }
207 virtual IXmlDocumentHolder* clone();
208 virtual void save(ByteArray& bytes);
209 virtual String save();
210
211 public:
212 void assignNode(NodePrv* node) { m_document_node = node; }
213
214 private:
215 NodePrv* m_document_node;
216};
217
219{
220 public:
222 : mRefcount(1)
223 {}
224
225 operator UInt32() { return mRefcount; }
226
227 LIBXML2_RefCount& operator=(const UInt32& aValue)
228 {
229 mRefcount = aValue;
230 return *this;
231 }
232
233 void operator++() { AtomicInt32::increment(&mRefcount); }
234
235 bool operator--()
236 {
237 AtomicInt32::decrement(&mRefcount);
238 return (mRefcount != 0);
239 }
240
241 private:
242 Int32 mRefcount;
243};
244
245#define LIBXML2_IMPL_REFCOUNT \
246 \
247private: \
248 LIBXML2_RefCount _libxml2_refcount; \
249 \
250public: \
251 void add_ref() throw() { ++_libxml2_refcount; } \
252 void release_ref() throw() \
253 { \
254 if (!--_libxml2_refcount) \
255 delete this; \
256 }
257
258class LIBXML2_Element;
259class LIBXML2_Document;
260class LIBXML2_Attr;
261class LIBXML2_Node;
262class LIBXML2_NodeList;
263class LIBXML2_NodeMap;
267class LIBXML2_Text;
268class QualifiedName;
269
270LIBXML2_Element* LIBXML2_NewElement(LIBXML2_Document* _xDoc, const String& nsURI, const String& elname);
271// The construction method for document...
272LIBXML2_Document* LIBXML2_NewDocument(const String& nsURI);
273
275{
276 public:
278 : mDocument(NULL)
279 {}
280 static LIBXML2_DOMImplementation* sDOMImplementation;
282 static const char* INTERFACE_NAME() { return "LIBXML2_DOMImplementation"; }
283 bool hasFeature(const String& feature, const String& version);
284 LIBXML2_DocumentType* createDocumentType(const String& qualifiedName, const String& publicId,
285 const String& systemId);
286 LIBXML2_Document* createDocument(const String& namespaceURI, const String& qualifiedName,
287 LIBXML2_DocumentType* doctype);
288 void SetDocument(LIBXML2_Document* _xDoc) { mDocument = _xDoc; }
289 LIBXML2_Document* GetDocument() { return mDocument; }
290 void ProcessXMLError(String& aErrorMessage, xmlError* aErr);
291 void ProcessContextError(String& aErrorMessage, xmlParserCtxt* ctxt);
292 LIBXML2_IMPL_REFCOUNT;
293
294 private:
295 LIBXML2_Document* mDocument;
296};
297
298LIBXML2_DOMImplementation* getDomImplementation();
299
301{
302 public:
303 static const char* INTERFACE_NAME() { return "LIBXML2_Node"; }
305 virtual ~LIBXML2_Node();
306 static const UInt16 NODE_NODE = 0;
307 static const UInt16 ELEMENT_NODE = 1;
308 static const UInt16 ATTRIBUTE_NODE = 2;
309 static const UInt16 TEXT_NODE = 3;
310 static const UInt16 CDATA_SECTION_NODE = 4;
311 static const UInt16 ENTITY_REFERENCE_NODE = 5;
312 static const UInt16 ENTITY_NODE = 6;
313 static const UInt16 PROCESSING_INSTRUCTION_NODE = 7;
314 static const UInt16 COMMENT_NODE = 8;
315 static const UInt16 DOCUMENT_NODE = 9;
316 static const UInt16 DOCUMENT_TYPE_NODE = 10;
317 static const UInt16 DOCUMENT_FRAGMENT_NODE = 11;
318 static const UInt16 NOTATION_NODE = 12;
319
320#ifdef DEBUG_NODELEAK
321 void find_leaked();
322#endif
323
324 String nodeName();
325 String nodeValue();
326 void nodeValue(const String& attr);
327 virtual UInt16 nodeType();
328 LIBXML2_Node* parentNode();
329 LIBXML2_NodeList* childNodes();
330 LIBXML2_Node* firstChild();
331 LIBXML2_Node* lastChild();
332 LIBXML2_Node* previousSibling();
333 LIBXML2_Node* nextSibling();
334 LIBXML2_NamedNodeMap* attributes();
335 LIBXML2_Document* ownerDocument();
337 LIBXML2_Node* insertBeforePrivate(LIBXML2_Node* newChild, LIBXML2_Node* refChild);
339 LIBXML2_Node* removeChild(LIBXML2_Node* oldChild);
340 LIBXML2_Node* removeChildPrivate(LIBXML2_Node* oldChild);
341 LIBXML2_Node* appendChild(LIBXML2_Node* newChild);
342 bool hasChildNodes();
343 virtual LIBXML2_Node* shallowCloneNode(LIBXML2_Document* doc)
344 {
345 ARCANE_UNUSED(doc);
346 throw NotImplementedException(A_FUNCINFO);
347 }
348 virtual LIBXML2_Node* cloneNode(bool deep);
349 LIBXML2_Node* cloneNodePrivate(LIBXML2_Document* aDoc, bool deep);
350 void normalize();
351 bool isSupported(const String& feature, const String& version);
352 String namespaceURI();
353 String prefix();
354 void prefix(const String& attr);
355 String localName();
356 bool hasAttributes() { return false; }
357 void updateDocumentAncestorStatus(bool aStatus);
358 void recursivelyChangeDocument(LIBXML2_Document* aNewDocument);
359 LIBXML2_Element* searchForElementById(const String& elementId);
360
361 public:
362 LIBXML2_Node* mParent;
363 std::list<LIBXML2_Node*>::iterator mPositionInParent;
364 bool mDocumentIsAncestor;
365 LIBXML2_Document* mDocument;
366 String mNodeName, mLocalName, mNodeValue, mNamespaceURI;
367 std::list<LIBXML2_Node*> mNodeList;
368 UInt16 mNodeType;
369 LIBXML2_RefCount _libxml2_refcount;
370
371 public:
372 void add_ref()
373 {
374 ++_libxml2_refcount;
375 if (mParent != NULL)
376 mParent->add_ref();
377 }
378
379 void release_ref()
380 {
381 if (_libxml2_refcount == 0) {
382 ARCANE_ASSERT((_libxml2_refcount == 0), ("release_ref called too many times"));
383 }
384 bool hitZero = !--_libxml2_refcount;
385 if (mParent == NULL) {
386 if (hitZero) {
387 delete this;
388 }
389 } else /* if the owner model is non-null, we will be destroyed when there are
390 * no remaining references to the model.
391 */
392 {
393 mParent->release_ref();
394 }
395 }
396};
397
399{
400 public:
401 static const char* INTERFACE_NAME() { return "LIBXML2_NodeList"; }
403 : mParent(NULL)
404 {}
406 : mParent(parent)
407 , m_hintIndex(0)
408 {
409 mParent->add_ref();
410 }
411 virtual ~LIBXML2_NodeList()
412 {
413 if (mParent != NULL)
414 mParent->release_ref();
415 }
416 LIBXML2_Node* item(UInt32 index);
417 UInt32 length();
418 LIBXML2_Node* mParent;
419 LIBXML2_IMPL_REFCOUNT;
420
421 private:
422 UInt32 m_hintIndex;
423 std::list<LIBXML2_Node*>::iterator m_hintIterator;
424};
425
427{
428 public:
430 : mParent(parent)
431 , mNameFilter(aNameFilter)
432 , mFilterType(LEVEL_1_NAME_FILTER)
433 {
434 mParent->add_ref();
435 }
436
439 : mParent(parent)
440 , mNamespaceFilter(aNamespaceFilter)
441 , mNameFilter(aLocalnameFilter)
442 , mFilterType(LEVEL_2_NAME_FILTER)
443 {
444 mParent->add_ref();
445 }
446
447 LIBXML2_Node* item(UInt32 index);
448 UInt32 length();
450 {
451 if (mParent != NULL)
452 mParent->release_ref();
453 }
454
455 LIBXML2_IMPL_REFCOUNT;
456
457 LIBXML2_Node* mParent;
458 String mNamespaceFilter, mNameFilter;
459 enum
460 {
461 LEVEL_1_NAME_FILTER,
462 LEVEL_2_NAME_FILTER
463 } mFilterType;
464};
465
468{
469 public:
470 static const char* INTERFACE_NAME() { return "LIBXML2_EmptyNamedNodeMap"; }
472 virtual ~LIBXML2_EmptyNamedNodeMap() {}
473 LIBXML2_Node* getNamedItem(const String& name)
474 {
475 ARCANE_UNUSED(name);
476 throw NotImplementedException(A_FUNCINFO);
477 }
478 LIBXML2_Node* setNamedItem(LIBXML2_Node* arg)
479 {
480 ARCANE_UNUSED(arg);
481 throw NotImplementedException(A_FUNCINFO);
482 }
483 LIBXML2_Node* removeNamedItem(const String& name)
484 {
485 ARCANE_UNUSED(name);
486 throw NotImplementedException(A_FUNCINFO);
487 }
488 LIBXML2_Node* item(UInt32 index)
489 {
490 ARCANE_UNUSED(index);
491 throw NotImplementedException(A_FUNCINFO);
492 }
493 UInt32 length()
494 {
495 throw NotImplementedException(A_FUNCINFO);
496 }
497 LIBXML2_Node* getNamedItemNS(const String& namespaceURI, String& localName)
498 {
499 ARCANE_UNUSED(namespaceURI);
500 ARCANE_UNUSED(localName);
501 throw NotImplementedException(A_FUNCINFO);
502 }
503 LIBXML2_Node* setNamedItemNS(LIBXML2_Node* arg)
504 {
505 ARCANE_UNUSED(arg);
506 throw NotImplementedException(A_FUNCINFO);
507 }
508 LIBXML2_Node* removeNamedItemNS(const String& namespaceURI, const String& localName)
509 {
510 ARCANE_UNUSED(namespaceURI);
511 ARCANE_UNUSED(localName);
512 throw NotImplementedException(A_FUNCINFO);
513 }
514 LIBXML2_IMPL_REFCOUNT;
515};
516
518{
519 public:
520 static const char* INTERFACE_NAME() { return "LIBXML2_CharacterData"; }
523 {}
524 virtual ~LIBXML2_CharacterData() {}
525 String Data();
526 void Data(const String& attr);
527 void nodeValue(const String& attr);
528 UInt32 length();
529 String substringdata(UInt32 offset, UInt32 count);
530 void appenddata(const String& arg);
531 void insertdata(UInt32 offset, const String& arg);
532 void deletedata(UInt32 offset, UInt32 count);
533 void replacedata(UInt32 offset, UInt32 count, const String& arg);
534 LIBXML2_IMPL_REFCOUNT;
535};
536
537#define LIBXML2_IMPL_NODETYPE(type) \
538 \
539UInt16 \
540 nodeType() \
541 { \
542 return LIBXML2_Node::type##_NODE; \
543 }
544
546{
547 public:
548 static const char* INTERFACE_NAME() { return "LIBXML2_Attr"; }
551 , mSpecified(false)
552 {}
553 virtual ~LIBXML2_Attr() {}
554 LIBXML2_IMPL_NODETYPE(ATTRIBUTE);
555 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
556 String name();
557 bool specified();
558 String value();
559 void value(const String& attr);
560 LIBXML2_Element* ownerElement();
561 bool mSpecified;
562};
563
565{
566 public:
567 static const char* INTERFACE_NAME() { return "LIBXML2_Element"; }
570 {}
571 virtual ~LIBXML2_Element();
572 LIBXML2_IMPL_NODETYPE(ELEMENT);
573 LIBXML2_NamedNodeMap* attributes();
574 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
575 String tagName();
576 String getAttribute(const String& name);
577 void setAttribute(const String& name, const String& value);
578 void removeAttribute(const String& name);
579 LIBXML2_Attr* getAttributeNode(const String& name);
580 LIBXML2_Attr* setAttributeNode(LIBXML2_Attr* newAttr);
581 LIBXML2_Attr* removeAttributeNode(LIBXML2_Attr* oldAttr);
582 LIBXML2_NodeList* getElementsByTagName(const String& name);
583 String getAttributeNS(const String& namespaceURI, const String& localname);
584 void setAttributeNS(const String& namespaceURI, const String& qualifiedname, const String& value);
585 void removeAttributeNS(const String& namespaceURI, const String& localname);
586 LIBXML2_Attr* getAttributeNodeNS(const String& namespaceURI, const String& localname);
587 LIBXML2_Attr* setAttributeNodeNS(LIBXML2_Attr* newAttr);
588 LIBXML2_NodeList* getElementsByTagNameNS(const String& namespaceURI, const String& localname);
589 bool hasAttribute(const String& name);
590 bool hasAttributeNS(const String& namespaceURI, const String& localname);
591 bool hasAttributes();
592 LIBXML2_Element* searchForElementById(const String& elementId);
593
595 {
596 public:
597 LocalName(const String& aname)
598 : name(aname)
599 {}
600 LocalName(const LocalName& ln)
601 : name(ln.name)
602 {}
603 bool operator==(const LocalName& aCompareWith) const { return name == aCompareWith.name; }
604
605 bool operator<(const LocalName& aCompareWith) const { return name < aCompareWith.name; }
606 String name;
607 };
608
610 {
611 public:
613 : ns(aNamespace)
614 , name(aname)
615 {}
617 : ns(ln.ns)
618 , name(ln.name)
619 {}
620
621 bool operator==(const QualifiedName& aCompareWith) const
622 {
623 return name == aCompareWith.name && ns == aCompareWith.ns;
624 }
625
626 bool operator<(const QualifiedName& aCompareWith) const { return name < aCompareWith.name; }
627 String ns;
628 String name;
629 };
630 LIBXML2_IMPL_REFCOUNT;
631
632 std::map<QualifiedName, LIBXML2_Attr*> attributeMapNS;
633 std::map<LocalName, LIBXML2_Attr*> attributeMap;
634};
635
637{
638 public:
639 static const char* INTERFACE_NAME() { return "LIBXML2_NamedNodeMap"; }
641 : mElement(NULL)
642 , m_hintIndex(0)
643 {}
645 virtual ~LIBXML2_NamedNodeMap();
646 virtual LIBXML2_Node* getNamedItem(const String& name);
647 virtual LIBXML2_Node* setNamedItem(LIBXML2_Node* arg);
648 virtual LIBXML2_Node* removeNamedItem(const String& name);
649 virtual LIBXML2_Node* item(UInt32 index);
650 virtual UInt32 length();
651 virtual LIBXML2_Node* getNamedItemNS(const String& namespaceURI, const String& localname);
652 virtual LIBXML2_Node* setNamedItemNS(LIBXML2_Node* arg);
653 virtual LIBXML2_Node* removeNamedItemNS(const String& namespaceURI, const String& localname);
654 LIBXML2_Element* mElement;
655 LIBXML2_IMPL_REFCOUNT;
656
657 private:
658 UInt32 m_hintIndex;
659 std::map<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>::iterator m_hintIterator;
660};
661
663{
664 public:
665 static const char* INTERFACE_NAME() { return "LIBXML2_NamedNodeDT"; }
667 virtual ~LIBXML2_NamedNodeMapDT();
668 LIBXML2_Node* getNamedItem(const String& name);
669 LIBXML2_Node* setNamedItem(LIBXML2_Node* arg);
670 LIBXML2_Node* removeNamedItem(const String& name);
671 LIBXML2_Node* item(UInt32 index);
672 UInt32 length();
673 LIBXML2_Node* getNamedItemNS(const String& namespaceURI, const String& localname);
674 LIBXML2_Node* setNamedItemNS(LIBXML2_Node* arg);
675 LIBXML2_Node* removeNamedItemNS(const String& namespaceURI, const String& localname);
676 LIBXML2_IMPL_REFCOUNT;
677
678 LIBXML2_DocumentType* mDocType;
679 UInt16 mType;
680};
681
683{
684 public:
685 static const char* INTERFACE_NAME() { return "LIBXML2_TextBase"; }
688 {}
689 virtual ~LIBXML2_TextBase() {}
690 LIBXML2_Text* splitText(UInt32 offset);
691 LIBXML2_IMPL_REFCOUNT;
692};
693
695{
696 public:
697 static const char* INTERFACE_NAME() { return "LIBXML2_Text"; }
700 {}
701 virtual ~LIBXML2_Text() {}
702 LIBXML2_IMPL_NODETYPE(TEXT);
703 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
704};
705
707{
708 public:
709 static const char* INTERFACE_NAME() { return "LIBXML2_Comment"; }
712 {}
713 virtual ~LIBXML2_Comment() {}
714 LIBXML2_IMPL_NODETYPE(COMMENT);
715 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
716};
717
719{
720 public:
721 static const char* INTERFACE_NAME() { return "LIBXML2_CDATASection"; }
724 {}
725 virtual ~LIBXML2_CDATASection() {}
726 LIBXML2_IMPL_NODETYPE(CDATA_SECTION);
727 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
728 LIBXML2_Text* splitText(UInt32 offset);
729};
730
732{
733 public:
734 static const char* INTERFACE_NAME() { return "LIBXML2_DocumentType"; }
736 const String& systemId)
738 {
739 mNodeName = qualifiedName;
740 mPublicId = publicId;
741 mSystemId = systemId;
742 }
743 virtual ~LIBXML2_DocumentType() {}
744 LIBXML2_IMPL_NODETYPE(DOCUMENT_TYPE);
745 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
746 String name();
747 LIBXML2_NamedNodeMap* entities();
748 LIBXML2_NamedNodeMap* notations();
749 String publicId();
750 String systemId();
751 String internalSubset();
752 String mPublicId, mSystemId;
753};
754
756{
757 public:
758 static const char* INTERFACE_NAME() { return "LIBXML2_Notation"; }
761 , mPublicId(aPublicId)
762 , mSystemId(aSystemId)
763 {}
764 virtual ~LIBXML2_Notation() {}
765 LIBXML2_IMPL_NODETYPE(NOTATION);
766 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
767 String publicId();
768 String systemId();
769 String mPublicId, mSystemId;
770};
771
773{
774 public:
775 static const char* INTERFACE_NAME() { return "LIBXML2_Entity"; }
776
779 , mPublicId(aPublicId)
780 , mSystemId(aSystemId)
781 , mNotationName(aNotationname)
782 {}
783 virtual ~LIBXML2_Entity() {}
784 LIBXML2_IMPL_NODETYPE(ENTITY);
785 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
786 String publicId();
787 String systemId();
788 String notationName();
789 String mPublicId, mSystemId, mNotationName;
790};
791
793{
794 public:
795 static const char* INTERFACE_NAME() { return "LIBXML2_EntityReference"; }
798 {}
799 virtual ~LIBXML2_EntityReference() {}
800 LIBXML2_IMPL_NODETYPE(ENTITY_REFERENCE);
801 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
802};
803
805{
806 public:
807 static const char* INTERFACE_NAME() { return "LIBXML2_ProcessingInstruction"; }
810 {
811 mNodeName = aTarget;
812 mNodeValue = aData;
813 }
814
816 LIBXML2_IMPL_NODETYPE(PROCESSING_INSTRUCTION);
817 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
818 String target();
819 String Data();
820 void Data(const String& attr);
821};
822
824{
825 public:
826 static const char* INTERFACE_NAME() { return "LIBXML2_DocumentFragment"; }
829 {}
830 virtual ~LIBXML2_DocumentFragment() {}
831 LIBXML2_IMPL_NODETYPE(DOCUMENT_FRAGMENT);
832 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
833};
834
836{
837 public:
838 static const char* INTERFACE_NAME() { return "LIBXML2_Document"; }
839 LIBXML2_Document(const String& namespaceURI, const String& qualifiedname, LIBXML2_DocumentType* doctype);
841 : LIBXML2_Node(this)
842 , impl_(NULL)
843 , context_(NULL)
844 {
845 // We are our own document ancestor...
846 mDocumentIsAncestor = true;
847 mDocument->release_ref();
848 }
849
850 virtual ~LIBXML2_Document()
851 {
852 if (context_) {
853 if (context_->myDoc != nullptr) {
854 xmlFreeDoc(context_->myDoc);
855 Impl_(nullptr);
856 }
857 }
858 if (Impl_() != nullptr) {
859 xmlFreeDoc(Impl_());
860 Impl_(nullptr);
861 }
862 }
863
864 LIBXML2_IMPL_NODETYPE(DOCUMENT);
865 LIBXML2_Text* doctype();
866 LIBXML2_DOMImplementation* implementation();
867 LIBXML2_Element* documentElement();
868 LIBXML2_Element* createElement(const String& tagName);
869 LIBXML2_DocumentFragment* createDocumentFragment();
870 LIBXML2_Text* createTextNode(const String& data);
871 LIBXML2_Comment* createComment(const String& data);
872 LIBXML2_CDATASection* createCDATASection(const String& data);
873 LIBXML2_ProcessingInstruction* createProcessingInstruction(const String& target, const String& data);
874 LIBXML2_Attr* createAttribute(const String& name);
875 LIBXML2_EntityReference* createEntityReference(const String& name);
876 LIBXML2_NodeList* getElementsByTagName(const String& tagName);
877 LIBXML2_Node* importNode(LIBXML2_Node* importedNode, bool deep);
878 LIBXML2_Element* createElementNS(const String& namespaceURI, const String& qualifiedname);
879 LIBXML2_Attr* createAttributeNS(const String& namespaceURI, const String& qualifiedname);
880 LIBXML2_NodeList* getElementsByTagNameNS(const String& namespaceURI, const String& localname);
881 LIBXML2_Element* getElementById(const String& elementId);
882 void Impl_(_xmlDoc* Doc) { impl_ = Doc; }
883 _xmlDoc* Impl_(void) { return impl_; }
884 void Context_(xmlParserCtxt* Context) { context_ = Context; }
885 xmlParserCtxt* Context_() { return context_; }
886 LIBXML2_Node* shallowCloneNode(LIBXML2_Document* aDoc);
887 LIBXML2_Element* searchForElementById(const String& elementId);
888
889 private:
890 _xmlDoc* impl_;
891 xmlParserCtxt* context_;
892};
893
895
897{
898 public:
900 : impl_(0)
901 , context_(0)
902 , indent(indentation)
903 , do_indent(0)
904 , DeepNode(0)
905 {}
906
908 : impl_(xmlDoc_)
909 , context_(context)
910 , indent(indentation)
911 , do_indent(0)
912 , DeepNode(0)
913 {}
921 void writeEntityReference(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_EntityReference* er,
923 void writeProcessingInstruction(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_ProcessingInstruction* pi,
928 void writeDocumentFragment(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_DocumentFragment* df,
931
932 static const char* get_encoding_or_utf8(const String& encoding)
933 {
934 if (encoding.empty()) {
935 // If we don't specify this to the xmlDocDump* functions (using nullptr instead),
936 // then some other encoding is used, causing them to fail on non-ASCII characters.
937 return "UTF-8";
938 } else
939 return (const char*)encoding.localstr();
940 }
941
942 private:
943 void DoIndentation(bool StartEnd, StringBuilder& appendTo);
944 _xmlDoc* impl_;
945 xmlParserCtxt* context_;
946
947 LIBXML2_IMPL_REFCOUNT;
948
949 public:
950 int indent;
951 int do_indent;
952 int DeepNode;
953};
954
956{
957 public:
959 void setDefaultNamespace(const String& newns);
960 void recordPrefix(const String& prefix, const String& ns);
961 String getDefaultNamespace();
962 String findNamespaceForPrefix(const String& prefix);
963 String findPrefixForNamespace(const String& ns);
964 void possiblyInventPrefix(const String& prefix);
965 void resolveOrInventPrefixes();
966 void writeXMLNS(StringBuilder& appendTo);
967 LIBXML2_IMPL_REFCOUNT;
968
969 private:
971 bool mOverrideDefaultNamespace;
972 String mDefaultNamespace;
973 std::map<String, String> mURIfromPrefix;
974 std::map<String, String> mPrefixfromURI;
975 std::list<String> mNamespacesNeedingPrefixes;
976};
977
978ARCANE_END_NAMESPACE_DOM
979ARCANE_END_NAMESPACE
980
981/*---------------------------------------------------------------------------*/
982/*---------------------------------------------------------------------------*/
983
984/*---------------------------------------------------------------------------*/
985/*---------------------------------------------------------------------------*/
986
988
989#include "arcane/XmlException.h"
990#include "arcane/utils/PlatformUtils.h"
991#include <arcane/utils/TraceInfo.h>
992
993#include <map>
994#include <string>
995
996#include <libxml/parserInternals.h> //For xmlCreateFileParserCtxt().
997#include <libxml/xinclude.h>
998#include <libxml/xmlschemas.h>
999
1000#include <algorithm>
1001
1002//#include <codecvt> // not available with gcc at least 4.8
1003
1004#ifdef USE_WCHAR
1005#include <cwchar>
1006#define U(S) L##S
1007typedef std::wstring ustring;
1008
1009#else /* USE_WCHAR */
1010#define U(S) u##S
1011typedef std::u16string ustring;
1012
1013static_assert(sizeof(char16_t) == sizeof(short), "Inconsistent size");
1014typedef unsigned short unsigned_char16_t;
1015
1016int
1017wcscmp(const char16_t* s1, const char16_t* s2)
1018{
1019 while (*s1 == *s2++)
1020 if (*s1++ == 0)
1021 return (0);
1022 return (*(const unsigned_char16_t*)s1 - *(const unsigned_char16_t*)--s2);
1023}
1024
1025int
1026wcsncmp(const char16_t* s1, const char16_t* s2, size_t n)
1027{
1028 if (n == 0)
1029 return (0);
1030 do {
1031 if (*s1 != *s2++) {
1032 return (*(const unsigned_char16_t*)s1 - *(const unsigned_char16_t*)--s2);
1033 }
1034 if (*s1++ == 0)
1035 break;
1036 } while (--n != 0);
1037 return (0);
1038}
1039
1040char16_t*
1041wcschr(const char16_t* s, const char16_t c)
1042{
1043 while (*s != c && *s != L'\0')
1044 s++;
1045 if (*s == c)
1046 return ((char16_t*)s);
1047 return (NULL);
1048}
1049
1050size_t
1051wcslen(const char16_t* s)
1052{
1053 const char16_t* p;
1054 p = s;
1055 while (*p)
1056 p++;
1057 return p - s;
1058}
1059
1060int
1061wcstombs(char* dest, const char16_t* src, size_t n)
1062{
1063 int i = n;
1064 while (--i >= 0) {
1065 if (!(*dest++ = *src++))
1066 break;
1067 }
1068 return n - i - 1;
1069}
1070#endif /* USE_WCHAR */
1071
1072// Begin interface with Arcane
1073ARCANE_BEGIN_NAMESPACE
1074ARCANE_BEGIN_NAMESPACE_DOM
1075
1076// Prevent compatibility check for next reinterpret_cast
1077// static_assert(sizeof(XMLCh) == sizeof(decltype(*String().utf16().begin())), "Inconsistent data size");
1078// static_assert(sizeof(XMLCh) == sizeof(UChar), "Inconsistent data size");
1079static_assert(sizeof(XMLByte) == sizeof(Byte), "Inconsistent data size");
1080static_assert(sizeof(xmlChar) == sizeof(char), "Inconsistent data size");
1081
1082LIBXML2_Node* WrapXML2Node(LIBXML2_Document* doc, xmlNode* x2node);
1083
1085{
1087 String mMsgTo;
1088};
1089
1090static void
1091LIBXML2_XMLStructuredHandler(void* userData, xmlErrorPtr error)
1092{
1093 LIBXML2_PartialLoad* pl = reinterpret_cast<LIBXML2_PartialLoad*>(userData);
1094 pl->mImpl->ProcessXMLError(pl->mMsgTo, error);
1095}
1096
1097/*---------------------------------------------------------------------------*/
1098/*---------------------------------------------------------------------------*/
1099
1100static LIBXML2_Node*
1101impl(NodePrv* p)
1102{
1103 return reinterpret_cast<LIBXML2_Node*>(p);
1104}
1105static LIBXML2_Attr*
1106impl(AttrPrv* p)
1107{
1108 return reinterpret_cast<LIBXML2_Attr*>(p);
1109}
1110static LIBXML2_Element*
1111impl(ElementPrv* p)
1112{
1113 return reinterpret_cast<LIBXML2_Element*>(p);
1114}
1115static LIBXML2_Document*
1116impl(DocumentPrv* p)
1117{
1118 return reinterpret_cast<LIBXML2_Document*>(p);
1119}
1120static LIBXML2_DocumentType*
1121impl(DocumentTypePrv* p)
1122{
1123 return reinterpret_cast<LIBXML2_DocumentType*>(p);
1124}
1125static LIBXML2_DOMImplementation*
1126impl(ImplementationPrv* p)
1127{
1128 return reinterpret_cast<LIBXML2_DOMImplementation*>(p);
1129}
1130static LIBXML2_CharacterData*
1131impl(CharacterDataPrv* p)
1132{
1133 return reinterpret_cast<LIBXML2_CharacterData*>(p);
1134}
1135static LIBXML2_Text*
1136impl(TextPrv* p)
1137{
1138 return reinterpret_cast<LIBXML2_Text*>(p);
1139}
1140static LIBXML2_NodeList*
1141impl(NodeListPrv* p)
1142{
1143 return reinterpret_cast<LIBXML2_NodeList*>(p);
1144}
1145static LIBXML2_DocumentFragment*
1146impl(DocumentFragmentPrv* p)
1147{
1148 return reinterpret_cast<LIBXML2_DocumentFragment*>(p);
1149}
1150static LIBXML2_NamedNodeMap*
1151impl(NamedNodeMapPrv* p)
1152{
1153 return reinterpret_cast<LIBXML2_NamedNodeMap*>(p);
1154}
1155static LIBXML2_Comment*
1156impl(CommentPrv* p)
1157{
1158 return reinterpret_cast<LIBXML2_Comment*>(p);
1159}
1160static LIBXML2_CDATASection*
1161impl(CDATASectionPrv* p)
1162{
1163 return reinterpret_cast<LIBXML2_CDATASection*>(p);
1164}
1165static LIBXML2_ProcessingInstruction*
1166impl(ProcessingInstructionPrv* p)
1167{
1168 return reinterpret_cast<LIBXML2_ProcessingInstruction*>(p);
1169}
1170static LIBXML2_EntityReference*
1171impl(EntityReferencePrv* p)
1172{
1173 return reinterpret_cast<LIBXML2_EntityReference*>(p);
1174}
1175static LIBXML2_Entity*
1176impl(EntityPrv* p)
1177{
1178 return reinterpret_cast<LIBXML2_Entity*>(p);
1179}
1180static LIBXML2_Notation*
1181impl(NotationPrv* p)
1182{
1183 return reinterpret_cast<LIBXML2_Notation*>(p);
1184}
1185static LIBXML2_DOMWriter*
1186impl(DOMWriterPrv* p)
1187{
1188 return reinterpret_cast<LIBXML2_DOMWriter*>(p);
1189}
1190
1191static NodePrv*
1192cvt(LIBXML2_Node* p)
1193{
1194 return reinterpret_cast<NodePrv*>(p);
1195}
1196static AttrPrv*
1197cvt(LIBXML2_Attr* p)
1198{
1199 return reinterpret_cast<AttrPrv*>(p);
1200}
1201static ElementPrv*
1202cvt(LIBXML2_Element* p)
1203{
1204 return reinterpret_cast<ElementPrv*>(p);
1205}
1206static DocumentPrv*
1207cvt(LIBXML2_Document* p)
1208{
1209 return reinterpret_cast<DocumentPrv*>(p);
1210}
1211static DocumentTypePrv*
1212cvt(LIBXML2_DocumentType* p)
1213{
1214 return reinterpret_cast<DocumentTypePrv*>(p);
1215}
1216static ImplementationPrv*
1217cvt(LIBXML2_DOMImplementation* p)
1218{
1219 return reinterpret_cast<ImplementationPrv*>(p);
1220}
1221static CharacterDataPrv*
1222cvt(LIBXML2_CharacterData* p)
1223{
1224 return reinterpret_cast<CharacterDataPrv*>(p);
1225}
1226static TextPrv*
1227cvt(LIBXML2_Text* p)
1228{
1229 return reinterpret_cast<TextPrv*>(p);
1230}
1231static NodeListPrv*
1232cvt(LIBXML2_NodeList* p)
1233{
1234 return reinterpret_cast<NodeListPrv*>(p);
1235}
1236static DocumentFragmentPrv*
1237cvt(LIBXML2_DocumentFragment* p)
1238{
1239 return reinterpret_cast<DocumentFragmentPrv*>(p);
1240}
1241static NamedNodeMapPrv*
1242cvt(LIBXML2_NamedNodeMap* p)
1243{
1244 return reinterpret_cast<NamedNodeMapPrv*>(p);
1245}
1246static CommentPrv*
1247cvt(LIBXML2_Comment* p)
1248{
1249 return reinterpret_cast<CommentPrv*>(p);
1250}
1251static CDATASectionPrv*
1252cvt(LIBXML2_CDATASection* p)
1253{
1254 return reinterpret_cast<CDATASectionPrv*>(p);
1255}
1256static ProcessingInstructionPrv*
1257cvt(LIBXML2_ProcessingInstruction* p)
1258{
1259 return reinterpret_cast<ProcessingInstructionPrv*>(p);
1260}
1261static EntityPrv*
1262cvt(LIBXML2_Entity* p)
1263{
1264 return reinterpret_cast<EntityPrv*>(p);
1265}
1266static EntityReferencePrv*
1267cvt(LIBXML2_EntityReference* p)
1268{
1269 return reinterpret_cast<EntityReferencePrv*>(p);
1270}
1271static NotationPrv*
1272cvt(LIBXML2_Notation* p)
1273{
1274 return reinterpret_cast<NotationPrv*>(p);
1275}
1276static DOMWriterPrv*
1277cvt(LIBXML2_DOMWriter* p)
1278{
1279 return reinterpret_cast<DOMWriterPrv*>(p);
1280}
1281
1282// ------------------------------------------------------------
1283// Static constants
1284// ------------------------------------------------------------
1285static const XMLCh g1_0[] = // Points to "1.0"
1286 { chDigit_1, chPeriod, chDigit_0, chNull };
1287static const XMLCh g2_0[] = // Points to "2.0"
1288 { chDigit_2, chPeriod, chDigit_0, chNull };
1289static const XMLCh g3_0[] = // Points to "3.0"
1290 { chDigit_3, chPeriod, chDigit_0, chNull };
1291static const XMLCh gTrav[] = // Points to "Traversal"
1292 { chLatin_T, chLatin_r, chLatin_a, chLatin_v, chLatin_e,
1293 chLatin_r, chLatin_s, chLatin_a, chLatin_l, chNull };
1294static const XMLCh gCore[] = // Points to "Core"
1295 { chLatin_C, chLatin_o, chLatin_r, chLatin_e, chNull };
1296static const XMLCh gRange[] = // Points to "Range"
1297 { chLatin_R, chLatin_a, chLatin_n, chLatin_g, chLatin_e, chNull };
1298static const XMLCh gLS[] = // Points to "LS"
1299 { chLatin_L, chLatin_S, chNull };
1300static const XMLCh gXPath[] = // Points to "XPath"
1301 { chLatin_X, chLatin_P, chLatin_a, chLatin_t, chLatin_h, chNull };
1302const XMLCh gXMLString[] = { chLatin_x, chLatin_m, chLatin_l, chNull };
1303// static XMLCh null_xc[1] = { 0 };
1304
1305String
1306format_xml_error(const xmlError* error)
1307{
1308 if (!error)
1309 error = xmlGetLastError();
1310
1311 if (!error || error->code == XML_ERR_OK)
1312 return String(); // No error
1313 String str, str2;
1314 String strError;
1315
1316 if (error->file && *error->file != '\0') {
1317 str = str + "File ";
1318 str = str + error->file;
1319 }
1320 if (error->line > 0) {
1321 strError = String::format("{0}", error->line);
1322 str = str + (str.empty() ? "Line " : ", line ") + strError;
1323 if (error->int2 > 0) {
1324 strError = String::format("{0}", error->int2);
1325 str = str + ", column " + strError;
1326 }
1327 }
1328 const bool two_lines = !str.empty();
1329 if (two_lines)
1330 str = str + " ";
1331 switch (error->level) {
1332 case XML_ERR_WARNING:
1333 str = str + "(warning):";
1334 break;
1335 case XML_ERR_ERROR:
1336 str = str + "(error):";
1337 break;
1338 case XML_ERR_FATAL:
1339 str = str + "(fatal):";
1340 break;
1341 default:
1342 str = str + "():";
1343 break;
1344 }
1345 str = str + (two_lines ? "\n" : " ");
1346 if (error->message && *error->message != '\0')
1347 str = str + error->message;
1348 else {
1349 strError = String::format("{0}", error->code);
1350 str = str + "Error code " + strError;
1351 }
1352 // If the string does not end with end-of-line, append an end-of-line.
1353 if (!str.endsWith("\n"))
1354 str = str + "\n";
1355 return str;
1356}
1357
1358String
1359format_xml_parser_error(const xmlParserCtxt* parser_context)
1360{
1361 if (!parser_context)
1362 return "Error. format_xml_parser_error() called with parser_context == nullptr\n";
1363 const xmlErrorPtr error = xmlCtxtGetLastError(const_cast<xmlParserCtxt*>(parser_context));
1364 if (!error)
1365 return String(); // No error
1366 String str;
1367 if (!parser_context->wellFormed)
1368 str = str + "Document not well-formed.\n";
1369 return str + format_xml_error(error);
1370}
1371
1372NodePrv*
1373toNodePrv(const Node& node)
1374{
1375 return node._impl();
1376}
1377
1378/*---------------------------------------------------------------------------*/
1379/*---------------------------------------------------------------------------*/
1380
1381/*---------------------------------------------------------------------------*/
1382/*---------------------------------------------------------------------------*/
1383
1384XmlDocumentHolderLibXml2::
1385~XmlDocumentHolderLibXml2()
1386{
1387 if (m_document_node)
1388 delete impl(m_document_node);
1389}
1390
1391IXmlDocumentHolder* XmlDocumentHolderLibXml2::
1392clone()
1393{
1394 LIBXML2_Node* n = impl(m_document_node)->cloneNode(true);
1395 return new XmlDocumentHolderLibXml2(cvt(n));
1396}
1397
1398void XmlDocumentHolderLibXml2::
1399save(ByteArray& bytes)
1400{
1401 domutils::saveDocument(bytes, documentNode().domNode());
1402}
1403
1404String XmlDocumentHolderLibXml2::
1405save()
1406{
1407 // TODO verifier qu'on sauve toujours en UTF8.
1408 ByteUniqueArray bytes;
1409 domutils::saveDocument(bytes, documentNode().domNode());
1410 // Ajoute le 0 terminal
1411 bytes.add('\0');
1412 String new_s = String::fromUtf8(bytes);
1413 return new_s;
1414}
1415
1416/*---------------------------------------------------------------------------*/
1417/*---------------------------------------------------------------------------*/
1418
1419DOMImplementation::
1420DOMImplementation()
1421: m_p(0)
1422{
1423 m_p = cvt(getDomImplementation());
1424}
1425
1426DOMImplementation::
1427DOMImplementation(ImplementationPrv* prv)
1428: m_p(prv)
1429{}
1430
1431DOMImplementation::
1432~DOMImplementation() {}
1433
1434void
1435DOMImplementation::
1436_checkValid() const
1437{
1438 if (!m_p)
1440}
1441
1442ImplementationPrv*
1443DOMImplementation::
1444_impl() const
1445{
1446 return m_p;
1447}
1448
1449/*---------------------------------------------------------------------------*/
1450/*---------------------------------------------------------------------------*/
1451bool DOMImplementation::
1452hasFeature(const DOMString& feature, const DOMString& version) const
1453{
1454 _checkValid();
1455 const XMLCh* xmlfeature = reinterpret_cast<const XMLCh*>(feature.utf16().begin());
1456 const XMLCh* xmlversion = reinterpret_cast<const XMLCh*>(version.utf16().begin());
1457 if (!xmlfeature)
1458 return false;
1459 // ignore the + modifier
1460 if (*xmlfeature == chPlus)
1461 xmlfeature++;
1462 bool anyVersion = (xmlversion == 0 || !*xmlversion);
1463 bool version1_0 = wcscmp(xmlversion, g1_0) == 0;
1464 bool version2_0 = wcscmp(xmlversion, g2_0) == 0;
1465 bool version3_0 = wcscmp(xmlversion, g3_0) == 0;
1466 // Currently, we support only XML Level 1 version 1.0
1467 if (wcscmp(xmlfeature, gXMLString) == 0 && (anyVersion || version1_0 || version2_0))
1468 return true;
1469 if (wcscmp(xmlfeature, gCore) == 0 && (anyVersion || version1_0 || version2_0 || version3_0))
1470 return true;
1471 if (wcscmp(xmlfeature, gTrav) == 0 && (anyVersion || version2_0))
1472 return true;
1473 if (wcscmp(xmlfeature, gRange) == 0 && (anyVersion || version2_0))
1474 return true;
1475 if (wcscmp(xmlfeature, gLS) == 0 && (anyVersion || version3_0))
1476 return true;
1477 if (wcscmp(xmlfeature, gXPath) == 0 && (anyVersion || version3_0))
1478 return true;
1479 return true;
1480}
1481
1484 const DocumentType& doctype) const
1485{
1486 _checkValid();
1487 LIBXML2_Document* doc = nullptr;
1488 try {
1489 LIBXML2_DocumentType* doctypei = impl(doctype._impl());
1490 doc = impl(m_p)->createDocument(namespace_uri, qualifiedname, doctypei);
1491 } catch (const DOMException& ex) {
1492 cerr << "** DOMException call in createDocument(const DOMString& namespace_uri, const DOMString& "
1493 "qualifiedname, const DocumentType& doctype)"
1494 << ex.code << '\n';
1495 throw ex;
1496 }
1497 impl(m_p)->SetDocument(doc);
1498 return cvt(doc);
1499}
1500
1501DocumentType DOMImplementation::
1502createDocumentType(const DOMString& qualifiedname, const DOMString& public_id,
1503 const DOMString& system_id) const
1504{
1505 _checkValid();
1506 LIBXML2_DocumentType* doctype = impl(m_p)->createDocumentType(qualifiedname, public_id, system_id);
1507 return cvt(doctype);
1508}
1509
1512{
1513 // create the Empty document
1515 if (doc == NULL)
1516 throw Arcane::Exception::exception();
1518 if (xml_doc == NULL)
1519 throw Arcane::Exception::exception();
1520 return xml_doc;
1521}
1522
1523enum XML_PARSE_TYPE
1524{
1525 XML_PARSE_SCHEMA_FILE,
1526 XML_PARSE_SCHEMA_MEMORY
1527};
1528static xmlParserCtxt*
1529_xmlSchemaValidationAndParsing(const String& fname, ITraceMng* msg, XML_PARSE_TYPE type,
1530 const String& schemaname, ByteConstArrayView schemaData)
1531{
1532 xmlSchemaPtr schema = NULL;
1533 xmlSchemaValidCtxtPtr vctxt = NULL;
1534 xmlSchemaParserCtxtPtr pctxt = NULL;
1535 xmlParserCtxt* context = NULL;
1536 xmlDocPtr myDoc = NULL;
1537 int result = 0;
1538 // create the file parser context
1539 if ((context = xmlCreateFileParserCtxt(fname.localstr())) == NULL) {
1540 throw Arcane::XmlException(A_FUNCINFO,
1541 String::format("LIBXML2 Could not create File parser context '{0}'\n{1}",
1542 fname, format_xml_error(xmlGetLastError())));
1543 }
1544 if (type == XML_PARSE_SCHEMA_FILE) {
1545 // create schema parser context
1546 if ((pctxt = xmlSchemaNewParserCtxt(schemaname.localstr())) == NULL) {
1547 throw Arcane::XmlException(A_FUNCINFO,
1548 String::format("LIBXML2 Could not create context Schema '{0}'\n{1}",
1549 schemaname, format_xml_error(xmlGetLastError())));
1550 }
1551 } else {
1552 // create schema parser context
1553 if ((pctxt = xmlSchemaNewMemParserCtxt(
1554 const_cast<char*>(reinterpret_cast<const char*>(schemaData.begin())), schemaData.size())) ==
1555 NULL) {
1556 throw Arcane::XmlException(A_FUNCINFO,
1557 String::format("LIBXML2 Could not create context Schema '{0}'\n{1}",
1558 schemaname, format_xml_error(xmlGetLastError())));
1559 }
1560 }
1561 xmlSchemaSetParserErrors(pctxt, (xmlSchemaValidityErrorFunc)fprintf, (xmlSchemaValidityWarningFunc)fprintf,
1562 stderr);
1563 if ((schema = xmlSchemaParse(pctxt)) == NULL) {
1564 throw Arcane::XmlException(A_FUNCINFO,
1565 String::format("LIBXML2 Could not parse Schema '{0}'\n{1}", schemaname,
1566 format_xml_error(xmlGetLastError())));
1567 }
1568
1569 if ((myDoc = xmlReadFile(fname.localstr(), NULL, 0)) == NULL) {
1570 throw Arcane::XmlException(A_FUNCINFO,
1571 String::format("LIBXML2 Could not read xml file '{0}'\n{1}", fname,
1572 format_xml_error(xmlGetLastError())));
1573 }
1574 if ((vctxt = xmlSchemaNewValidCtxt(schema)) == NULL) {
1575 throw Arcane::XmlException(A_FUNCINFO,
1576 String::format("LIBXML2 Could not validate context Schema '{0}'\n{1}",
1577 schemaname, format_xml_error(xmlGetLastError())));
1578 }
1579 xmlSchemaSetParserErrors(pctxt, (xmlSchemaValidityErrorFunc)fprintf, (xmlSchemaValidityWarningFunc)fprintf,
1580 stderr);
1581 // populate xml tree with default values
1582 xmlSchemaSetValidOptions(vctxt, XML_SCHEMA_VAL_VC_I_CREATE);
1583 result = xmlSchemaValidateDoc(vctxt, myDoc);
1584 if (pctxt != NULL)
1585 xmlSchemaFreeParserCtxt(pctxt);
1586 if (schema != NULL)
1587 xmlSchemaFree(schema);
1588 if (vctxt != NULL)
1589 xmlSchemaFreeValidCtxt(vctxt);
1590 if (result == 0) {
1591 if (msg) {
1592 msg->info() << "LIBXML2 ---------------- _xmlSchemaValidation OK";
1593 }
1594 } else if (result > 0) {
1597 // throw Arcane::XmlException(A_FUNCINFO, String::format("-LIBXML2 the XML file '{0}' does not match the
1598 // XML Schema '{1}' error='{2}' \n",fname,schemaname, format_xml_error(xmlGetLastError())));
1599
1601 } else {
1602 throw Arcane::XmlException(A_FUNCINFO,
1603 String::format("LIBXML2 '{0}' validation generated an internal error \n{1}",
1604 fname, format_xml_error(xmlGetLastError())));
1605 }
1606 xmlResetLastError();
1607 if (context)
1608 context->myDoc = myDoc;
1609 return context;
1610}
1611
1614{
1615 _checkValid();
1616 std::unique_ptr<XmlDocumentHolderLibXml2> xml_doc(new XmlDocumentHolderLibXml2());
1617 if (xml_doc == NULL)
1618 throw Arcane::Exception::exception();
1619 xmlParserCtxt* context = NULL;
1620 char* encoding = NULL; // "UTF-8";// "ISO-8859-1";
1622 if (!fname.empty())
1623 xinclude_baseurl = platform::getFileDirName(fname) + "/"; // Get the test directory
1624 bool _useSchema = true;
1626 if (schemaname.null()) {
1627 _useSchema = false;
1628 }
1629 if (fname.null()) {
1630 throw Arcane::XmlException(A_FUNCINFO, String::format("LIBXML2 XML file not defined '{0}'\n", fname));
1631 }
1632 if (_useSchema) {
1634 if (msg)
1635 msg->info() << "LIBXML2 ---------------- the parser uses schema (1): " << schemaname;
1636 if ((context = _xmlSchemaValidationAndParsing(fname, msg, XML_PARSE_SCHEMA_FILE, schemaname,
1637 schemaData)) == NULL) {
1638 throw Arcane::XmlException(A_FUNCINFO,
1639 String::format("LIBXML2 XML validation schema '{0}' failed \n", schemaname));
1640 }
1641 if (msg) {
1642 msg->info() << String::format("LIBXML2 '{0}' validates\n", fname);
1643 }
1644 } else {
1645 // create the file parser context
1646 if ((context = xmlCreateFileParserCtxt(fname.localstr())) == NULL) {
1647 throw Arcane::XmlException(A_FUNCINFO,
1648 String::format("LIBXML2 Could not create File parser context '{0}'\n{1}",
1649 fname, format_xml_error(xmlGetLastError())));
1650 }
1651
1652 // The following is based on the implementation of xmlParseFile(), in xmlSAXParseFileWithData():
1653 if (encoding)
1654 context->encoding = reinterpret_cast<xmlChar*>(encoding);
1655
1656 int options = context->options;
1657 options |=
1659 if (xinclude_baseurl.null())
1660 options &= ~XML_PARSE_XINCLUDE;
1661 else
1662 options |= XML_PARSE_XINCLUDE;
1663 xmlCtxtUseOptions(context, options);
1664
1665 if (!xmlParseDocument(context)) {
1666 ARCANE_ASSERT((context->myDoc != NULL && context->myDoc->URL == NULL), ("Inconsistent initial state"));
1667
1668 if (!xinclude_baseurl.null()) {
1669 std::unique_ptr<xmlChar> URL(new xmlChar[xinclude_baseurl.len() + 1]);
1670 if (URL == NULL)
1671 throw Arcane::Exception::exception();
1672 context->myDoc->URL = URL.get();
1673 strcpy(const_cast<char*>(reinterpret_cast<const char*>(context->myDoc->URL)),
1674 xinclude_baseurl.localstr()); // change the current directory to the test directory. The method
1675 // xmlXIncludeProcess need this
1676 const int retcode = xmlXIncludeProcess(context->myDoc); // 0 if no substitution were done, -1 if some
1677 // processing failed or the number of
1678 // substitutions done.
1679 URL.release();
1680 context->myDoc->URL = NULL;
1681 if (retcode < 0) {
1682 throw Arcane::XmlException(A_FUNCINFO,
1683 String::format("LIBXML2 XInclude processing failed '{0}'\n{1}", fname,
1684 format_xml_error(xmlGetLastError())));
1685 }
1686 }
1687 } else {
1688 throw Arcane::XmlException(A_FUNCINFO,
1689 String::format("LIBXML2 xmlParseDocument failed 1 '{0}'\n{1}", fname,
1690 format_xml_error(xmlGetLastError())));
1691 }
1692 }
1693 // We just defined an LIBXML2 document . Convert to our data-structure...
1695 static_cast<LIBXML2_Document*>(WrapXML2Node(NULL, reinterpret_cast<xmlNode*>(context->myDoc)));
1696 xml_doc->assignNode(reinterpret_cast<NodePrv*>(doc));
1697 doc->Impl_(context->myDoc);
1698 doc->Context_(context);
1699 return xml_doc.release();
1700}
1701
1705{
1706 _checkValid();
1707 std::unique_ptr<XmlDocumentHolderLibXml2> xml_doc(new XmlDocumentHolderLibXml2());
1708 if (xml_doc == NULL)
1709 throw Arcane::Exception::exception();
1710 xmlParserCtxt* context = NULL;
1712 LIBXML2_PartialLoad pl = { getDomImplementation(), aErrorMessage };
1713 xmlSetStructuredErrorFunc(reinterpret_cast<void*>(&pl), LIBXML2_XMLStructuredHandler);
1714 char* encoding = NULL; // "UTF-8";// "ISO-8859-1";
1716 if (!fname.empty())
1717 xinclude_baseurl = platform::getFileDirName(fname) + "/"; // Get the test directory
1718 bool _useSchema = true;
1719 if (schemaData.empty()) {
1720 _useSchema = false;
1721 }
1722 if (fname.null()) {
1723 throw Arcane::XmlException(A_FUNCINFO, String::format("LIBXML2 XML file not defined '{0}'\n", fname));
1724 }
1725 if (_useSchema) {
1727 if (msg) {
1728 msg->info() << "LIBXML2 ---------------- the parser uses schema (2): " << schemaname;
1729 }
1730 if ((context = _xmlSchemaValidationAndParsing(fname, msg, XML_PARSE_SCHEMA_MEMORY, schemaname,
1731 schemaData)) == NULL) {
1732 throw Arcane::XmlException(A_FUNCINFO,
1733 String::format("LIBXML2 XML validation schema '{0}' failed \n", schemaname));
1734 }
1735 if (msg) {
1736 msg->info() << String::format("LIBXML2 '{0}' validates", fname);
1737 }
1738 } else {
1739 // create the file parser context
1740 if ((context = xmlCreateFileParserCtxt(fname.localstr())) == NULL) {
1741 throw Arcane::XmlException(A_FUNCINFO,
1742 String::format("LIBXML2 xmlCreateFileParserCtxt failed '{0}'\n{1}", fname,
1743 format_xml_error(xmlGetLastError())));
1744 }
1745 // The following is based on the implementation of xmlParseFile(), in xmlSAXParseFileWithData():
1746 if (encoding)
1747 context->encoding = reinterpret_cast<xmlChar*>(encoding);
1748 int options = context->options;
1750 if (xinclude_baseurl.null())
1751 options &= ~XML_PARSE_XINCLUDE;
1752 else
1753 options |= XML_PARSE_XINCLUDE;
1754 xmlCtxtUseOptions(context, options);
1755 if (!xmlParseDocument(context)) {
1756 ARCANE_ASSERT((context->myDoc != NULL && context->myDoc->URL == NULL), ("Inconsistent initial state"));
1757 if (!xinclude_baseurl.null()) {
1758 std::unique_ptr<xmlChar> URL(new xmlChar[xinclude_baseurl.len() + 1]);
1759 if (URL == NULL)
1760 throw Arcane::Exception::exception();
1761 context->myDoc->URL = URL.get();
1762 strcpy(const_cast<char*>(reinterpret_cast<const char*>(context->myDoc->URL)),
1763 xinclude_baseurl.localstr()); // change the current directory to the test directory. The method
1764 // xmlXIncludeProcess need this
1765 const int retcode = xmlXIncludeProcess(context->myDoc); // 0 if no substitution were done, -1 if some
1766 // processing failed or the number of
1767 // substitutions done.
1768 URL.release();
1769 context->myDoc->URL = NULL;
1770 if (retcode < 0) {
1771 throw Arcane::XmlException(A_FUNCINFO,
1772 String::format("LIBXML2 XInclude processing failed '{0}'\n{1}", fname,
1773 format_xml_error(xmlGetLastError())));
1774 }
1775 }
1776 } else {
1777 throw Arcane::XmlException(A_FUNCINFO,
1778 String::format("LIBXML2 xmlParseDocument failed 2 '{0}'\n{1}", fname,
1779 format_xml_error(xmlGetLastError())));
1780 }
1781 }
1782 // We just defined an LIBXML2 document . Convert to our data-structure...
1784 static_cast<LIBXML2_Document*>(WrapXML2Node(NULL, reinterpret_cast<xmlNode*>(context->myDoc)));
1785 xml_doc->assignNode(reinterpret_cast<NodePrv*>(doc));
1786 doc->Impl_(context->myDoc);
1787 doc->Context_(context);
1788 return xml_doc.release();
1789}
1790
1792_load(ByteConstArrayView buffer, const String& fname, ITraceMng* trace)
1793{
1794 ARCANE_UNUSED(trace);
1795 _checkValid();
1796 std::unique_ptr<XmlDocumentHolderLibXml2> xml_doc(new XmlDocumentHolderLibXml2());
1797 if (xml_doc == NULL)
1798 throw Arcane::Exception::exception();
1799 if (buffer.empty())
1800 return xml_doc.release();
1801 xmlParserCtxt* context = NULL;
1803 LIBXML2_PartialLoad pl = { getDomImplementation(), aErrorMessage };
1804 xmlSetStructuredErrorFunc(reinterpret_cast<void*>(&pl), LIBXML2_XMLStructuredHandler);
1805 char* encoding = NULL; // "UTF-8";// "ISO-8859-1";
1806
1807 String xinclude_baseurl = String();
1808 if (!fname.empty())
1809 xinclude_baseurl = platform::getFileDirName(fname) + "/"; // Get the test directory
1810
1811 // lecture en memoire du document
1812 xmlResetLastError();
1813 const XMLByte* src = reinterpret_cast<const XMLByte*>(buffer.begin());
1814 context = xmlCreateMemoryParserCtxt(
1815 reinterpret_cast<const char*>(src),
1816 buffer.size()); // tous les champs non utilisés sont initialisés à 0 lors de la création
1817 if (!context) {
1818 throw Arcane::XmlException(A_FUNCINFO,
1819 String::format("LIBXML2 Could not create parser context '{0}'\n{1}", fname,
1820 format_xml_error(xmlGetLastError())));
1821 }
1822 if (encoding)
1823 context->encoding = reinterpret_cast<xmlChar*>(encoding);
1824 int options = context->options;
1825 options |= XML_PARSE_DTDLOAD | XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDVALID;
1826 if (xinclude_baseurl.null())
1827 options &= ~XML_PARSE_XINCLUDE;
1828 else
1829 options |= XML_PARSE_XINCLUDE;
1830
1831 xmlCtxtUseOptions(context, options);
1832 if (!xmlParseDocument(context)) {
1833 ARCANE_ASSERT((context->myDoc != NULL && context->myDoc->URL == NULL), ("Inconsistent initial state"));
1834 if (!xinclude_baseurl.null()) {
1835 std::unique_ptr<xmlChar> URL(new xmlChar[xinclude_baseurl.len() + 1]);
1836 if (URL == NULL)
1837 throw Arcane::Exception::exception();
1838 context->myDoc->URL = URL.get();
1839 strcpy(const_cast<char*>(reinterpret_cast<const char*>(context->myDoc->URL)),
1840 xinclude_baseurl.localstr()); // change the current directory to the test directory. The method
1841 // xmlXIncludeProcess need this
1842 const int retcode = xmlXIncludeProcess(context->myDoc); // 0 if no substitution were done, -1 if some
1843 // processing failed or the number of
1844 // substitutions done.
1845 URL.release();
1846 context->myDoc->URL = NULL;
1847 if (retcode < 0) {
1848 throw Arcane::XmlException(A_FUNCINFO,
1849 String::format("LIBXML2 XInclude processing failed '{0}'\n{1}", fname,
1850 format_xml_error(xmlGetLastError())));
1851 }
1852 }
1853 } else {
1854 throw Arcane::XmlException(A_FUNCINFO,
1855 String::format("LIBXML2 xmlParseDocument failed 3 '{0}'{1}\n", fname,
1856 format_xml_error(xmlGetLastError())));
1857 }
1858 // We just defined an LIBXML2 document . Convert to our data-structure...
1859 LIBXML2_Document* doc =
1860 static_cast<LIBXML2_Document*>(WrapXML2Node(NULL, reinterpret_cast<xmlNode*>(context->myDoc)));
1861 xml_doc->assignNode(reinterpret_cast<NodePrv*>(doc));
1862 doc->Impl_(context->myDoc);
1863 doc->Context_(context);
1864 return xml_doc.release();
1865}
1866
1867/*---------------------------------------------------------------------------*/
1868
1869void DOMImplementation::
1870_save(std::ostream& ostr, const Document& document, int indent_level)
1871{
1872 bool indented = (indent_level == 1);
1873 LIBXML2_DOMWriter dw(indented);
1874 StringBuilder text;
1875
1876 dw.writeDocument(NULL, reinterpret_cast<LIBXML2_Document*>(document._impl()), text);
1877 int len = text.toString().len();
1878 if (len > 1) {
1879 ostr.write(text.toString().localstr(), len);
1880 }
1881}
1882
1883/*---------------------------------------------------------------------------*/
1884/*---------------------------------------------------------------------------*/
1885
1886/*---------------------------------------------------------------------------*/
1887/* Node implementation */
1888/*---------------------------------------------------------------------------*/
1889
1890Node::
1891Node()
1892: m_p(0)
1893{}
1894
1895Node::
1896Node(NodePrv* prv)
1897: m_p(prv)
1898{}
1899
1900Node::
1901Node(const Node& from)
1902: m_p(from.m_p)
1903{}
1904
1905const Node& Node::
1906operator=(const Node& from)
1907{
1908 _assign(from);
1909 return (*this);
1910}
1911
1912Node::
1913~Node() {}
1914
1915bool Node::
1916_null() const
1917{
1918 return !m_p;
1919}
1920
1921void Node::
1922_checkValid() const
1923{
1924 if (_null())
1926}
1927
1928NodePrv* Node::
1929_impl() const
1930{
1931 return m_p;
1932}
1933
1934UShort Node::
1935nodeType() const
1936{
1937 _checkValid();
1938 return impl(m_p)->nodeType();
1939}
1940
1941Node Node::
1942firstChild() const
1943{
1944 _checkValid();
1945 LIBXML2_Node* n = impl(m_p)->firstChild();
1946 return cvt(n);
1947}
1948
1949Node Node::
1950lastChild() const
1951{
1952 _checkValid();
1953 LIBXML2_Node* n = impl(m_p)->lastChild();
1954 return cvt(n);
1955}
1956
1957Node Node::
1958previousSibling() const
1959{
1960 _checkValid();
1961 LIBXML2_Node* n = impl(m_p)->previousSibling();
1962 return cvt(n);
1963}
1964
1965Node Node::
1966nextSibling() const
1967{
1968 LIBXML2_Node* n = impl(m_p)->nextSibling();
1969 return cvt(n);
1970}
1971
1972Node Node::
1973parentNode() const
1974{
1975 _checkValid();
1976 LIBXML2_Node* n = impl(m_p)->parentNode();
1977 return cvt(n);
1978}
1979
1980NodeList Node::
1981childNodes() const
1982{
1983 _checkValid();
1984 LIBXML2_NodeList* n = impl(m_p)->childNodes();
1985 return cvt(n);
1986}
1987
1988DOMString Node::
1989nodeName() const
1990{
1991 _checkValid();
1992 return impl(m_p)->nodeName();
1993}
1994
1995NamedNodeMap Node::
1996attributes() const
1997{
1998 LIBXML2_Node* node = impl(m_p);
1999 LIBXML2_Element* aElement = dynamic_cast<LIBXML2_Element*>(node);
2000 LIBXML2_NamedNodeMap* NamedNodeMap = aElement->attributes();
2001 return cvt(NamedNodeMap);
2002}
2003
2004Document Node::
2005ownerDocument() const
2006{
2007 _checkValid();
2008 LIBXML2_Document* d = impl(m_p)->ownerDocument();
2009 return cvt(d);
2010}
2011
2012DOMString Node::
2013nodeValue() const
2014{
2015 _checkValid();
2016 return impl(m_p)->nodeValue();
2017}
2018
2019void Node::
2020nodeValue(const DOMString& str) const
2021{
2022 _checkValid();
2023 impl(m_p)->nodeValue(str);
2024}
2025
2026void Node::
2027_assign(const Node& node)
2028{
2029 m_p = node.m_p;
2030}
2031
2032Node Node::
2033insertBefore(const Node& new_child, const Node& ref_child) const
2034{
2035 _checkValid();
2036 LIBXML2_Node* n = impl(m_p)->insertBefore(impl(new_child._impl()), impl(ref_child._impl()));
2037 ;
2038 return cvt(n);
2039}
2040
2041Node Node::
2042replaceChild(const Node& new_child, const Node& old_child) const
2043{
2044 _checkValid();
2045 LIBXML2_Node* n = impl(m_p)->replaceChild(impl(new_child._impl()), impl(old_child._impl()));
2046 return cvt(n);
2047}
2048
2049Node Node::
2050removeChild(const Node& old_child) const
2051{
2052 _checkValid();
2053 LIBXML2_Node* n = impl(m_p)->removeChild(impl(old_child._impl()));
2054 return cvt(n);
2055}
2056
2057Node Node::
2058appendChild(const Node& new_child) const
2059{
2060 _checkValid();
2061 LIBXML2_Node* n = impl(m_p)->appendChild(impl(new_child._impl()));
2062 return cvt(n);
2063}
2064
2065bool Node::
2066hasChildNodes() const
2067{
2068 _checkValid();
2069 return impl(m_p)->hasChildNodes();
2070}
2071
2072Node Node::
2073cloneNode(bool deep) const
2074{
2075 _checkValid();
2076 LIBXML2_Node* n = impl(m_p)->cloneNode(deep);
2077 return cvt(n);
2078}
2079
2080DOMString Node::
2081prefix() const
2082{
2083 _checkValid();
2084 return impl(m_p)->prefix();
2085}
2086
2087void Node::
2088prefix(const DOMString& new_prefix) const
2089{
2090 _checkValid();
2091 impl(m_p)->prefix(new_prefix);
2092}
2093
2094void Node::
2095normalize() const
2096{
2097 _checkValid();
2098 impl(m_p)->normalize();
2099}
2100
2101bool Node::
2102isSupported(const DOMString& feature, const DOMString& version) const
2103{
2104 _checkValid();
2105 return impl(m_p)->isSupported(feature, version);
2106}
2107
2108DOMString Node::
2109namespaceURI() const
2110{
2111 _checkValid();
2112 return impl(m_p)->namespaceURI();
2113}
2114
2115DOMString Node::
2116localName() const
2117{
2118 _checkValid();
2119 return impl(m_p)->localName();
2120}
2121
2122DOMString Node::
2123baseURI() const
2124{
2125 _checkValid();
2126 throw NotImplementedException(A_FUNCINFO);
2127}
2128
2129DOMString Node::
2130textContent() const
2131{
2132 _checkValid();
2133 return impl(m_p)->nodeValue();
2134}
2135
2136void Node::
2137textContent(const DOMString& value) const
2138{
2139 _checkValid();
2140 impl(m_p)->nodeValue(value);
2141 return;
2142}
2143
2144bool Node::
2145isSameNode(const Node& node) const
2146{
2147 return (this == &node);
2148}
2149
2150#ifndef ARCANE_USE_LIBXML2
2151UShort Node::
2152compareTreePosition(const Node& other) const
2153{
2154 _checkValid();
2155 throw NotImplementedException(A_FUNCINFO);
2156}
2157#endif
2158#ifndef ARCANE_USE_LIBXML2
2159Node Node::
2160getInterface(const DOMString& feature) const
2161{
2162 _checkValid();
2163 throw NotImplementedException(A_FUNCINFO);
2164}
2165#endif
2166
2167bool Node::
2168isEqualNode(const Node& other) const
2169{
2170 return (this == &other);
2171}
2172
2173bool Node::
2174isDefaultNamespace(const DOMString& namespace_uri) const
2175{
2176 ARCANE_UNUSED(namespace_uri);
2177 _checkValid();
2178 throw NotImplementedException(A_FUNCINFO);
2179}
2180#ifndef ARCANE_USE_LIBXML2
2181DOMString Node::
2182lookupNamespacePrefix(const DOMString& namespace_uri, bool use_default) const
2183{
2184 ARCANE_UNUSED(namespace_uri);
2185 ARCANE_UNUSED(use_default);
2186 _checkValid();
2187 throw NotImplementedException(A_FUNCINFO);
2188}
2189#endif
2190DOMString Node::
2191lookupNamespaceURI(const DOMString& prefix) const
2192{
2193 ARCANE_UNUSED(prefix);
2194 _checkValid();
2195 throw NotImplementedException(A_FUNCINFO);
2196}
2197
2198DOMObject Node::
2199setUserData(const DOMString& key, const DOMObject& data, const UserDataHandler& handler) const
2200{
2201 ARCANE_UNUSED(key);
2202 ARCANE_UNUSED(data);
2203 ARCANE_UNUSED(handler);
2204 _checkValid();
2205 throw NotImplementedException(A_FUNCINFO);
2206}
2207
2208DOMObject Node::
2209getUserData(const DOMString& key) const
2210{
2211 ARCANE_UNUSED(key);
2212 _checkValid();
2213 throw NotImplementedException(A_FUNCINFO);
2214}
2215
2216bool
2217operator==(const Node& n1, const Node& n2)
2218{
2219 return impl(n1.m_p) == impl(n2.m_p);
2220}
2221
2222bool
2223operator!=(const Node& n1, const Node& n2)
2224{
2225 return !operator==(n1, n2);
2226}
2227
2228/*---------------------------------------------------------------------------*/
2229/* Character implementation */
2230/*---------------------------------------------------------------------------*/
2231
2232CharacterData::
2233CharacterData(CharacterDataPrv* prv)
2234: Node(reinterpret_cast<NodePrv*>(impl(prv)))
2235{}
2236
2237CharacterData::
2238CharacterData()
2239: Node()
2240{}
2241
2242CharacterData::
2243CharacterData(const CharacterData& node)
2244: Node(node)
2245{}
2246
2247CharacterData::
2248CharacterData(const Node& node)
2249: Node()
2250{
2251 CDATASectionPrv* ni = reinterpret_cast<CDATASectionPrv*>(node._impl());
2252 if (ni && (impl(ni)->nodeType() == CDATA_SECTION_NODE))
2253 _assign(node);
2254}
2255
2256CharacterDataPrv* CharacterData::
2257_impl() const
2258{
2259 return cvt(reinterpret_cast<LIBXML2_CharacterData*>(impl(m_p)));
2260}
2261
2262/*---------------------------------------------------------------------------*/
2263/* Text implementation */
2264/*---------------------------------------------------------------------------*/
2265
2266Text::
2267Text(TextPrv* prv)
2268: CharacterData(reinterpret_cast<CharacterDataPrv*>(impl(prv)))
2269{}
2270
2271Text::
2272Text()
2273: CharacterData()
2274{}
2275
2276Text::
2277Text(const Text& node)
2278: CharacterData(node)
2279{}
2280
2281Text::
2282Text(const Node& node)
2283: CharacterData()
2284{
2285 TextPrv* ni = reinterpret_cast<TextPrv*>(node._impl());
2286 if (ni && (impl(ni)->nodeType() == TEXT_NODE))
2287 _assign(node);
2288}
2289
2290TextPrv* Text::
2291_impl() const
2292{
2293 return cvt(reinterpret_cast<LIBXML2_Text*>(impl(m_p)));
2294}
2295
2296/*---------------------------------------------------------------------------*/
2297/* Document implementation */
2298/*---------------------------------------------------------------------------*/
2299
2300Document::
2301Document() {}
2302
2303Document::
2304Document(DocumentPrv* prv)
2305: Node(reinterpret_cast<NodePrv*>(impl(prv)))
2306{}
2307
2308Document::
2309Document(const Node& node)
2310: Node()
2311{
2312 DocumentPrv* ni = reinterpret_cast<DocumentPrv*>(node._impl());
2313 if (ni && (impl(ni)->nodeType() == DOCUMENT_NODE))
2314 _assign(node);
2315}
2316
2317DocumentPrv* Document::
2318_impl() const
2319{
2320 return cvt(reinterpret_cast<LIBXML2_Document*>(impl(m_p)));
2321}
2322
2323DocumentType Document::
2324doctype() const
2325{
2326 _checkValid();
2327 LIBXML2_DocumentType* dt = reinterpret_cast<LIBXML2_DocumentType*>(impl(_impl())->doctype());
2328 return cvt(dt);
2329}
2330
2331DOMImplementation Document::
2332implementation() const
2333{
2334 _checkValid();
2335 return cvt(getDomImplementation());
2336}
2337
2338Element Document::
2339documentElement() const
2340{
2341 _checkValid();
2342 LIBXML2_Element* el = impl(_impl())->documentElement();
2343 return cvt(el);
2344}
2345
2346Element Document::
2347createElement(const DOMString& name) const
2348{
2349 _checkValid();
2350 LIBXML2_Element* el = impl(_impl())->createElement(name);
2351 return cvt(el);
2352}
2353
2354DocumentFragment Document::
2355createDocumentFragment() const
2356{
2357 _checkValid();
2358 LIBXML2_DocumentFragment* df = impl(_impl())->createDocumentFragment();
2359 return cvt(df);
2360}
2361
2362Text Document::
2363createTextNode(const DOMString& data) const
2364{
2365 _checkValid();
2366 LIBXML2_Text* tn = impl(_impl())->createTextNode(data);
2367 return cvt(tn);
2368}
2369
2370Comment Document::
2371createComment(const DOMString& data) const
2372{
2373 _checkValid();
2374 LIBXML2_Comment* cn = impl(_impl())->createComment(data);
2375 return cvt(cn);
2376}
2377
2378CDATASection Document::
2379createCDATASection(const DOMString& data) const
2380{
2381 _checkValid();
2382 LIBXML2_CDATASection* cds = impl(_impl())->createCDATASection(data);
2383 return cvt(cds);
2384}
2385
2386ProcessingInstruction Document::
2387createProcessingInstruction(const DOMString& target, const DOMString& data) const
2388{
2389 _checkValid();
2390 LIBXML2_ProcessingInstruction* pi = impl(_impl())->createProcessingInstruction(target, data);
2391 return cvt(pi);
2392}
2393
2394Attr Document::
2395createAttribute(const DOMString& name) const
2396{
2397 _checkValid();
2398 LIBXML2_Attr* at = impl(_impl())->createAttribute(name);
2399 return cvt(at);
2400}
2401
2402EntityReference Document::
2403createEntityReference(const DOMString& name) const
2404{
2405 _checkValid();
2406 LIBXML2_EntityReference* er = impl(_impl())->createEntityReference(name);
2407 return cvt(er);
2408}
2409
2410NodeList Document::
2411getElementsByTagName(const DOMString& tagname) const
2412{
2413 _checkValid();
2414 LIBXML2_NodeList* nl = impl(_impl())->getElementsByTagName(tagname);
2415 return cvt(nl);
2416}
2417
2418Node Document::
2419importNode(const Node& imported_node, bool deep) const
2420{
2421 _checkValid();
2422 LIBXML2_Node* n = impl(_impl())->importNode(impl(toNodePrv(imported_node)), deep);
2423 return cvt(n);
2424}
2425
2426Element Document::
2427createElementNS(const DOMString& namespace_uri, const DOMString& qualifiedname) const
2428{
2429 _checkValid();
2430 LIBXML2_Element* el = impl(_impl())->createElementNS(namespace_uri, qualifiedname);
2431 return cvt(el);
2432}
2433
2434Attr Document::
2435createAttributeNS(const DOMString& namespace_uri, const DOMString& qualifiedname) const
2436{
2437 _checkValid();
2438 LIBXML2_Attr* at = impl(_impl())->createAttributeNS(namespace_uri, qualifiedname);
2439 return cvt(at);
2440}
2441
2442NodeList Document::
2443getElementsByTagNameNS(const DOMString& namespace_uri, const DOMString& localname) const
2444{
2445 _checkValid();
2446 LIBXML2_NodeList* nl = impl(_impl())->getElementsByTagNameNS(namespace_uri, localname);
2447 return cvt(nl);
2448}
2449
2450Element Document::
2451getElementById(const DOMString& element_id) const
2452{
2453 _checkValid();
2454 LIBXML2_Element* el = impl(_impl())->getElementById(element_id);
2455 return cvt(el);
2456}
2457
2458DOMString Document::
2459actualEncoding() const
2460{
2461 _checkValid();
2462 throw NotImplementedException(A_FUNCINFO);
2463}
2464
2465void Document::
2466actualEncoding(const DOMString& value) const
2467{
2468 ARCANE_UNUSED(value);
2469 _checkValid();
2470 throw NotImplementedException(A_FUNCINFO);
2471}
2472
2473DOMString Document::
2474encoding() const
2475{
2476 _checkValid();
2477 throw NotImplementedException(A_FUNCINFO);
2478}
2479
2480void Document::
2481encoding(const DOMString& value) const
2482{
2483 ARCANE_UNUSED(value);
2484 _checkValid();
2485 throw NotImplementedException(A_FUNCINFO);
2486}
2487
2488bool Document::
2489standalone() const
2490{
2491 _checkValid();
2492 throw NotImplementedException(A_FUNCINFO);
2493}
2494
2495void Document::
2496standalone(bool value) const
2497{
2498 ARCANE_UNUSED(value);
2499 _checkValid();
2500 throw NotImplementedException(A_FUNCINFO);
2501}
2502
2503bool Document::
2504strictErrorChecking() const
2505{
2506 _checkValid();
2507 throw NotImplementedException(A_FUNCINFO);
2508}
2509
2510void Document::
2511strictErrorChecking(bool value) const
2512{
2513 ARCANE_UNUSED(value);
2514 _checkValid();
2515 throw NotImplementedException(A_FUNCINFO);
2516}
2517#ifndef ARCANE_USE_LIBXML2
2518DOMString Document::
2519version() const
2520{
2521 _checkValid();
2522 throw NotImplementedException(A_FUNCINFO);
2523}
2524#endif
2525#ifndef ARCANE_USE_LIBXML2
2526void Document::
2527version(const DOMString& value) const
2528{
2529 ARCANE_UNUSED(value);
2530 _checkValid();
2531 throw NotImplementedException(A_FUNCINFO);
2532}
2533#endif
2534
2535void Document::
2536documentURI(const DOMString& document_uri) const
2537{
2538 ARCANE_UNUSED(document_uri);
2539 _checkValid();
2540 throw NotImplementedException(A_FUNCINFO);
2541}
2542
2543DOMString Document::
2544documentURI() const
2545{
2546 _checkValid();
2547 throw NotImplementedException(A_FUNCINFO);
2548}
2549
2550Node Document::
2551adoptNode(const Node& source) const
2552{
2553 ARCANE_UNUSED(source);
2554 _checkValid();
2555 throw NotImplementedException(A_FUNCINFO);
2556}
2557
2558void Document::
2559normalizeDocument()
2560{
2561 _checkValid();
2562 throw NotImplementedException(A_FUNCINFO);
2563}
2564
2565Node Document::
2566renameNode(const Node& node, const DOMString& namespace_uri, const DOMString& name)
2567{
2568 ARCANE_UNUSED(node);
2569 ARCANE_UNUSED(namespace_uri);
2570 ARCANE_UNUSED(name);
2571 _checkValid();
2572 throw NotImplementedException(A_FUNCINFO);
2573}
2574
2575/*---------------------------------------------------------------------------*/
2576/* DocumentFragment implementation */
2577/*---------------------------------------------------------------------------*/
2578
2579DocumentFragment::
2580DocumentFragment()
2581: Node()
2582{}
2583
2584DocumentFragment::
2585DocumentFragment(DocumentFragmentPrv* prv)
2586: Node(reinterpret_cast<NodePrv*>(impl(prv)))
2587{}
2588
2589/*---------------------------------------------------------------------------*/
2590/* Comment implementation */
2591/*---------------------------------------------------------------------------*/
2592
2593Comment::
2594Comment()
2595: CharacterData()
2596{}
2597
2598Comment::
2599Comment(CommentPrv* prv)
2600: CharacterData(reinterpret_cast<CharacterDataPrv*>(impl(prv)))
2601{}
2602
2603/*---------------------------------------------------------------------------*/
2604/* CDATASection implementation */
2605/*---------------------------------------------------------------------------*/
2606
2607CDATASection::
2608CDATASection()
2609: Text()
2610{}
2611
2612CDATASection::
2613CDATASection(CDATASectionPrv* prv)
2614: Text(reinterpret_cast<TextPrv*>(impl(prv)))
2615{}
2616
2617/*---------------------------------------------------------------------------*/
2618/* EntityReference implementation */
2619/*---------------------------------------------------------------------------*/
2620
2621EntityReference::
2622EntityReference()
2623: Node()
2624{}
2625
2626EntityReference::
2627EntityReference(EntityReferencePrv* prv)
2628: Node(reinterpret_cast<NodePrv*>(impl(prv)))
2629{}
2630
2631/*---------------------------------------------------------------------------*/
2632/* NodeList implementation */
2633/*---------------------------------------------------------------------------*/
2634
2635NodeList::
2636NodeList()
2637: m_p(0)
2638{}
2639
2640NodeList::
2641NodeList(NodeListPrv* prv)
2642: m_p(prv)
2643{}
2644
2645void NodeList::
2646_checkValid() const
2647{
2648 if (!m_p)
2650}
2651
2652Node NodeList::
2653item(ULong index) const
2654{
2655 _checkValid();
2656 LIBXML2_Node* n = impl(m_p)->item(index);
2657 return cvt(n);
2658}
2659
2660ULong NodeList::
2661length() const
2662{
2663 _checkValid();
2664 return impl(m_p)->length();
2665}
2666
2667/*---------------------------------------------------------------------------*/
2668/* CharacterData implementation */
2669/*---------------------------------------------------------------------------*/
2670
2671DOMString CharacterData::
2672data() const
2673{
2674 _checkValid();
2675 return impl(_impl())->Data();
2676}
2677
2678void CharacterData::
2679data(const DOMString& value) const
2680{
2681 _checkValid();
2682 impl(_impl())->Data(value);
2683}
2684
2685ULong CharacterData::
2686length() const
2687{
2688 _checkValid();
2689 return impl(_impl())->length();
2690}
2691
2692DOMString CharacterData::
2693substringData(ULong offset, ULong count) const
2694{
2695 _checkValid();
2696 return impl(_impl())->substringdata(offset, count);
2697}
2698
2699void CharacterData::
2700appendData(const DOMString& arg) const
2701{
2702 _checkValid();
2703 impl(_impl())->appenddata(arg);
2704}
2705
2706void CharacterData::
2707insertData(ULong offset, const DOMString& arg) const
2708{
2709 _checkValid();
2710 impl(_impl())->insertdata(offset, arg);
2711}
2712
2713void CharacterData::
2714deleteData(ULong offset, ULong count) const
2715{
2716 _checkValid();
2717 impl(_impl())->deletedata(offset, count);
2718}
2719
2720void CharacterData::
2721replaceData(ULong offset, ULong count, const DOMString& arg) const
2722{
2723 _checkValid();
2724 impl(_impl())->replacedata(offset, count, arg);
2725}
2726
2727/*---------------------------------------------------------------------------*/
2728/* Attr implementation */
2729/*---------------------------------------------------------------------------*/
2730
2731Attr::
2732Attr()
2733: Node()
2734{}
2735
2736Attr::
2737Attr(AttrPrv* prv)
2738: Node(reinterpret_cast<NodePrv*>(impl(prv)))
2739{}
2740
2741Attr::
2742Attr(const Attr& f)
2743: Node((const Node&)f)
2744{}
2745
2746Attr::
2747Attr(const Node& node)
2748: Node()
2749{
2750 AttrPrv* ni = reinterpret_cast<AttrPrv*>(node._impl());
2751 if (ni && (impl(ni)->nodeType() == ATTRIBUTE_NODE))
2752 _assign(node);
2753}
2754
2755Attr::
2756~Attr() {}
2757
2758AttrPrv* Attr::
2759_impl() const
2760{
2761 return cvt(reinterpret_cast<LIBXML2_Attr*>(impl(m_p)));
2762}
2763
2764DOMString Attr::
2765name() const
2766{
2767 _checkValid();
2768 return impl(_impl())->name();
2769}
2770
2771bool Attr::
2772specified() const
2773{
2774 _checkValid();
2775 return impl(_impl())->specified();
2776}
2777
2778DOMString Attr::
2779value() const
2780{
2781 _checkValid();
2782 return impl(_impl())->value();
2783}
2784
2785void Attr::
2786value(const DOMString& str) const
2787{
2788 _checkValid();
2789 impl(_impl())->value(str);
2790}
2791
2792Element Attr::
2793ownerElement() const
2794{
2795 _checkValid();
2796 LIBXML2_Element* el = impl(_impl())->ownerElement();
2797 return cvt(el);
2798}
2799
2800/*---------------------------------------------------------------------------*/
2801/* Element implementation */
2802/*---------------------------------------------------------------------------*/
2803
2804Element::
2805Element()
2806: Node()
2807{}
2808
2809Element::
2810Element(ElementPrv* prv)
2811: Node(reinterpret_cast<NodePrv*>(impl(prv)))
2812{}
2813
2814Element::
2815Element(const Node& node)
2816: Node()
2817{
2818 ElementPrv* ni = reinterpret_cast<ElementPrv*>(node._impl());
2819 if (ni && (impl(ni)->nodeType() == ELEMENT_NODE))
2820 _assign(node);
2821}
2822
2823Element::
2824Element(const Element& node)
2825: Node(node)
2826{}
2827
2828ElementPrv* Element::
2829_impl() const
2830{
2831 return cvt(reinterpret_cast<LIBXML2_Element*>(impl(m_p)));
2832}
2833
2834DOMString Element::
2835tagName() const
2836{
2837 _checkValid();
2838 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2839 return el->tagName();
2840}
2841
2842DOMString Element::
2843getAttribute(const DOMString& name) const
2844{
2845 _checkValid();
2846 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2847 return el->getAttribute(name);
2848}
2849
2850void Element::
2851setAttribute(const DOMString& name, const DOMString& value) const
2852{
2853 _checkValid();
2854 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2855 el->setAttribute(name, value);
2856}
2857
2858void Element::
2859removeAttribute(const DOMString& name) const
2860{
2861 _checkValid();
2862 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2863 el->removeAttribute(name);
2864}
2865
2866Attr Element::
2867getAttributeNode(const DOMString& name) const
2868{
2869 _checkValid();
2870 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2871 LIBXML2_Attr* attr = el->getAttributeNode(name);
2872 return cvt(attr);
2873}
2874
2875Attr Element::
2876setAttributeNode(const Attr& new_attr) const
2877{
2878 _checkValid();
2879 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2880 LIBXML2_Attr* attr = el->setAttributeNode(impl(new_attr._impl()));
2881 return cvt(attr);
2882}
2883
2884Attr Element::
2885removeAttributeNode(const Attr& old_attr) const
2886{
2887 _checkValid();
2888 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2889 LIBXML2_Attr* attr = el->removeAttributeNode(impl(old_attr._impl()));
2890 return cvt(attr);
2891}
2892
2893NodeList Element::
2894getElementsByTagName(const DOMString& name) const
2895{
2896 _checkValid();
2897 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2898 LIBXML2_NodeList* ndl = el->getElementsByTagName(name);
2899 return NodeList(reinterpret_cast<NodeListPrv*>(ndl));
2900}
2901
2902DOMString Element::
2903getAttributeNS(const DOMString& namespace_uri, const DOMString& localname) const
2904{
2905 _checkValid();
2906 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2907 return el->getAttributeNS(namespace_uri, localname);
2908}
2909
2910void Element::
2911setAttributeNS(const DOMString& namespace_uri, const DOMString& localname,
2912 const DOMString& value) const
2913{
2914 _checkValid();
2915 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2916 el->setAttributeNS(namespace_uri, localname, value);
2917}
2918
2919void Element::
2920removeAttributeNS(const DOMString& namespace_uri, const DOMString& localname) const
2921{
2922 _checkValid();
2923 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2924 el->removeAttributeNS(namespace_uri, localname);
2925}
2926
2927Attr Element::
2928getAttributeNodeNS(const DOMString& namespace_uri, const DOMString& localname) const
2929{
2930 _checkValid();
2931 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2932 LIBXML2_Attr* attr = el->getAttributeNodeNS(namespace_uri, localname);
2933 return cvt(attr);
2934}
2935
2936Attr Element::
2937setAttributeNodeNS(const Attr& new_attr) const
2938{
2939 _checkValid();
2940 new_attr._checkValid();
2941 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2942 LIBXML2_Attr* attr = el->setAttributeNodeNS(impl(new_attr._impl()));
2943 return cvt(attr);
2944}
2945
2946NodeList Element::
2947getElementsByTagNameNS(const DOMString& namespace_uri, const DOMString& localname) const
2948{
2949 _checkValid();
2950 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2951 LIBXML2_NodeList* ndl = el->getElementsByTagNameNS(namespace_uri, localname);
2952 return NodeList(cvt(ndl));
2953}
2954
2955bool Element::
2956hasAttribute(const DOMString& name) const
2957{
2958 _checkValid();
2959 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2960 return el->hasAttribute(name);
2961}
2962
2963bool Element::
2964hasAttributeNS(const DOMString& namespace_uri, const DOMString& localname) const
2965{
2966 _checkValid();
2967 LIBXML2_Element* el = reinterpret_cast<LIBXML2_Element*>(_impl());
2968 return el->hasAttributeNS(namespace_uri, localname);
2969}
2970
2971/*---------------------------------------------------------------------------*/
2972/* Text implementation */
2973/*---------------------------------------------------------------------------*/
2974
2975Text Text::
2976splitText(ULong offset) const
2977{
2978 _checkValid();
2979 LIBXML2_Text* txt = reinterpret_cast<LIBXML2_Text*>(_impl());
2980 LIBXML2_Text* txt2 = txt->splitText(offset);
2981 return Text(cvt(txt2));
2982}
2983
2984#ifndef ARCANE_USE_LIBXML2
2985bool Text::
2986isWhiteSpaceInElementContent() const
2987{
2988 _checkValid();
2989 throw NotImplementedException(A_FUNCINFO);
2990}
2991#endif
2992
2993DOMString Text::
2994wholeText() const
2995{
2996 _checkValid();
2997 throw NotImplementedException(A_FUNCINFO);
2998}
2999
3000Text Text::
3001replaceWholeText(const DOMString& content) const
3002{
3003 ARCANE_UNUSED(content);
3004 _checkValid();
3005 throw NotImplementedException(A_FUNCINFO);
3006}
3007
3008/*---------------------------------------------------------------------------*/
3009/* DocumentType implementation */
3010/*---------------------------------------------------------------------------*/
3011
3012DocumentType::
3013DocumentType()
3014: Node()
3015{}
3016
3017DocumentType::
3018DocumentType(DocumentTypePrv* prv)
3019: Node(reinterpret_cast<NodePrv*>(impl(prv)))
3020{}
3021
3022DocumentTypePrv* DocumentType::
3023_impl() const
3024{
3025 return cvt(reinterpret_cast<LIBXML2_DocumentType*>(m_p));
3026}
3027
3028DOMString DocumentType::
3029name() const
3030{
3031 _checkValid();
3032 return impl(_impl())->name();
3033}
3034
3035NamedNodeMap DocumentType::
3036entities() const
3037{
3038 _checkValid();
3039 LIBXML2_NamedNodeMap* nnodeMap = impl(_impl())->entities();
3040 return NamedNodeMap(reinterpret_cast<NamedNodeMapPrv*>(nnodeMap));
3041}
3042
3043NamedNodeMap DocumentType::
3044notations() const
3045{
3046 _checkValid();
3047 LIBXML2_NamedNodeMap* nnodeMap = impl(_impl())->notations();
3048 return NamedNodeMap(reinterpret_cast<NamedNodeMapPrv*>(nnodeMap));
3049}
3050
3051DOMString DocumentType::
3052publicId() const
3053{
3054 _checkValid();
3055 return impl(_impl())->publicId();
3056}
3057
3058DOMString DocumentType::
3059systemId() const
3060{
3061 _checkValid();
3062 return impl(_impl())->systemId();
3063}
3064
3065DOMString DocumentType::
3066internalSubset() const
3067{
3068 _checkValid();
3069 return impl(_impl())->internalSubset();
3070}
3071
3072/*---------------------------------------------------------------------------*/
3073/* Notation implementation */
3074/*---------------------------------------------------------------------------*/
3075
3076NotationPrv* Notation::
3077_impl() const
3078{
3079 return cvt(reinterpret_cast<LIBXML2_Notation*>(impl(m_p)));
3080}
3081
3082DOMString Notation::
3083publicId() const
3084{
3085 _checkValid();
3086 return impl(_impl())->publicId();
3087}
3088
3089DOMString Notation::
3090systemId() const
3091{
3092 _checkValid();
3093 return impl(_impl())->systemId();
3094}
3095
3096/*---------------------------------------------------------------------------*/
3097/* Entity implementation */
3098/*---------------------------------------------------------------------------*/
3099
3100EntityPrv* Entity::
3101_impl() const
3102{
3103 return cvt(reinterpret_cast<LIBXML2_Entity*>(impl(m_p)));
3104}
3105
3106DOMString Entity::
3107publicId() const
3108{
3109 _checkValid();
3110 return impl(_impl())->publicId();
3111}
3112
3113DOMString Entity::
3114systemId() const
3115{
3116 _checkValid();
3117 return impl(_impl())->systemId();
3118}
3119
3120DOMString Entity::
3121notationName() const
3122{
3123 _checkValid();
3124 return impl(_impl())->notationName();
3125}
3126
3127#ifndef ARCANE_USE_LIBXML2
3128DOMString Entity::
3129actualEncoding() const
3130{
3131 _checkValid();
3132 throw NotImplementedException(A_FUNCINFO);
3133}
3134#endif
3135#ifndef ARCANE_USE_LIBXML2
3136void Entity::
3137actualEncoding(const DOMString& value) const
3138{
3139 _checkValid();
3140 throw NotImplementedException(A_FUNCINFO);
3141}
3142#endif
3143#ifndef ARCANE_USE_LIBXML2
3144DOMString Entity::
3145encoding() const
3146{
3147 _checkValid();
3148 throw NotImplementedException(A_FUNCINFO);
3149}
3150#endif
3151#ifndef ARCANE_USE_LIBXML2
3152void Entity::
3153encoding(const DOMString& value) const
3154{
3155 _checkValid();
3156 throw NotImplementedException(A_FUNCINFO);
3157}
3158#endif
3159#ifndef ARCANE_USE_LIBXML2
3160DOMString Entity::
3161version() const
3162{
3163 _checkValid();
3164 throw NotImplementedException(A_FUNCINFO);
3165}
3166#endif
3167#ifndef ARCANE_USE_LIBXML2
3168void Entity::
3169version(const DOMString& value) const
3170{
3171 _checkValid();
3172 throw NotImplementedException(A_FUNCINFO);
3173}
3174#endif
3175
3176/*---------------------------------------------------------------------------*/
3177/* ProcessingInstruction implementation */
3178/*---------------------------------------------------------------------------*/
3179
3180ProcessingInstruction::
3181ProcessingInstruction()
3182: Node()
3183{}
3184
3185ProcessingInstruction::
3186ProcessingInstruction(ProcessingInstructionPrv* prv)
3187: Node(reinterpret_cast<NodePrv*>(impl(prv)))
3188{}
3189
3190ProcessingInstructionPrv* ProcessingInstruction::
3191_impl() const
3192{
3193 return cvt(reinterpret_cast<LIBXML2_ProcessingInstruction*>(impl(m_p)));
3194}
3195
3196DOMString ProcessingInstruction::
3197target() const
3198{
3199 _checkValid();
3200 return impl(_impl())->target();
3201}
3202
3203DOMString ProcessingInstruction::
3204data() const
3205{
3206 _checkValid();
3207 return impl(_impl())->Data();
3208}
3209
3210void ProcessingInstruction::
3211data(const DOMString& value) const
3212{
3213 _checkValid();
3214 impl(_impl())->Data(value);
3215}
3216
3217/*---------------------------------------------------------------------------*/
3218/* NamedNodeMap implementation */
3219/*---------------------------------------------------------------------------*/
3220
3221NamedNodeMap::
3222NamedNodeMap() {}
3223
3224NamedNodeMap::
3225NamedNodeMap(NamedNodeMapPrv* p)
3226: m_p(p)
3227{}
3228
3229NamedNodeMap::
3230NamedNodeMap(const NamedNodeMap& from)
3231: m_p(from.m_p)
3232{}
3233
3234const NamedNodeMap& NamedNodeMap::
3235operator=(const NamedNodeMap& from)
3236{
3237 m_p = from.m_p;
3238 return (*this);
3239}
3240
3241NamedNodeMap::
3242~NamedNodeMap() {}
3243
3244NamedNodeMapPrv* NamedNodeMap::
3245_impl() const
3246{
3247 return m_p;
3248}
3249
3250bool NamedNodeMap::
3251_null() const
3252{
3253 return !m_p;
3254}
3255
3256ULong NamedNodeMap::
3257length() const
3258{
3259 if (_null())
3260 return 0;
3261 return impl(m_p)->length();
3262}
3263
3264Node NamedNodeMap::
3265getNamedItem(const DOMString& name) const
3266{
3267 if (_null())
3268 return Node();
3269 LIBXML2_Node* n = impl(m_p)->getNamedItem(name);
3270 return cvt(n);
3271}
3272
3273Node NamedNodeMap::
3274setNamedItem(const Node& arg) const
3275{
3276 if (_null() || arg._null())
3277 return Node();
3278 LIBXML2_Node* n = impl(_impl())->setNamedItem(impl(arg._impl()));
3279 return Node(reinterpret_cast<NodePrv*>(n));
3280}
3281
3282Node NamedNodeMap::
3283removeNamedItem(const DOMString& name) const
3284{
3285 if (_null())
3286 return Node();
3287 LIBXML2_Node* n = impl(_impl())->removeNamedItem(name);
3288 return Node(cvt(n));
3289}
3290
3291Node NamedNodeMap::
3292item(ULong index) const
3293{
3294 if (_null())
3295 return Node();
3296 LIBXML2_Node* n = impl(m_p)->item(index);
3297 return Node(reinterpret_cast<NodePrv*>(n));
3298}
3299
3300Node NamedNodeMap::
3301getNamedItemNS(const DOMString& namespace_uri, const DOMString& localname) const
3302{
3303 if (_null())
3304 return Node();
3305 LIBXML2_Node* n = impl(_impl())->getNamedItemNS(namespace_uri, localname);
3306 return Node(reinterpret_cast<NodePrv*>(n));
3307}
3308
3309Node NamedNodeMap::
3310setNamedItemNS(const Node& arg) const
3311{
3312 if (_null())
3313 return Node();
3314 if (arg._null())
3315 return Node();
3316 LIBXML2_Node* n = impl(_impl())->setNamedItemNS(impl(arg._impl()));
3317 return Node(cvt(n));
3318}
3319
3320Node NamedNodeMap::
3321removeNamedItemNS(const DOMString& namespace_uri, const DOMString& localname) const
3322{
3323 if (_null())
3324 return Node();
3325 LIBXML2_Node* n = impl(_impl())->removeNamedItemNS(namespace_uri, localname);
3326 return Node(cvt(n));
3327}
3328
3329/*---------------------------------------------------------------------------*/
3330/* DOMImplementationSource implementation */
3331/*---------------------------------------------------------------------------*/
3332
3333DOMImplementation DOMImplementationSource::
3334getDOMImplementation(const DOMString& features) const
3335{
3336 ARCANE_UNUSED(features);
3337 throw NotImplementedException(A_FUNCINFO);
3338}
3339
3340/*---------------------------------------------------------------------------*/
3341/*---------------------------------------------------------------------------*/
3342
3343void UserDataHandler::
3344handle(UShort operation, const DOMString& key, const DOMObject& data, const Node& src,
3345 const Node& dest) const
3346{
3347 ARCANE_UNUSED(operation);
3348 ARCANE_UNUSED(key);
3349 ARCANE_UNUSED(data);
3350 ARCANE_UNUSED(src);
3351 ARCANE_UNUSED(dest);
3352 throw NotImplementedException(A_FUNCINFO);
3353}
3354
3355/*---------------------------------------------------------------------------*/
3356/* DOMWriter implementation */
3357/*---------------------------------------------------------------------------*/
3358
3359DOMWriter::
3360DOMWriter()
3361: m_p(0)
3362{}
3363
3364DOMWriter::
3365DOMWriter(DOMWriterPrv* p)
3366: m_p(p)
3367{}
3368
3369DOMWriter::
3370DOMWriter(const DOMWriter& from)
3371: m_p(from.m_p)
3372{}
3373
3374const DOMWriter& DOMWriter::
3375operator=(const DOMWriter& from)
3376{
3377 m_p = from.m_p;
3378 return (*this);
3379}
3380
3381DOMWriter::
3382~DOMWriter() {}
3383
3384bool DOMWriter::
3385_null() const
3386{
3387 return !m_p;
3388}
3389
3390void DOMWriter::
3391_checkValid() const
3392{
3393 if (_null())
3395}
3396
3397DOMWriterPrv* DOMWriter::
3398_impl() const
3399{
3400 return m_p;
3401}
3402
3403ByteUniqueArray DOMWriter::
3404writeNode(const Node& node) const
3405{
3406 ARCANE_UNUSED(node);
3407 _checkValid();
3408 throw NotImplementedException(A_FUNCINFO);
3409}
3410
3411void DOMWriter::
3412encoding(const String& encoding)
3413{
3414 ARCANE_UNUSED(encoding);
3415 throw NotImplementedException(A_FUNCINFO);
3416}
3417
3418String DOMWriter::
3419encoding() const
3420{
3421 throw NotImplementedException(A_FUNCINFO);
3422}
3423
3424/*---------------------------------------------------------------------------*/
3425/* DOMError implementation */
3426/*---------------------------------------------------------------------------*/
3427
3428DOMError::
3429DOMError()
3430: m_p(0)
3431{}
3432
3433DOMError::
3434DOMError(DOMErrorPrv* p)
3435: m_p(p)
3436{}
3437
3438DOMError::
3439DOMError(const DOMError& from)
3440: m_p(from.m_p)
3441{}
3442
3443const DOMError& DOMError::
3444operator=(const DOMError& from)
3445{
3446 m_p = from.m_p;
3447 return (*this);
3448}
3449
3450DOMError::
3451~DOMError() {}
3452
3453bool DOMError::
3454_null() const
3455{
3456 return !m_p;
3457}
3458
3459void DOMError::
3460_checkValid() const
3461{
3462 if (_null())
3464}
3465
3466DOMErrorPrv* DOMError::
3467_impl() const
3468{
3469 return m_p;
3470}
3471
3472UShort DOMError::
3473severity() const
3474{
3475 throw NotImplementedException(A_FUNCINFO);
3476}
3477
3478DOMString DOMError::
3479message() const
3480{
3481 throw NotImplementedException(A_FUNCINFO);
3482}
3483
3484DOMObject DOMError::
3485relatedException() const
3486{
3487 throw NotImplementedException(A_FUNCINFO);
3488}
3489
3490DOMLocator DOMError::
3491location() const
3492{
3493 throw NotImplementedException(A_FUNCINFO);
3494}
3495
3496/*---------------------------------------------------------------------------*/
3497/* DOMErrorHandler implementation */
3498/*---------------------------------------------------------------------------*/
3499
3500bool DOMErrorHandler::
3501handleError(const DOMError& error) const
3502{
3503 ARCANE_UNUSED(error);
3504 throw NotImplementedException(A_FUNCINFO);
3505}
3506
3507/*---------------------------------------------------------------------------*/
3508/* DOMLocator implementation */
3509/*---------------------------------------------------------------------------*/
3510
3511DOMLocator::
3512DOMLocator()
3513: m_p(0)
3514{}
3515
3516DOMLocator::
3517DOMLocator(DOMLocatorPrv* p)
3518: m_p(p)
3519{}
3520
3521DOMLocator::
3522DOMLocator(const DOMLocator& from)
3523: m_p(from.m_p)
3524{}
3525
3526const DOMLocator& DOMLocator::
3527operator=(const DOMLocator& from)
3528{
3529 m_p = from.m_p;
3530 return (*this);
3531}
3532
3533DOMLocator::
3534~DOMLocator() {}
3535
3536bool DOMLocator::
3537_null() const
3538{
3539 return !m_p;
3540}
3541
3542void DOMLocator::
3543_checkValid() const
3544{
3545 if (_null())
3547}
3548
3549DOMLocatorPrv* DOMLocator::
3550_impl() const
3551{
3552 return m_p;
3553}
3554
3555long DOMLocator::
3556lineNumber() const
3557{
3558 throw NotImplementedException(A_FUNCINFO);
3559}
3560
3561long DOMLocator::
3562columnNumber() const
3563{
3564 throw NotImplementedException(A_FUNCINFO);
3565}
3566
3567#ifndef ARCANE_USE_LIBXML2
3568long DOMLocator::
3569offset() const
3570{
3571 throw NotImplementedException(A_FUNCINFO);
3572}
3573#endif
3574
3575#ifndef ARCANE_USE_LIBXML2
3576Node DOMLocator::
3577errorNode() const
3578{
3579 throw NotImplementedException(A_FUNCINFO);
3580}
3581#endif
3582
3583DOMString DOMLocator::
3584uri() const
3585{
3586 return DOMString();
3587}
3588
3589/*---------------------------------------------------------------------------*/
3590/* XPathEvaluator implementation */
3591/*---------------------------------------------------------------------------*/
3592
3593XPathExpression XPathEvaluator::
3594createExpression(const DOMString& expression, const XPathNSResolver& resolver) const
3595{
3596 ARCANE_UNUSED(expression);
3597 ARCANE_UNUSED(resolver);
3598 throw NotImplementedException(A_FUNCINFO);
3599}
3600
3601XPathResult XPathEvaluator::
3602createResult() const
3603{
3604 throw NotImplementedException(A_FUNCINFO);
3605}
3606
3607XPathNSResolver XPathEvaluator::
3608createNSResolver(const Node& node_resolver) const
3609{
3610 ARCANE_UNUSED(node_resolver);
3611 throw NotImplementedException(A_FUNCINFO);
3612}
3613
3614XPathResult XPathEvaluator::
3615evaluate(const DOMString& expression, const Node& context_node,
3616 const XPathNSResolver& resolver, UShort type, const XPathResult& result) const
3617{
3618 ARCANE_UNUSED(expression);
3619 ARCANE_UNUSED(context_node);
3620 ARCANE_UNUSED(resolver);
3621 ARCANE_UNUSED(type);
3622 ARCANE_UNUSED(result);
3623 throw NotImplementedException(A_FUNCINFO);
3624}
3625
3626XPathResult XPathEvaluator::
3627evaluateExpression(const XPathExpression& expression, const Node& context_node, UShort type,
3628 const XPathResult& result) const
3629{
3630 ARCANE_UNUSED(expression);
3631 ARCANE_UNUSED(context_node);
3632 ARCANE_UNUSED(type);
3633 ARCANE_UNUSED(result);
3634 throw NotImplementedException(A_FUNCINFO);
3635}
3636
3637/*---------------------------------------------------------------------------*/
3638/* XPathNSResolver implementation */
3639/*---------------------------------------------------------------------------*/
3640
3641DOMString XPathNSResolver::
3642lookupNamespaceURI(const DOMString& prefix) const
3643{
3644 ARCANE_UNUSED(prefix);
3645 throw NotImplementedException(A_FUNCINFO);
3646}
3647
3648/*---------------------------------------------------------------------------*/
3649/*---------------------------------------------------------------------------*/
3650
3651UShort XPathResult::
3652resultType() const
3653{
3654 throw NotImplementedException(A_FUNCINFO);
3655}
3656
3657double XPathResult::
3658numberValue() const
3659{
3660 throw NotImplementedException(A_FUNCINFO);
3661}
3662
3663DOMString XPathResult::
3664stringValue() const
3665{
3666 throw NotImplementedException(A_FUNCINFO);
3667}
3668
3669bool XPathResult::
3670booleanValue() const
3671{
3672 throw NotImplementedException(A_FUNCINFO);
3673}
3674
3675Node XPathResult::
3676singleNodeValue() const
3677{
3678 throw NotImplementedException(A_FUNCINFO);
3679}
3680
3681XPathSetIterator XPathResult::
3682getSetIterator(bool ordered) const
3683{
3684 ARCANE_UNUSED(ordered);
3685 throw NotImplementedException(A_FUNCINFO);
3686}
3687
3688XPathSetSnapshot XPathResult::
3689getSetSnapshot(bool ordered) const
3690{
3691 ARCANE_UNUSED(ordered);
3692 throw NotImplementedException(A_FUNCINFO);
3693}
3694
3695/*---------------------------------------------------------------------------*/
3696/* XPathSetIterator implementation */
3697/*---------------------------------------------------------------------------*/
3698
3699Node XPathSetIterator::
3700nextNode() const
3701{
3702 throw NotImplementedException(A_FUNCINFO);
3703}
3704
3705/*---------------------------------------------------------------------------*/
3706/*---------------------------------------------------------------------------*/
3707
3708ULong XPathSetSnapshot::
3709length() const
3710{
3711 throw NotImplementedException(A_FUNCINFO);
3712}
3713
3714Node XPathSetSnapshot::
3715item(ULong index) const
3716{
3717 ARCANE_UNUSED(index);
3718 throw NotImplementedException(A_FUNCINFO);
3719}
3720
3721/*---------------------------------------------------------------------------*/
3722/* XPathNamespace implementation */
3723/*---------------------------------------------------------------------------*/
3724
3725Element XPathNamespace::
3726ownerElement() const
3727{
3728 throw NotImplementedException(A_FUNCINFO);
3729}
3730
3731/*---------------------------------------------------------------------------*/
3732/* LIBXML2_DOM implementation */
3733/*---------------------------------------------------------------------------*/
3734LIBXML2_DOMImplementation*
3735getDomImplementation()
3736{
3737 return LIBXML2_DOMImplementation::sDOMImplementation;
3738}
3739
3740LIBXML2_DOMImplementation::
3741~LIBXML2_DOMImplementation()
3742{
3743 LIBXML2_Document* _xDoc = GetDocument();
3744 if (_xDoc) {
3745 xmlParserCtxtPtr ctxt = _xDoc->Context_();
3746 if (ctxt) {
3747 if (ctxt->myDoc)
3748 xmlFreeDoc(ctxt->myDoc);
3749 if (ctxt)
3750 xmlFreeParserCtxt(ctxt);
3751 } else {
3752 _xmlDoc* myDoc = _xDoc->Impl_();
3753 if (myDoc)
3754 xmlFreeDoc(myDoc);
3755 }
3756 delete _xDoc;
3757 SetDocument(nullptr);
3758 }
3759}
3760
3761std::unique_ptr<LIBXML2_DOMImplementation> sDom(new LIBXML2_DOMImplementation());
3762LIBXML2_DOMImplementation* LIBXML2_DOMImplementation::sDOMImplementation = sDom.release();
3763
3764LIBXML2_Element*
3765LIBXML2_NewElement(LIBXML2_Document* doc, const String& nsURI, const String& elname)
3766{
3767 ARCANE_UNUSED(nsURI);
3768 ARCANE_UNUSED(elname);
3769 return new LIBXML2_Element(doc);
3770}
3771
3772LIBXML2_Document*
3773LIBXML2_NewDocument(const String& nsURI)
3774{
3775 ARCANE_UNUSED(nsURI);
3776 return new LIBXML2_Document();
3777}
3778
3779bool LIBXML2_DOMImplementation::
3780hasFeature(const String& feature, const String& version)
3781{
3782 return (feature == "Core" && (version == "1.0" || version == "2.0" || version == "3.0"));
3783}
3784
3785LIBXML2_DocumentType* LIBXML2_DOMImplementation::
3786createDocumentType(const String& qualifiedname, const String& publicId,
3787 const String& systemId)
3788{
3789 return new LIBXML2_DocumentType(NULL, qualifiedname, publicId, systemId);
3790}
3791
3792LIBXML2_Document* LIBXML2_DOMImplementation::
3793createDocument(const String& namespaceURI, const String& qualifiedname,
3794 LIBXML2_DocumentType* doctype)
3795{
3796 const XMLCh* cqname = reinterpret_cast<const XMLCh*>(qualifiedname.utf16().begin());
3797 const XMLCh* cpos = wcschr(cqname, L':');
3798 if (cpos == NULL)
3799 cpos = cqname;
3800 else
3801 cpos++;
3802 ByteUniqueArray utf8_array(cpos[0]);
3803 String localName = String::fromUtf8(utf8_array);
3804 if (namespaceURI == String()) {
3805 throw Arcane::Exception::exception();
3806 }
3807 if (cpos - cqname == 3 && !wcsncmp(cqname, U("xml"), 3) &&
3808 qualifiedname != "http://www.w3.org/XML/1998/namespace") {
3809 throw Arcane::Exception::exception();
3810 }
3811
3812 if (doctype && doctype->mDocument != NULL) {
3813 throw Arcane::Exception::exception();
3814 }
3815 LIBXML2_Document* doc = LIBXML2_NewDocument(namespaceURI);
3816 if (doc == NULL)
3817 throw Arcane::Exception::exception();
3818 if (doctype != NULL) {
3819 doctype->mDocument = doc;
3820 doctype->mDocumentIsAncestor = false;
3821 doc->add_ref();
3822 doc->insertBeforePrivate(doctype, NULL)->release_ref();
3823 }
3824
3825 LIBXML2_Element* docel = new LIBXML2_Element(doc);
3826 if (docel == NULL)
3827 throw Arcane::Exception::exception();
3828 docel->mNamespaceURI = namespaceURI;
3829 docel->mNodeName = qualifiedname;
3830 docel->mLocalName = localName;
3831
3832 doc->mNamespaceURI = namespaceURI;
3833 doc->mNodeName = qualifiedname;
3834 doc->mLocalName = localName;
3835 doc->appendChild(docel)->release_ref();
3836 doc->add_ref();
3837 _xmlDoc* myDoc = xmlNewDoc(reinterpret_cast<const xmlChar*>("1.0"));
3838 if (myDoc == NULL)
3839 throw Arcane::Exception::exception();
3840 doc->Impl_(myDoc);
3841 SetDocument(doc);
3842 return doc;
3843}
3844
3845LIBXML2_Node::
3846LIBXML2_Node(LIBXML2_Document* aDocument)
3847: mParent(NULL)
3848, mDocumentIsAncestor(false)
3849, mDocument(aDocument)
3850, mNodeType(DOCUMENT_NODE)
3851{
3852 if (mDocument)
3853 mDocument->add_ref();
3854}
3855
3856LIBXML2_Node::
3857~LIBXML2_Node()
3858{
3859 if (!mDocumentIsAncestor && mDocument)
3860 mDocument->release_ref();
3861 // Now start deleting the children...
3862 for (std::list<LIBXML2_Node*>::iterator i2(mNodeList.begin()); i2 != mNodeList.end(); i2++)
3863 delete (*i2);
3864}
3865
3866String LIBXML2_Node::
3867nodeName()
3868{
3869 return mNodeName;
3870}
3871
3872String LIBXML2_Node::
3873nodeValue()
3874{
3875 return mNodeValue;
3876}
3877
3878void LIBXML2_Node::
3879nodeValue(const String& attr)
3880{
3881 mNodeValue = attr;
3882}
3883
3884UInt16 LIBXML2_Node::
3885nodeType()
3886{
3887 return mNodeType;
3888}
3889
3890LIBXML2_Node* LIBXML2_Node::
3891parentNode()
3892{
3893 if (mParent != NULL)
3894 mParent->add_ref();
3895 return mParent;
3896}
3897
3898LIBXML2_NodeList* LIBXML2_Node::
3899childNodes()
3900{
3901 return new LIBXML2_NodeList(this);
3902}
3903
3904LIBXML2_Node* LIBXML2_Node::
3905firstChild()
3906{
3907 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++) {
3908 UInt16 type = (*i)->nodeType();
3909 if (type != LIBXML2_Node::ATTRIBUTE_NODE && type != LIBXML2_Node::NOTATION_NODE &&
3910 type != LIBXML2_Node::ENTITY_NODE) {
3911 (*i)->add_ref();
3912 return (*i);
3913 }
3914 }
3915 return NULL;
3916}
3917
3918LIBXML2_Node* LIBXML2_Node::
3919lastChild()
3920{
3921 std::list<LIBXML2_Node*>::iterator i = mNodeList.end();
3922 while (i != mNodeList.begin()) {
3923 i--;
3924 UInt16 type = (*i)->nodeType();
3925 if (type != LIBXML2_Node::ATTRIBUTE_NODE && type != LIBXML2_Node::NOTATION_NODE &&
3926 type != LIBXML2_Node::ENTITY_NODE) {
3927 (*i)->add_ref();
3928 return (*i);
3929 }
3930 }
3931 return NULL;
3932}
3933
3934LIBXML2_Node* LIBXML2_Node::
3935previousSibling()
3936{
3937 if (mParent == NULL)
3938 return NULL;
3939 if (nodeType() == LIBXML2_Node::ATTRIBUTE_NODE)
3940 return NULL;
3941 std::list<LIBXML2_Node*>::iterator i = mPositionInParent;
3942 while (true) {
3943 if (i == mParent->mNodeList.begin())
3944 return NULL;
3945 i--;
3946 UInt16 type = (*i)->nodeType();
3947 if (type != LIBXML2_Node::ATTRIBUTE_NODE && type != LIBXML2_Node::ENTITY_NODE &&
3948 type != LIBXML2_Node::NOTATION_NODE) {
3949 (*i)->add_ref();
3950 return (*i);
3951 }
3952 }
3953}
3954
3955LIBXML2_Node* LIBXML2_Node::
3956nextSibling()
3957{
3958 if (mParent == NULL)
3959 return NULL;
3960 if (nodeType() == LIBXML2_Node::ATTRIBUTE_NODE)
3961 return NULL;
3962 std::list<LIBXML2_Node*>::iterator i = mPositionInParent;
3963 while (true) {
3964 i++;
3965 if (i == mParent->mNodeList.end())
3966 return NULL;
3967 UInt16 type = (*i)->nodeType();
3968 if (type != LIBXML2_Node::ATTRIBUTE_NODE && type != LIBXML2_Node::ENTITY_NODE &&
3969 type != LIBXML2_Node::NOTATION_NODE) {
3970 (*i)->add_ref();
3971 return (*i);
3972 }
3973 }
3974}
3975
3976LIBXML2_NamedNodeMap* LIBXML2_Node::
3977attributes()
3978{
3979 return (LIBXML2_NamedNodeMap*)(new LIBXML2_EmptyNamedNodeMap()); // CHECK
3980}
3981
3982LIBXML2_Document* LIBXML2_Node::
3983ownerDocument()
3984{
3985 if (mDocument != NULL)
3986 mDocument->add_ref();
3987 return mDocument;
3988}
3989
3990void LIBXML2_Node::
3991updateDocumentAncestorStatus(bool aStatus)
3992{
3993 if (mDocumentIsAncestor == aStatus)
3994 return;
3995 if (aStatus && mDocument) {
3996 // We are now under the document's refcount...
3997 mDocument->release_ref();
3998 } else if (mDocument && !aStatus) {
3999 // The document is no longer sharing our refcount, so needs an explicit ref
4000 mDocument->add_ref();
4001 }
4002 mDocumentIsAncestor = aStatus;
4003 // Now tell our children...
4004 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++)
4005 (*i)->updateDocumentAncestorStatus(aStatus);
4006}
4007
4008LIBXML2_Node* LIBXML2_Node::
4009insertBefore(LIBXML2_Node* newChild, LIBXML2_Node* refChild)
4010{
4011 if (newChild == NULL)
4012 throw Arcane::Exception::exception();
4013
4014 UInt16 type = newChild->nodeType();
4015
4016 // Get rid of nodes which can't be added this way...
4017 if (type == LIBXML2_Node::ATTRIBUTE_NODE || type == LIBXML2_Node::DOCUMENT_NODE ||
4018 type == LIBXML2_Node::DOCUMENT_TYPE_NODE || type == LIBXML2_Node::NOTATION_NODE ||
4019 type == LIBXML2_Node::ENTITY_NODE)
4020 throw Arcane::Exception::exception();
4021 if (type == LIBXML2_Node::DOCUMENT_FRAGMENT_NODE) {
4022 if (newChild == NULL)
4023 throw Arcane::Exception::exception();
4024 // We skip the d.f. and recurse onto its children...
4025 for (std::list<LIBXML2_Node*>::iterator i = newChild->mNodeList.begin(); i != newChild->mNodeList.end();
4026 i++)
4027 insertBefore(*i, refChild)->release_ref();
4028 newChild->add_ref();
4029 return newChild;
4030 }
4031 return insertBeforePrivate(newChild, refChild);
4032}
4033
4034LIBXML2_Node* LIBXML2_Node::
4035insertBeforePrivate(LIBXML2_Node* newChild, LIBXML2_Node* refChild)
4036{
4037 // Check the new child...
4038 if (newChild == NULL)
4039 throw Arcane::Exception::exception();
4040 // If there is a refchild, it must belong to us...
4041 if (refChild && refChild->mParent != this)
4042 throw Arcane::Exception::exception();
4043 if (newChild->mDocument != mDocument)
4044 throw Arcane::Exception::exception();
4045 if (newChild == refChild) {
4046 // It is already in the right place...
4047 newChild->add_ref();
4048 return newChild;
4049 }
4050 if (newChild->mParent != NULL) {
4051 // Check that it is not our ancestor
4052 LIBXML2_Node* n = this;
4053 while (n) {
4054 if (n == newChild)
4055 throw Arcane::Exception::exception();
4056 n = n->mParent;
4057 }
4058 }
4059 std::list<LIBXML2_Node*>::iterator posit;
4060 if (newChild->mParent != NULL) {
4061 ARCANE_ASSERT(!refChild || (refChild->mParent == this),
4062 ("The child belongs to us, but isn't on the list!"));
4063 newChild->mParent->removeChild(newChild)->release_ref();
4064 ARCANE_ASSERT(!refChild || (refChild->mParent == this),
4065 ("The child belongs to us, but isn't on the list!"));
4066 }
4067 // Just in case the remove failed.
4068 if (newChild->mParent != NULL)
4069 throw Arcane::Exception::exception();
4070 if (refChild != NULL) {
4071 posit = std::find(mNodeList.begin(), mNodeList.end(), refChild);
4072 if (posit == mNodeList.end()) {
4073 // The child belongs to us, but isn't on the list!
4074 ARCANE_ASSERT(refChild->mParent == this, ("The child belongs to us, but isn't on the list!"));
4075 throw Arcane::Exception::exception();
4076 }
4077 } else
4078 posit = mNodeList.end();
4079 // Update nodes' mDocumentIsAncestor...
4080 if (mDocumentIsAncestor)
4081 newChild->updateDocumentAncestorStatus(true);
4082 newChild->mParent = this;
4083 newChild->mPositionInParent = mNodeList.insert(posit, newChild);
4084 UInt32 i, rc = newChild->_libxml2_refcount;
4085 for (i = 0; i < rc; i++)
4086 add_ref();
4087 newChild->add_ref();
4088 return newChild;
4089}
4090
4091LIBXML2_Node* LIBXML2_Node::
4092replaceChild(LIBXML2_Node* newChild, LIBXML2_Node* oldChild)
4093{
4094 if (newChild == oldChild) {
4095 oldChild->add_ref();
4096 return oldChild;
4097 }
4098 if (oldChild == NULL)
4099 throw Arcane::Exception::exception();
4100 insertBefore(newChild, oldChild)->release_ref();
4101 return removeChild(oldChild);
4102}
4103
4104LIBXML2_Node* LIBXML2_Node::
4105removeChild(LIBXML2_Node* oldChild)
4106{
4107 if (oldChild == NULL)
4108 throw Arcane::Exception::exception();
4109 UInt16 type = oldChild->nodeType();
4110 if (type == LIBXML2_Node::ATTRIBUTE_NODE || type == LIBXML2_Node::DOCUMENT_TYPE_NODE ||
4111 type == LIBXML2_Node::NOTATION_NODE || type == LIBXML2_Node::ENTITY_NODE)
4112 throw Arcane::Exception::exception();
4113 return removeChildPrivate(oldChild);
4114}
4115
4116LIBXML2_Node* LIBXML2_Node::
4117removeChildPrivate(LIBXML2_Node* oldChild)
4118{
4119 std::list<LIBXML2_Node*>::iterator posit = std::find(mNodeList.begin(), mNodeList.end(), oldChild);
4120 if (posit == mNodeList.end())
4121 throw Arcane::Exception::exception();
4122 mNodeList.erase(posit);
4123 oldChild->mParent = NULL;
4124 UInt32 i, rc = oldChild->_libxml2_refcount;
4125 for (i = 0; i < rc; i++)
4126 release_ref();
4127 if (mDocumentIsAncestor)
4128 oldChild->updateDocumentAncestorStatus(false);
4129 oldChild->add_ref();
4130 return oldChild;
4131}
4132
4133LIBXML2_Node* LIBXML2_Node::
4134appendChild(LIBXML2_Node* inewChild)
4135{
4136 return insertBefore(inewChild, NULL);
4137}
4138
4139bool LIBXML2_Node::
4140hasChildNodes()
4141{
4142 return !mNodeList.empty();
4143}
4144
4145LIBXML2_Node* LIBXML2_Node::
4146cloneNode(bool deep)
4147{
4148 return cloneNodePrivate(mDocument, deep);
4149}
4150
4151LIBXML2_Node* LIBXML2_Node::
4152cloneNodePrivate(LIBXML2_Document* aDoc, bool deep)
4153{
4154 LIBXML2_Node* c = shallowCloneNode(aDoc);
4155 if (!deep) {
4156 c->add_ref();
4157 return c;
4158 }
4159 // Clone all children...
4160 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++) {
4161 // See if its an attribute(in which case we already cloned it).
4162 if ((*i)->nodeType() == LIBXML2_Node::ATTRIBUTE_NODE)
4163 continue;
4164 LIBXML2_Node* n = (*i)->cloneNodePrivate(c->mDocument, true);
4165 c->insertBeforePrivate(n, NULL)->release_ref();
4166 }
4167 c->add_ref();
4168 return c;
4169}
4170
4171void LIBXML2_Node::
4172normalize()
4173{
4174 // Normalize the children...
4175 std::list<LIBXML2_Node*>::iterator i;
4176 for (i = mNodeList.begin(); i != mNodeList.end(); i++)
4177 (*i)->normalize();
4178
4179 // Now scan through our nodes and look for adjacent text nodes to fold into
4180 // single nodes, or delete...
4181 LIBXML2_TextBase* lastText = NULL;
4182 for (i = mNodeList.begin(); i != mNodeList.end(); i++) {
4183 LIBXML2_TextBase* tb = dynamic_cast<LIBXML2_TextBase*>(*i);
4184 if (tb == NULL) {
4185 lastText = NULL;
4186 continue;
4187 }
4188 if (tb->mNodeValue == String()) {
4189 removeChild(tb)->release_ref();
4190 continue;
4191 }
4192 if (lastText != NULL) {
4193 removeChild(tb)->release_ref();
4194 lastText->mNodeValue = lastText->mNodeValue + tb->mNodeValue;
4195 continue;
4196 }
4197 lastText = tb;
4198 }
4199}
4200
4201bool LIBXML2_Node::
4202isSupported(const String& feature, const String& version)
4203{
4204 if ((feature == "xml" && (version == "1.0")) || (version == "2.0") || (version == "3.0"))
4205 return true;
4206 if ((feature == "Core" && (version == "1.0")) || (version == "2.0") || (version == "3.0"))
4207 return true;
4208 if (feature == "Trav" && (version == "2.0"))
4209 return true;
4210 if (feature == "Range" && (version == "2.0"))
4211 return true;
4212 if (feature == "LS" && (version == "2.0"))
4213 return true;
4214 if (feature == "XPath" && (version == "3.0"))
4215 return true;
4216 return false;
4217}
4218
4219String LIBXML2_Node::
4220namespaceURI()
4221{
4222 return mNamespaceURI;
4223}
4224
4225String LIBXML2_Node::
4226prefix()
4227{
4228 const XMLCh* cNodename = reinterpret_cast<const XMLCh*>(mNodeName.utf16().begin());
4229 const XMLCh* cpos = wcschr(cNodename, U(':'));
4230 if (cpos == NULL)
4231 return String();
4232 cpos++;
4233 return mNodeName.substring(0, wcslen(cNodename) - wcslen(cpos));
4234}
4235
4236void LIBXML2_Node::
4237prefix(const String& attr)
4238{
4239 if (mNamespaceURI == String())
4240 throw Arcane::Exception::exception();
4241 if (attr == "xml" && mNamespaceURI != "http://www.w3.org/XML/1998/namespace")
4242 throw Arcane::Exception::exception();
4243 if (mLocalName == "xmlns" && attr != String())
4244 throw Arcane::Exception::exception();
4245 if (attr == "xmlns" && mNamespaceURI != "http://www.w3.org/2000/xmlns/")
4246 throw Arcane::Exception::exception();
4247 mNodeName = attr;
4248 mNodeName = mNodeName + ":";
4249 mNodeName = mNodeName + mLocalName;
4250}
4251
4252String LIBXML2_Node::
4253localName()
4254{
4255 return mLocalName;
4256}
4257
4258void LIBXML2_Node::
4259recursivelyChangeDocument(LIBXML2_Document* aNewDocument)
4260{
4261 ARCANE_ASSERT(!mDocumentIsAncestor, ("The document is the ancestor !"));
4262 if (mDocument == aNewDocument)
4263 return;
4264 if (mDocument != NULL)
4265 mDocument->release_ref();
4266 mDocument = aNewDocument;
4267 if (mDocument != NULL)
4268 mDocument->add_ref();
4269 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++)
4270 (*i)->recursivelyChangeDocument(mDocument);
4271}
4272
4273LIBXML2_Element* LIBXML2_Node::
4274searchForElementById(const String& elementId)
4275{
4276 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++) {
4277 LIBXML2_Element* e = (*i)->searchForElementById(elementId);
4278 if (e != NULL)
4279 return e;
4280 }
4281 return NULL;
4282}
4283
4284#ifdef DEBUG_NODELEAK
4285void LIBXML2_Node::
4286find_leaked()
4287{
4288 UInt32 sum = 0;
4289 for (std::list<LIBXML2_Node*>::const_iterator i(mNodeList.begin()); i != mNodeList.end(); i++) {
4290 sum += (*i)->_libxml2_refcount;
4291 (*i)->find_leaked();
4292 }
4293 ARCANE_ASSERT((_libxml2_refcount != sum), ("Warning: object leaked "));
4294}
4295#endif // DEBUG_NODELEAK
4296
4297LIBXML2_Node* LIBXML2_NodeList::
4298 item(UInt32 index)
4299{
4300 UInt32 saveIndex = index;
4301 if (mParent == NULL)
4302 return NULL;
4303 for (std::list<LIBXML2_Node*>::iterator i = mParent->mNodeList.begin(); i != mParent->mNodeList.end();
4304 i++) {
4305 // See if it is a type we ignore...
4306 UInt16 type = (*i)->nodeType();
4307 if (type == LIBXML2_Node::ATTRIBUTE_NODE || type == LIBXML2_Node::DOCUMENT_TYPE_NODE)
4308 continue;
4309 if (index == 0) {
4310 m_hintIterator = i;
4311 m_hintIndex = saveIndex;
4312 (*i)->add_ref();
4313 return (*i);
4314 }
4315 index--;
4316 }
4317 return NULL;
4318}
4319
4320UInt32 LIBXML2_NodeList::
4321 length()
4322{
4323 UInt32 length = 0;
4324 for (std::list<LIBXML2_Node*>::iterator i = mParent->mNodeList.begin(); i != mParent->mNodeList.end();
4325 i++) {
4326 UInt16 type = (*i)->nodeType();
4327 if (type == LIBXML2_Node::ATTRIBUTE_NODE || type == LIBXML2_Node::DOCUMENT_TYPE_NODE)
4328 continue;
4329 length++;
4330 }
4331 return length;
4332}
4333
4334LIBXML2_Node* LIBXML2_NodeListDFSSearch::
4335 item(UInt32 index)
4336{
4337 if (mParent == NULL)
4338 return NULL;
4339 // We have a list of iterators...
4340 std::list<std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>> iteratorStack;
4341 iteratorStack.push_front(std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>(
4342 mParent->mNodeList.begin(), mParent->mNodeList.end()));
4343 while (!iteratorStack.empty()) {
4344 std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>& itp =
4345 iteratorStack.front();
4346 if (itp.first == itp.second) {
4347 iteratorStack.pop_front();
4348 continue;
4349 }
4350 std::list<LIBXML2_Node*>::iterator p = itp.first;
4351 itp.first++;
4352 // This is a pre-order traversal, so consider the element first...
4353 if ((*p)->nodeType() == LIBXML2_Node::ELEMENT_NODE) {
4354 bool hit = true;
4355 switch (mFilterType) {
4356 case LEVEL_1_NAME_FILTER:
4357 if ((*p)->mNodeName != mNameFilter && (*p)->mNodeName != "*")
4358 hit = false;
4359 break;
4360 case LEVEL_2_NAME_FILTER:
4361 if ((*p)->mLocalName != mNameFilter && (mNameFilter != "*"))
4362 hit = false;
4363 if ((*p)->mNamespaceURI != mNamespaceFilter && (mNamespaceFilter != "*"))
4364 hit = false;
4365 break;
4366 }
4367 if (hit) {
4368 if (index == 0) {
4369 (*p)->add_ref();
4370 return *p;
4371 }
4372 index--;
4373 }
4374 }
4375 // Next, we need to recurse...
4376 iteratorStack.push_front(
4377 std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>(
4378 (*p)->mNodeList.begin(), (*p)->mNodeList.end()));
4379 }
4380 return NULL;
4381}
4382
4383UInt32 LIBXML2_NodeListDFSSearch::
4384 length()
4385{
4386 if (mParent == NULL)
4387 return 0;
4388 UInt32 length = 0;
4389 // We have a list of iterators...
4390 std::list<std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>> iteratorStack;
4391 iteratorStack.push_front(std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>(
4392 mParent->mNodeList.begin(), mParent->mNodeList.end()));
4393 while (!iteratorStack.empty()) {
4394 std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>& itp =
4395 iteratorStack.front();
4396 if (itp.first == itp.second) {
4397 iteratorStack.pop_front();
4398 continue;
4399 }
4400 // This is a pre-order traversal, so consider the element first...
4401 if ((*(itp.first))->nodeType() == LIBXML2_Node::ELEMENT_NODE) {
4402 bool hit = true;
4403 switch (mFilterType) {
4404 case LEVEL_1_NAME_FILTER:
4405 if ((*(itp.first))->mNodeName != mNameFilter && (*(itp.first))->mNodeName != "*")
4406 hit = false;
4407 break;
4408 case LEVEL_2_NAME_FILTER:
4409 if ((*(itp.first))->mLocalName != mNameFilter && (mNameFilter != "*"))
4410 hit = false;
4411 if ((*(itp.first))->mNamespaceURI != mNamespaceFilter && (mNamespaceFilter != "*"))
4412 hit = false;
4413 break;
4414 }
4415 if (hit) {
4416 length++;
4417 }
4418 }
4419 // Next, we need to recurse...
4420 LIBXML2_Node* n = *(itp.first);
4421 itp.first++;
4422 iteratorStack.push_front(
4423 std::pair<std::list<LIBXML2_Node*>::iterator, std::list<LIBXML2_Node*>::iterator>(
4424 n->mNodeList.begin(), n->mNodeList.end()));
4425 }
4426 return length;
4427}
4428
4429LIBXML2_NamedNodeMap::
4430 LIBXML2_NamedNodeMap(LIBXML2_Element* aElement)
4431: mElement(aElement)
4432, m_hintIndex(0)
4433{
4434 mElement->add_ref();
4435}
4436
4437LIBXML2_NamedNodeMap::
4438 ~LIBXML2_NamedNodeMap()
4439{
4440 mElement->release_ref();
4441}
4442
4443LIBXML2_Node* LIBXML2_NamedNodeMap::
4444 getNamedItem(const String& name)
4445{
4446 std::map<LIBXML2_Element::LocalName, LIBXML2_Attr*>::iterator i =
4447 mElement->attributeMap.find(LIBXML2_Element::LocalName(name));
4448 if (i == mElement->attributeMap.end())
4449 return NULL;
4450 (*i).second->add_ref();
4451 return (*i).second;
4452}
4453
4454LIBXML2_Node* LIBXML2_NamedNodeMap::
4455 setNamedItem(LIBXML2_Node* arg)
4456{
4457 LIBXML2_Attr* attr = dynamic_cast<LIBXML2_Attr*>(arg);
4458 return mElement->setAttributeNode(attr);
4459}
4460
4461LIBXML2_Node* LIBXML2_NamedNodeMap::
4462 removeNamedItem(const String& name)
4463{
4464 std::map<LIBXML2_Element::LocalName, LIBXML2_Attr*>::iterator i =
4465 mElement->attributeMap.find(LIBXML2_Element::LocalName(name));
4466 if (i == mElement->attributeMap.end())
4467 throw Arcane::Exception::exception();
4468 // Remove the child(which sorts out the refcounting)...
4469 LIBXML2_Attr* at = (*i).second;
4470 mElement->removeChildPrivate(at)->release_ref();
4471 LIBXML2_Element::LocalName ln((*i).first);
4472 mElement->attributeMap.erase(i);
4473 std::map<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>::iterator j =
4474 mElement->attributeMapNS.find(LIBXML2_Element::QualifiedName(at->mNamespaceURI, at->mLocalName));
4475 LIBXML2_Element::QualifiedName qn((*j).first);
4476 mElement->attributeMapNS.erase(j);
4477 return at;
4478}
4479
4480LIBXML2_Node* LIBXML2_NamedNodeMap::
4481 item(UInt32 index)
4482{
4483 UInt32 saveIndex = index;
4484 for (std::map<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>::iterator i = mElement->attributeMapNS.begin();
4485 i != mElement->attributeMapNS.end(); i++) {
4486 if (index == 0) {
4487 m_hintIterator = i;
4488 m_hintIndex = saveIndex;
4489
4490 (*i).second->add_ref();
4491 return (*i).second;
4492 }
4493 index--;
4494 }
4495 return NULL;
4496}
4497
4498UInt32 LIBXML2_NamedNodeMap::
4499length()
4500{
4501 return mElement->attributeMap.size();
4502}
4503
4504LIBXML2_Node* LIBXML2_NamedNodeMap::
4505getNamedItemNS(const String& namespaceURI, const String& localName)
4506{
4507 std::map<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>::iterator i =
4508 mElement->attributeMapNS.find(LIBXML2_Element::QualifiedName(namespaceURI, localName));
4509 if (i == mElement->attributeMapNS.end())
4510 return NULL;
4511 (*i).second->add_ref();
4512 return (*i).second;
4513}
4514
4515LIBXML2_Node* LIBXML2_NamedNodeMap::
4516setNamedItemNS(LIBXML2_Node* arg)
4517{
4518 LIBXML2_Attr* attr = dynamic_cast<LIBXML2_Attr*>(arg);
4519 return mElement->setAttributeNodeNS(attr);
4520}
4521
4522LIBXML2_Node* LIBXML2_NamedNodeMap::
4523removeNamedItemNS(const String& namespaceURI, const String& localName)
4524{
4525 std::map<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>::iterator i =
4526 mElement->attributeMapNS.find(LIBXML2_Element::QualifiedName(namespaceURI, localName));
4527 if (i == mElement->attributeMapNS.end())
4528 throw Arcane::Exception::exception();
4529 // Remove the child(which sorts out the refcounting)...
4530 LIBXML2_Attr* at = (*i).second;
4531 mElement->removeChildPrivate(at)->release_ref();
4532 std::map<LIBXML2_Element::LocalName, LIBXML2_Attr*>::iterator j =
4533 mElement->attributeMap.find(LIBXML2_Element::LocalName(at->mNodeName));
4534 mElement->attributeMapNS.erase(i);
4535 mElement->attributeMap.erase(j);
4536 return at;
4537}
4538
4539LIBXML2_NamedNodeMapDT::
4540LIBXML2_NamedNodeMapDT(LIBXML2_DocumentType* aDocType, UInt16 aType)
4541: mDocType(aDocType)
4542, mType(aType)
4543{
4544 mDocType->add_ref();
4545}
4546
4547LIBXML2_NamedNodeMapDT::
4548~LIBXML2_NamedNodeMapDT()
4549{
4550 mDocType->release_ref();
4551}
4552
4553LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4554getNamedItem(const String& name)
4555{
4556 for (std::list<LIBXML2_Node*>::iterator i = mDocType->mNodeList.begin(); i != mDocType->mNodeList.end();
4557 i++) {
4558 if ((*i)->nodeType() != mType)
4559 continue;
4560 if ((*i)->mNodeName != name)
4561 continue;
4562 (*i)->add_ref();
4563 return (*i);
4564 }
4565 return NULL;
4566}
4567
4568LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4569setNamedItem(LIBXML2_Node* arg)
4570{
4571 ARCANE_UNUSED(arg);
4572 throw NotImplementedException(A_FUNCINFO);
4573}
4574
4575LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4576removeNamedItem(const String& name)
4577{
4578 ARCANE_UNUSED(name);
4579 throw NotImplementedException(A_FUNCINFO);
4580}
4581
4582LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4583item(UInt32 index)
4584{
4585 for (std::list<LIBXML2_Node*>::iterator i = mDocType->mNodeList.begin(); i != mDocType->mNodeList.end();
4586 i++) {
4587 if ((*i)->nodeType() != mType)
4588 continue;
4589 if (index != 0) {
4590 index--;
4591 continue;
4592 }
4593 (*i)->add_ref();
4594 return *i;
4595 }
4596 return NULL;
4597}
4598
4599UInt32 LIBXML2_NamedNodeMapDT::
4600length()
4601{
4602 UInt32 l = 0;
4603 for (std::list<LIBXML2_Node*>::iterator i = mDocType->mNodeList.begin(); i != mDocType->mNodeList.end();
4604 i++) {
4605 if ((*i)->nodeType() != mType)
4606 continue;
4607 l++;
4608 }
4609 return l;
4610}
4611
4612LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4613getNamedItemNS(const String& namespaceURI, const String& localName)
4614{
4615 for (std::list<LIBXML2_Node*>::iterator i = mDocType->mNodeList.begin(); i != mDocType->mNodeList.end();
4616 i++) {
4617 if ((*i)->nodeType() != mType)
4618 continue;
4619 if ((*i)->mNamespaceURI != namespaceURI)
4620 continue;
4621 if ((*i)->mLocalName != localName)
4622 continue;
4623 (*i)->add_ref();
4624 return (*i);
4625 }
4626 return NULL;
4627}
4628
4629LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4630setNamedItemNS(LIBXML2_Node* arg)
4631{
4632 ARCANE_UNUSED(arg);
4633 throw NotImplementedException(A_FUNCINFO);
4634}
4635
4636LIBXML2_Node* LIBXML2_NamedNodeMapDT::
4637removeNamedItemNS(const String& namespaceURI, const String& localName)
4638{
4639 ARCANE_UNUSED(namespaceURI);
4640 ARCANE_UNUSED(localName);
4641 throw NotImplementedException(A_FUNCINFO);
4642}
4643
4644String LIBXML2_CharacterData::
4645Data()
4646{
4647 return mNodeValue;
4648}
4649
4650void LIBXML2_CharacterData::
4651Data(const String& attr)
4652{
4653 mNodeValue = attr;
4654}
4655
4656void LIBXML2_CharacterData::
4657nodeValue(const String& attr)
4658{
4659 mNodeValue = attr;
4660}
4661
4662UInt32 LIBXML2_CharacterData::
4663length()
4664{
4665 return mNodeValue.len();
4666}
4667
4668String LIBXML2_CharacterData::
4669substringdata(UInt32 offset, UInt32 count)
4670{
4671 try {
4672 return mNodeValue.substring(offset, count);
4673 }
4674 catch (const Arcane::dom::DOMException& ex) {
4675 cerr << "** EXCEPTION " << ex.code << '\n';
4676 throw ex;
4677 }
4678}
4679
4680void LIBXML2_CharacterData::
4681appenddata(const String& arg)
4682{
4683 mNodeValue = mNodeValue + arg;
4684}
4685
4686void LIBXML2_CharacterData::
4687insertdata(UInt32 offset, const String& arg)
4688{
4689 try {
4690 String t = mNodeValue.substring(offset);
4691 mNodeValue = mNodeValue.substring(0, offset);
4692 mNodeValue = mNodeValue + arg;
4693 mNodeValue = mNodeValue + t;
4694 }
4695 catch (const Arcane::dom::DOMException& ex) {
4696 cerr << "** EXCEPTION " << ex.code << '\n';
4697 throw ex;
4698 }
4699}
4700
4701void LIBXML2_CharacterData::
4702deletedata(UInt32 offset, UInt32 count)
4703{
4704 try {
4705 String t = mNodeValue.substring(offset + count);
4706 mNodeValue = mNodeValue.substring(0, offset);
4707 mNodeValue = mNodeValue + t;
4708 }
4709 catch (const Arcane::dom::DOMException& ex) {
4710 cerr << "** EXCEPTION " << ex.code << '\n';
4711 throw ex;
4712 }
4713}
4714
4715void LIBXML2_CharacterData::
4716replacedata(UInt32 offset, UInt32 count, const String& arg)
4717{
4718 try {
4719 String t = mNodeValue.substring(offset + count);
4720 mNodeValue = mNodeValue.substring(0, offset);
4721 mNodeValue = mNodeValue + arg;
4722 mNodeValue = mNodeValue + t;
4723 }
4724 catch (const Arcane::dom::DOMException& ex) {
4725 cerr << "** EXCEPTION " << ex.code << '\n';
4726 throw ex;
4727 }
4728}
4729
4730LIBXML2_Node* LIBXML2_Attr::
4731shallowCloneNode(LIBXML2_Document* aDoc)
4732{
4733 LIBXML2_Attr* attr = new LIBXML2_Attr(aDoc);
4734 attr->mLocalName = mLocalName;
4735 attr->mNamespaceURI = mNamespaceURI;
4736 attr->mNodeName = mNodeName;
4737 attr->mNodeValue = mNodeValue;
4738 attr->mSpecified = mSpecified;
4739 return attr;
4740}
4741
4742String LIBXML2_Attr::
4743name()
4744{
4745 return mNodeName;
4746}
4747
4748bool LIBXML2_Attr::
4749specified()
4750{
4751 return mSpecified;
4752}
4753
4754String LIBXML2_Attr::
4755value()
4756{
4757 return mNodeValue;
4758}
4759
4760void LIBXML2_Attr::
4761value(const String& attr)
4762{
4763 mNodeValue = attr;
4764 mSpecified = true;
4765}
4766
4767LIBXML2_Element* LIBXML2_Attr::
4768ownerElement()
4769{
4770 LIBXML2_Element* el = dynamic_cast<LIBXML2_Element*>(mParent);
4771 if (el != NULL)
4772 el->add_ref();
4773 return el;
4774}
4775
4776LIBXML2_Element::
4777~LIBXML2_Element() {}
4778
4779LIBXML2_Node* LIBXML2_Element::
4780shallowCloneNode(LIBXML2_Document* aDoc)
4781{
4782 LIBXML2_Element* el = LIBXML2_NewElement(aDoc, mNamespaceURI, mLocalName);
4783 el->mLocalName = mLocalName;
4784 el->mNamespaceURI = mNamespaceURI;
4785 el->mNodeName = mNodeName;
4786 el->mNodeValue = mNodeValue;
4787 // Attributes get cloned too...
4788 for (std::map<QualifiedName, LIBXML2_Attr*>::iterator i = attributeMapNS.begin(); i != attributeMapNS.end();
4789 i++) {
4790 LIBXML2_Attr* at = dynamic_cast<LIBXML2_Attr*>((*i).second->shallowCloneNode(aDoc));
4791 LIBXML2_Attr* atTmp = el->setAttributeNodeNS(at);
4792 ARCANE_ASSERT(atTmp == NULL,
4793 ("InternalError in LIBXML2_Element::shallowCloneNode(). The attribute is Null !"));
4794 }
4795 return el;
4796}
4797
4798LIBXML2_NamedNodeMap* LIBXML2_Element::
4799attributes()
4800{
4801 return new LIBXML2_NamedNodeMap(this);
4802}
4803
4804bool LIBXML2_Element::
4805hasAttributes()
4806{
4807 return !attributeMap.empty();
4808}
4809
4810String LIBXML2_Element::
4811tagName()
4812{
4813 return mNodeName;
4814}
4815
4816String LIBXML2_Element::
4817getAttribute(const String& name)
4818{
4819 std::map<LocalName, LIBXML2_Attr*>::iterator i = attributeMap.find(LocalName(name));
4820 if (i == attributeMap.end())
4821 return String();
4822 return (*i).second->value();
4823}
4824
4825void LIBXML2_Element::
4826setAttribute(const String& name, const String& value)
4827{
4828 std::map<LocalName, LIBXML2_Attr*>::iterator i = attributeMap.find(LocalName(name));
4829 if (i == attributeMap.end()) {
4830 LIBXML2_Attr* a = new LIBXML2_Attr(mDocument);
4831 if (a == NULL)
4832 throw Arcane::Exception::exception();
4833 a->mNodeValue = value;
4834 a->mNodeName = name;
4835 insertBeforePrivate(a, NULL)->release_ref();
4836 attributeMapNS.insert(std::pair<QualifiedName, LIBXML2_Attr*>(QualifiedName(String(), name), a));
4837 attributeMap.insert(std::pair<LocalName, LIBXML2_Attr*>(LocalName(name), a));
4838 return;
4839 }
4840 String oldvalue = (*i).second->mNodeValue;
4841 (*i).second->mNodeValue = value;
4842}
4843
4844void LIBXML2_Element::
4845removeAttribute(const String& name)
4846{
4847 std::map<LocalName, LIBXML2_Attr*>::iterator i = attributeMap.find(LocalName(name));
4848 if (i == attributeMap.end()) {
4849 // DOM doesn't say its an error to remove a non-existant attribute.
4850 return;
4851 }
4852 // Remove the child(which sorts out the refcounting)...
4853 LIBXML2_Attr* at = (*i).second;
4854 removeChildPrivate(at)->release_ref();
4855 attributeMap.erase(i);
4856 std::map<QualifiedName, LIBXML2_Attr*>::iterator j;
4857 if (at->mLocalName != String())
4858 j = attributeMapNS.find(QualifiedName(at->mNamespaceURI, at->mLocalName));
4859 else
4860 j = attributeMapNS.find(QualifiedName(at->mNamespaceURI, at->mNodeName));
4861 attributeMapNS.erase(j);
4862}
4863
4864LIBXML2_Attr* LIBXML2_Element::
4865getAttributeNode(const String& name)
4866{
4867 std::map<LocalName, LIBXML2_Attr*>::iterator i = attributeMap.find(LocalName(name));
4868 if (i == attributeMap.end())
4869 return NULL;
4870 (*i).second->add_ref();
4871 return (*i).second;
4872}
4873
4874LIBXML2_Attr* LIBXML2_Element::
4875setAttributeNode(LIBXML2_Attr* newAttr)
4876{
4877 if (newAttr == NULL)
4878 throw Arcane::Exception::exception();
4879 String name = newAttr->name();
4880 std::map<LocalName, LIBXML2_Attr*>::iterator i = attributeMap.find(LocalName(name));
4881 std::map<QualifiedName, LIBXML2_Attr*>::iterator j = attributeMapNS.find(QualifiedName(String(), name));
4882 if (i == attributeMap.end()) {
4883 insertBeforePrivate(newAttr, NULL)->release_ref();
4884 attributeMap.insert(std::pair<LocalName, LIBXML2_Attr*>(name, newAttr));
4885 attributeMapNS.insert(std::pair<QualifiedName, LIBXML2_Attr*>(QualifiedName(String(), name), newAttr));
4886 return NULL;
4887 }
4888 LIBXML2_Attr* at = (*i).second;
4889 removeChildPrivate(at)->release_ref();
4890 attributeMap.erase(i);
4891 if (j != attributeMapNS.end()) {
4892 attributeMapNS.erase(j);
4893 }
4894 insertBeforePrivate(newAttr, NULL)->release_ref();
4895 attributeMap.insert(std::pair<LocalName, LIBXML2_Attr*>(LocalName(name), newAttr));
4896 attributeMapNS.insert(std::pair<QualifiedName, LIBXML2_Attr*>(QualifiedName(String(), name), newAttr));
4897 return at;
4898}
4899
4900LIBXML2_Attr* LIBXML2_Element::
4901removeAttributeNode(LIBXML2_Attr* oldAttr)
4902{
4903 if (oldAttr == NULL)
4904 throw Arcane::Exception::exception();
4905 String name = oldAttr->name();
4906 String lname = oldAttr->localName();
4907 String nsuri = oldAttr->namespaceURI();
4908 std::map<LocalName, LIBXML2_Attr*>::iterator i = attributeMap.find(LocalName(name));
4909 if (i == attributeMap.end()) {
4910 throw Arcane::Exception::exception();
4911 }
4912 LIBXML2_Attr* at = (*i).second;
4913 LocalName ln((*i).first);
4914 removeChildPrivate(at)->release_ref();
4915 attributeMap.erase(i);
4916
4917 std::map<QualifiedName, LIBXML2_Attr*>::iterator j = attributeMapNS.find(QualifiedName(nsuri, lname));
4918 QualifiedName qn((*j).first);
4919 attributeMapNS.erase(j);
4920 return at;
4921}
4922
4923LIBXML2_NodeList* LIBXML2_Element::
4924getElementsByTagName(const String& name)
4925{
4926 return new LIBXML2_NodeListDFSSearch(this, name);
4927}
4928
4929String LIBXML2_Element::
4930getAttributeNS(const String& namespaceURI, const String& localName)
4931{
4932 std::map<QualifiedName, LIBXML2_Attr*>::iterator i =
4933 attributeMapNS.find(QualifiedName(namespaceURI, localName));
4934 if (i == attributeMapNS.end())
4935 return String();
4936 return (*i).second->value();
4937}
4938
4939void LIBXML2_Element::
4940setAttributeNS(const String& namespaceURI, const String& qualifiedName, const String& value)
4941{
4942 const XMLCh* cqname = reinterpret_cast<const XMLCh*>(qualifiedName.utf16().begin());
4943 const XMLCh* cpos = wcschr(cqname, L':');
4944 if (cpos == NULL)
4945 cpos = cqname;
4946 else
4947 cpos++;
4948 ByteUniqueArray utf8_array(cpos[0]);
4949 String localName = String::fromUtf8(utf8_array);
4950 std::map<QualifiedName, LIBXML2_Attr*>::iterator i =
4951 attributeMapNS.find(QualifiedName(namespaceURI, localName));
4952 if (i == attributeMapNS.end()) {
4953 LIBXML2_Attr* a = new LIBXML2_Attr(mDocument);
4954 if (a == NULL)
4955 throw Arcane::Exception::exception();
4956 a->value(value);
4957 a->mNodeName = qualifiedName;
4958 a->mLocalName = localName;
4959 a->mNamespaceURI = namespaceURI;
4960 insertBeforePrivate(a, NULL)->release_ref();
4961 attributeMapNS.insert(std::pair<QualifiedName, LIBXML2_Attr*>(QualifiedName(namespaceURI, localName), a));
4962 std::map<LocalName, LIBXML2_Attr*>::iterator j = attributeMap.find(LocalName(qualifiedName));
4963 if (j != attributeMap.end()) {
4964 attributeMap.erase(j);
4965 }
4966 attributeMap.insert(std::pair<LocalName, LIBXML2_Attr*>(LocalName(qualifiedName), a));
4967 return;
4968 }
4969 String oldValue = (*i).second->mNodeValue;
4970 (*i).second->mNodeValue = value;
4971}
4972
4973void LIBXML2_Element::
4974removeAttributeNS(const String& namespaceURI, const String& localName)
4975{
4976 std::map<QualifiedName, LIBXML2_Attr*>::iterator i =
4977 attributeMapNS.find(QualifiedName(namespaceURI, localName));
4978 if (i == attributeMapNS.end()) {
4979 // DOM doesn't say its an error to remove a non-existant attribute.
4980 return;
4981 }
4982 // Remove the child(which sorts out the refcounting)...
4983 LIBXML2_Attr* at = (*i).second;
4984 removeChildPrivate(at)->release_ref();
4985 QualifiedName qn((*i).first);
4986 std::map<LocalName, LIBXML2_Attr*>::iterator j = attributeMap.find(LocalName((*i).second->mNodeName));
4987 attributeMapNS.erase(i);
4988 LocalName ln((*j).first);
4989 attributeMap.erase(j);
4990}
4991
4992LIBXML2_Attr* LIBXML2_Element::
4993getAttributeNodeNS(const String& namespaceURI, const String& localName)
4994{
4995 std::map<QualifiedName, LIBXML2_Attr*>::iterator i =
4996 attributeMapNS.find(QualifiedName(namespaceURI, localName));
4997 if (i == attributeMapNS.end())
4998 return NULL;
4999 (*i).second->add_ref();
5000 return (*i).second;
5001}
5002
5003LIBXML2_Attr* LIBXML2_Element::
5004setAttributeNodeNS(LIBXML2_Attr* newAttr)
5005{
5006 if (newAttr == NULL)
5007 throw Arcane::Exception::exception();
5008 if (newAttr->mLocalName == String())
5009 newAttr->mLocalName = newAttr->mNodeName;
5010 std::pair<String, String> p(newAttr->mNamespaceURI, newAttr->mLocalName);
5011 std::map<QualifiedName, LIBXML2_Attr*>::iterator i =
5012 attributeMapNS.find(QualifiedName(newAttr->mNamespaceURI, newAttr->mLocalName));
5013 if (i == attributeMapNS.end()) {
5014 insertBeforePrivate(newAttr, NULL)->release_ref();
5015 attributeMapNS.insert(std::pair<QualifiedName, LIBXML2_Attr*>(
5016 QualifiedName(newAttr->mNamespaceURI, newAttr->mLocalName), newAttr));
5017 attributeMap.insert(std::pair<LocalName, LIBXML2_Attr*>(LocalName(newAttr->mNodeName), newAttr));
5018 return NULL;
5019 }
5020 LIBXML2_Attr* at = (*i).second;
5021 QualifiedName qn((*i).first);
5022 removeChildPrivate(at)->release_ref();
5023 attributeMapNS.erase(i);
5024 std::map<LocalName, LIBXML2_Attr*>::iterator j = attributeMap.find(LocalName(at->mNodeName));
5025 LocalName ln((*j).first);
5026 attributeMap.erase(j);
5027 insertBeforePrivate(newAttr, NULL)->release_ref();
5028 attributeMapNS.insert(std::pair<QualifiedName, LIBXML2_Attr*>(
5029 QualifiedName(newAttr->mNamespaceURI, newAttr->mLocalName), newAttr));
5030 attributeMap.insert(std::pair<LocalName, LIBXML2_Attr*>(LocalName(at->mNodeName), newAttr));
5031 return at;
5032}
5033
5034LIBXML2_NodeList* LIBXML2_Element::
5035getElementsByTagNameNS(const String& namespaceURI, const String& localName)
5036{
5037 return new LIBXML2_NodeListDFSSearch(this, namespaceURI, localName);
5038}
5039
5040bool LIBXML2_Element::
5041hasAttribute(const String& name)
5042{
5043 return attributeMap.find(LocalName(name)) != attributeMap.end();
5044}
5045
5046bool LIBXML2_Element::
5047hasAttributeNS(const String& namespaceURI, const String& localName)
5048{
5049 return attributeMapNS.find(QualifiedName(namespaceURI, localName)) != attributeMapNS.end();
5050}
5051
5052LIBXML2_Element* LIBXML2_Element::
5053searchForElementById(const String& elementId)
5054{
5055 // XXX DOM says: 'Attributes with the name "ID" are not of type ID unless so
5056 // defined.', but we don't deal with DTDs, so we deviate from the DOM and
5057 // just assume that "id" in namespace "" is of type ID.
5058 String ourId = getAttribute("id");
5059 if (ourId == String()) {
5060 String tmp = getAttribute("xml:id");
5061 if (tmp != String())
5062 ourId = tmp;
5063 }
5064 if (ourId == elementId) {
5065 add_ref();
5066 return this;
5067 }
5068 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++) {
5069 LIBXML2_Element* e = (*i)->searchForElementById(elementId);
5070 if (e != NULL)
5071 return e;
5072 }
5073 return NULL;
5074}
5075
5076LIBXML2_Text* LIBXML2_TextBase::
5077splitText(UInt32 offset)
5078{
5079 if (mParent == NULL)
5080 throw Arcane::Exception::exception();
5081 LIBXML2_TextBase* tb = static_cast<LIBXML2_TextBase*>(shallowCloneNode(mDocument));
5082 tb->mNodeValue = mNodeValue.substring(offset);
5083 mNodeValue = mNodeValue.substring(0, offset);
5084 LIBXML2_Node* n2 = nextSibling();
5085 mParent->insertBefore(tb, n2)->release_ref();
5086 tb->add_ref();
5087 return reinterpret_cast<LIBXML2_Text*>(tb);
5088}
5089
5090LIBXML2_Text* LIBXML2_CDATASection::
5091splitText(UInt32 offset)
5092{
5093 if (mParent == NULL)
5094 throw Arcane::Exception::exception();
5095 LIBXML2_TextBase* tb = static_cast<LIBXML2_TextBase*>(shallowCloneNode(mDocument));
5096 tb->mNodeValue = mNodeValue.substring(offset);
5097 mNodeValue = mNodeValue.substring(0, offset);
5098 LIBXML2_Node* n2 = nextSibling();
5099 mParent->insertBefore(tb, n2)->release_ref();
5100 tb->add_ref();
5101 return reinterpret_cast<LIBXML2_Text*>(tb);
5102}
5103
5104LIBXML2_Node* LIBXML2_Text::
5105shallowCloneNode(LIBXML2_Document* aDoc)
5106{
5107 LIBXML2_Text* txt = new LIBXML2_Text(aDoc);
5108 if (txt == NULL)
5109 throw Arcane::Exception::exception();
5110 txt->mLocalName = mLocalName;
5111 txt->mNamespaceURI = mNamespaceURI;
5112 txt->mNodeName = mNodeName;
5113 txt->mNodeValue = mNodeValue;
5114 return txt;
5115}
5116
5117LIBXML2_Node* LIBXML2_Comment::
5118shallowCloneNode(LIBXML2_Document* aDoc)
5119{
5120 LIBXML2_Comment* com = new LIBXML2_Comment(aDoc);
5121 if (com == NULL)
5122 throw Arcane::Exception::exception();
5123 com->mLocalName = mLocalName;
5124 com->mNamespaceURI = mNamespaceURI;
5125 com->mNodeName = mNodeName;
5126 com->mNodeValue = mNodeValue;
5127 return com;
5128}
5129
5130LIBXML2_Node* LIBXML2_CDATASection::
5131shallowCloneNode(LIBXML2_Document* aDoc)
5132{
5133 LIBXML2_CDATASection* cds = new LIBXML2_CDATASection(aDoc);
5134 if (cds == NULL)
5135 throw Arcane::Exception::exception();
5136 cds->mLocalName = mLocalName;
5137 cds->mNamespaceURI = mNamespaceURI;
5138 cds->mNodeName = mNodeName;
5139 cds->mNodeValue = mNodeValue;
5140 return cds;
5141}
5142
5143LIBXML2_Node* LIBXML2_DocumentType::
5144shallowCloneNode(LIBXML2_Document* aDoc)
5145{
5146 LIBXML2_DocumentType* doctype = new LIBXML2_DocumentType(aDoc, mNodeName, mPublicId, mSystemId);
5147 if (doctype == NULL)
5148 throw Arcane::Exception::exception();
5149 doctype->mLocalName = mLocalName;
5150 doctype->mNamespaceURI = mNamespaceURI;
5151 doctype->mNodeValue = mNodeValue;
5152 return doctype;
5153}
5154
5155String LIBXML2_DocumentType::
5156name()
5157{
5158 return mNodeName;
5159}
5160
5161LIBXML2_NamedNodeMap* LIBXML2_DocumentType::
5162entities()
5163{
5164 return new LIBXML2_NamedNodeMapDT(this, LIBXML2_Node::ENTITY_NODE);
5165}
5166
5167LIBXML2_NamedNodeMap* LIBXML2_DocumentType::
5168notations()
5169{
5170 return new LIBXML2_NamedNodeMapDT(this, LIBXML2_Node::NOTATION_NODE);
5171}
5172
5173String LIBXML2_DocumentType::
5174publicId()
5175{
5176 return mPublicId;
5177}
5178
5179String LIBXML2_DocumentType::
5180systemId()
5181{
5182 return mSystemId;
5183}
5184
5185String LIBXML2_DocumentType::
5186internalSubset()
5187{
5188 // The DOM basically leaves this up to the API, and since we don't store this
5189 // information as it is irrelevant to appli, lets just skip it...
5190 return String();
5191}
5192
5193LIBXML2_Node* LIBXML2_Notation::
5194shallowCloneNode(LIBXML2_Document* aDoc)
5195{
5196 LIBXML2_Notation* nota = new LIBXML2_Notation(aDoc, mPublicId, mSystemId);
5197 if (nota == NULL)
5198 throw Arcane::Exception::exception();
5199 nota->mLocalName = mLocalName;
5200 nota->mNamespaceURI = mNamespaceURI;
5201 nota->mNodeName = mNodeName;
5202 nota->mNodeValue = mNodeValue;
5203 return nota;
5204}
5205
5206String LIBXML2_Notation::
5207publicId()
5208{
5209 return mPublicId;
5210}
5211
5212String LIBXML2_Notation::
5213systemId()
5214{
5215 return mSystemId;
5216}
5217
5218LIBXML2_Node*
5219LIBXML2_Entity::
5220shallowCloneNode(LIBXML2_Document* aDoc)
5221{
5222 LIBXML2_Entity* ent = new LIBXML2_Entity(aDoc, mPublicId, mSystemId, mNotationName);
5223 if (ent == NULL)
5224 throw Arcane::Exception::exception();
5225 ent->mLocalName = mLocalName;
5226 ent->mNamespaceURI = mNamespaceURI;
5227 ent->mNodeName = mNodeName;
5228 ent->mNodeValue = mNodeValue;
5229 return ent;
5230}
5231
5232String LIBXML2_Entity::
5233publicId()
5234{
5235 return mPublicId;
5236}
5237
5238String LIBXML2_Entity::
5239systemId()
5240{
5241 return mSystemId;
5242}
5243
5244String LIBXML2_Entity::
5245notationName()
5246{
5247 return mNotationName;
5248}
5249
5250LIBXML2_Node* LIBXML2_EntityReference::
5251shallowCloneNode(LIBXML2_Document* aDoc)
5252{
5253 LIBXML2_EntityReference* er = new LIBXML2_EntityReference(aDoc);
5254 if (er == NULL)
5255 throw Arcane::Exception::exception();
5256 er->mLocalName = mLocalName;
5257 er->mNamespaceURI = mNamespaceURI;
5258 er->mNodeName = mNodeName;
5259 er->mNodeValue = mNodeValue;
5260 return er;
5261}
5262
5263LIBXML2_Node* LIBXML2_ProcessingInstruction::
5264shallowCloneNode(LIBXML2_Document* aDoc)
5265{
5266 LIBXML2_ProcessingInstruction* pi = new LIBXML2_ProcessingInstruction(aDoc, mNodeName, mNodeValue);
5267 if (pi == NULL)
5268 throw Arcane::Exception::exception();
5269 pi->mLocalName = mLocalName;
5270 pi->mNamespaceURI = mNamespaceURI;
5271 return pi;
5272}
5273
5274String LIBXML2_ProcessingInstruction::
5275target()
5276{
5277 return mNodeName;
5278}
5279
5280String LIBXML2_ProcessingInstruction::
5281Data()
5282{
5283 return mNodeValue;
5284}
5285
5286void LIBXML2_ProcessingInstruction::
5287Data(const String& attr)
5288{
5289 mNodeValue = attr;
5290}
5291
5292LIBXML2_Node* LIBXML2_DocumentFragment::
5293shallowCloneNode(LIBXML2_Document* aDoc)
5294{
5295 LIBXML2_DocumentFragment* docfrag = new LIBXML2_DocumentFragment(aDoc);
5296 if (docfrag == NULL)
5297 throw Arcane::Exception::exception();
5298 docfrag->mLocalName = mLocalName;
5299 docfrag->mNamespaceURI = mNamespaceURI;
5300 docfrag->mNodeName = mNodeName;
5301 docfrag->mNodeValue = mNodeValue;
5302 return docfrag;
5303}
5304
5305LIBXML2_Document::
5306LIBXML2_Document(const String& namespaceURI, const String& qualifiedName,
5307 LIBXML2_DocumentType* doctype)
5308: LIBXML2_Node(this)
5309{
5310 const XMLCh* cqname = reinterpret_cast<const XMLCh*>(qualifiedName.utf16().begin());
5311 const XMLCh* cpos = wcschr(cqname, L':');
5312 if (cpos == NULL)
5313 cpos = cqname;
5314 else
5315 cpos++;
5316 ByteUniqueArray utf8_array(cpos[0]);
5317 String localName = String::fromUtf8(utf8_array);
5318
5319 // We are our own document ancestor, so fix the refcounts...
5320 mDocumentIsAncestor = true;
5321 mDocument->release_ref();
5322 if (doctype && doctype->mDocument != NULL)
5323 throw Arcane::Exception::exception();
5324 if (doctype) {
5325 doctype->mDocument = this;
5326 doctype->mDocumentIsAncestor = false;
5327 doctype->mDocument->add_ref();
5328 }
5329 if (doctype != NULL)
5330 insertBeforePrivate(doctype, NULL)->release_ref();
5331 LIBXML2_Element* docel = LIBXML2_NewElement(this, namespaceURI, localName);
5332 if (docel == NULL)
5333 throw Arcane::Exception::exception();
5334 docel->mNamespaceURI = namespaceURI;
5335 docel->mNodeName = qualifiedName;
5336 docel->mLocalName = localName;
5337 appendChild(docel)->release_ref();
5338}
5339
5340LIBXML2_Text* LIBXML2_Document::
5341doctype()
5342{
5343 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++)
5344 if ((*i)->nodeType() == LIBXML2_Node::DOCUMENT_TYPE_NODE) {
5345 LIBXML2_DocumentType* dt = static_cast<LIBXML2_DocumentType*>(*i);
5346 dt->add_ref();
5347 return dynamic_cast<LIBXML2_Text*>(dt);
5348 }
5349 return NULL;
5350}
5351
5352LIBXML2_DOMImplementation* LIBXML2_Document::
5353implementation()
5354{
5355 LIBXML2_DOMImplementation::sDOMImplementation->add_ref();
5356 return LIBXML2_DOMImplementation::sDOMImplementation;
5357}
5358
5359LIBXML2_Element* LIBXML2_Document::
5360documentElement()
5361{
5362 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++)
5363 if ((*i)->nodeType() == LIBXML2_Node::ELEMENT_NODE) {
5364 LIBXML2_Element* el = static_cast<LIBXML2_Element*>(*i);
5365 el->add_ref();
5366 return el;
5367 }
5368 return NULL;
5369}
5370
5371LIBXML2_Element* LIBXML2_Document::
5372createElement(const String& tagName)
5373{
5374 LIBXML2_Element* el = LIBXML2_NewElement(this, String(), tagName);
5375 if (el == NULL)
5376 throw Arcane::Exception::exception();
5377 el->mNodeName = tagName;
5378 return el;
5379}
5380
5381LIBXML2_DocumentFragment* LIBXML2_Document::
5382createDocumentFragment()
5383{
5384 LIBXML2_DocumentFragment* df = new LIBXML2_DocumentFragment(this);
5385 if (df == NULL)
5386 throw Arcane::Exception::exception();
5387 return df;
5388}
5389
5390LIBXML2_Text* LIBXML2_Document::
5391createTextNode(const String& data)
5392{
5393 LIBXML2_Text* tn = new LIBXML2_Text(this);
5394 if (tn == NULL)
5395 throw Arcane::Exception::exception();
5396 tn->mNodeValue = data;
5397 return tn;
5398}
5399
5400LIBXML2_Comment* LIBXML2_Document::
5401createComment(const String& data)
5402{
5403 LIBXML2_Comment* com = new LIBXML2_Comment(this);
5404 if (com == NULL)
5405 throw Arcane::Exception::exception();
5406 com->mNodeValue = data;
5407 return com;
5408}
5409
5410LIBXML2_CDATASection* LIBXML2_Document::
5411createCDATASection(const String& data)
5412{
5413 LIBXML2_CDATASection* cds = new LIBXML2_CDATASection(this);
5414 if (cds == NULL)
5415 throw Arcane::Exception::exception();
5416 cds->mNodeValue = data;
5417 return cds;
5418}
5419
5420LIBXML2_ProcessingInstruction* LIBXML2_Document::
5421createProcessingInstruction(const String& target, const String& data)
5422{
5423 return new LIBXML2_ProcessingInstruction(this, target, data);
5424}
5425
5426LIBXML2_Attr* LIBXML2_Document::
5427createAttribute(const String& name)
5428{
5429 LIBXML2_Attr* at = new LIBXML2_Attr(this);
5430 if (at == NULL)
5431 throw Arcane::Exception::exception();
5432 at->mNodeName = name;
5433 return at;
5434}
5435
5436LIBXML2_EntityReference* LIBXML2_Document::
5437createEntityReference(const String& name)
5438{
5439 LIBXML2_EntityReference* er = new LIBXML2_EntityReference(this);
5440 if (er == NULL)
5441 throw Arcane::Exception::exception();
5442 er->mNodeName = name;
5443 return er;
5444}
5445
5446LIBXML2_NodeList* LIBXML2_Document::
5447getElementsByTagName(const String& tagname)
5448{
5449 LIBXML2_NodeList* nl = new LIBXML2_NodeListDFSSearch(this, tagname);
5450 if (nl == NULL)
5451 throw Arcane::Exception::exception();
5452 return nl;
5453}
5454
5455LIBXML2_Node* LIBXML2_Document::
5456importNode(LIBXML2_Node* importedNode, bool deep)
5457{
5458 // the incoming node implements our interface but is not from this implementation.
5459 // In this case, we would have to do the clone ourselves using only
5460 // the standard interfaces.
5461 // Next we need to change the document all the way through...
5462 LIBXML2_Node* n = importedNode->cloneNode(deep);
5463 // It makes no sense to change the document associated with a document...
5464 if (n->nodeType() == LIBXML2_Node::DOCUMENT_NODE)
5465 throw Arcane::Exception::exception();
5466 n->recursivelyChangeDocument(this);
5467 n->add_ref();
5468 return n;
5469}
5470
5471LIBXML2_Element* LIBXML2_Document::
5472createElementNS(const String& namespaceURI, const String& qualifiedName)
5473{
5474 const XMLCh* cqname = reinterpret_cast<const XMLCh*>(qualifiedName.utf16().begin());
5475 const XMLCh* cpos = wcschr(cqname, L':');
5476 if (cpos == NULL)
5477 cpos = cqname;
5478 else
5479 cpos++;
5480 ByteUniqueArray utf8_array(cpos[0]);
5481 String localName = String::fromUtf8(utf8_array);
5482 LIBXML2_Element* el = LIBXML2_NewElement(this, namespaceURI, localName);
5483 el->mNamespaceURI = namespaceURI;
5484 el->mNodeName = qualifiedName;
5485 el->mLocalName = localName;
5486 return el;
5487}
5488
5489LIBXML2_Attr* LIBXML2_Document::
5490createAttributeNS(const String& namespaceURI, const String& qualifiedName)
5491{
5492 LIBXML2_Attr* at = new LIBXML2_Attr(mDocument);
5493 if (at == NULL)
5494 throw Arcane::Exception::exception();
5495 at->mNamespaceURI = namespaceURI;
5496 at->mNodeName = qualifiedName;
5497 const XMLCh* cqname = reinterpret_cast<const XMLCh*>(qualifiedName.utf16().begin());
5498 const XMLCh* cpos = wcschr(cqname, L':');
5499 if (cpos == NULL)
5500 cpos = cqname;
5501 else
5502 cpos++;
5503 ByteUniqueArray utf8_array(cpos[0]);
5504 String localName = String::fromUtf8(utf8_array);
5505 at->mLocalName = localName;
5506 return at;
5507}
5508
5509LIBXML2_NodeList* LIBXML2_Document::
5510getElementsByTagNameNS(const String& namespaceURI, const String& localName)
5511{
5512 LIBXML2_NodeListDFSSearch* nlDFSS = new LIBXML2_NodeListDFSSearch(this, namespaceURI, localName);
5513 if (nlDFSS == NULL)
5514 throw Arcane::Exception::exception();
5515 return nlDFSS;
5516}
5517
5518LIBXML2_Element* LIBXML2_Document::
5519getElementById(const String& elementId)
5520{
5521 return searchForElementById(elementId);
5522}
5523
5524LIBXML2_Node* LIBXML2_Document::
5525shallowCloneNode(LIBXML2_Document* aDoc)
5526{
5527 // TODO: regarder pourquoi aDoc n'est pas utilisé.
5528 LIBXML2_Document* Doc = new LIBXML2_Document();
5529 if (Doc == NULL)
5530 throw Arcane::Exception::exception();
5531 Doc->mLocalName = mLocalName;
5532 Doc->mNodeValue = mNodeValue;
5533 return Doc;
5534}
5535
5536LIBXML2_Element* LIBXML2_Document::
5537searchForElementById(const String& elementId)
5538{
5539 for (std::list<LIBXML2_Node*>::iterator i = mNodeList.begin(); i != mNodeList.end(); i++) {
5540 LIBXML2_Element* el = (*i)->searchForElementById(elementId);
5541 if (el != NULL)
5542 return el;
5543 }
5544 return NULL;
5545}
5546
5547// These tables were adapted from the Mozilla code.
5548static const XMLCh* kEntities[] = {
5549 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""),
5550 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""),
5551 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U("&amp;"),
5552 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""),
5553 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U("&lt;"), U(""), U("&gt;")
5554};
5555static const XMLCh* kAttrEntities[] = {
5556 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""),
5557 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""),
5558 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U("&quot;"), U(""), U(""), U(""), U("&amp;"),
5559 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""),
5560 U(""), U(""), U(""), U(""), U(""), U(""), U(""), U(""), U("&lt;"), U(""), U("&gt;")
5561};
5562
5563String
5564TranslateEntities(const String& data, bool isAttribute = false)
5565{
5566 const XMLCh* Data = reinterpret_cast<const XMLCh*>(data.utf16().begin());
5567 const XMLCh** table;
5568 ustring o;
5569 if (isAttribute)
5570 table = kAttrEntities;
5571 else
5572 table = kEntities;
5573
5574 UInt32 i, l = data.len();
5575 XMLCh c;
5576 for (i = 0; i < l; i++) {
5577 c = Data[i];
5578 if (c > 62 || (table[c][0] == 0)) {
5579 o += c;
5580 continue;
5581 }
5582 o += table[c];
5583 }
5584 const XMLCh* p = o.c_str();
5585 l = o.size();
5586 char* tp = new char[l + 1];
5587 size_t w = wcstombs(tp, p, l);
5588 if (w != l) {
5589 delete[] tp;
5590 return String();
5591 } else {
5592 tp[l] = '\0';
5593 std::string ret(tp);
5594 delete[] tp;
5595 return String(ret);
5596 }
5597}
5598
5599void LIBXML2_DOMWriter::
5600writeNode(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_Node* n, StringBuilder& appendTo)
5601{
5602 UInt16 nt = n->nodeType();
5603
5604#define NODETYPE_CODE(nt, ntn) \
5605 case LIBXML2_Node::nt##_NODE: { \
5606 LIBXML2_##ntn* t = dynamic_cast<LIBXML2_##ntn*>(n); \
5607 if (t == NULL) \
5608 throw Arcane::Exception::exception(); \
5609 DeepNode++; \
5610 write##ntn(dnc, t, appendTo); \
5611 } break;
5612
5613 switch (nt) {
5614 NODETYPE_CODE(ELEMENT, Element)
5615 NODETYPE_CODE(ATTRIBUTE, Attr)
5616 NODETYPE_CODE(TEXT, Text)
5617 NODETYPE_CODE(CDATA_SECTION, CDATASection)
5618 NODETYPE_CODE(ENTITY_REFERENCE, EntityReference)
5619 NODETYPE_CODE(ENTITY, Entity)
5620 NODETYPE_CODE(PROCESSING_INSTRUCTION, ProcessingInstruction)
5621 NODETYPE_CODE(COMMENT, Comment)
5622 NODETYPE_CODE(DOCUMENT, Document)
5623 NODETYPE_CODE(DOCUMENT_TYPE, DocumentType)
5624 NODETYPE_CODE(DOCUMENT_FRAGMENT, DocumentFragment)
5625 NODETYPE_CODE(NOTATION, Notation)
5626 }
5627}
5628
5631{
5633 int limite = 0;
5634 bool check = (DeepNode >= 1);
5635 if ((indent) && check) {
5636 if (!appendTo.toString().endsWith("\n")){ // try to find last CR if exist 3 = 2 bytes for CR in unicode + 1
5637 appendTo += "\n"; // adds CR;
5638 }
5639 if (StartEnd)
5640 limite = 1;
5641 else
5642 limite = 2;
5643 for ( int i = 0; i + limite < DeepNode; i++)
5644 appendTo += " "; // Space;
5645 }
5646}
5647
5651{
5653 // Firstly scan for xmlns attributes...
5654 LIBXML2_NamedNodeMap* elnl = el->attributes();
5655 UInt32 l = elnl->length(), i;
5656
5657 // See if this element has a prefix...
5658 String elpr = el->prefix();
5659 String elns = el->namespaceURI();
5660 if (elpr != String()) {
5661 // See if it is already defined...
5662 String existns = elementContext.findNamespaceForPrefix(elpr);
5663 if (existns == String()) {
5664 // They suggested a prefix, and it is available. Add it.
5665 elementContext.recordPrefix(elpr, elns);
5666 } else if (existns != elns) {
5667 // Can't use the suggested prefix. Do we need a prefix anyway?
5668 if (elementContext.getDefaultNamespace() == elns)
5669 elpr = String();
5670 else {
5671 elpr = elementContext.findPrefixForNamespace(elns);
5672 if (elpr == String()) {
5673 // Can't use any existing prefix. Set the default namespace instead.
5674 elementContext.setDefaultNamespace(elns);
5675 }
5676 // otherwise, don't need to do anything as elpr is now suitably defined.
5677 }
5678 }
5679 // otherwise don't need to do anything, as prefix is already valid.
5680 } else {
5681 // Only do anything if the namespace is non-default...
5682 if (elementContext.getDefaultNamespace() != elns) {
5683 // We have an element in the non-default namespace, with no suggested
5684 // prefix. See if there is an existing prefix for the namespace...
5685 elpr = elementContext.findPrefixForNamespace(elns);
5686 if (elpr == String()) {
5687 // Set the default namespace to the one used for this element.
5688 elementContext.setDefaultNamespace(elns);
5689 }
5690 // otherwise, elpr is valid.
5691 }
5692 // otherwise elpr=String() and the element is in the default namespace.
5693 }
5694
5695 // Start the tag...
5696 DoIndentation(true, appendTo);
5697 appendTo += "<";
5699
5700 qname += elpr;
5701 if (elpr != String())
5702 qname += ":";
5703 String ln = el->localName();
5704 if (ln == String())
5705 ln = el->nodeName();
5706 qname += ln;
5707 appendTo += qname;
5708 for (i = 0; i < l; i++) {
5709 LIBXML2_Node* atn = elnl->item(i);
5710 if (atn == NULL)
5711 break;
5712 LIBXML2_Attr* at = dynamic_cast<LIBXML2_Attr*>(atn);
5713 // See if the attribute is in the XMLNS namespace...
5714 String nsURI = at->namespaceURI();
5715 String ln = at->localName(); // CHECK (hide previous ln variable)
5716 if (ln == String())
5717 ln = at->nodeName();
5718 if (nsURI == "http://www.w3.org/2000/xmlns/" ||
5719 /* This is tecnically incorrect but needed in practice... */
5720 (nsURI == String() && ln == "xmlns")) {
5721 String value = at->value();
5722 if (ln == "xmlns")
5723 elementContext.setDefaultNamespace(value);
5724 else
5725 elementContext.recordPrefix(ln, value);
5726 }
5727 }
5728 for (i = 0; i < l; i++) {
5729 LIBXML2_Node* atn = elnl->item(i);
5730 if (atn == NULL)
5731 break;
5732 LIBXML2_Attr* at = dynamic_cast<LIBXML2_Attr*>(atn);
5733 // See if the attribute is in the XMLNS namespace...
5734 String nsURI = at->namespaceURI();
5735 ln = at->localName();
5736 if (ln == String())
5737 ln = at->nodeName();
5738 if (nsURI == "http://www.w3.org/2000/xmlns/")
5739 continue;
5740 /* This is tecnically incorrect but needed in practice... */
5741 if (nsURI == String() && ln == "xmlns")
5742 continue;
5743 // If the attribute has a prefix, see if it is defined...
5744 String atpr = at->prefix();
5745 String atns = at->namespaceURI();
5746 // If no namespace(like most attributes will probably have) do nothing...
5747 if (atns == String())
5748 continue;
5749 if (atpr != String()) {
5750 String existpr = elementContext.findNamespaceForPrefix(atpr);
5751 if (existpr == String()) {
5752 // They suggested a prefix, and it is available, so use it...
5753 elementContext.recordPrefix(atpr, atns);
5754 } else if (existpr != atns) {
5755 // Can't use the desired prefix, so see if we can find another suitable
5756 // prefix...
5757 atpr = elementContext.findPrefixForNamespace(atns);
5758 if (atpr == String())
5759 elementContext.possiblyInventPrefix(atns);
5760 }
5761 // otherwise the prefix is correct and already defined.
5762 } else // no suggested prefix.
5763 {
5764 // if can't find a suitable prefix, invent one...
5765 atpr = elementContext.findPrefixForNamespace(atns);
5766 if (atpr == String())
5767 elementContext.possiblyInventPrefix(atns);
5768 }
5769 }
5770 elementContext.resolveOrInventPrefixes();
5771 elementContext.writeXMLNS(appendTo);
5772 // Now once more through the attributes...
5773 for (i = 0; i < l; i++) {
5774 LIBXML2_Node* atn = elnl->item(i);
5775 if (atn == NULL)
5776 break;
5777 LIBXML2_Attr* at = dynamic_cast<LIBXML2_Attr*>(atn);
5778 // See if the attribute is in the XMLNS namespace...
5779 String nsURI = at->namespaceURI();
5780 String ln = at->localName();
5781 if (ln == String())
5782 ln = at->nodeName();
5783 if (nsURI == "http://www.w3.org/2000/xmlns/")
5784 continue;
5785 /* This is tecnically incorrect but needed in practice... */
5786 if (nsURI == String() && ln == "xmlns")
5787 continue;
5788 // Write out this attribute...
5789 writeAttr(&elementContext, at, appendTo);
5790 }
5791 LIBXML2_NodeList* elcnl = el->childNodes();
5792 l = elcnl->length();
5793 if (l == 0) {
5794 appendTo += "/>";
5795 return;
5796 }
5797 appendTo += ">";
5798
5799 // This time, we write everything except the attributes...
5800 for (i = 0; i < l; i++) {
5801 LIBXML2_Node* n = elcnl->item(i);
5802 if (n == NULL)
5803 break;
5804 // Gdome doesn't put attributes on child nodes. I'm not sure if this is the
5805 // correct interpretation of the DOM specification.
5806 // LIBXML2_Attr* at = dynamic_cast<LIBXML2_Attr*> (n);
5807 // if (at != NULL)
5808 // continue;
5809 writeNode(&elementContext, n, appendTo);
5810 DeepNode--;
5811 }
5812 appendTo += "</" + qname + ">";
5814 DoIndentation(false, appendTo);
5815}
5816
5817void LIBXML2_DOMWriter::
5819{
5820 // Always put a space first...
5821 appendTo += " ";
5822 // Next, we might need a prefix.
5823 String atpr = at->prefix();
5824 String atns = at->namespaceURI();
5825 // If no namespace(like most attributes will probably have) use empty prefix.
5826 if (atns == String())
5827 atpr = String();
5828 else if (atpr != String()) {
5829 String existpr = dnc->findNamespaceForPrefix(atpr);
5830 if (existpr != atns) {
5831 atpr = dnc->findPrefixForNamespace(atpr);
5832 }
5833 // otherwise we use the specified prefix.
5834 } else
5835 atpr = dnc->findPrefixForNamespace(atns);
5836 if (atpr != String()) {
5837 appendTo += atpr;
5838 appendTo += ":";
5839 }
5840 String ln = at->localName();
5841 if (ln == String())
5842 ln = at->nodeName();
5843 appendTo += ln;
5844 appendTo += "=\"";
5845 appendTo += TranslateEntities(at->value(), true);
5846 appendTo += "\"";
5847}
5848
5849void LIBXML2_DOMWriter::
5850writeText(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_Text* txt, StringBuilder& appendTo)
5851{
5852 //TODO: Regarder pourquoi dnc n'est pas utilisé
5853 appendTo += TranslateEntities(txt->Data());
5854}
5855
5856void LIBXML2_DOMWriter::
5857writeCDATASection(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_CDATASection* cds,
5858 StringBuilder& appendTo)
5859{
5860 //TODO: Regarder pourquoi dnc n'est pas utilisé
5861 appendTo += "<![CDATA[";
5862 appendTo += cds->Data();
5863 appendTo += "]]>";
5864 appendTo += "\n";
5865}
5866
5867void LIBXML2_DOMWriter::
5868writeEntity(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_Entity* er, StringBuilder& appendTo)
5869{
5870 ARCANE_UNUSED(dnc);
5871 ARCANE_UNUSED(er);
5872 ARCANE_UNUSED(appendTo);
5873 throw NotImplementedException(A_FUNCINFO);
5874}
5875
5876void LIBXML2_DOMWriter::
5877writeEntityReference(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_EntityReference* er,
5878 StringBuilder& appendTo)
5879{
5880 ARCANE_UNUSED(dnc);
5881 ARCANE_UNUSED(er);
5882 ARCANE_UNUSED(appendTo);
5883 throw NotImplementedException(A_FUNCINFO);
5884}
5885
5886void LIBXML2_DOMWriter::
5887writeProcessingInstruction(LIBXML2_DOMNamespaceContext* dnc,
5888 LIBXML2_ProcessingInstruction* proci, StringBuilder& appendTo)
5889{
5890 appendTo += "<?";
5891 appendTo += proci->target();
5892 String data = proci->Data();
5893 if (data.len()) {
5894 appendTo += " " + data;
5895 }
5896 appendTo += "?>";
5897 appendTo += "\n";
5898}
5899
5900void LIBXML2_DOMWriter::
5901writeComment(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_Comment* comment,
5902 StringBuilder& appendTo)
5903{
5904 appendTo += "<!--";
5905 appendTo += comment->Data();
5906 appendTo += "-->";
5907 appendTo += "\n";
5908}
5909
5910void LIBXML2_DOMWriter::
5911writeDocument(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_Document* doc,
5912 StringBuilder& appendTo)
5913{
5914 // Firstly write the header...
5915 appendTo = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
5916 if (indent)
5917 appendTo += "\n";
5918 LIBXML2_NodeList* elnl = doc->childNodes();
5919 UInt32 l = elnl->length(), i;
5920 for (i = 0; i < l; i++) {
5921 LIBXML2_Node* n = elnl->item(i);
5922 if (n == NULL)
5923 break;
5924 writeNode(dnc, n, appendTo);
5925 }
5926}
5927
5928void LIBXML2_DOMWriter::
5929writeDocumentType(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_DocumentType* dt,
5930 StringBuilder& appendTo)
5931{
5932 ARCANE_UNUSED(dnc);
5933 ARCANE_UNUSED(dt);
5934 ARCANE_UNUSED(appendTo);
5935 throw NotImplementedException(A_FUNCINFO);
5936}
5937
5938void LIBXML2_DOMWriter::
5939writeDocumentFragment(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_DocumentFragment* df,
5940 StringBuilder& appendTo)
5941{
5942 LIBXML2_NodeList* elnl = df->childNodes();
5943 UInt32 l = elnl->length(), i;
5944 for (i = 0; i < l; i++) {
5945 LIBXML2_Node* n = elnl->item(i);
5946 if (n == NULL)
5947 break;
5948 writeNode(dnc, n, appendTo);
5949 }
5950}
5951
5952void LIBXML2_DOMWriter::
5953writeNotation(LIBXML2_DOMNamespaceContext* dnc, LIBXML2_Notation* nt,
5954 StringBuilder& appendTo)
5955{
5956 ARCANE_UNUSED(dnc);
5957 ARCANE_UNUSED(nt);
5958 ARCANE_UNUSED(appendTo);
5959 throw NotImplementedException(A_FUNCINFO);
5960}
5961
5962LIBXML2_DOMNamespaceContext::
5963LIBXML2_DOMNamespaceContext(LIBXML2_DOMNamespaceContext* aParent)
5964: mParent(aParent)
5965, mOverrideDefaultNamespace(false)
5966{}
5967
5968void LIBXML2_DOMNamespaceContext::
5969setDefaultNamespace(const String& newNS)
5970{
5971 if (!mOverrideDefaultNamespace) {
5972 mOverrideDefaultNamespace = true;
5973 mDefaultNamespace = newNS;
5974 }
5975}
5976
5977String LIBXML2_DOMNamespaceContext::
5978getDefaultNamespace()
5979{
5980 if (mOverrideDefaultNamespace)
5981 return mDefaultNamespace;
5982 if (mParent == NULL)
5983 return String();
5984 return mParent->getDefaultNamespace();
5985}
5986
5987String LIBXML2_DOMNamespaceContext::
5988findNamespaceForPrefix(const String& prefix)
5989{
5990 std::map<String, String>::iterator i;
5991 i = mURIfromPrefix.find(prefix);
5992 if (i != mURIfromPrefix.end())
5993 return (*i).second;
5994 if (mParent == NULL)
5995 return String();
5996 return mParent->findNamespaceForPrefix(prefix);
5997}
5998
5999String LIBXML2_DOMNamespaceContext::
6000findPrefixForNamespace(const String& ns)
6001{
6002 std::map<String, String>::iterator i;
6003 i = mPrefixfromURI.find(ns);
6004 if (i != mPrefixfromURI.end())
6005 return (*i).second;
6006 if (mParent == NULL) {
6007 // Some prefixes are built in...
6008 if (ns == "http://www.w3.org/XML/1998/namespace")
6009 return "xml";
6010 return String();
6011 }
6012 return mParent->findPrefixForNamespace(ns);
6013}
6014
6015void LIBXML2_DOMNamespaceContext::
6016recordPrefix(const String& prefix, const String& ns)
6017{
6018 mURIfromPrefix.insert(std::pair<String, String>(prefix, ns));
6019 mPrefixfromURI.insert(std::pair<String, String>(ns, prefix));
6020}
6021
6022void LIBXML2_DOMNamespaceContext::
6023possiblyInventPrefix(const String& prefix)
6024{
6025 mNamespacesNeedingPrefixes.push_back(prefix);
6026}
6027
6028void LIBXML2_DOMNamespaceContext::
6029resolveOrInventPrefixes()
6030{
6031 while (!mNamespacesNeedingPrefixes.empty()) {
6032 String nnp = mNamespacesNeedingPrefixes.back();
6033 mNamespacesNeedingPrefixes.pop_back();
6034 // If nnp resolves, we are done...
6035 if (findPrefixForNamespace(nnp) != String())
6036 continue;
6037 String suggestion;
6038 // We now need to invent a name. If we see a well-known namespace, we try
6039 // to use a common prefix first.
6040 if (nnp == "http://www.w3.org/1999/xlink")
6041 suggestion = "xlink";
6042 else if (nnp == "http://www.w3.org/1999/xhtml")
6043 suggestion = "html";
6044 else
6045 suggestion = "ns";
6046 StringBuilder attempt = suggestion;
6047 UInt32 attemptCount = 0;
6048 while (findPrefixForNamespace(attempt) != String()) {
6049 attempt = suggestion;
6050 String buf = String::format("{0}", attemptCount++);
6051 attempt += buf;
6052 }
6053 // We found an unique prefix...
6054 recordPrefix(attempt, nnp);
6055 }
6056}
6057
6058void LIBXML2_DOMNamespaceContext::
6059writeXMLNS(StringBuilder& appendTo)
6060{
6061 std::map<String, String>::iterator i;
6062 // If we have changed our default prefix, set that here...
6063 if (mOverrideDefaultNamespace) {
6064 appendTo += " xmlns=\"" + TranslateEntities(mDefaultNamespace) + "\"";
6065 }
6066 for (i = mURIfromPrefix.begin(); i != mURIfromPrefix.end(); i++) {
6067 const String prefix = (*i).first;
6068 if (prefix == "xml")
6069 continue;
6070 appendTo += " xmlns:" + prefix + "=\"" + TranslateEntities((*i).second, true) + "\"";
6071 }
6072}
6073
6074LIBXML2_Node*
6075WrapXML2Node(LIBXML2_Document* doc, xmlNode* x2node)
6076{
6077 LIBXML2_Document* docR;
6078 LIBXML2_Node* n;
6079 StringBuilder localname, namespaceURI;
6080
6081 if (x2node->name != NULL) {
6082 localname = reinterpret_cast<const char*>(x2node->name);
6083 }
6084 bool setNS = false;
6085 bool isNodeStructure = false;
6086 switch (x2node->type) {
6087 case XML_ELEMENT_NODE: {
6088 setNS = true;
6089 if (x2node->ns && x2node->ns->href) {
6090 namespaceURI += reinterpret_cast<const char*>(x2node->ns->href);
6091 }
6092 isNodeStructure = true;
6093 LIBXML2_Element* el = LIBXML2_NewElement(doc, namespaceURI, localname);
6094 if (el == NULL)
6095 throw Arcane::Exception::exception();
6096 n = el;
6097 for (xmlAttr* at = x2node->properties; at != NULL; at = at->next) {
6098 LIBXML2_Attr* cattr = new LIBXML2_Attr(doc);
6099 if (cattr == NULL)
6100 throw Arcane::Exception::exception();
6101 String nsURI, prefix, localname;
6102 if (at->ns && at->ns->href) {
6103 nsURI = reinterpret_cast<const char*>(at->ns->href);
6104 prefix = reinterpret_cast<const char*>(at->ns->prefix);
6105 }
6106 localname = reinterpret_cast<const char*>(at->name);
6107
6108 cattr->mLocalName = localname;
6109 if (prefix != String())
6110 cattr->mNodeName = prefix + ":" + localname;
6111 else
6112 cattr->mNodeName = localname;
6113 cattr->mNamespaceURI = nsURI;
6114 xmlNode* tmp;
6115 for (tmp = at->children; tmp != NULL; tmp = tmp->next) {
6116 LIBXML2_Node* nw = WrapXML2Node(doc, tmp);
6117 if (nw != NULL)
6118 cattr->appendChild(nw)->release_ref();
6119 }
6120 // Finally, fetch the value as a single string...
6121 if (at->ns != NULL && at->ns->href != NULL)
6122 cattr->mNodeValue = reinterpret_cast<const char*>(xmlGetNsProp(at->parent, at->name, at->ns->href));
6123 else
6124 cattr->mNodeValue = reinterpret_cast<const char*>(xmlGetNoNsProp(at->parent, at->name));
6125 el->attributeMapNS.insert(std::pair<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>(
6126 LIBXML2_Element::QualifiedName(nsURI, localname), cattr));
6127 el->attributeMap.insert(std::pair<LIBXML2_Element::LocalName, LIBXML2_Attr*>(
6128 LIBXML2_Element::LocalName(cattr->mNodeName), cattr));
6129 el->insertBeforePrivate(cattr, NULL)->release_ref();
6130 }
6131
6132 for (xmlNs* nsd = x2node->nsDef; nsd != NULL; nsd = nsd->next) {
6133 LIBXML2_Attr* cattr = new LIBXML2_Attr(doc);
6134 if (cattr == NULL)
6135 throw Arcane::Exception::exception();
6136 StringBuilder nsURI, prefix, localname;
6137 if (nsd->prefix && strcmp(reinterpret_cast<const char*>(nsd->prefix), "")) {
6138 nsURI += "http://www.w3.org/2000/xmlns/";
6139 prefix += "xmlns";
6140 localname += reinterpret_cast<const char*>(nsd->prefix);
6141 } else
6142 localname += "xmlns";
6143 cattr->mLocalName = localname;
6144 if (prefix != String()) {
6145 prefix += ":" + localname;
6146 cattr->mNodeName = prefix;
6147 } else
6148 cattr->mNodeName = localname;
6149 cattr->mNamespaceURI = nsURI;
6150
6151 cattr->mNodeValue = reinterpret_cast<const char*>(nsd->href);
6152 el->attributeMapNS.insert(std::pair<LIBXML2_Element::QualifiedName, LIBXML2_Attr*>(
6153 LIBXML2_Element::QualifiedName(nsURI, localname), cattr));
6154 el->attributeMap.insert(std::pair<LIBXML2_Element::LocalName, LIBXML2_Attr*>(
6155 LIBXML2_Element::LocalName(cattr->mNodeName), cattr));
6156 el->insertBeforePrivate(cattr, NULL)->release_ref();
6157 }
6158 } break;
6159 case XML_TEXT_NODE: {
6160 isNodeStructure = true;
6161 n = new LIBXML2_Text(doc);
6162 if (n == NULL)
6163 throw Arcane::Exception::exception();
6164 } break;
6165 case XML_CDATA_SECTION_NODE: {
6166 isNodeStructure = true;
6167 n = new LIBXML2_CDATASection(doc);
6168 if (n == NULL)
6169 throw Arcane::Exception::exception();
6170 } break;
6171 case XML_ENTITY_REF_NODE: {
6172 isNodeStructure = true;
6173 n = new LIBXML2_EntityReference(doc);
6174 if (n == NULL)
6175 throw Arcane::Exception::exception();
6176 } break;
6177 case XML_ENTITY_NODE: {
6178 String notName, pubID, sysID;
6179 xmlEntity* se = reinterpret_cast<xmlEntity*>(x2node);
6180 notName = reinterpret_cast<const char*>(se->name);
6181 pubID = reinterpret_cast<const char*>(se->ExternalID);
6182 sysID = reinterpret_cast<const char*>(se->SystemID);
6183 n = new LIBXML2_Entity(doc, pubID, sysID, notName);
6184 if (n == NULL)
6185 throw Arcane::Exception::exception();
6186 } break;
6187 case XML_PI_NODE: {
6188 isNodeStructure = true;
6189 n = new LIBXML2_ProcessingInstruction(doc, String(), String());
6190 if (n == NULL)
6191 throw Arcane::Exception::exception();
6192 } break;
6193 case XML_COMMENT_NODE: {
6194 isNodeStructure = true;
6195 n = new LIBXML2_Comment(doc);
6196 if (n == NULL)
6197 throw Arcane::Exception::exception();
6198 } break;
6199 case XML_DOCUMENT_NODE:
6200#ifdef XML_DOCB_DOCUMENT_NODE
6201 case XML_DOCB_DOCUMENT_NODE:
6202#endif
6203#ifdef XML_HTML_DOCUMENT_NODE
6204 case XML_HTML_DOCUMENT_NODE:
6205#endif
6206 {
6207 // We need to decide what type of document before we add the children to
6208 // so do a preliminary scan...
6209 String rootNS;
6210 for (xmlNode* tnode = x2node->children; tnode; tnode = tnode->next) {
6211 if (tnode->type != XML_ELEMENT_NODE)
6212 continue;
6213 if (tnode->ns == NULL || tnode->ns->href == NULL)
6214 break;
6215 rootNS = reinterpret_cast<const char*>(tnode->ns->href);
6216 break;
6217 }
6218 docR = LIBXML2_NewDocument(rootNS);
6219 doc = docR;
6220 xmlDoc* sd = reinterpret_cast<xmlDoc*>(x2node);
6221 xmlDtd* dt = sd->intSubset;
6222 if (dt != NULL) {
6223 LIBXML2_Node* dtwrap = WrapXML2Node(doc, reinterpret_cast<xmlNode*>(dt));
6224 if (dtwrap != NULL)
6225 doc->insertBeforePrivate(dtwrap, NULL)->release_ref();
6226 }
6227 n = doc;
6228 } break;
6229 case XML_DOCUMENT_TYPE_NODE: {
6230 String pubID, sysID;
6231 xmlDtd* dt = reinterpret_cast<xmlDtd*>(x2node);
6232 pubID = reinterpret_cast<const char*>(dt->ExternalID);
6233 sysID = reinterpret_cast<const char*>(dt->SystemID);
6234 n = new LIBXML2_DocumentType(doc, localname, pubID, sysID);
6235 if (n == NULL)
6236 throw Arcane::Exception::exception();
6237 } break;
6238 case XML_DOCUMENT_FRAG_NODE: {
6239 isNodeStructure = true;
6240 n = new LIBXML2_DocumentFragment(doc);
6241 if (n == NULL)
6242 throw Arcane::Exception::exception();
6243 } break;
6244 // Handled as part of element...
6245 case XML_ATTRIBUTE_NODE:
6246 // Handled as part of document type...
6247 case XML_NOTATION_NODE:
6248 // The remaining types are not part of the standard DOM...
6249 default:
6250 return NULL;
6251 }
6252 if (isNodeStructure) {
6253 if (!setNS) {
6254 if (x2node->ns && x2node->ns->href) {
6255 namespaceURI = reinterpret_cast<const char*>(x2node->ns->href);
6256 }
6257 }
6258 n->mLocalName = localname;
6259 if (x2node->ns && x2node->ns->href) {
6260 n->mNamespaceURI = namespaceURI;
6261 }
6262 if (x2node->ns && x2node->ns->prefix) {
6263 StringBuilder prefix;
6264 prefix = reinterpret_cast<const char*>(x2node->ns->prefix);
6265 prefix += ":" + localname;
6266 n->mNodeName = prefix;
6267 } else
6268 n->mNodeName = localname;
6269 if (x2node->content) {
6270 n->mNodeValue = reinterpret_cast<const char*>(x2node->content);
6271 }
6272 }
6273 // Now visit children...
6274 x2node = x2node->children;
6275 while (x2node) {
6276 LIBXML2_Node* wn = WrapXML2Node(doc, x2node);
6277 if (wn != NULL)
6278 n->insertBeforePrivate(wn, NULL)->release_ref();
6279 x2node = x2node->next;
6280 }
6281 n->add_ref();
6282 return n;
6283}
6284
6285void LIBXML2_DOMImplementation::
6286ProcessContextError(String& aErrorMessage, xmlParserCtxtPtr ctxt)
6287{
6288 xmlErrorPtr err = xmlCtxtGetLastError(ctxt);
6289 if (err == NULL) {
6290 xmlFreeParserCtxt(ctxt);
6291 aErrorMessage = "Could not fetch the error message.";
6292 return;
6293 }
6294 ProcessXMLError(aErrorMessage, err);
6295 xmlFreeParserCtxt(ctxt);
6296}
6297
6298void LIBXML2_DOMImplementation::
6299ProcessXMLError(String& aErrorMessage, xmlError* err)
6300{
6301 String fname, msg;
6302 String buf;
6303 if (err->file) {
6304 fname = reinterpret_cast<const char*>(err->file);
6305 }
6306 if (err->message) {
6307 msg = reinterpret_cast<const char*>(err->message);
6308 }
6309
6310 switch (err->code) {
6311 case XML_ERR_INTERNAL_ERROR:
6312 aErrorMessage = "internalerror";
6313 break;
6314 case XML_ERR_NO_MEMORY:
6315 aErrorMessage = "nomemory";
6316 break;
6317 case XML_ERR_DOCUMENT_START:
6318 case XML_ERR_DOCUMENT_EMPTY:
6319 case XML_ERR_DOCUMENT_END:
6320 case XML_ERR_INVALID_HEX_CHARREF:
6321 case XML_ERR_INVALID_DEC_CHARREF:
6322 case XML_ERR_INVALID_CHARREF:
6323 case XML_ERR_INVALID_CHAR:
6324 case XML_ERR_CHARREF_AT_EOF:
6325 case XML_ERR_CHARREF_IN_PROLOG:
6326 case XML_ERR_CHARREF_IN_EPILOG:
6327 case XML_ERR_CHARREF_IN_DTD:
6328 case XML_ERR_ENTITYREF_AT_EOF:
6329 case XML_ERR_ENTITYREF_IN_PROLOG:
6330 case XML_ERR_ENTITYREF_IN_EPILOG:
6331 case XML_ERR_ENTITYREF_IN_DTD:
6332 case XML_ERR_PEREF_AT_EOF:
6333 case XML_ERR_PEREF_IN_PROLOG:
6334 case XML_ERR_PEREF_IN_EPILOG:
6335 case XML_ERR_PEREF_IN_INT_SUBSET:
6336 case XML_ERR_ENTITYREF_NO_NAME:
6337 case XML_ERR_ENTITYREF_SEMICOL_MISSING:
6338 case XML_ERR_PEREF_NO_NAME:
6339 case XML_ERR_PEREF_SEMICOL_MISSING:
6340 case XML_ERR_UNDECLARED_ENTITY:
6341 case XML_WAR_UNDECLARED_ENTITY:
6342 case XML_ERR_UNPARSED_ENTITY:
6343 case XML_ERR_ENTITY_IS_EXTERNAL:
6344 case XML_ERR_ENTITY_IS_PARAMETER:
6345 case XML_ERR_UNKNOWN_ENCODING:
6346 case XML_ERR_UNSUPPORTED_ENCODING:
6347 case XML_ERR_STRING_NOT_STARTED:
6348 case XML_ERR_STRING_NOT_CLOSED:
6349 case XML_ERR_NS_DECL_ERROR:
6350 case XML_ERR_ENTITY_NOT_STARTED:
6351 case XML_ERR_ENTITY_NOT_FINISHED:
6352 case XML_ERR_LT_IN_ATTRIBUTE:
6353 case XML_ERR_ATTRIBUTE_NOT_STARTED:
6354 case XML_ERR_ATTRIBUTE_NOT_FINISHED:
6355 case XML_ERR_ATTRIBUTE_WITHOUT_VALUE:
6356 case XML_ERR_ATTRIBUTE_REDEFINED:
6357 case XML_ERR_LITERAL_NOT_STARTED:
6358 case XML_ERR_LITERAL_NOT_FINISHED:
6359 case XML_ERR_COMMENT_NOT_FINISHED:
6360 case XML_ERR_PI_NOT_STARTED:
6361 case XML_ERR_PI_NOT_FINISHED:
6362 case XML_ERR_NOTATION_NOT_STARTED:
6363 case XML_ERR_NOTATION_NOT_FINISHED:
6364 case XML_ERR_ATTLIST_NOT_STARTED:
6365 case XML_ERR_ATTLIST_NOT_FINISHED:
6366 case XML_ERR_MIXED_NOT_STARTED:
6367 case XML_ERR_MIXED_NOT_FINISHED:
6368 case XML_ERR_ELEMCONTENT_NOT_STARTED:
6369 case XML_ERR_ELEMCONTENT_NOT_FINISHED:
6370 case XML_ERR_XMLDECL_NOT_STARTED:
6371 case XML_ERR_XMLDECL_NOT_FINISHED:
6372 case XML_ERR_CONDSEC_NOT_STARTED:
6373 case XML_ERR_CONDSEC_NOT_FINISHED:
6374 case XML_ERR_EXT_SUBSET_NOT_FINISHED:
6375 case XML_ERR_DOCTYPE_NOT_FINISHED:
6376 case XML_ERR_MISPLACED_CDATA_END:
6377 case XML_ERR_CDATA_NOT_FINISHED:
6378 case XML_ERR_RESERVED_XML_NAME:
6379 case XML_ERR_SPACE_REQUIRED:
6380 case XML_ERR_SEPARATOR_REQUIRED:
6381 case XML_ERR_NMTOKEN_REQUIRED:
6382 case XML_ERR_NAME_REQUIRED:
6383 case XML_ERR_PCDATA_REQUIRED:
6384 case XML_ERR_URI_REQUIRED:
6385 case XML_ERR_PUBID_REQUIRED:
6386 case XML_ERR_LT_REQUIRED:
6387 case XML_ERR_GT_REQUIRED:
6388 case XML_ERR_LTSLASH_REQUIRED:
6389 case XML_ERR_EQUAL_REQUIRED:
6390 case XML_ERR_TAG_NAME_MISMATCH:
6391 case XML_ERR_TAG_NOT_FINISHED:
6392 case XML_ERR_STANDALONE_VALUE:
6393 case XML_ERR_ENCODING_NAME:
6394 case XML_ERR_HYPHEN_IN_COMMENT:
6395 case XML_ERR_INVALID_ENCODING:
6396 case XML_ERR_EXT_ENTITY_STANDALONE:
6397 case XML_ERR_CONDSEC_INVALID:
6398 case XML_ERR_VALUE_REQUIRED:
6399 case XML_ERR_NOT_WELL_BALANCED:
6400 case XML_ERR_EXTRA_CONTENT:
6401 case XML_ERR_ENTITY_CHAR_ERROR:
6402 case XML_ERR_ENTITY_PE_INTERNAL:
6403 case XML_ERR_ENTITY_LOOP:
6404 case XML_ERR_ENTITY_BOUNDARY:
6405#if LIBXML_VERSION > 20403
6406 case XML_WAR_CATALOG_PI:
6407#endif
6408#if LIBXML_VERSION > 20404
6409 case XML_ERR_NO_DTD:
6410#endif
6411 case XML_ERR_CONDSEC_INVALID_KEYWORD:
6412 case XML_ERR_VERSION_MISSING:
6413 case XML_WAR_UNKNOWN_VERSION:
6414 case XML_WAR_LANG_VALUE:
6415 case XML_WAR_NS_URI:
6416 case XML_WAR_NS_URI_RELATIVE:
6417 case XML_ERR_MISSING_ENCODING:
6418#if LIBXML_VERSION > 20616
6419 case XML_WAR_SPACE_VALUE:
6420 case XML_ERR_NOT_STANDALONE:
6421 case XML_ERR_ENTITY_PROCESSING:
6422 case XML_ERR_NOTATION_PROCESSING:
6423 case XML_WAR_NS_COLUMN:
6424 case XML_WAR_ENTITY_REDEFINED:
6425 // case XML_NS_ERR_XML:
6426#if LIBXML_VERSION > 20600
6427 case XML_NS_ERR_UNDEFINED_NAMESPACE:
6428 case XML_NS_ERR_QNAME:
6429 case XML_NS_ERR_ATTRIBUTE_REDEFINED:
6430#endif
6431 case XML_NS_ERR_EMPTY:
6432#endif
6433 // case XML_DTD_ATTRIBUTE:
6434 case XML_DTD_ATTRIBUTE_REDEFINED:
6435 case XML_DTD_ATTRIBUTE_VALUE:
6436 case XML_DTD_CONTENT_ERROR:
6437 case XML_DTD_CONTENT_MODEL:
6438 case XML_DTD_CONTENT_NOT_DETERMINIST:
6439 case XML_DTD_DIFFERENT_PREFIX:
6440 case XML_DTD_ELEM_DEFAULT_NAMESPACE:
6441 case XML_DTD_ELEM_NAMESPACE:
6442 case XML_DTD_ELEM_REDEFINED:
6443 case XML_DTD_EMPTY_NOTATION:
6444 case XML_DTD_ENTITY_TYPE:
6445 case XML_DTD_ID_FIXED:
6446 case XML_DTD_ID_REDEFINED:
6447 case XML_DTD_ID_SUBSET:
6448 case XML_DTD_INVALID_CHILD:
6449 case XML_DTD_INVALID_DEFAULT:
6450 case XML_DTD_LOAD_ERROR:
6451 case XML_DTD_MISSING_ATTRIBUTE:
6452 case XML_DTD_MIXED_CORRUPT:
6453 case XML_DTD_MULTIPLE_ID:
6454 case XML_DTD_NO_DOC:
6455 case XML_DTD_NO_DTD:
6456 case XML_DTD_NO_ELEM_NAME:
6457 case XML_DTD_NO_PREFIX:
6458 case XML_DTD_NO_ROOT:
6459 case XML_DTD_NOTATION_REDEFINED:
6460 case XML_DTD_NOTATION_VALUE:
6461 case XML_DTD_NOT_EMPTY:
6462 case XML_DTD_NOT_PCDATA:
6463 case XML_DTD_NOT_STANDALONE:
6464 case XML_DTD_ROOT_NAME:
6465 case XML_DTD_STANDALONE_WHITE_SPACE:
6466 case XML_DTD_UNKNOWN_ATTRIBUTE:
6467 case XML_DTD_UNKNOWN_ELEM:
6468 case XML_DTD_UNKNOWN_ENTITY:
6469 case XML_DTD_UNKNOWN_ID:
6470 case XML_DTD_UNKNOWN_NOTATION:
6471 case XML_DTD_STANDALONE_DEFAULTED:
6472 case XML_DTD_XMLID_VALUE:
6473 case XML_DTD_XMLID_TYPE:
6474 case XML_XINCLUDE_PARSE_VALUE:
6475 case XML_XINCLUDE_ENTITY_DEF_MISMATCH:
6476 case XML_XINCLUDE_NO_HREF:
6477 case XML_XINCLUDE_NO_FALLBACK:
6478 case XML_XINCLUDE_HREF_URI:
6479 case XML_XINCLUDE_TEXT_FRAGMENT:
6480 case XML_XINCLUDE_TEXT_DOCUMENT:
6481 case XML_XINCLUDE_INVALID_CHAR:
6482 case XML_XINCLUDE_BUILD_FAILED:
6483 case XML_XINCLUDE_UNKNOWN_ENCODING:
6484 case XML_XINCLUDE_MULTIPLE_ROOT:
6485 case XML_XINCLUDE_XPTR_FAILED:
6486 case XML_XINCLUDE_XPTR_RESULT:
6487 case XML_XINCLUDE_INCLUDE_IN_INCLUDE:
6488 case XML_XINCLUDE_FALLBACKS_IN_INCLUDE:
6489 case XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE:
6490 case XML_XINCLUDE_DEPRECATED_NS:
6491 case XML_XINCLUDE_FRAGMENT_ID:
6492 // case XML_CATALOG_MISSING:
6493 case XML_CATALOG_ENTRY_BROKEN:
6494 case XML_CATALOG_PREFER_VALUE:
6495 case XML_CATALOG_NOT_CATALOG:
6496 case XML_CATALOG_RECURSION:
6497 // case XML_SCHEMAP_PREFIX:
6498 case XML_SCHEMAP_ATTRFORMDEFAULT_VALUE:
6499 case XML_SCHEMAP_ATTRGRP_NONAME_NOREF:
6500 case XML_SCHEMAP_ATTR_NONAME_NOREF:
6501 case XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF:
6502 case XML_SCHEMAP_ELEMFORMDEFAULT_VALUE:
6503 case XML_SCHEMAP_ELEM_NONAME_NOREF:
6504 case XML_SCHEMAP_EXTENSION_NO_BASE:
6505 case XML_SCHEMAP_FACET_NO_VALUE:
6506 case XML_SCHEMAP_FAILED_BUILD_IMPORT:
6507 case XML_SCHEMAP_GROUP_NONAME_NOREF:
6508 case XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI:
6509 case XML_SCHEMAP_IMPORT_REDEFINE_NSNAME:
6510 case XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI:
6511 case XML_SCHEMAP_INVALID_BOOLEAN:
6512 case XML_SCHEMAP_INVALID_ENUM:
6513 case XML_SCHEMAP_INVALID_FACET:
6514 case XML_SCHEMAP_INVALID_FACET_VALUE:
6515 case XML_SCHEMAP_INVALID_MAXOCCURS:
6516 case XML_SCHEMAP_INVALID_MINOCCURS:
6517 case XML_SCHEMAP_INVALID_REF_AND_SUBTYPE:
6518 case XML_SCHEMAP_INVALID_WHITE_SPACE:
6519 case XML_SCHEMAP_NOATTR_NOREF:
6520 case XML_SCHEMAP_NOTATION_NO_NAME:
6521 case XML_SCHEMAP_NOTYPE_NOREF:
6522 case XML_SCHEMAP_REF_AND_SUBTYPE:
6523 case XML_SCHEMAP_RESTRICTION_NONAME_NOREF:
6524 case XML_SCHEMAP_SIMPLETYPE_NONAME:
6525 case XML_SCHEMAP_TYPE_AND_SUBTYPE:
6526 case XML_SCHEMAP_UNKNOWN_ALL_CHILD:
6527 case XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD:
6528 case XML_SCHEMAP_UNKNOWN_ATTR_CHILD:
6529 case XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD:
6530 case XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP:
6531 case XML_SCHEMAP_UNKNOWN_BASE_TYPE:
6532 case XML_SCHEMAP_UNKNOWN_CHOICE_CHILD:
6533 case XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD:
6534 case XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD:
6535 case XML_SCHEMAP_UNKNOWN_ELEM_CHILD:
6536 case XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD:
6537 case XML_SCHEMAP_UNKNOWN_FACET_CHILD:
6538 case XML_SCHEMAP_UNKNOWN_FACET_TYPE:
6539 case XML_SCHEMAP_UNKNOWN_GROUP_CHILD:
6540 case XML_SCHEMAP_UNKNOWN_IMPORT_CHILD:
6541 case XML_SCHEMAP_UNKNOWN_LIST_CHILD:
6542 case XML_SCHEMAP_UNKNOWN_NOTATION_CHILD:
6543 case XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD:
6544 case XML_SCHEMAP_UNKNOWN_REF:
6545 case XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD:
6546 case XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD:
6547 case XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD:
6548 case XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD:
6549 case XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD:
6550 case XML_SCHEMAP_UNKNOWN_TYPE:
6551 case XML_SCHEMAP_UNKNOWN_UNION_CHILD:
6552 case XML_SCHEMAP_ELEM_DEFAULT_FIXED:
6553 case XML_SCHEMAP_REGEXP_INVALID:
6554 case XML_SCHEMAP_FAILED_LOAD:
6555 case XML_SCHEMAP_NOTHING_TO_PARSE:
6556 case XML_SCHEMAP_NOROOT:
6557 case XML_SCHEMAP_REDEFINED_GROUP:
6558 case XML_SCHEMAP_REDEFINED_TYPE:
6559 case XML_SCHEMAP_REDEFINED_ELEMENT:
6560 case XML_SCHEMAP_REDEFINED_ATTRGROUP:
6561 case XML_SCHEMAP_REDEFINED_ATTR:
6562 case XML_SCHEMAP_REDEFINED_NOTATION:
6563 case XML_SCHEMAP_FAILED_PARSE:
6564 case XML_SCHEMAP_UNKNOWN_PREFIX:
6565 case XML_SCHEMAP_DEF_AND_PREFIX:
6566 case XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD:
6567 case XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI:
6568 case XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI:
6569 case XML_SCHEMAP_NOT_SCHEMA:
6570 case XML_SCHEMAP_UNKNOWN_MEMBER_TYPE:
6571 case XML_SCHEMAP_INVALID_ATTR_USE:
6572 case XML_SCHEMAP_RECURSIVE:
6573 case XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE:
6574 case XML_SCHEMAP_INVALID_ATTR_COMBINATION:
6575 case XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION:
6576 case XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD:
6577 case XML_SCHEMAP_INVALID_ATTR_NAME:
6578 case XML_SCHEMAP_REF_AND_CONTENT:
6579 case XML_SCHEMAP_CT_PROPS_CORRECT_1:
6580 case XML_SCHEMAP_CT_PROPS_CORRECT_2:
6581 case XML_SCHEMAP_CT_PROPS_CORRECT_3:
6582 case XML_SCHEMAP_CT_PROPS_CORRECT_4:
6583 case XML_SCHEMAP_CT_PROPS_CORRECT_5:
6584 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1:
6585 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1:
6586 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2:
6587 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2:
6588 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3:
6589 case XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER:
6590 case XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE:
6591 case XML_SCHEMAP_UNION_NOT_EXPRESSIBLE:
6592 case XML_SCHEMAP_SRC_IMPORT_3_1:
6593 case XML_SCHEMAP_SRC_IMPORT_3_2:
6594 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1:
6595 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2:
6596 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3:
6597 case XML_SCHEMAP_COS_CT_EXTENDS_1_3:
6598 // case XML_SCHEMAV:
6599 case XML_SCHEMAV_UNDECLAREDELEM:
6600 case XML_SCHEMAV_NOTTOPLEVEL:
6601 case XML_SCHEMAV_MISSING:
6602 case XML_SCHEMAV_WRONGELEM:
6603 case XML_SCHEMAV_NOTYPE:
6604 case XML_SCHEMAV_NOROLLBACK:
6605 case XML_SCHEMAV_ISABSTRACT:
6606 case XML_SCHEMAV_NOTEMPTY:
6607 case XML_SCHEMAV_ELEMCONT:
6608 case XML_SCHEMAV_HAVEDEFAULT:
6609 case XML_SCHEMAV_NOTNILLABLE:
6610 case XML_SCHEMAV_EXTRACONTENT:
6611 case XML_SCHEMAV_INVALIDATTR:
6612 case XML_SCHEMAV_INVALIDELEM:
6613 case XML_SCHEMAV_NOTDETERMINIST:
6614 case XML_SCHEMAV_CONSTRUCT:
6615 case XML_SCHEMAV_INTERNAL:
6616 case XML_SCHEMAV_NOTSIMPLE:
6617 case XML_SCHEMAV_ATTRUNKNOWN:
6618 case XML_SCHEMAV_ATTRINVALID:
6619 case XML_SCHEMAV_VALUE:
6620 case XML_SCHEMAV_FACET:
6621 case XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1:
6622 case XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2:
6623 case XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3:
6624 case XML_SCHEMAV_CVC_TYPE_3_1_1:
6625 case XML_SCHEMAV_CVC_TYPE_3_1_2:
6626 case XML_SCHEMAV_CVC_FACET_VALID:
6627 case XML_SCHEMAV_CVC_LENGTH_VALID:
6628 case XML_SCHEMAV_CVC_MINLENGTH_VALID:
6629 case XML_SCHEMAV_CVC_MAXLENGTH_VALID:
6630 case XML_SCHEMAV_CVC_MININCLUSIVE_VALID:
6631 case XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID:
6632 case XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID:
6633 case XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID:
6634 case XML_SCHEMAV_CVC_TOTALDIGITS_VALID:
6635 case XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID:
6636 case XML_SCHEMAV_CVC_PATTERN_VALID:
6637 case XML_SCHEMAV_CVC_ENUMERATION_VALID:
6638 case XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1:
6639 case XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2:
6640 case XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3:
6641 case XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4:
6642 case XML_SCHEMAV_CVC_ELT_1:
6643 case XML_SCHEMAV_CVC_ELT_2:
6644 case XML_SCHEMAV_CVC_ELT_3_1:
6645 case XML_SCHEMAV_CVC_ELT_3_2_1:
6646 case XML_SCHEMAV_CVC_ELT_3_2_2:
6647 case XML_SCHEMAV_CVC_ELT_4_1:
6648 case XML_SCHEMAV_CVC_ELT_4_2:
6649 case XML_SCHEMAV_CVC_ELT_4_3:
6650 case XML_SCHEMAV_CVC_ELT_5_1_1:
6651 case XML_SCHEMAV_CVC_ELT_5_1_2:
6652 case XML_SCHEMAV_CVC_ELT_5_2_1:
6653 case XML_SCHEMAV_CVC_ELT_5_2_2_1:
6654 case XML_SCHEMAV_CVC_ELT_5_2_2_2_1:
6655 case XML_SCHEMAV_CVC_ELT_5_2_2_2_2:
6656 case XML_SCHEMAV_CVC_ELT_6:
6657 case XML_SCHEMAV_CVC_ELT_7:
6658 case XML_SCHEMAV_CVC_ATTRIBUTE_1:
6659 case XML_SCHEMAV_CVC_ATTRIBUTE_2:
6660 case XML_SCHEMAV_CVC_ATTRIBUTE_3:
6661 case XML_SCHEMAV_CVC_ATTRIBUTE_4:
6662 case XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1:
6663 case XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1:
6664 case XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2:
6665 case XML_SCHEMAV_CVC_COMPLEX_TYPE_4:
6666 case XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1:
6667 case XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2:
6668 case XML_SCHEMAV_ELEMENT_CONTENT:
6669 case XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING:
6670 case XML_SCHEMAV_CVC_COMPLEX_TYPE_1:
6671 case XML_SCHEMAV_CVC_AU:
6672 case XML_SCHEMAV_CVC_TYPE_1:
6673 case XML_SCHEMAV_CVC_TYPE_2:
6674#if LIBXML_VERSION > 20616
6675 case XML_SCHEMAV_CVC_IDC:
6676 case XML_SCHEMAV_CVC_WILDCARD:
6677#endif
6678 // case XML_XPTR_UNKNOWN:
6679 case XML_XPTR_CHILDSEQ_START:
6680 case XML_XPTR_EVAL_FAILED:
6681 case XML_XPTR_EXTRA_OBJECTS:
6682 // case XML_C14N_CREATE:
6683 case XML_C14N_REQUIRES_UTF8:
6684 case XML_C14N_CREATE_STACK:
6685 case XML_C14N_INVALID_NODE:
6686#if LIBXML_VERSION > 20616
6687 case XML_C14N_UNKNOW_NODE:
6688 case XML_C14N_RELATIVE_NAMESPACE:
6689#endif
6690 case XML_SCHEMAP_SRC_SIMPLE_TYPE_2:
6691 case XML_SCHEMAP_SRC_SIMPLE_TYPE_3:
6692 case XML_SCHEMAP_SRC_SIMPLE_TYPE_4:
6693 case XML_SCHEMAP_SRC_RESOLVE:
6694 case XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE:
6695 case XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE:
6696 case XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES:
6697 case XML_SCHEMAP_ST_PROPS_CORRECT_1:
6698 case XML_SCHEMAP_ST_PROPS_CORRECT_2:
6699 case XML_SCHEMAP_ST_PROPS_CORRECT_3:
6700 case XML_SCHEMAP_COS_ST_RESTRICTS_1_1:
6701 case XML_SCHEMAP_COS_ST_RESTRICTS_1_2:
6702 case XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1:
6703 case XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2:
6704 case XML_SCHEMAP_COS_ST_RESTRICTS_2_1:
6705 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1:
6706 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2:
6707 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1:
6708 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2:
6709 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3:
6710 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4:
6711 case XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5:
6712 case XML_SCHEMAP_COS_ST_RESTRICTS_3_1:
6713 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1:
6714 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2:
6715 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2:
6716 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1:
6717 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3:
6718 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4:
6719 case XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5:
6720 case XML_SCHEMAP_COS_ST_DERIVED_OK_2_1:
6721 case XML_SCHEMAP_COS_ST_DERIVED_OK_2_2:
6722 case XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED:
6723 case XML_SCHEMAP_S4S_ELEM_MISSING:
6724 case XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED:
6725 case XML_SCHEMAP_S4S_ATTR_MISSING:
6726 case XML_SCHEMAP_S4S_ATTR_INVALID_VALUE:
6727 case XML_SCHEMAP_SRC_ELEMENT_1:
6728 case XML_SCHEMAP_SRC_ELEMENT_2_1:
6729 case XML_SCHEMAP_SRC_ELEMENT_2_2:
6730 case XML_SCHEMAP_SRC_ELEMENT_3:
6731 case XML_SCHEMAP_P_PROPS_CORRECT_1:
6732 case XML_SCHEMAP_P_PROPS_CORRECT_2_1:
6733 case XML_SCHEMAP_P_PROPS_CORRECT_2_2:
6734 case XML_SCHEMAP_E_PROPS_CORRECT_2:
6735 case XML_SCHEMAP_E_PROPS_CORRECT_3:
6736 case XML_SCHEMAP_E_PROPS_CORRECT_4:
6737 case XML_SCHEMAP_E_PROPS_CORRECT_5:
6738 case XML_SCHEMAP_E_PROPS_CORRECT_6:
6739 case XML_SCHEMAP_SRC_INCLUDE:
6740 case XML_SCHEMAP_SRC_ATTRIBUTE_1:
6741 case XML_SCHEMAP_SRC_ATTRIBUTE_2:
6742 case XML_SCHEMAP_SRC_ATTRIBUTE_3_1:
6743 case XML_SCHEMAP_SRC_ATTRIBUTE_3_2:
6744 case XML_SCHEMAP_SRC_ATTRIBUTE_4:
6745 case XML_SCHEMAP_NO_XMLNS:
6746 case XML_SCHEMAP_NO_XSI:
6747 case XML_SCHEMAP_COS_VALID_DEFAULT_1:
6748 case XML_SCHEMAP_COS_VALID_DEFAULT_2_1:
6749 case XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1:
6750 case XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2:
6751 case XML_SCHEMAP_CVC_SIMPLE_TYPE:
6752 case XML_SCHEMAP_COS_CT_EXTENDS_1_1:
6753 case XML_SCHEMAP_SRC_IMPORT_1_1:
6754 case XML_SCHEMAP_SRC_IMPORT_1_2:
6755 case XML_SCHEMAP_SRC_IMPORT_2:
6756 case XML_SCHEMAP_SRC_IMPORT_2_1:
6757 case XML_SCHEMAP_SRC_IMPORT_2_2:
6758 case XML_SCHEMAP_INTERNAL:
6759 case XML_SCHEMAP_NOT_DETERMINISTIC:
6760 case XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1:
6761 case XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2:
6762 case XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3:
6763 case XML_SCHEMAP_MG_PROPS_CORRECT_1:
6764 case XML_SCHEMAP_MG_PROPS_CORRECT_2:
6765 case XML_SCHEMAP_SRC_CT_1:
6766 case XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3:
6767 case XML_SCHEMAP_AU_PROPS_CORRECT_2:
6768 case XML_SCHEMAP_A_PROPS_CORRECT_2:
6769#if XML_VERSION > 20616
6770 case XML_SCHEMAP_C_PROPS_CORRECT:
6771 case XML_SCHEMAP_SRC_REDEFINE:
6772#if XML_VERSION > 20621
6773 case XML_SCHEMAP_SRC_IMPORT:
6774 case XML_SCHEMAP_WARN_SKIP_SCHEMA:
6775 case XML_SCHEMAP_WARN_UNLOCATED_SCHEMA:
6776 case XML_SCHEMAP_WARN_ATTR_REDECL_PROH:
6777 case XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH:
6778 case XML_SCHEMAP_AG_PROPS_CORRECT:
6779 case XML_SCHEMAP_COS_CT_EXTENDS_1_2:
6780 case XML_SCHEMAP_AU_PROPS_CORRECT:
6781 case XML_SCHEMAP_A_PROPS_CORRECT_3:
6782 case XML_SCHEMAP_COS_ALL_LIMITED:
6783#endif
6784 case XML_MODULE_OPEN:
6785 case XML_MODULE_CLOSE:
6786#endif
6787 case XML_CHECK_FOUND_ATTRIBUTE:
6788 case XML_CHECK_FOUND_TEXT:
6789 case XML_CHECK_FOUND_CDATA:
6790 case XML_CHECK_FOUND_ENTITYREF:
6791 case XML_CHECK_FOUND_ENTITY:
6792 case XML_CHECK_FOUND_PI:
6793 case XML_CHECK_FOUND_COMMENT:
6794 case XML_CHECK_FOUND_DOCTYPE:
6795 case XML_CHECK_FOUND_FRAGMENT:
6796 case XML_CHECK_FOUND_NOTATION:
6797 case XML_CHECK_UNKNOWN_NODE:
6798 case XML_CHECK_ENTITY_TYPE:
6799 case XML_CHECK_NO_PARENT:
6800 case XML_CHECK_NO_DOC:
6801 case XML_CHECK_NO_NAME:
6802 case XML_CHECK_NO_ELEM:
6803 case XML_CHECK_WRONG_DOC:
6804 case XML_CHECK_NO_PREV:
6805 case XML_CHECK_WRONG_PREV:
6806 case XML_CHECK_NO_NEXT:
6807 case XML_CHECK_WRONG_NEXT:
6808 case XML_CHECK_NOT_DTD:
6809 case XML_CHECK_NOT_ATTR:
6810 case XML_CHECK_NOT_ATTR_DECL:
6811 case XML_CHECK_NOT_ELEM_DECL:
6812 case XML_CHECK_NOT_ENTITY_DECL:
6813 case XML_CHECK_NOT_NS_DECL:
6814 case XML_CHECK_NO_HREF:
6815 case XML_CHECK_WRONG_PARENT:
6816 case XML_CHECK_NS_SCOPE:
6817 case XML_CHECK_NS_ANCESTOR:
6818 case XML_CHECK_NOT_UTF8:
6819 case XML_CHECK_NO_DICT:
6820 case XML_CHECK_NOT_NCNAME:
6821 case XML_CHECK_OUTSIDE_DICT:
6822 case XML_CHECK_WRONG_NAME:
6823 case XML_CHECK_NAME_NOT_NULL:
6824#if LIBXML_VERSION > 20616
6825 case XML_I18N_NO_HANDLER:
6826 case XML_I18N_EXCESS_HANDLER:
6827 case XML_I18N_CONV_FAILED:
6828 case XML_I18N_NO_OUTPUT:
6829#endif
6830 aErrorMessage = "badxml/";
6831 buf = String::format("{0}", err->line);
6832 aErrorMessage = aErrorMessage + buf;
6833 aErrorMessage = aErrorMessage + "/0/";
6834 aErrorMessage = aErrorMessage + fname + "/";
6835 aErrorMessage = aErrorMessage + msg;
6836 break;
6837 case XML_IO_ENCODER:
6838 case XML_IO_FLUSH:
6839 case XML_IO_WRITE:
6840 case XML_IO_BUFFER_FULL:
6841 case XML_IO_LOAD_ERROR:
6842 aErrorMessage = "servererror";
6843 break;
6844 case XML_IO_EACCES:
6845 aErrorMessage = "servererror/EACCESS";
6846 break;
6847 case XML_IO_EAGAIN:
6848 aErrorMessage = "servererror/AGAIN";
6849 break;
6850 case XML_IO_EBADF:
6851 aErrorMessage = "servererror/BADF";
6852 break;
6853 case XML_IO_EBADMSG:
6854 aErrorMessage = "servererror/BADMSG";
6855 break;
6856 case XML_IO_EBUSY:
6857 aErrorMessage = "servererror/BUSY";
6858 break;
6859 case XML_IO_ECANCELED:
6860 aErrorMessage = "servererror/CANCELED";
6861 break;
6862 case XML_IO_ECHILD:
6863 aErrorMessage = "servererror/CHILD";
6864 break;
6865 case XML_IO_EDEADLK:
6866 aErrorMessage = "servererror/DEADLK";
6867 break;
6868 case XML_IO_EDOM:
6869 aErrorMessage = "servererror/DOM";
6870 break;
6871 case XML_IO_EEXIST:
6872 aErrorMessage = "servererror/EXIST";
6873 break;
6874 case XML_IO_EFAULT:
6875 aErrorMessage = "servererror/FAULT";
6876 break;
6877 case XML_IO_EFBIG:
6878 aErrorMessage = "servererror/FBIG";
6879 break;
6880 case XML_IO_EINPROGRESS:
6881 aErrorMessage = "servererror/INPROGRESS";
6882 break;
6883 case XML_IO_EINTR:
6884 aErrorMessage = "servererror/INTR";
6885 break;
6886 case XML_IO_EINVAL:
6887 aErrorMessage = "servererror/INVAL";
6888 break;
6889 case XML_IO_EIO:
6890 aErrorMessage = "servererror/IO";
6891 break;
6892 case XML_IO_EISDIR:
6893 aErrorMessage = "servererror/ISDIR";
6894 break;
6895 case XML_IO_EMFILE:
6896 aErrorMessage = "servererror/MFILE";
6897 break;
6898 case XML_IO_EMLINK:
6899 aErrorMessage = "servererror/MLINK";
6900 break;
6901 case XML_IO_EMSGSIZE:
6902 aErrorMessage = "servererror/MSGSIZE";
6903 break;
6904 case XML_IO_ENAMETOOLONG:
6905 aErrorMessage = "servererror/NAMETOOLONG";
6906 break;
6907 case XML_IO_ENFILE:
6908 aErrorMessage = "servererror/NFILE";
6909 break;
6910 case XML_IO_ENODEV:
6911 aErrorMessage = "servererror/NODEV";
6912 break;
6913 case XML_IO_ENOENT:
6914 aErrorMessage = "servererror/NOENT";
6915 break;
6916 case XML_IO_ENOEXEC:
6917 aErrorMessage = "servererror/NOEXEC";
6918 break;
6919 case XML_IO_ENOLCK:
6920 aErrorMessage = "servererror/NOLCK";
6921 break;
6922 case XML_IO_ENOMEM:
6923 aErrorMessage = "servererror/NOMEM";
6924 break;
6925 case XML_IO_ENOSPC:
6926 aErrorMessage = "servererror/NOSPC";
6927 break;
6928 case XML_IO_ENOSYS:
6929 aErrorMessage = "servererror/NOSYS";
6930 break;
6931 case XML_IO_ENOTDIR:
6932 aErrorMessage = "servererror/NOTDIR";
6933 break;
6934 case XML_IO_ENOTEMPTY:
6935 aErrorMessage = "servererror/NOTEMPTY";
6936 break;
6937 case XML_IO_ENOTSUP:
6938 aErrorMessage = "servererror/NOTSUP";
6939 break;
6940 case XML_IO_ENOTTY:
6941 aErrorMessage = "servererror/NOTTY";
6942 break;
6943 case XML_IO_ENXIO:
6944 aErrorMessage = "servererror/NXIO";
6945 break;
6946 case XML_IO_EPERM:
6947 aErrorMessage = "servererror/PERM";
6948 break;
6949 case XML_IO_EPIPE:
6950 aErrorMessage = "servererror/PIPE";
6951 break;
6952 case XML_IO_ERANGE:
6953 aErrorMessage = "servererror/RANGE";
6954 break;
6955 case XML_IO_EROFS:
6956 aErrorMessage = "servererror/ROFS";
6957 break;
6958 case XML_IO_ESPIPE:
6959 aErrorMessage = "servererror/SPIPE";
6960 break;
6961 case XML_IO_ESRCH:
6962 aErrorMessage = "servererror/SRCH";
6963 break;
6964 case XML_IO_ETIMEDOUT:
6965 aErrorMessage = "servererror/TIMEDOUT";
6966 break;
6967 case XML_IO_EXDEV:
6968 aErrorMessage = "servererror/XDEV";
6969 break;
6970 case XML_IO_NO_INPUT:
6971 aErrorMessage = "servererror/NOINPUT";
6972 break;
6973 case XML_IO_ENOTSOCK:
6974 aErrorMessage = "servererror/NOTSOCK";
6975 break;
6976 case XML_IO_EISCONN:
6977 aErrorMessage = "servererror/ISCONN";
6978 break;
6979 case XML_IO_ECONNREFUSED:
6980 aErrorMessage = "servererror/CONNREFUSED";
6981 break;
6982 case XML_IO_ENETUNREACH:
6983 aErrorMessage = "servererror/NETUNREACHABLE";
6984 break;
6985 case XML_IO_EADDRINUSE:
6986 aErrorMessage = "servererror/ADDRINUSE";
6987 break;
6988 case XML_IO_EALREADY:
6989 aErrorMessage = "servererror/ALREADY";
6990 break;
6991 case XML_IO_EAFNOSUPPORT:
6992 aErrorMessage = "servererror/AFNOSUPPORT";
6993 break;
6994 case XML_FTP_EPSV_ANSWER:
6995 aErrorMessage = "servererror/EPSV_ANSWER";
6996 break;
6997 case XML_FTP_ACCNT:
6998 aErrorMessage = "servererror/FTPACCOUNT";
6999 break;
7000 case XML_HTTP_USE_IP:
7001 aErrorMessage = "servererror/USE_IP";
7002 break;
7003 case XML_HTTP_UNKNOWN_HOST:
7004 aErrorMessage = "servererror/UNKNOWNHOST";
7005 break;
7006 case XML_ERR_INVALID_URI:
7007 case XML_ERR_URI_FRAGMENT:
7008#if LIBXML_VERSION > 20616
7009 case XML_FTP_URL_SYNTAX:
7010#endif
7011 aErrorMessage = "badurl";
7012 break;
7013 case XML_IO_NETWORK_ATTEMPT:
7014 aErrorMessage = "noperm";
7015 break;
7016 default:
7017 aErrorMessage = "unexpectedxml2error";
7018 }
7019}
7020
7021ARCANE_END_NAMESPACE_DOM
7022ARCANE_END_NAMESPACE
Déclarations des types utilisés dans Arcane.
Tableau d'items de types quelconques.
Document createDocument(const DOMString &namespace_uri, const DOMString &qualified_name, const DocumentType &doctype) const
IXmlDocumentHolder * _load(const String &fname, ITraceMng *msg, const String &schemaname)
IXmlDocumentHolder * _newDocument()
Les méthodes suivantes sont internes à Arcane.
Gestionnaire d'un document DOM.
void DoIndentation(bool StartEnd, StringBuilder &appendTo)
void writeElement(LIBXML2_DOMNamespaceContext *dnc, LIBXML2_Element *el, StringBuilder &appendTo)
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
NodePrv * m_p
Implémentation de la classe.
Definition Dom.h:412
virtual XmlNode documentNode()
Noeud document. Ce noeud est nul si le document n'existe pas.
Exception liées aux fichiers XML.
Noeud d'un arbre DOM.
Definition XmlNode.h:51
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Vue constante d'un tableau de type T.
constexpr bool empty() const noexcept
true si le tableau est vide (size()==0)
constexpr const_iterator begin() const noexcept
Itérateur sur le premier élément du tableau.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Interface du gestionnaire de traces.
Exception lorsqu'une fonction n'est pas implémentée.
Constructeur de chaîne de caractère unicode.
Chaîne de caractères unicode.
ConstArrayView< UChar > utf16() const
Retourne la conversion de l'instance dans l'encodage UTF-16.
Definition String.cc:266
bool empty() const
Vrai si la chaîne est vide (nulle ou "")
Definition String.cc:315
Integer len() const
Retourne la longueur de la chaîne en 32 bits.
Definition String.cc:328
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
Definition String.cc:227
String substring(Int64 pos) const
Sous-chaîne commençant à la position pos.
Definition String.cc:1114
TraceMessage info() const
Flot pour un message d'information.
Vecteur 1D de données avec sémantique par valeur (style STL).
Integer len(const char *s)
Retourne la longueur de la chaîne s.
void arcaneNullPointerError()
Signalue l'utilisation d'un pointeur nul.
UniqueArray< Byte > ByteUniqueArray
Tableau dynamique à une dimension de caractères.
Definition UtilsTypes.h:509
ConstArrayView< Byte > ByteConstArrayView
Equivalent C d'un tableau à une dimension de caractères.
Definition UtilsTypes.h:634
unsigned short UInt16
Type d'un Int16 non signé
Definition UtilsTypes.h:148
std::uint32_t UInt32
Type entier non signé sur 32 bits.