1 | // |
2 | // DOMImplementation.cpp |
3 | // |
4 | // Library: XML |
5 | // Package: DOM |
6 | // Module: DOM |
7 | // |
8 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/DOM/DOMImplementation.h" |
16 | #include "Poco/DOM/DocumentType.h" |
17 | #include "Poco/DOM/Document.h" |
18 | #include "Poco/DOM/Element.h" |
19 | #include "Poco/String.h" |
20 | #include "Poco/SingletonHolder.h" |
21 | |
22 | |
23 | namespace Poco { |
24 | namespace XML { |
25 | |
26 | |
27 | const XMLString DOMImplementation::FEATURE_XML = toXMLString("xml" ); |
28 | const XMLString DOMImplementation::FEATURE_CORE = toXMLString("core" ); |
29 | const XMLString DOMImplementation::FEATURE_EVENTS = toXMLString("events" ); |
30 | const XMLString DOMImplementation::FEATURE_MUTATIONEVENTS = toXMLString("mutationevents" ); |
31 | const XMLString DOMImplementation::FEATURE_TRAVERSAL = toXMLString("traversal" ); |
32 | const XMLString DOMImplementation::VERSION_1_0 = toXMLString("1.0" ); |
33 | const XMLString DOMImplementation::VERSION_2_0 = toXMLString("2.0" ); |
34 | |
35 | |
36 | DOMImplementation::DOMImplementation() |
37 | { |
38 | } |
39 | |
40 | |
41 | DOMImplementation::~DOMImplementation() |
42 | { |
43 | } |
44 | |
45 | |
46 | bool DOMImplementation::hasFeature(const XMLString& feature, const XMLString& version) const |
47 | { |
48 | XMLString lcFeature = Poco::toLower(feature); |
49 | return (lcFeature == FEATURE_XML && version == VERSION_1_0) || |
50 | (lcFeature == FEATURE_CORE && version == VERSION_2_0) || |
51 | (lcFeature == FEATURE_EVENTS && version == VERSION_2_0) || |
52 | (lcFeature == FEATURE_MUTATIONEVENTS && version == VERSION_2_0) || |
53 | (lcFeature == FEATURE_TRAVERSAL && version == VERSION_2_0); |
54 | } |
55 | |
56 | |
57 | DocumentType* DOMImplementation::createDocumentType(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const |
58 | { |
59 | return new DocumentType(0, name, publicId, systemId); |
60 | } |
61 | |
62 | |
63 | Document* DOMImplementation::createDocument(const XMLString& namespaceURI, const XMLString& qualifiedName, DocumentType* doctype) const |
64 | { |
65 | Document* pDoc = new Document(doctype); |
66 | if (namespaceURI.empty()) |
67 | pDoc->appendChild(pDoc->createElement(qualifiedName))->release(); |
68 | else |
69 | pDoc->appendChild(pDoc->createElementNS(namespaceURI, qualifiedName))->release(); |
70 | return pDoc; |
71 | } |
72 | |
73 | |
74 | namespace |
75 | { |
76 | static Poco::SingletonHolder<DOMImplementation> sh; |
77 | } |
78 | |
79 | |
80 | const DOMImplementation& DOMImplementation::instance() |
81 | { |
82 | return *sh.get(); |
83 | } |
84 | |
85 | |
86 | } } // namespace Poco::XML |
87 | |