1 | // |
---|
2 | // DOMImplementation.cpp |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/XML/src/DOMImplementation.cpp#2 $ |
---|
5 | // |
---|
6 | // Library: XML |
---|
7 | // Package: DOM |
---|
8 | // Module: DOM |
---|
9 | // |
---|
10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
---|
11 | // and Contributors. |
---|
12 | // |
---|
13 | // Permission is hereby granted, free of charge, to any person or organization |
---|
14 | // obtaining a copy of the software and accompanying documentation covered by |
---|
15 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
16 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
17 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
18 | // do so, all subject to the following: |
---|
19 | // |
---|
20 | // The copyright notices in the Software and this entire statement, including |
---|
21 | // the above license grant, this restriction and the following disclaimer, |
---|
22 | // must be included in all copies of the Software, in whole or in part, and |
---|
23 | // all derivative works of the Software, unless such copies or derivative |
---|
24 | // works are solely in the form of machine-executable object code generated by |
---|
25 | // a source language processor. |
---|
26 | // |
---|
27 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
28 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
29 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
30 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
31 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
32 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
33 | // DEALINGS IN THE SOFTWARE. |
---|
34 | // |
---|
35 | |
---|
36 | |
---|
37 | #include <Poco/DOM/DOMImplementation.h> |
---|
38 | #include <Poco/DOM/DocumentType.h> |
---|
39 | #include <Poco/DOM/Document.h> |
---|
40 | #include <Poco/DOM/Element.h> |
---|
41 | #include <Poco/String.h> |
---|
42 | #include <Poco/SingletonHolder.h> |
---|
43 | |
---|
44 | |
---|
45 | namespace Poco { |
---|
46 | namespace XML { |
---|
47 | |
---|
48 | |
---|
49 | const XMLString DOMImplementation::FEATURE_XML = toXMLString("xml"); |
---|
50 | const XMLString DOMImplementation::FEATURE_CORE = toXMLString("core"); |
---|
51 | const XMLString DOMImplementation::FEATURE_EVENTS = toXMLString("events"); |
---|
52 | const XMLString DOMImplementation::FEATURE_MUTATIONEVENTS = toXMLString("mutationevents"); |
---|
53 | const XMLString DOMImplementation::FEATURE_TRAVERSAL = toXMLString("traversal"); |
---|
54 | const XMLString DOMImplementation::VERSION_1_0 = toXMLString("1.0"); |
---|
55 | const XMLString DOMImplementation::VERSION_2_0 = toXMLString("2.0"); |
---|
56 | |
---|
57 | |
---|
58 | DOMImplementation::DOMImplementation() |
---|
59 | { |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | DOMImplementation::~DOMImplementation() |
---|
64 | { |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | bool DOMImplementation::hasFeature(const XMLString& feature, const XMLString& version) const |
---|
69 | { |
---|
70 | XMLString lcFeature = Poco::toLower(feature); |
---|
71 | return (lcFeature == FEATURE_XML && version == VERSION_1_0) || |
---|
72 | (lcFeature == FEATURE_CORE && version == VERSION_2_0) || |
---|
73 | (lcFeature == FEATURE_EVENTS && version == VERSION_2_0) || |
---|
74 | (lcFeature == FEATURE_MUTATIONEVENTS && version == VERSION_2_0) || |
---|
75 | (lcFeature == FEATURE_TRAVERSAL && version == VERSION_2_0); |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | DocumentType* DOMImplementation::createDocumentType(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const |
---|
80 | { |
---|
81 | return new DocumentType(0, name, publicId, systemId); |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | Document* DOMImplementation::createDocument(const XMLString& namespaceURI, const XMLString& qualifiedName, DocumentType* doctype) const |
---|
86 | { |
---|
87 | Document* pDoc = new Document(doctype); |
---|
88 | if (namespaceURI.empty()) |
---|
89 | pDoc->appendChild(pDoc->createElement(qualifiedName))->release(); |
---|
90 | else |
---|
91 | pDoc->appendChild(pDoc->createElementNS(namespaceURI, qualifiedName))->release(); |
---|
92 | return pDoc; |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | const DOMImplementation& DOMImplementation::instance() |
---|
97 | { |
---|
98 | static Poco::SingletonHolder<DOMImplementation> sh; |
---|
99 | return *sh.get(); |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | } } // namespace Poco::XML |
---|