2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
20 * Abstract interface to objects that can be manipulated in and out of XML form.
\r
23 #if !defined(__xmltooling_xmlobj_h__)
\r
24 #define __xmltooling_xmlobj_h__
\r
28 #include <xmltooling/QName.h>
\r
29 #include <xmltooling/Namespace.h>
\r
31 namespace xmltooling {
\r
34 * Object that represents an XML Element that has been unmarshalled into this C++ object.
\r
36 class XMLTOOL_API XMLObject
\r
38 MAKE_NONCOPYABLE(XMLObject);
\r
41 virtual ~XMLObject() {}
\r
44 * Creates a copy of the object, along with all of its children.
\r
46 * The new object tree will be completely distinct and independent of
\r
47 * the original in all respects.
\r
49 virtual XMLObject* clone() const=0;
\r
52 * Gets the QName for this element. This QName <strong>MUST</strong>
\r
53 * contain the namespace URI, namespace prefix, and local element name.
\r
55 * @return constant reference to the QName for this object
\r
57 virtual const QName& getElementQName() const=0;
\r
60 * Sets the namespace prefix for this element.
\r
62 * @param prefix the prefix for this element
\r
64 virtual void setElementNamespacePrefix(const XMLCh* prefix)=0;
\r
67 * Gets the namespaces that are scoped to this element.
\r
69 * The caller MUST NOT modify the set returned, but may use any
\r
70 * non-modifying operations or algorithms on it. Iterators will
\r
71 * remain valid unless the set member referenced is removed using
\r
72 * the removeNamespace method.
\r
74 * @return the namespaces that are scoped to this element
\r
76 virtual const std::set<Namespace>& getNamespaces() const=0;
\r
79 * Adds a namespace to the ones already scoped to this element
\r
81 * @param ns the namespace to add
\r
83 virtual void addNamespace(const Namespace& ns)=0;
\r
86 * Removes a namespace from this element
\r
88 * @param ns the namespace to remove
\r
90 virtual void removeNamespace(const Namespace& ns)=0;
\r
93 * Gets the XML schema type of this element. This translates to contents the xsi:type
\r
94 * attribute for the element.
\r
96 * @return XML schema type of this element
\r
98 virtual const QName* getSchemaType() const=0;
\r
101 * Sets the XML schema type of this element. This translates to contents the xsi:type
\r
102 * attribute for the element.
\r
104 * @param type XML schema type of this element
\r
106 virtual void setSchemaType(const QName* type)=0;
\r
109 * Checks to see if this object has a parent.
\r
111 * @return true if the object has a parent, false if not
\r
113 virtual bool hasParent() const=0;
\r
116 * Gets the parent of this element or null if there is no parent.
\r
118 * @return the parent of this element or null
\r
120 virtual XMLObject* getParent() const=0;
\r
123 * Sets the parent of this element.
\r
125 * @param parent the parent of this element
\r
127 virtual void setParent(XMLObject* parent)=0;
\r
130 * Checks if this XMLObject has children.
\r
132 * @return true if this XMLObject has children, false if not
\r
134 virtual bool hasChildren() const=0;
\r
137 * Returns an unmodifiable list of child objects in the order that they
\r
138 * should appear in the serialized representation.
\r
140 * The validity of the returned list is not maintained if any non-const
\r
141 * operations are performed on the parent object.
\r
143 * @return the list of children
\r
145 virtual const std::list<XMLObject*>& getOrderedChildren() const=0;
\r
150 #endif /* __xmltooling_xmlobj_h__ */
\r