1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2003 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: PSVIAttribute.hpp,v $
|
---|
59 | * Revision 1.6 2003/12/30 05:58:56 neilg
|
---|
60 | * allow schema normalized values to be associated with a PSVIAttribute after it is reset
|
---|
61 | *
|
---|
62 | * Revision 1.5 2003/11/28 20:20:54 neilg
|
---|
63 | * make use of canonical representation in PSVIAttribute implementation
|
---|
64 | *
|
---|
65 | * Revision 1.4 2003/11/27 06:10:32 neilg
|
---|
66 | * PSVIAttribute implementation
|
---|
67 | *
|
---|
68 | * Revision 1.3 2003/11/06 21:50:33 neilg
|
---|
69 | * fix compilation errors under gcc 3.3.
|
---|
70 | *
|
---|
71 | * Revision 1.2 2003/11/06 15:30:04 neilg
|
---|
72 | * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
|
---|
73 | *
|
---|
74 | * Revision 1.1 2003/09/16 14:33:36 neilg
|
---|
75 | * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
|
---|
76 | *
|
---|
77 | */
|
---|
78 |
|
---|
79 | #if !defined(PSVIATTRIBUTE_HPP)
|
---|
80 | #define PSVIATTRIBUTE_HPP
|
---|
81 |
|
---|
82 | #include <xercesc/framework/psvi/PSVIItem.hpp>
|
---|
83 | #include <xercesc/framework/psvi/XSSimpleTypeDefinition.hpp>
|
---|
84 | #include <xercesc/validators/datatype/DatatypeValidator.hpp>
|
---|
85 |
|
---|
86 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Represent the PSVI contributions for one attribute information item.
|
---|
90 | * This is *always* owned by the scanner/parser object from which
|
---|
91 | * it is obtained. The validator will specify
|
---|
92 | * under what conditions it may be relied upon to have meaningful contents.
|
---|
93 | */
|
---|
94 |
|
---|
95 | // forward declarations
|
---|
96 | class XSAttributeDeclaration;
|
---|
97 |
|
---|
98 | class XMLPARSER_EXPORT PSVIAttribute : public PSVIItem
|
---|
99 | {
|
---|
100 | public:
|
---|
101 |
|
---|
102 | // Constructors and Destructor
|
---|
103 | // -----------------------------------------------------------------------
|
---|
104 | /** @name Constructors */
|
---|
105 | //@{
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * The default constructor
|
---|
109 | *
|
---|
110 | * @param manager The configurable memory manager
|
---|
111 | */
|
---|
112 | PSVIAttribute( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
113 |
|
---|
114 | //@};
|
---|
115 |
|
---|
116 | /** @name Destructor */
|
---|
117 | //@{
|
---|
118 | ~PSVIAttribute();
|
---|
119 | //@}
|
---|
120 |
|
---|
121 | //---------------------
|
---|
122 | /** @name PSVIAttribute methods */
|
---|
123 |
|
---|
124 | //@{
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * An item isomorphic to the attribute declaration used to validate
|
---|
128 | * this attribute.
|
---|
129 | *
|
---|
130 | * @return an attribute declaration
|
---|
131 | */
|
---|
132 | XSAttributeDeclaration *getAttributeDeclaration();
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * An item isomorphic to the type definition used to validate this element.
|
---|
136 | *
|
---|
137 | * @return a type declaration
|
---|
138 | */
|
---|
139 | XSTypeDefinition *getTypeDefinition();
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * If and only if that type definition is a simple type definition
|
---|
143 | * with {variety} union, or a complex type definition whose {content type}
|
---|
144 | * is a simple thype definition with {variety} union, then an item isomorphic
|
---|
145 | * to that member of the union's {member type definitions} which actually
|
---|
146 | * validated the element item's normalized value.
|
---|
147 | *
|
---|
148 | * @return a simple type declaration
|
---|
149 | */
|
---|
150 | XSSimpleTypeDefinition *getMemberTypeDefinition();
|
---|
151 |
|
---|
152 | //@}
|
---|
153 |
|
---|
154 | //----------------------------------
|
---|
155 | /** methods needed by implementation */
|
---|
156 |
|
---|
157 | //@{
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * reset this object. Intended to be called by
|
---|
161 | * the implementation.
|
---|
162 | */
|
---|
163 | void reset(
|
---|
164 | const XMLCh * const valContext
|
---|
165 | , PSVIItem::VALIDITY_STATE state
|
---|
166 | , PSVIItem::ASSESSMENT_TYPE assessmentType
|
---|
167 | , XSSimpleTypeDefinition * validatingType
|
---|
168 | , XSSimpleTypeDefinition * memberType
|
---|
169 | , const XMLCh * const defaultValue
|
---|
170 | , const bool isSpecified
|
---|
171 | , XSAttributeDeclaration * attrDecl
|
---|
172 | , DatatypeValidator * dv
|
---|
173 | );
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * set the schema normalized value (and
|
---|
177 | * implicitly the canonical value) of this object; intended to be used
|
---|
178 | * by the implementation.
|
---|
179 | */
|
---|
180 | void setValue(const XMLCh * const normalizedValue);
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * set VALIDITY_STATE to specified value; intended to be
|
---|
184 | * called by implementation.
|
---|
185 | */
|
---|
186 | void updateValidity(VALIDITY_STATE newValue);
|
---|
187 |
|
---|
188 | //@}
|
---|
189 |
|
---|
190 | private:
|
---|
191 |
|
---|
192 | // -----------------------------------------------------------------------
|
---|
193 | // Unimplemented constructors and operators
|
---|
194 | // -----------------------------------------------------------------------
|
---|
195 | PSVIAttribute(const PSVIAttribute&);
|
---|
196 | PSVIAttribute & operator=(const PSVIAttribute &);
|
---|
197 |
|
---|
198 |
|
---|
199 | // -----------------------------------------------------------------------
|
---|
200 | // data members
|
---|
201 | // -----------------------------------------------------------------------
|
---|
202 | // fAttributeDecl
|
---|
203 | // attribute declaration component that validated this attribute
|
---|
204 | // fDV
|
---|
205 | // implementation-specific datatype validator used to validate this attribute
|
---|
206 | XSAttributeDeclaration * fAttributeDecl;
|
---|
207 | DatatypeValidator * fDV;
|
---|
208 | };
|
---|
209 | inline PSVIAttribute::~PSVIAttribute()
|
---|
210 | {
|
---|
211 | fMemoryManager->deallocate((void *)fCanonicalValue);
|
---|
212 | }
|
---|
213 |
|
---|
214 | inline XSAttributeDeclaration *PSVIAttribute::getAttributeDeclaration()
|
---|
215 | {
|
---|
216 | return fAttributeDecl;
|
---|
217 | }
|
---|
218 |
|
---|
219 | inline XSTypeDefinition* PSVIAttribute::getTypeDefinition()
|
---|
220 | {
|
---|
221 | return fType;
|
---|
222 | }
|
---|
223 |
|
---|
224 | inline XSSimpleTypeDefinition* PSVIAttribute::getMemberTypeDefinition()
|
---|
225 | {
|
---|
226 | return fMemberType;
|
---|
227 | }
|
---|
228 |
|
---|
229 | inline void PSVIAttribute::updateValidity(VALIDITY_STATE newValue)
|
---|
230 | {
|
---|
231 | fValidityState = newValue;
|
---|
232 | }
|
---|
233 |
|
---|
234 | XERCES_CPP_NAMESPACE_END
|
---|
235 |
|
---|
236 | #endif
|
---|