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
18 * @file AttributeExtensibleXMLObject.h
\r
20 * An XMLObject that supports arbitrary attributes
\r
23 #if !defined(__xmltooling_attrextxmlobj_h__)
\r
24 #define __xmltooling_attrextxmlobj_h__
\r
26 #include <xmltooling/XMLObject.h>
\r
28 using namespace xercesc;
\r
30 #if defined (_MSC_VER)
\r
31 #pragma warning( push )
\r
32 #pragma warning( disable : 4250 4251 )
\r
35 namespace xmltooling {
\r
38 * An XMLObject that supports arbitrary attributes.
\r
40 class XMLTOOL_API AttributeExtensibleXMLObject : public virtual XMLObject
\r
43 AttributeExtensibleXMLObject() {}
\r
46 virtual ~AttributeExtensibleXMLObject() {}
\r
49 * Gets the value of an XML attribute of the object.
\r
51 * @param qualifiedName qualified name of the attribute
\r
52 * @return the attribute value, or NULL
\r
54 virtual const XMLCh* getAttribute(const QName& qualifiedName) const=0;
\r
57 * Sets (or clears) an XML attribute of the object.
\r
59 * @param qualifiedName qualified name of the attribute
\r
60 * @param value value to set, or NULL to clear
\r
61 * @param ID true iff the attribute is an XML ID
\r
63 virtual void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false)=0;
\r
66 * Gets an immutable map of the extended XML attributes of the object.
\r
68 * This set is not guaranteed to (and generally will not) include
\r
69 * attributes defined directly on the object's "type".
\r
71 virtual const std::map<QName,XMLCh*>& getExtensionAttributes() const=0;
\r
74 * Gets an immutable list of all the ID attributes currently registered.
\r
76 * @return list of all the ID attributes currently registered
\r
78 static const std::set<QName>& getRegisteredIDAttributes() {
\r
79 return m_idAttributeSet;
\r
83 * Tests whether an XML attribute is registered as an XML ID.
\r
85 * @return true iff the attribute name matches a registered XML ID attribute
\r
87 static bool isRegisteredIDAttribute(const QName& name) {
\r
88 return m_idAttributeSet.find(name)!=m_idAttributeSet.end();
\r
92 * Registers a new attribute as being of XML ID type.
\r
94 * @param name the qualified attribute name
\r
96 static void registerIDAttribute(const QName& name) {
\r
97 m_idAttributeSet.insert(name);
\r
101 * Deregisters an ID attribute.
\r
103 * @param name the qualified attribute name
\r
105 static void deregisterIDAttribute(const QName& name) {
\r
106 m_idAttributeSet.erase(name);
\r
110 * Deregisters all ID attributes.
\r
112 static void deregisterIDAttributes() {
\r
113 m_idAttributeSet.clear();
\r
117 /** Set of attributes to treat as XML IDs. */
\r
118 static std::set<QName> m_idAttributeSet;
\r
123 #if defined (_MSC_VER)
\r
124 #pragma warning( pop )
\r
127 #endif /* __xmltooling_attrextxmlobj_h__ */
\r