00001 /* 00002 ** ClanLib SDK 00003 ** Copyright (c) 1997-2005 The ClanLib Team 00004 ** 00005 ** This software is provided 'as-is', without any express or implied 00006 ** warranty. In no event will the authors be held liable for any damages 00007 ** arising from the use of this software. 00008 ** 00009 ** Permission is granted to anyone to use this software for any purpose, 00010 ** including commercial applications, and to alter it and redistribute it 00011 ** freely, subject to the following restrictions: 00012 ** 00013 ** 1. The origin of this software must not be misrepresented; you must not 00014 ** claim that you wrote the original software. If you use this software 00015 ** in a product, an acknowledgment in the product documentation would be 00016 ** appreciated but is not required. 00017 ** 2. Altered source versions must be plainly marked as such, and must not be 00018 ** misrepresented as being the original software. 00019 ** 3. This notice may not be removed or altered from any source distribution. 00020 ** 00021 ** Note: Some of the libraries ClanLib link to may have additional 00022 ** requirements or restrictions. 00023 ** 00024 ** File Author(s): 00025 ** 00026 ** Magnus Norddahl 00027 */ 00028 00031 00032 #ifndef header_dom_attr 00033 #define header_dom_attr 00034 00035 #if _MSC_VER > 1000 00036 #pragma once 00037 #endif 00038 00039 #include "dom_node.h" 00040 00041 //: DOM Attribute class. 00042 //- !group=Core/XML! 00043 //- !header=core.h! 00044 //- <p>The Attr interface represents an attribute in an Element object. Typically 00045 //- the allowable values for the attribute are defined in a document type definition.</p> 00046 //- <p>Attr objects inherit the Node interface, but since they are not actually child 00047 //- nodes of the element they describe, the DOM does not consider them part of the 00048 //- document tree. Thus, the Node attributes parentNode, previousSibling, and nextSibling 00049 //- have a null value for Attr objects. The DOM takes the view that attributes are 00050 //- properties of elements rather than having a separate identity from the elements 00051 //- they are associated with; this should make it more efficient to implement such 00052 //- features as default attributes associated with all elements of a given type. Furthermore, 00053 //- Attr nodes may not be immediate children of a DocumentFragment. However, they can 00054 //- be associated with Element nodes contained within a DocumentFragment. In short, 00055 //- users and implementors of the DOM need to be aware that Attr nodes have some 00056 //- things in common with other objects inheriting the Node interface, but they also 00057 //- are quite distinct.</p> 00058 //- <p>The attribute's effective value is determined as follows: if this attribute 00059 //- has been explicitly assigned any value, that value is the attribute's effective 00060 //- value; otherwise, if there is a declaration for this attribute, and that declaration 00061 //- includes a default value, then that default value is the attribute's effective value; 00062 //- otherwise, the attribute does not exist on this element in the structure model until 00063 //- it has been explicitly added. Note that the nodeValue attribute on the Attr instance 00064 //- can also be used to retrieve the string version of the attribute's value(s).</p> 00065 //- <p>In XML, where the value of an attribute can contain entity references, the child 00066 //- nodes of the Attr node provide a representation in which entity references are not 00067 //- expanded. These child nodes may be either Text or EntityReference nodes. Because the 00068 //- attribute type may be unknown, there are no tokenized attribute values.</p> 00069 class CL_DomAttr : public CL_DomNode 00070 { 00072 public: 00073 //: Constructs a DOM Attr handle. 00074 CL_DomAttr(); 00075 00076 CL_DomAttr(CL_DomDocument doc, const std::string &name); 00077 00078 CL_DomAttr(const CL_SharedPtr<CL_DomNode_Generic> &impl); 00079 00080 ~CL_DomAttr(); 00081 00083 public: 00084 //: Returns the name of this attribute. 00085 std::string get_name() const; 00086 00087 //: If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false. 00088 //- <ul> 00089 //- <li>If the attribute has an assigned value in the document then specified is true, 00090 //- and the value is the assigned value.</li> 00091 //- <li>If the attribute has no assigned value in the document and has a default value 00092 //- in the DTD, then specified is false, and the value is the default value in the DTD.</li> 00093 //- <li>If the attribute has no assigned value in the document and has a value of #IMPLIED 00094 //- in the DTD, then the attribute does not appear in the structure model of the document.</li> 00095 //- </ul> 00096 bool get_specified() const; 00097 00098 //: Returns the value of the attribute. 00099 std::string get_value() const; 00100 00101 //: Sets the value of the attribute. 00102 void set_value(const std::string &value); 00103 00105 public: 00106 00108 private: 00109 friend class CL_DomElement; 00110 }; 00111 00112 #endif
1.4.1