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
40 virtual ~XMLObject() {}
\r
43 * Creates a copy of the object, along with all of its children.
\r
45 * The new object tree will be completely distinct and independent of
\r
46 * the original in all respects.
\r
48 virtual XMLObject* clone() const=0;
\r
51 * Gets the QName for this element. This QName <strong>MUST</strong>
\r
52 * contain the namespace URI, namespace prefix, and local element name.
\r
54 * @return constant reference to the QName for this object
\r
56 virtual const QName& getElementQName() const=0;
\r
59 * Sets the namespace prefix for this element.
\r
61 * @param prefix the prefix for this element
\r
63 virtual void setElementNamespacePrefix(const XMLCh* prefix)=0;
\r
66 * Gets the namespaces that are scoped to this element.
\r
68 * The caller MUST NOT modify the set returned, but may use any
\r
69 * non-modifying operations or algorithms on it. Iterators will
\r
70 * remain valid unless the set member referenced is removed using
\r
71 * the removeNamespace method.
\r
73 * @return the namespaces that are scoped to this element
\r
75 virtual const std::set<Namespace>& getNamespaces() const=0;
\r
78 * Adds a namespace to the ones already scoped to this element
\r
80 * @param ns the namespace to add
\r
82 virtual void addNamespace(const Namespace& ns)=0;
\r
85 * Removes a namespace from this element
\r
87 * @param ns the namespace to remove
\r
89 virtual void removeNamespace(const Namespace& ns)=0;
\r
92 * Gets the XML schema type of this element. This translates to contents the xsi:type
\r
93 * attribute for the element.
\r
95 * @return XML schema type of this element
\r
97 virtual const QName* getSchemaType() const=0;
\r
100 * Sets the XML schema type of this element. This translates to contents the xsi:type
\r
101 * attribute for the element.
\r
103 * @param type XML schema type of this element
\r
105 virtual void setSchemaType(const QName* type)=0;
\r
108 * Checks to see if this object has a parent.
\r
110 * @return true if the object has a parent, false if not
\r
112 virtual bool hasParent() const=0;
\r
115 * Gets the parent of this element or null if there is no parent.
\r
117 * @return the parent of this element or null
\r
119 virtual XMLObject* getParent() const=0;
\r
122 * Sets the parent of this element.
\r
124 * @param parent the parent of this element
\r
126 virtual void setParent(XMLObject* parent)=0;
\r
129 * Checks if this XMLObject has children.
\r
131 * @return true if this XMLObject has children, false if not
\r
133 virtual bool hasChildren() const=0;
\r
136 * Returns an unmodifiable list of child objects in the order that they
\r
137 * should appear in the serialized representation.
\r
139 * The validity of the returned list is not maintained if any non-const
\r
140 * operations are performed on the parent object.
\r
142 * @return the list of children
\r
144 virtual const std::list<XMLObject*>& getOrderedChildren() const=0;
\r
152 #endif /* __xmltooling_xmlobj_h__ */
\r